/**
  * Creates a new instance. Called on 'after_setup_theme'.
  * May be used to access class methods from outside.
  *
  * @see    __construct()
  * @return void
  */
 public static function instance()
 {
     null === self::$instance and self::$instance = new self();
     return self::$instance;
 }
 public function __construct()
 {
     if (!is_admin()) {
         return;
     }
     // set plugin base
     self::$plugin = REQUIRED_FIELDS_BASE;
     // plugin url
     self::$plugin_url = REQUIRED_FIELDS_URL;
     // translations
     load_plugin_textdomain(self::DOM, false, dirname(plugin_basename(__FILE__)) . '/lang');
     // force post to remain as draft if error messages are set
     add_filter('wp_insert_post_data', array($this, 'force_draft'), 12, 2);
     // force non empty title & content so plugin can take over
     add_filter('pre_post_title', array($this, 'mask_empty'));
     add_filter('pre_post_content', array($this, 'mask_empty'));
     // display & clear any errors
     add_action('admin_notices', array($this, 'notice_handler'));
     // settings
     add_action('admin_init', array($this, 'admin_init'), 9);
     // set up vars
     $this->post_id = isset($_GET['post']) ? intval($_GET['post']) : 0;
     $this->current_user = get_current_user_id();
     $this->transient_key = "save_post_error_{$this->post_id}_{$this->current_user}";
     // key should be specific to post and the user editing the post
     // add settings link
     add_filter('plugin_action_links_' . self::$plugin, array($this, 'settings_link'), 10, 1);
     // enqueue assets
     add_action('admin_enqueue_scripts', array($this, 'scripts'), 100);
 }