Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Created November 9, 2015 19:36
Show Gist options
  • Save whyisjake/5ae82e99af5016a04eeb to your computer and use it in GitHub Desktop.
Save whyisjake/5ae82e99af5016a04eeb to your computer and use it in GitHub Desktop.
<?php
/*
* Plugin Name: Ready to Publish
* Description: Add a little checkbox to ensure that you are ready to publish a post.
* Author: Jake Spurlock
* Version: 0.5.0
*/
class Ready_to_Publish {
/**
* The one instance of Ready_to_Publish.
*
* @var Ready_to_Publish
*/
private static $instance;
/**
* Instantiate or return the one Ready_to_Publish instance.
*
* @return Ready_to_Publish
*/
public static function instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Initiate actions.
*
* @return Ready_to_Publish
*/
public function __construct() {
add_action( 'admin_enqueue_scripts', array( $this, 'enqueueueue_js' ) );
add_shortcode( 'table', array( $this, 'table' ) );
}
/**
* Enqueue the Javascript
* @return void
*/
public function enqueueueue_js() {
global $post;
if ( has_shortcode( $post->post_content, 'table' ) ) {
wp_enqueue_script( $this->slug, plugin_dir_url( __FILE__ ) . 'ready-to-publish.js', array( 'jquery' ) );
}
}
/**
* Add a checkbox to post_submitbox_misc_actions area that must be checked ahead of publishing a post.
* @return void
*/
public function table( $atts, $content ) {
return esc_url( $atts['url'] );
}
}
/**
* Instantiate or return the one Ready_to_Publish instance.
*
* @return Ready_to_Publish
*/
function ready_to_publish_instance() {
return Ready_to_Publish::instance();
}
// Kick off the plugin on init
add_action( 'init', 'ready_to_publish_instance' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment