Asking for help with your code

Here is what I had to look at this weekend, only about ten times longer.

add_action('save_post','my_save_post',10,2);
function my_save_post($post_id,$post){ if(wp_is_post_revision($post_id)){return;
}
$post= get_post($post_id);
if($post->post_parent==5){
$donotpublish=true;
if($donotpublish){
remove_action('save_post','my_save_post');
wp_update_post(array('ID'=>$post_id,'post_status'=>'draft'));
}
}
}

Yuck! So if you’re planning to ask for help with your code on forums, IRC, etc., please, do take some time to clean it up for the people that would love to help you. The WordPress Coding Standards is a good place to start.

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.