Displaying Logged-In User Name and avatar in WordPress Menu

You can use “get_avatar” function to display avatar in menu with user name. Please try code given below: add_filter( ‘wp_nav_menu_objects’, ‘my_dynamic_menu_items’, 10 ); function my_dynamic_menu_items( $menu_items ) { foreach ( $menu_items as $menu_item ) { if ( strpos($menu_item->title, ‘#profile_name#’) !== false) { $menu_item->title = str_replace(“#profile_name#”, wp_get_current_user()->user_login .’ ‘. get_avatar( wp_get_current_user()->user_email, 50), $menu_item->title); } } return … Read more

Problem with WordPress Ajax form

Ok, after a lengthy discussion Edegist and I actually sorted this all out. Here’s a couple of the key factors that comprise the solution. One, we had to loop through all of the selected checkboxes to pass via AJAX. jQuery( document ).ready( function( $ ) { $( ‘.kvo_ajax_submit_button’ ).click( function( e ) { e.preventDefault(); var … Read more

New Plugin Review

Now I’ve seen your code, I think the reviewer is wrong: they’re talking about the form in agg-as-options.php, which is handled the way I describe below except they’re wrong: the form is processed in the agg_options function, not outside of a function as they say this is only shown and processed on the admin aggregate-options … Read more

How to do conditional publishing?

That’s because the hook “transition_post_status” is called: After the post has been published or updated in the database After the status has been updated in the database. Based on your problem statement, I believe the hook you want is “pre_post_update”, as stated in relevant WordPress source code: /** * Fires immediately before an existing post … Read more

Javascript code inside “” in core WordPress files .php

These are Underscore Templates, handled by the wp.template() JavaScript function (source here) which takes in a template ID corresponding to a <script type=”text/html” id=”tmpl-{template ID}”> element containing such code and compiles it into a function. This function can then be executed with the variables used in the template in order to produce a string of … Read more

wordpress inserting posts programatically through a url

I finally got the answer to the problem. To make this code work: global $user_ID; $new_post = array( ‘post_title’ => ‘My New Post’, ‘post_content’ => ‘Lorem ipsum dolor sit amet…’, ‘post_status’ => ‘publish’, ‘post_date’ => date(‘Y-m-d H:i:s’), ‘post_author’ => $user_ID, ‘post_type’ => ‘post’, ‘post_category’ => array(0) ); $post_id = wp_insert_post($new_post); we need to make sure … Read more