コード例 #1
0
 /**
  * Return an instance of this class.
  *
  * @since     1.0.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;
 }
コード例 #2
0
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     1.0.0
  */
 private function __construct()
 {
     /*
      * @TODO :
      *
      * - Uncomment following lines if the admin class should only be available for super admins
      */
     /* if( ! is_super_admin() ) {
     	  return;
     	  } */
     /*
      * Call $plugin_slug from public plugin class.
      */
     $plugin = PT_Content_Views::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     // Fix redirect error
     add_action('init', array($this, 'do_output_buffer'));
     // Redirect to "Add View" page when click "Add new" link in "All Views" page
     add_action('admin_init', array($this, 'redirect_add_new'));
     // Load admin style sheet and JavaScript.
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
     add_action('admin_print_footer_scripts', array($this, 'print_footer_scripts'));
     // Add the options page and menu item.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
     // Ajax action
     $action = 'preview_request';
     add_action('wp_ajax_' . $action, array('PT_CV_Functions', 'ajax_callback_' . $action));
     // Output assets content at footer of page
     add_action(PT_CV_PREFIX_ . 'preview_footer', array('PT_CV_Html', 'assets_of_view_types'));
     // Add an action link pointing to the options page.
     $plugin_basename = plugin_basename(plugin_dir_path(dirname(__FILE__)) . $this->plugin_slug . '.php');
     add_filter('plugin_action_links_' . $plugin_basename, array($this, 'filter_add_action_links'));
     // Filter link of actions in All Views page
     add_filter('post_row_actions', array($this, 'filter_view_row_actions'), 10, 2);
     // Add Shortcode column
     add_filter('manage_pt_view_posts_columns', array($this, 'filter_view_custom_column_header'));
     add_action('manage_pt_view_posts_custom_column', array($this, 'action_view_custom_column_content'), 10, 2);
     // Filter link of Title in All Views page
     add_filter('get_edit_post_link', array($this, 'filter_get_edit_post_link'), 10, 3);
     // Filter Title of Edit View page
     add_filter('admin_title', array($this, 'filter_admin_title'), 10, 2);
     // Custom hooks for both preview & frontend
     PT_CV_Hooks::init();
     // Custom settings page
     PT_CV_Plugin::init();
 }
コード例 #3
0
define('PT_CV_PATH', plugin_dir_path(__FILE__));
include_once PT_CV_PATH . 'includes/defines.php';
// Include library files
include_once PT_CV_PATH . 'includes/assets.php';
include_once PT_CV_PATH . 'includes/functions.php';
include_once PT_CV_PATH . 'includes/hooks.php';
include_once PT_CV_PATH . 'includes/html-viewtype.php';
include_once PT_CV_PATH . 'includes/html.php';
include_once PT_CV_PATH . 'includes/settings.php';
include_once PT_CV_PATH . 'includes/update.php';
include_once PT_CV_PATH . 'includes/values.php';
// Main file
include_once PT_CV_PATH . 'public/content-views.php';
// Register hooks when the plugin is activated or deactivated.
register_activation_hook(__FILE__, array('PT_Content_Views', 'activate'));
register_deactivation_hook(__FILE__, array('PT_Content_Views', 'deactivate'));
// Load plugin
PT_Content_Views::get_instance();
// For Admin
if (is_admin()) {
    include_once PT_CV_PATH . 'admin/includes/options.php';
    include_once PT_CV_PATH . 'admin/includes/plugin.php';
    include_once PT_CV_PATH . 'admin/content-views-admin.php';
    PT_Content_Views_Admin::get_instance();
}
// Support for post thumbnails
add_theme_support('post-thumbnails');
// Enable shortcode in content
add_filter('the_content', 'do_shortcode', 15);
// Enable shortcodes in text widgets.
add_filter('widget_text', 'do_shortcode', 15);