Add admin bar link to edit author

You could try this modification of your code: function add_author_edit_link( $wp_admin_bar ) { if ( is_author() && current_user_can( ‘add_users’ ) ) { $args = array( ‘id’ => ‘author-edit’, ‘title’ => __( ‘Edit Author’ ), ‘href’ => admin_url( sprintf( ‘user-edit.php?user_id=%d’, get_queried_object_id() ) ) ); $wp_admin_bar->add_node($args); } } add_action( ‘admin_bar_menu’, ‘add_author_edit_link’, 99 ); where we use the … Read more

opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);

I am not sure if there’s a native function for this, but a little regex might help the case: function open_links_in_new_tab($content){ $pattern = ‘/<a(.*?)?href=[\'”]?[\'”]?(.*?)?>/i’; $content = preg_replace_callback($pattern, function($m){ $tpl = array_shift($m); $hrf = isset($m[1]) ? $m[1] : null; if ( preg_match(‘/target=[\'”]?(.*?)[\'”]?/i’, $tpl) ) { return $tpl; } if ( trim($hrf) && 0 === strpos($hrf, ‘#’) … Read more

How do I create a new WP admin color scheme?

This code works with WordPress 5.2 and is correct. You now need to go to your Profile and select it by going to Users > Your Profile > Admin Color Scheme select the scheme and save. Edit: Adding updated code for your colors CSS file since you’re using a child theme: function additional_admin_color_schemes() { wp_admin_css_color( … Read more

How can I programmatically create “child” pages on theme activation?

As @Soulseekah said, you can do this with post_parent. I didn’t test with the following code, but it should work $pages = array( array( ‘name’ => ‘page1’, ‘title’ => ‘Page 1’, ‘child’ => array( array( ‘name’ => ‘page11’, ‘title’ => ‘Page 1.1’ ), array( ‘name’ => ‘page12’, ‘title’ => ‘Page 1.2’ ) ) ), array( … Read more

How to override core is_ssl() function?

If you look at the source of the is_ssl() function you’ll see it checks various $_SERVER variables. Therefore, you could try adding this to a plugin: if ( isset( $_SERVER[‘HTTP_MY_CUSTOM_HEADER’] ) ) $_SERVER[‘HTTPS’] = ‘on’; You’d need to call that code as early as possible, ie. directly in the plugin body rather than on a … Read more

How to display random users with avatars

I am not sure why your query is returning more IDs than necessary. The $args for get_users look correct. By default get_users does not support orderby=rand, but you can overwrite that option. See below: function random_user_query( &$query ) { $query->query_orderby = “ORDER BY RAND()”; } // Usage: [random_users how_many = 3] add_shortcode( ‘random_users’, ‘display_random_users’ ); … Read more

How to target specific wp_nav_menu in function?

I tried the below code and it worked. Add this to your functions.php register_nav_menus(array( ‘top-menu’ => __(‘Menu1’, ‘twentyfourteen’), ‘side-menu’ => __(‘Menu2’, ‘twentyfourteen’), ‘footer-menu’ => __(‘Menu3’, ‘twentyfourteen’) ) ); function my_walker_nav_menu_start_el($item_output, $item, $depth, $args) { $menu_locations = get_nav_menu_locations(); if ( has_term($menu_locations[‘top-menu’], ‘nav_menu’, $item) ) { $item_output = preg_replace(‘/<a /’, ‘<a class=”list-group” ‘, $item_output, 1); } return … Read more