What does “Do not deregister the jquery script in the administration area” mean?

Based on the error… add_action( ‘wp_enqueue_scripts’, function(){ if (is_admin()) return; // don’t dequeue on the backend wp_deregister_script( ‘jquery’ ); wp_register_script( ‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js’, array(), null, false ); wp_enqueue_script( ‘jquery’); }); Honestly, unless you have tremendous traffic over a broad geographic area, I’d say that CDNs are grossly over-rated. I’ve watched the hangup on sites I’ve managed … Read more

Where do I find the functions triggered within a hook?

Looking at the current version of Storefront’s header.php: /** * Functions hooked into storefront_header action * * @hooked storefront_skip_links – 0 * @hooked storefront_social_icons – 10 * @hooked storefront_site_branding – 20 * @hooked storefront_secondary_navigation – 30 * @hooked storefront_product_search – 40 * @hooked storefront_primary_navigation_wrapper – 42 * @hooked storefront_primary_navigation – 50 * @hooked storefront_header_cart – … Read more

How to develop a multilingual theme?

Daniel’s answer was very similar, but applied to plugins rather than themes. For that reason I’ll explain how I specifically did it for themes for anyone else who comes across this problem. Create a folder in the root of your theme called “languages” Go to https://wpcentral.io/internationalization/, search for your language and copy the “WordPress Locale” … Read more

Add a notice to users upon first login to the admin area

something like: add_action(‘admin_notices’, ‘my_notice’); add_action(‘wp_ajax_hide_my_notice’, ‘hide_my_notice’); function hide_my_notice(){ check_ajax_referer(‘hide-my-notice’); $user = wp_get_current_user(); // update status for this user $seen_notice = get_option(‘my_notice’); $seen_notice[$user->ID] = true; update_option(‘my_notice’, $seen_notice); exit; } function my_notice(){ $user = wp_get_current_user(); $seen_notice = get_option(‘my_notice’); // already seen it? if(isset($seen_notice[$user->ID]) && $seen_notice[$user->ID]) return; ?> <div class=”updated fade below-h2″> <p> Hi <?php print esc_attr($user->user_login); ?>! … Read more

Override Current Theme Setting in wp_config.php

Drop this in a plugin & activate. I should note this doesn’t take into account things like child themes – it’s purely for toggling which theme renders based on SOME_FLAG. add_filter( ‘stylesheet’, ‘switch_ma_theme’ ); add_filter( ‘template’, ‘switch_ma_theme’ ); function switch_ma_theme() { // Return the theme directory name return SOME_FLAG ? ‘theme-1’ : ‘theme-2’; }

Why is styling comments so complex?

If you prefer simple template files, you can do that with custom comment callbacks too. Call wp_list_comments() with a custom callback handler: wp_list_comments( array( ‘callback’ => ‘custom_comment_callback’, ‘style’ => ‘ol’ ) ); Now make that callback function very simple: function custom_comment_callback( $comment, $args, $depth ) { include ‘comment-template.php’; } And now you can use comment-template.php … Read more

How to disable 3.1 “Admin Bar” via script for the admin user?

You could use a function inside your theme’s functions file to selectively disable it for specific users. function disable_bar_for_user( $ids ) { if( !is_user_logged_in() ) return; global $current_user; if( is_numeric( $ids ) ) $ids = (array) $ids; if( !in_array( $current_user->data->ID, $ids ) ) return; add_filter( ‘show_admin_bar’, ‘__return_false’, 9 ); } Then call it for the … Read more