Change name of existing post status type

A number of admin interfaces are hardcoded to return the default statuses regardless of what you do. The post status system in WordPress is not exactly fully formed and you’ll no doubt encounter bugs. Refer to the edit flow plugin for examples of working around this

wp_insert_post_data filter hook identify current action

Not sure, but seems maybe $data[‘post_status’] would be set to ‘trash’ at that point. If so, then you could just do something like… if ($data[‘post_status’] == ‘trash’) { return $data; } …before the other manipulations. EDIT That code should work then – but needs to be at top of the function, like… public function updatetitle($data) … Read more

How add a group by to the query used by the media library?

I found a solution; use pre_get_posts: add_action( ‘pre_get_posts’, ‘modify_attachments’ ); function modify_attachments( $query ) { if ( is_admin() && strpos( $_SERVER[ ‘REQUEST_URI’ ], ‘admin-ajax.php’ ) !== false ) { add_filter( ‘posts_groupby’, ‘group_attachments’ ); } return $query; } function group_attachments( $groupby ) { $groupby .= ” guid”; return $groupby; }

Is this the proper way of switching the “Edit My Profile” link with my BuddyPress “Extended Profile” link?

Here is an example of what I’ve done: <?php $link = home_url( ‘/members/’ . bp_core_get_username( bp_displayed_user_id() ) . ‘/followers/’ ); echo “<a href=””. esc_attr( $link ) .””>Followers</a>”; ?> So maybe its home_url now, than site_url. In the echo, esc_attr gives out the $link. Change the whole bp_core_get_username( bp_displayed_user_id() ) to whatever you need – wp_get_current_user() … Read more

Are there actions or filters I can use for Ajax calls?

If you check the source for admin-ajax.php you will notice that the admin_init hook fires and that the system checks $_REQUEST[‘action’] for hooks. Given that, you could hook to admin_init, check the “request” super global, construct wp_ajax_* and wp_ajax_nopriv_* values, then use has_action() to see if anything is hooked in.

Filter Media by Featured on Admin

We can add the Featured option as a fake mime-type with: add_filter( ‘media_view_settings’, function( $settings ) { $settings[‘mimeTypes’][‘wpsefeaturedimage’] = ‘Featured’; return $settings; }); It will show up like this: Then we can use the posts_where filter and check for our fake mime type: /** * Filter for featured images in the media library popup */ … Read more

How to stop wrapping comments in P tag

Comments aren’t part of the post body. Those won’t be effected by the filters that you are trying to use. The core front end comment filters are these: 146 add_filter( ‘comment_text’, ‘wptexturize’ ); 147 add_filter( ‘comment_text’, ‘convert_chars’ ); 148 add_filter( ‘comment_text’, ‘make_clickable’, 9 ); 149 add_filter( ‘comment_text’, ‘force_balance_tags’, 25 ); 150 add_filter( ‘comment_text’, ‘convert_smilies’, 20 … Read more