How to pass conditional array to wp_localize_script

Ended up with this as the function: // set up the settings for the theme.js function mb_scripts_settings() { // blanks $mb_ajax_form_type = $mb_get_page_slug = $mb_redirect = $mb_redirect_time = $mb_form_disable = $mb_array = ”; // get the form type $mb_ajax_form_type = ( is_front_page() ? ‘change’ : ‘submit’ ); // get the page slug from ID $mb_get_page_slug … Read more

Display a div only in some author’s single posts

is_author() isn’t working as you expect because it checks whether the current query is for an existing author archive page. If you’re placing your code in single.php inside the loop, you can use this instead: <?php if( $post->post_author == ’15’ || $post->post_author == ’16’ ) { ?> <div>Your code here</div> <?php } ?>

Allow users with Editor role to edit menus (without a plugin)

Recently I had to tackle the same issue. Instead of setting the capability permanently for editors, I used user_has_cap filter to allow access dynamically. add_filter(‘user_has_cap’, ‘editor_allow_edit_menu’, 10, 4); function editor_allow_edit_menu($allcaps, $caps, $args, $user) { if ( ! isset( $allcaps[‘editor’] ) || true !== $allcaps[‘editor’] ) { return $allcaps; } global $pagenow; // new items are … Read more

Conditional secondary menus

This is just sort of a PHP shortcut, but you could create a mapping describing which conditional values map to what menu locations, and loop through it testing each condition and printing menus for matches: /** * Prints wp_nav_menu(s) by matching conditional function arguments to menu locations. * * @param array $locations A mapping of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)