public function __construct() { /* * Call $plugin_slug from public plugin class. */ $plugin = Google_Maps_Builder::get_instance(); $this->plugin_slug = $plugin->get_plugin_slug(); // Filter to automatically add maps to post type content add_filter('the_content', array($this, 'the_content'), 2); //add shortcode support add_shortcode('google_maps', array($this, 'google_maps_shortcode')); }
/** * Constructor * @since 0.1.0 */ public function __construct() { $plugin = Google_Maps_Builder::get_instance(); $this->plugin_slug = $plugin->get_plugin_slug(); $this->meta = $plugin->meta; //Create Settings submenu add_action('admin_init', array($this, 'mninit')); add_action('admin_menu', array($this, 'add_page')); // 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('wp_ajax_hide_welcome', array($this, 'hide_welcome_callback')); add_action('admin_enqueue_scripts', array($this, 'enqueue_pointer_script_style')); add_action('cmb_render_lat_lng_default', array($this, 'cmb_render_lat_lng_default'), 10, 2); //Add links/information to plugin row meta add_filter('plugin_row_meta', array($this, 'add_plugin_meta_links'), 10, 2); add_filter('plugin_action_links', array($this, 'add_plugin_page_links'), 10, 2); }
/** * Specifies the classname and description, instantiates the widget, * loads localization files, and includes necessary stylesheets and JavaScript. */ public function __construct() { /* * Call $plugin_slug from public plugin class. */ $plugin = Google_Maps_Builder::get_instance(); $this->plugin_slug = $plugin->get_plugin_slug(); parent::__construct('widget-google-places', __('WordPress Google Places', $this->plugin_slug), array('classname' => 'widget-google-places', 'description' => __('Add Google business reviews, ratings and maps and more.', $this->plugin_slug))); // Register admin styles and scripts add_action('admin_print_styles', array($this, 'register_admin_styles')); add_action('admin_enqueue_scripts', array($this, 'register_admin_scripts')); // Register site styles and scripts add_action('wp_enqueue_scripts', array($this, 'register_widget_styles')); add_action('wp_enqueue_scripts', array($this, 'register_widget_scripts')); // Refreshing the widget's cached output with each new post add_action('save_post', array($this, 'flush_widget_cache')); add_action('deleted_post', array($this, 'flush_widget_cache')); add_action('switch_theme', array($this, 'flush_widget_cache')); }
/** * Initialize the plugin by loading admin scripts & styles and adding a * settings page and menu. * * @since 1.0.0 */ private function __construct() { /* * Call $plugin_slug from public plugin class. */ $plugin = Google_Maps_Builder::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 metaboxes and fields to CPT add_filter('cmb_meta_boxes', array($this, 'cpt_metaboxes_fields'), 1); //Custom Meta Fields add_action('cmb_render_google_geocoder', array($this, 'cmb_render_google_geocoder'), 10, 2); add_action('cmb_render_google_maps_preview', array($this, 'cmb_render_google_maps_preview'), 10, 2); add_action('cmb_render_search_options', array($this, 'cmb_render_search_options'), 10, 2); add_action('cmb_render_width_height', array($this, 'cmb_render_width_height'), 10, 2); add_action('cmb_render_lat_lng', array($this, 'cmb_render_lat_lng'), 10, 2); add_action('post_submitbox_misc_actions', array($this, 'gmb_add_shortcode_to_publish_metabox')); }
/** * Main Google_Maps_Builder Instance * * Insures that only one instance of Google_Maps_Builder exists in memory at any one * time. Also prevents needing to define globals all over the place. * * @since 2.0 * @static * @static var array $instance * @uses Google_Maps_Builder::setup_constants() Setup the constants needed * @uses Google_Maps_Builder::includes() Include the required files * @uses Google_Maps_Builder::load_textdomain() load the language files * @see Google_Maps_Builder() * @return Google_Maps_Builder */ public static function instance() { if (!isset(self::$instance) && !self::$instance instanceof Google_Maps_Builder) { self::$instance = new Google_Maps_Builder(); self::$instance->setup_constants(); add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); self::$instance->includes(); self::$instance->activate = new Google_Maps_Builder_Activate(); self::$instance->scripts = new Google_Maps_Builder_Scripts(); self::$instance->settings = new Google_Maps_Builder_Settings(); self::$instance->engine = new Google_Maps_Builder_Engine(); //Init CPT (after CMB2 -> hence the 10000 priority) add_action('init', array(self::$instance, 'setup_post_type'), 10000); // Read plugin meta // Check that function get_plugin_data exists if (!function_exists('get_plugin_data')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } self::$instance->meta = get_plugin_data(GMB_PLUGIN_FILE, false); } return self::$instance; }
/** * Main Google_Maps_Builder Instance * * Insures that only one instance of Google_Maps_Builder exists in memory at any one * time. Also prevents needing to define globals all over the place. * * @since 2.0 * @static * @static var array $instance * @uses Google_Maps_Builder::setup_constants() Setup the constants needed * @uses Google_Maps_Builder::includes() Include the required files * @uses Google_Maps_Builder::load_textdomain() load the language files * @see Google_Maps_Builder() * @return Google_Maps_Builder */ public static function instance() { if (!isset(self::$instance) && !self::$instance instanceof Google_Maps_Builder) { self::$instance = new Google_Maps_Builder(); self::$instance->setup_constants(); add_action('plugins_loaded', array(self::$instance, 'load_textdomain')); self::$instance->includes(); self::$instance->activate = new Google_Maps_Builder_Activate(); self::$instance->scripts = new Google_Maps_Builder_Scripts(); self::$instance->settings = new Google_Maps_Builder_Settings(); self::$instance->engine = new Google_Maps_Builder_Engine(); register_activation_hook(__FILE__, array(self::$instance->activate, 'activation_flush_rewrites')); // Read plugin meta // Check that function get_plugin_data exists if (!function_exists('get_plugin_data')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } self::$instance->meta = get_plugin_data(GMB_PLUGIN_FILE, false); } return self::$instance; }
/** * 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; }
/** * The main function responsible for returning the one true Maps Builder instance to function everywhere. * * Use this function like you would a global variable, except without needing * to declare the global. * * Example: <?php $gmb = Google_Maps_Builder(); ?> * * @since 2.0 * @return object|Google_Maps_Builder */ function Google_Maps_Builder() { return Google_Maps_Builder::instance(); }