How can I add a jQuery OnClick event to the Publish posts button?

You can hook into the post footer actions (based on this answer, not tested): add_action( ‘admin_footer-post-new.php’, ‘wpse_80215_script’ ); add_action( ‘admin_footer-post.php’, ‘wpse_80215_script’ ); function wpse_80215_script() { if ( ‘post’ !== $GLOBALS[‘post_type’] ) return; ?> <script> document.getElementById(“publish”).onclick = function() { if ( confirm( “Ready?” ) ) return true; return false; }</script> <?php } These actions are called … Read more

Publish pending article from front end with a button?

First create a function that will print the publish button : //function to print publish button function show_publish_button(){ Global $post; //only print fi admin if (current_user_can(‘manage_options’)){ echo ‘<form name=”front_end_publish” method=”POST” action=””> <input type=”hidden” name=”pid” id=”pid” value=”‘.$post->ID.'”> <input type=”hidden” name=”FE_PUBLISH” id=”FE_PUBLISH” value=”FE_PUBLISH”> <input type=”submit” name=”submit” id=”submit” value=”Publish”> </form>’; } } Next create a function to change … Read more

Post publish only hook?

The {$old_status}_to_{$new_status} and {$new_status}_{$post->post_type} hooks tend to generally solve the problem. To avoid running the code in case post status is changed to draft then published again (after already being published), implement a simple flag using the post_meta functionality. Note: the updated hook should be ‘draft_to_publish’ instead of ‘draft_to_published’ however, the code below is not … Read more

How can I make post fields required in WordPress?

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

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