Skip to content

Instantly share code, notes, and snippets.

View anilmeena's full-sized avatar

Anil Meena anilmeena

View GitHub Profile
@anilmeena
anilmeena / add-plus-minus-buttons-with-input.html
Created April 2, 2017 12:00
Add plus & minus buttons with input type text
<style>
#myform {
text-align: center;
padding: 5px;
border: 1px dotted #ccc;
margin: 2%;
}
.qty {
width: 40px;
height: 25px;
@anilmeena
anilmeena / show-hide-fixed-menu-after-specific-height.html
Created March 27, 2017 08:19
Show and hide fixed menu after specific height
<style>
body {
height:1600px;
margin:0;
}
#navWrap {
height:70px
}
nav {
height: 70px;
@anilmeena
anilmeena / add-wp-media-uploader-plugin.php
Created October 24, 2016 03:39
Add WP Media Uploader in Plugin
<?php
/* Add WP Media Uploader in Plugin */
add_action('admin_enqueue_scripts', 'custom_admin_media_scripts');
function custom_admin_media_scripts() {
if (isset($_GET['page']) && $_GET['page'] == 'custom-icons-settings-page') {
wp_enqueue_media();
wp_register_script('custom-media-uploader-js', WP_PLUGIN_URL.'/custom-theme-settings-plugin/js/media.js', array('jquery'));
wp_enqueue_script('custom-media-uploader-js');
}
@anilmeena
anilmeena / add-extra-fields-media-attachment.php
Created October 24, 2016 03:35
Add extra fields in media attachment
<?php
/* Add extra fields in media attachment */
/**
* Add Photographer Name and URL fields to media uploader
*
* @param $form_fields array, fields to include in attachment form
* @param $post object, attachment record in database
* @return $form_fields, modified form fields
*/
@anilmeena
anilmeena / jquery-datepicker-onselect-event-get-class.html
Created October 23, 2016 10:37
jQuery Datepicker onSelect event get class
(function ($) {
$(document).ready(function () {
$("#calendar").datepicker({
dateFormat: 'yyyy-mm-dd',
beforeShowDay: function (date) {
return [true, 'reserved', 'this date reserved'];
},
onSelect: function (date, el) {
var day = el.selectedDay,
mon = el.selectedMonth,
@anilmeena
anilmeena / avoid-browser-popup-blockers.html
Created October 22, 2016 02:52
Avoid browser popup blockers
/* Pseudo code with Javascript snippets: */
// Immediately create a blank popup on user action
var importantStuff = window.open('', '_blank');
// Optional: add some "waiting" info message. Examples:
// a) An external HTML page: replace the above line with
var importantStuff = window.open('http://example.com/waiting.html', '_blank');
// b) Text: add the following line below the above one:
@anilmeena
anilmeena / add-custom-fields-wordpress-post-category
Created October 21, 2016 03:10
Add Custom Fields in Wordpress Post Category
<?php
/* Add Custom Fields in Wordpress Post Category */
// the option name
define('MY_CATEGORY_FIELDS', 'my_category_fields_option');
// your fields (the form)
add_filter('edit_category_form', 'my_category_fields');
function my_category_fields($tag) {
$tag_extra_fields = get_option(MY_CATEGORY_FIELDS);
@anilmeena
anilmeena / add-custom-fields-wordpress-category.php
Created October 21, 2016 03:04
Add Custom Fields in Wordpress Category
<?php
/* Add Custom Fields in Wordpress Category */
// Add term page
function tutorialshares_taxonomy_add_new_meta_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="term_meta[custom_term_meta]"><?php _e( 'Example meta field', 'tutorialshares' ); ?></label>
<input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="">
<p class="description"><?php _e( 'Enter a value for this field','tutorialshares' ); ?></p>
@anilmeena
anilmeena / add-custom-column-custom-post-type.php
Created October 21, 2016 03:00
Add custom column in custom post type
<?php
// Add custom column in custom post type (here custom_post = latest_at_sonic)
add_filter( 'manage_edit-latest_at_sonic_columns', 'my_edit_latest_at_sonic_columns' ) ;
function my_edit_latest_at_sonic_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Title' ),
@anilmeena
anilmeena / adding-custom-options-existing-widgets.php
Created October 16, 2016 15:06
Adding Custom Options to Existing Widgets
<?php
/* Displaying a Custom Widget Option */
function thmfdn_add_menu_description_option( $widget, $return, $instance ) {
// Are we dealing with a nav menu widget?
if ( 'nav_menu' == $widget->id_base ) {
// Display the description option.
$description = isset( $instance['description'] ) ? $instance['description'] : '';
?>