/**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     0.1.0
  */
 private function __construct()
 {
     /*
      * Call $plugin_slug from public plugin class.
      *
      */
     $plugin = Custom_Featured_Image_Metabox::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     // Add the options page and menu item.
     require_once plugin_dir_path(__FILE__) . 'includes/settings.php';
     // Add the options page and menu item.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
     // Add an action link pointing to the options page.
     $plugin_basename = plugin_basename(plugin_dir_path(realpath(dirname(__FILE__))) . 'custom-featured-image-metabox.php');
     add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_action_links'));
     add_action('add_meta_boxes', array($this, 'change_metabox_title'));
     add_filter('admin_post_thumbnail_html', array($this, 'change_metabox_content'));
     add_filter('media_view_strings', array($this, 'change_media_strings'), 10, 2);
 }
Beispiel #2
0
 /**
  * Registering the Sections, Fields, and Settings.
  *
  * This function is registered with the 'admin_init' hook.
  */
 public function admin_init()
 {
     $plugin = Custom_Featured_Image_Metabox::get_instance();
     $post_types = $plugin->supported_post_types();
     $defaults = array('title' => '', 'instruction' => '', 'set_text' => '', 'remove_text' => '');
     foreach ($post_types as $pt) {
         $post_object = get_post_type_object($pt);
         $section = $this->plugin_slug . '_' . $pt;
         if (false == get_option($section)) {
             add_option($section, apply_filters($section . '_default_settings', $defaults));
         }
         $args = array($section, get_option($section));
         add_settings_section($pt, sprintf(__('Featured Image Metabox in %s', $this->plugin_slug), $post_object->labels->name), '', $section);
         add_settings_field('title', __('Title Text', $this->plugin_slug), array($this, 'title_callback'), $section, $pt, $args);
         add_settings_field('instruction', __('Instruction', $this->plugin_slug), array($this, 'instruction_callback'), $section, $pt, $args);
         add_settings_field('set_text', __('Set Text', $this->plugin_slug), array($this, 'set_text_callback'), $section, $pt, $args);
         add_settings_field('remove_text', __('Remove Text', $this->plugin_slug), array($this, 'remove_text_callback'), $section, $pt, $args);
         register_setting($section, $section, array($this, 'validate_inputs'));
     }
 }
Beispiel #3
0
<?php

/**
 * Fired when the plugin is uninstalled.
 *
 * @package   Custom Featured Image Metabox
 * @author    1fixdotio <*****@*****.**>
 * @license   GPL-2.0+
 * @link      http://example.com
 * @copyright 2014 1Fix.io
 */
// If uninstall not called from WordPress, then exit
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}
require_once plugin_dir_path(__FILE__) . 'public/class-custom-featured-image-metabox.php';
$plugin = Custom_Featured_Image_Metabox::get_instance();
$post_types = $plugin->supported_post_types();
foreach ($post_types as $pt) {
    delete_option($plugin->get_plugin_slug() . '_' . $pt);
}
delete_option('cfim-display-activation-message');
/**
 * @todo Delete options in whole network
 */
 /**
  * Return an instance of this class.
  *
  * @since     0.1.0
  *
  * @return    object    A single instance of this class.
  */
 public static function get_instance()
 {
     // If the single instance hasn't been set, set it now.
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }