/**
 * Load template files of the plugin also include a filter pn_get_template_part<br>
 * Based on WooCommerce function<br>
 *
 * @package   Plugin_Name
 * @author  Mte90 <*****@*****.**>
 * @license   GPL-2.0+
 * @copyright 2014-2015
 * @since    1.0.0
 */
function pn_get_template_part($slug, $name = '', $include = true)
{
    $template = '';
    $path = plugin_dir_path(realpath(dirname(__FILE__))) . 'templates/';
    $plugin = Plugin_Name::get_instance();
    $plugin_slug = $plugin->get_plugin_slug() . '/';
    // Look in yourtheme/slug-name.php and yourtheme/plugin-name/slug-name.php
    if ($name) {
        $template = locate_template(array("{$slug}-{$name}.php", $plugin_slug . "{$slug}-{$name}.php"));
    } else {
        $template = locate_template(array("{$slug}.php", $plugin_slug . "{$slug}.php"));
    }
    // Get default slug-name.php
    if (!$template && $name && file_exists($path . "{$slug}-{$name}.php")) {
        $template = $path . "{$slug}-{$name}.php";
    }
    // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/woocommerce/slug.php
    if (!$template) {
        $template = locate_template(array("{$slug}.php", $plugin_slug . "{$slug}.php"));
    }
    // Allow 3rd party plugin filter template file from their plugin
    $template = apply_filters('pn_get_template_part', $template, $slug, $name);
    if ($template && $include === true) {
        load_template($template, false);
    } else {
        if ($template && $include === false) {
            return $template;
        }
    }
}
/**
 * Load the plugin text domain for translation.
 *
 * @since    1.0.0
 */
function pn_load_plugin_textdomain()
{
    $plugin = Plugin_Name::get_instance();
    $domain = $plugin->get_plugin_slug();
    $locale = apply_filters('plugin_locale', get_locale(), $domain);
    load_textdomain($domain, trailingslashit(WP_LANG_DIR) . $domain . '/' . $domain . '-' . $locale . '.mo');
    load_plugin_textdomain($domain, FALSE, basename(plugin_dir_path(dirname(__FILE__))) . '/languages/');
}
 /**
  * Initialize the class
  *
  * @since     1.0.0
  */
 private function __construct()
 {
     /**
      * Call $plugin_slug from public plugin class.
      */
     $plugin = Plugin_Name::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     $this->plugin_version = $plugin->get_plugin_version();
 }
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     1.0.0
  */
 public function __construct()
 {
     $plugin = Plugin_Name::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     $this->plugin_name = $plugin->get_plugin_name();
     //Add the export settings method
     add_action('admin_init', array($this, 'settings_export'));
     //Add the import settings method
     add_action('admin_init', array($this, 'settings_import'));
 }
 function __construct()
 {
     $plugin = Plugin_Name::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     // Configure widget array
     $args = array('label' => __('My Recent Posts', $this->plugin_slug), 'description' => __('My Recent Posts Widget Description', $this->plugin_slug));
     // Configure the widget fields
     // Example for: Title ( text ) and Amount of posts to show ( select box )
     $args['fields'] = array(array('name' => __('Title', $this->plugin_slug), 'desc' => __('Enter the widget title.', $this->plugin_slug), 'id' => 'title', 'type' => 'text', 'class' => 'widefat', 'std' => __('Recent Posts', $this->plugin_slug), 'validate' => 'alpha_dash', 'filter' => 'strip_tags|esc_attr'), array('name' => __('Amount'), 'desc' => __('Select how many posts to show.', $this->plugin_slug), 'id' => 'amount', 'type' => 'select', 'fields' => array(array('name' => __('1 Post', $this->plugin_slug), 'value' => '1'), array('name' => __('2 Posts', $this->plugin_slug), 'value' => '2'), array('name' => __('3 Posts', $this->plugin_slug), 'value' => '3')), 'validate' => 'my_custom_validation', 'filter' => 'strip_tags|esc_attr'), array('name' => __('Output as list', $this->plugin_slug), 'desc' => __('Wraps posts with the <li> tag.', $this->plugin_slug), 'id' => 'list', 'type' => 'checkbox', 'std' => 1, 'filter' => 'strip_tags|esc_attr'));
     // fields array
     // create widget
     $this->create_widget($args);
 }
 /**
  * Initialize the class
  *
  * @since     1.0.0
  */
 private function __construct()
 {
     /*
      * Call $plugin_slug from public plugin class.
      */
     $plugin = Plugin_Name::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     $this->plugin_version = $plugin->get_plugin_version();
     // Backend hooks and filters
     if (is_admin()) {
         add_action('admin_enqueue_scripts', array($this, 'tinymce_plugin_css'));
         add_action("admin_head", array($this, 'js_ajax_nonce'));
         add_action('admin_init', array($this, 'register_tinymce_plugin'));
         add_action('wp_ajax_admin_shortcode_popup', array($this, 'ajax_admin_shortcode_popup'));
     }
 }
 /**
  * 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 = Plugin_Name::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     $this->plugin_version = $plugin->get_plugin_version();
     // Load admin style sheet and JavaScript.
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_css_js'));
     // Add the plugin admin pages and menu items.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
 }
 /**
  * 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 = Plugin_Name::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     $this->plugin_version = $plugin->get_plugin_version();
     // Load admin style sheet and JavaScript.
     //add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_css_js' ) );
     // Add an action link pointing to the options page.
     $plugin_basename = plugin_basename(plugin_dir_path(realpath(dirname(dirname(__FILE__)))) . $this->plugin_slug . '.php');
     add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_action_links'));
 }
/**
 * Load email template files of the plugin also include a filter pn_get_email_template<br>
 *
 * @package   Plugin_Name
 * @author  Mte90 <*****@*****.**>
 * @license   GPL-2.0+
 * @copyright 2014-2015
 * @since    1.0.0
 */
function pn_get_email_template($name, $prefix = '')
{
    $template = '';
    $folder = 'email-templates/';
    $path = plugin_dir_path(realpath(dirname(__FILE__))) . $folder;
    $plugin = Plugin_Name::get_instance();
    $plugin_slug = $plugin->get_plugin_slug() . '/';
    $locale = apply_filters("plugin_locale", get_locale(), $plugin->get_plugin_slug());
    // Look in yourtheme/plugin-name/{locale}/name.tpl and yourtheme/plugin-name/email-templates/{locale}/name.tpl
    if (empty($template)) {
        $search = array($plugin_slug . $folder . $locale . '/' . $name . '.tpl', $plugin_slug . $folder . 'en_US/' . $name . '.tpl', $plugin_slug . $locale . '/' . $name . '.tpl', $plugin_slug . 'en_US/' . $name . '.tpl');
        if (!empty($prefix)) {
            array_unshift($search, $plugin_slug . 'en_US/' . $prefix . '-' . $name . '.tpl');
            array_unshift($search, $plugin_slug . $folder . 'en_US/' . $prefix . '-' . $name . '.tpl');
            array_unshift($search, $plugin_slug . $locale . '/' . $prefix . '-' . $name . '.tpl');
            array_unshift($search, $plugin_slug . $folder . $locale . '/' . $prefix . '-' . $name . '.tpl');
        }
        $template = locate_template($search);
    }
    // Load the template from plugin folders
    if (!empty($prefix)) {
        if (file_exists($path . $locale . '/' . $prefix . '-' . $name . '.tpl')) {
            $template = $path . $locale . '/' . $prefix . '-' . $name . '.tpl';
        } elseif (file_exists($path . 'en_US/' . $prefix . '-' . $name . '.tpl')) {
            $template = $path . 'en_US/' . $prefix . '-' . $name . '.tpl';
        }
    }
    if (empty($template)) {
        if (file_exists($path . $locale . '/' . $name . '.tpl')) {
            $template = $path . $locale . '/' . $name . '.tpl';
        } elseif (file_exists($path . 'en_US/' . $name . '.tpl')) {
            $template = $path . 'en_US/' . $name . '.tpl';
        }
    }
    // Allow 3rd party plugin filter template file from their plugin
    $template = apply_filters('pn_get_email_template', $template, $name, $prefix);
    return wpautop(file_get_contents($template));
}
 /**
  * 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.
      *
      * @TODO:
      *
      * - Rename "Plugin_Name" to the name of your initial plugin class
      *
      */
     $plugin = Plugin_Name::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     // 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 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(__DIR__) . $this->plugin_slug . '.php');
     add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_action_links'));
     /*
      * Define custom functionality.
      *
      * Read more about actions and filters:
      * http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters
      */
     add_action('@TODO', array($this, 'action_method_name'));
     add_filter('@TODO', array($this, 'filter_method_name'));
 }
 /**
  * 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.
      *
      * @TODO:
      *
      * - Rename "Plugin_Name" to the name of your initial plugin class
      *
      */
     $plugin = Plugin_Name::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     $this->plugin_name = $plugin->get_plugin_name();
     $this->version = $plugin->get_plugin_version();
     $this->cpts = $plugin->get_cpts();
     // 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'));
     // Load admin style in dashboard for the At glance widget
     add_action('admin_head-index.php', array($this, 'enqueue_admin_styles'));
     // At Glance Dashboard widget for your cpts
     add_filter('dashboard_glance_items', array($this, 'cpt_dashboard_support'), 10, 1);
     // Add the options page and menu item.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
     //Add bubble notification for cpt pending
     add_action('admin_menu', array($this, 'pending_cpt_bubble'), 999);
     // Add an action link pointing to the options page.
     $plugin_basename = plugin_basename(plugin_dir_path(realpath(dirname(__FILE__))) . $this->plugin_slug . '.php');
     add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_action_links'));
     /*
      * CMB 2 for metabox and many other cool things!
      * https://github.com/WebDevStudios/CMB2
      * Also CMB2 Shortcode support 
      * Check on the repo for the example and documentation 
      * https://github.com/jtsternberg/Shortcode_Button
      */
     require_once plugin_dir_path(__FILE__) . '/includes/CMB2/init.php';
     require_once plugin_dir_path(__FILE__) . '/includes/CMB2-Shortcode/shortcode-button.php';
     /*
      * Add metabox
      */
     add_action('cmb2_init', array($this, 'cmb_demo_metaboxes'));
     /*
      * Define custom functionality.
      *
      * Read more about actions and filters:
      * http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters
      */
     add_action('@TODO', array($this, 'action_method_name'));
     add_filter('@TODO', array($this, 'filter_method_name'));
     //Add the export settings method
     add_action('admin_init', array($this, 'settings_export'));
     //Add the import settings method
     add_action('admin_init', array($this, 'settings_import'));
     /*
      * Debug mode
      */
     require_once plugin_dir_path(__FILE__) . 'includes/debug.php';
     $debug = new Pn_Debug($this);
     $debug->log(__('Plugin Loaded', $this->plugin_slug));
     /*
      * Load Wp_Contextual_Help for the help tabs
      */
     add_filter('wp_contextual_help_docs_dir', array($this, 'help_docs_dir'));
     add_filter('wp_contextual_help_docs_url', array($this, 'help_docs_url'));
     if (!class_exists('WP_Contextual_Help')) {
         require_once plugin_dir_path(__FILE__) . 'includes/WP-Contextual-Help/wp-contextual-help.php';
     }
     add_action('init', array($this, 'contextual_help'));
     /*
      * Load Wp_Admin_Notice for the notices in the backend
      * 
      * First parameter the HTML, the second is the css class
      */
     if (!class_exists('WP_Admin_Notice')) {
         require_once plugin_dir_path(__FILE__) . 'includes/WP-Admin-Notice/WP_Admin_Notice.php';
     }
     new WP_Admin_Notice(__('Updated Messages'), 'updated');
     new WP_Admin_Notice(__('Error Messages'), 'error');
     /*
      * Load PointerPlus for the Wp Pointer
      * 
      * Unique paramter is the prefix
      */
     if (!class_exists('PointerPlus')) {
         require_once plugin_dir_path(__FILE__) . 'includes/PointerPlus/class-pointerplus.php';
     }
     $pointerplus = new PointerPlus(array('prefix' => $this->plugin_slug));
     //With this you can reset all the pointer with your prefix
     //$pointerplus->reset_pointer();
     add_filter('pointerplus_list', array($this, 'custom_initial_pointers'), 10, 2);
     /*
      * Load CPT_Columns
      * 
      * Check the file for example
      */
     require_once plugin_dir_path(__FILE__) . 'includes/CPT_Columns.php';
     $post_columns = new CPT_columns('demo');
     $post_columns->add_column('cmb2_field', array('label' => __('CMB2 Field'), 'type' => 'post_meta', 'meta_key' => '_demo_' . $this->plugin_slug . '_text', 'orderby' => 'meta_value', 'sortable' => true, 'prefix' => "<b>", 'suffix' => "</b>", 'def' => "Not defined", 'order' => "-1"));
 }
/**
 * Begins execution of the plugin.
 *
 * @since    1.0.0
 */
function run_plugin_name()
{
    /**
     * Check requirements and load main class
     * The main program needs to be in a separate file that only gets loaded if the plugin requirements are met.
     * Otherwise older PHP installations could crash when trying to parse it.
     **/
    if (plugin_name_requirements_met()) {
        /**
         * The core plugin class that is used to define internationalization,
         * admin-specific hooks, and public-facing site hooks.
         */
        require_once plugin_dir_path(__FILE__) . 'includes/class-plugin-name.php';
        /**
         * Begins execution of the plugin.
         *
         * Since everything within the plugin is registered via hooks,
         * then kicking off the plugin from this point in the file does
         * not affect the page life cycle.
         *
         * @since    1.0.0
         */
        $plugin = Plugin_Name::get_instance();
    } else {
        add_action('admin_notices', 'plugin_name_show_requirements_error');
        require_once ABSPATH . 'wp-admin/includes/plugin.php';
        deactivate_plugins(plugin_basename(__FILE__));
    }
}