Example #1
0
/**
 * Load the plugin text domain for translation.
 *
 * @since    1.0.0
 */
function pn_load_plugin_textdomain()
{
    $plugin = DoBalance::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/');
}
Example #2
0
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     1.0.0
  */
 public function __construct()
 {
     $plugin = DoBalance::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'));
 }
Example #3
0
 function __construct()
 {
     $plugin = DoBalance::get_instance();
     $this->plugin_slug = $plugin->get_plugin_slug();
     // Configure widget array
     $args = array('label' => __('My Recent Posts Example', $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' => __('Taxonomy', $this->plugin_slug), 'desc' => __('Set the taxonomy.', $this->plugin_slug), 'id' => 'taxonomy', 'type' => 'taxonomy', 'class' => 'widefat'), array('name' => __('Taxonomy terms', $this->plugin_slug), 'desc' => __('Set the taxonomy terms.', $this->plugin_slug), 'id' => 'taxonomyterm', 'type' => 'taxonomyterm', 'taxonomy' => 'category', 'class' => 'widefat'), array('name' => __('Pages', $this->plugin_slug), 'desc' => __('Set the page.', $this->plugin_slug), 'id' => 'pages', 'type' => 'pages', 'class' => 'widefat'), array('name' => __('Post type', $this->plugin_slug), 'desc' => __('Set the post type.', $this->plugin_slug), 'id' => 'posttype', 'type' => 'posttype', 'posttype' => 'post', 'class' => 'widefat'), 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 plugin by loading admin scripts & styles and adding a settings page and menu.
  * @since     0.0.1
  */
 private function __construct()
 {
     // available only for super admins
     if (!is_super_admin()) {
         return;
     }
     /**
      * Call $plugin_slug from public plugin class.
      */
     $plugin = DoBalance::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_glance_dashboard_support'), 10, 1);
     // Activity Dashboard widget for your cpts
     add_filter('dashboard_recent_posts_query_args', array($this, 'cpt_activity_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'));
     require_once plugin_dir_path(__FILE__) . 'views/user_hierarchy.php';
     /**
      * CMB 2 for metabox and many other cool things!
      * https://github.com/WebDevStudios/CMB2
      */
     require_once plugin_dir_path(__FILE__) . '/includes/CMB2/init.php';
     /**
      * 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-Shortcode/shortcode-button.php';
     /**
      * CMB2 Grid 
      * Check on the repo for the example and documentation 
      * https://github.com/origgami/CMB2-grid
      */
     require_once plugin_dir_path(__FILE__) . '/includes/CMB2-grid/Cmb2GridPlugin.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'));
     /**
      * Import Export settings
      */
     require_once plugin_dir_path(__FILE__) . 'includes/impexp.php';
     /**
      * Debug mode
      */
     require_once plugin_dir_path(__FILE__) . 'includes/debug.php';
     $debug = new Pn_Debug();
     $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 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"));
 }
Example #5
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;
 }