What’s $object->filter for?

The $post->filter contains the context under which the contents of the post have been filtered. Context could be something like “display” indicating the post is meant to be displayed on the page. This is done by the sanitization functions, to indicate under what context the post data was sanitized. Different contexts get different types of … Read more

Post/Page Preview Template

You could use the conditional is_preview() to add a bit of extra content. For instance, you could put this at the very top of your single.php right after the header is called – or you could put it in your header.php file if you want it shown at the very top of the page: <?php … Read more

Make featured image required

Fairly simple using jQuery and global $typenow ex: add_action(‘admin_print_scripts-post.php’, ‘my_publish_admin_hook’); add_action(‘admin_print_scripts-post-new.php’, ‘my_publish_admin_hook’); function my_publish_admin_hook(){ global $typenow; if (in_array($typenow, array(‘post’,’page’,’mm_photo ‘))){ ?> <script language=”javascript” type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#post’).submit(function() { if (jQuery(“#set-post-thumbnail”).find(‘img’).size() > 0) { jQuery(‘#ajax-loading’).hide(); jQuery(‘#publish’).removeClass(‘button-primary-disabled’); return true; }else{ alert(“please set a featured image!!!”); jQuery(‘#ajax-loading’).hide(); jQuery(‘#publish’).removeClass(‘button-primary-disabled’); return false; } return false; }); }); </script> <?php } … Read more

Dynamically add id to heading tags

I had this very same dilemma, and I found this plugin: Add IDs to Header Tags, and it works fine for posts. (I’m not affiliated to the plugin in any way). To make it work for pages too, I had to make a change in the code, which is explained on this support page: Not … Read more

WordPress removing tags?

This is pretty much what Foxsk8 mentioned in a comment, so credit should go to him, but these additional instructions will be useful. The WordPress plugin called TinyMCE Advanced will solve your problem. This plugin comes with an option inside Settings > TinyMCE Advanced that will fix your disappearing <p> tags. Mark the checkbox labeled … Read more

Find out who deleted a page or post?

By default, no, WordPress doesn’t keep track of who changes post statuses (at least that I can see). you can hook into transition_post_status and log the user id. add_action( ‘transition_post_status’, ‘wwm_transition_post_status’, 10, 3 ); function wwm_transition_post_status( $new_status, $old_status, $post ) { if ( ‘trash’ == $new_status ) { $uid = get_current_user_id(); //somehow or another log … Read more

How to validate XML-RPC post creation and cancel when needed?

It looks like the xmlrpc_prepare_post filter is only applied to the output of the wp_getPost and wp_getRevision methods of the wp_xmlrpc_server class. It would be great if this code line: do_action( ‘xmlrpc_call’, ‘wp.newPost’ ); would be replaced with extra input arguments, for example: do_action( ‘xmlrpc_call’, ‘wp.newPost’, …, $content_struct ); but that’s not going to happen … Read more

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