add_action( 'admin_init', 'slt_lock_theme' ); function slt_lock_theme() { global $submenu, $userdata; get_currentuserinfo(); if ( $userdata->ID != 1 ) { unset( $submenu['themes.php'][5] ); unset( $submenu['themes.php'][15] ); } }
Month: February 2015
Mark Comments with Very Long URLs as Spam
<?php function rkv_url_spamcheck( $approved , $commentdata ) { return ( strlen( $commentdata['comment_author_url'] ) > 50 ) ? 'spam' : $approved; } add_filter( 'pre_comment_approved', 'rkv_url_spamcheck', 99, 2 ); ?>
Note: The snippet below allows you to mark a comment as spam that has a website URL over 50 characters. You can increase or decrease this limit to suit your own needs.
How to randomize the order of widgets in wp
add_filter ('sidebars_widgets', 'wcs_randomize_widget_order'); function wcs_randomize_widget_order($sidebars_widgets) { $sidebar = 'sidebar'; // Replace 'sidebar' with the name of the widget you want to shuffle if (isset($sidebars_widgets[$sidebar]) && !is_admin()) { shuffle ($sidebars_widgets[$sidebar]); } return $sidebars_widgets; }
If you want to randomize the widgets in all your sidebars, you can use:
add_filter ('sidebars_widgets', 'wcs_randomize_widget_order'); function wcs_randomize_widget_order($sidebars_widgets) { if (!is_admin()) { foreach ($sidebars_widgets as &$widget) { shuffle ($widget); } } return $sidebars_widgets; }
Add Custom Dashboard Widgets in WordPress
function my_custom_dashboard_widgets() { global $wp_meta_boxes; wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help'); } function custom_dashboard_help() { echo '<p>Here write custom widget data which show on widget if use the custom widget.</p>'; } add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');
Different widget for different pages
<?php if ( is_page('testimonials') ) : ?> <?php if ( !dynamic_sidebar('testimonial_sidebar') ) : ?><?php endif ; ?> <?php elseif (is_page('contact')) : ?> <?php if ( !dynamic_sidebar('contact_sidebar') ) : ?> <?php endif ; ?> <?php elseif (is_page(147)) : ?> <?php if ( !dynamic_sidebar('matrix_nlp') ) : ?> <?php endif ; ?> <?php elseif (is_page(71)) : ?> <?php if ( !dynamic_sidebar('corporate_nlp_programs') ) : ?> <?php endif ; ?> <?php elseif (is_page(154)) : ?> <?php if ( !dynamic_sidebar('nlp_practitioner_certification') ) : ?> <?php endif ; ?> <?php elseif (is_page(165)) : ?> <?php if ( !dynamic_sidebar('nlp_master') ) : ?> <?php endif ; ?> <?php elseif (is_page(200)) : ?> <?php if ( !dynamic_sidebar('nlp_to_excellence') ) : ?> <?php endif ; ?> <?php else : ?> <?php if ( !dynamic_sidebar('unique_sidebar_id') ) : ?><?php endif ; ?> <?php endif; ?>
Note: Using number is page id