Skip to content

Instantly share code, notes, and snippets.

View digvijayad's full-sized avatar

Digvijay Naruka digvijayad

View GitHub Profile
@digvijayad
digvijayad / functions.php
Last active August 13, 2023 16:42
WordPress add settings field dynamically using associative arrays
<?php
add_action('admin_menu', 'myTheme_admin');
function myTheme_admin() {
/* Base Menu */
add_menu_page(
'myTheme settings', // Admin page title
'myTheme settings', // Admin menu label
'manage_options',
'myTheme-general-options', // Admin slug
@digvijayad
digvijayad / color-scheme-preview.js
Last active February 11, 2020 23:07
How to add Color Schemes to your WordPress theme with live preview: full working sample
(function($) {
var style = $('#yourtheme-color-scheme-css'),
api = wp.customize;
if (!style.length) {
style = $('head').append('<style type="text/css" id="yourtheme-color-scheme-css" />')
.find('#yourtheme-color-scheme-css');
}
// Color Scheme CSS.
api.bind('preview-ready', function() {
@digvijayad
digvijayad / hide_show_metabox.php
Created October 13, 2017 05:15
Dynamically Hide/show Meta box on run time during category selection for themes and Plugins.
<?php
/**
* Hide/Show a any div element by selecting a categories for a wordpress theme.
*
* Copy all of these functions to your function.php file,
*
* and call => do_action(
* 'mythemeprefix_hide_meta_for_categories',
* array("category1","category2"),
* 'my_meta_id_div'