Is it advisable to use `add_rewrite_rule()` to serve a custom page?

Try instead using the template_redirect hook. Here I have a blogpost on using that approach: http://www.tomjn.com/386/content-without-posts/ I’ve had no issues with the admin toolbar using this method. It includes a helper class: <?php /** * A helper class to implement arbitrary content at arbitrary URLs without a supporting post or page. * Inherit from this … Read more

Default Display Name As Username

/** * Set new user’s display name as their login. * * @link http://wordpress.stackexchange.com/q/138034/1685 * * @param int $user_id */ function wpse_138034_display_name_as_login( $user_id ) { if ( $user = get_user_by( ‘id’, $user_id ) ) { // Prevent infinite loop. remove_action( ‘user_register’, __function__ ); wp_update_user( array( ‘ID’ => $user_id, ‘display_name’ => $user->user_login, ) ); // All … Read more

wp_customize set_transient except during preview

This seems to work, modifying the display_css_output() in this way: function display_css_output() { $html = get_transient( ‘my_custom_styles’ ); if ( empty( $html ) ) { $html = $this->generate_css_output(); global $wp_customize; if ( ! isset( $wp_customize ) ) { set_transient( ‘my_custom_styles’, $html, DAY_IN_SECONDS ); } } echo $html; } $short_life no longer needed. Basically check to … Read more

Widgets won’t save

This line of code is incorrect <?php if ( !function_exists(‘redmenu_widget’) || !dynamic_sidebar(‘redmenu_widget’) ) : ?> More to the point, your negative operator (!) is wrong here That line of code simply translates to If the function redmenu_widget does not exist OR if the sidebar redmenu_widget does not exists, do something You should just drop the … Read more

Determine if action was executed in functions

media_row_actions only filters the links in the Media Library (/wp-admin/upload.php?mode=list) And $wp_query_obj really should be $actions, since that’s whats being filtered. What’s in the object is an array of action keys and corresponding action links: ( [edit] => <a href=”http://domain.com/wp-admin/post.php?post=XX&amp;action=edit”>Edit</a> [delete] => <a class=”submitdelete” onclick=’return showNotice.warn();’ href=”post.php?action=delete&amp;post=XX&amp;_wpnonce=XXXX”>Delete Permanently</a> [view] => <a href=”http://domain.com/?attachment_id=XX” title=”View &#8220;Attachment Title&#8221;” … Read more