Get publish post link?

I used URL parameters and created a specific function called at init: add_action( ‘init’, ‘publish_post_status’ ); function publish_post_status($post_id){ if (isset($_GET[‘publish’]) && current_user_can(‘publish_posts’)) { if ($_GET[‘publish’] == “true”) { $current_post = get_post( $_GET[‘post_id’], ‘ARRAY_A’ ); $current_post[‘post_status’] = ‘publish’; wp_update_post($current_post); } } if (isset($_GET[‘queue’])) { if ($_GET[‘queue’] == “true”) { $current_post = get_post( $_GET[‘post_id’], ‘ARRAY_A’ ); $current_post[‘post_status’] … Read more

Custom save button shows ‘Are you sure you want to…’ dialog

SOLVED: Found the solution. Trick is to disable the autosave. But take care to only do this on a non-ajax save. add_action( ‘admin_enqueue_scripts’, ‘my_admin_enqueue_scripts’ ); function my_admin_enqueue_scripts() { if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return false; // don’t disable if it is an auto-autosave if ( ‘POST_TYPE’ == get_post_type() ){ wp_dequeue_script( ‘autosave’ ); … Read more

publish_post called too early

Try this workaround of this issue without using publish_post hook (using save_post) add_action( ‘save_post’, ‘wpse228941_save_post’ ); function wpse228941_save_post( $post_id ) { if( defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE ) return; if ( “publish” == get_post_status( $post_id ) && ! get_post_meta( $post_id, “se_228941_mailed”, 1 ) ) { do_action( “sm12_publish_post”, $post_id ); update_post_meta( $post_id, “se_228941_mailed”, time() ); } } add_action( … Read more