/** * Return an instance of this class. * * @return object A single instance of this class. * * @since 1.3 * @version 1.3.7 * */ 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; }
/** * Constructor Function * * Initialize the plugin by loading admin scripts & styles and adding a * settings page and menu. * * @since 1.2 * @version 1.3.7 * */ function __construct() { /** * Call $plugin_slug from public plugin class. * */ $plugin = Easy_Google_Fonts::get_instance(); $this->plugin_slug = $plugin->get_plugin_slug(); $this->register_actions(); $this->register_filters(); }
/** * Load Customizer Styles * * Loads the required css for the live theme previewer. It is used * as a way to style the custom customizer controls on the live * preview screen. This is hooked into the live previewer using the * action: 'customize_register'. * * @return void * * @since 1.3 * @version 1.3.6 * */ public function customize_preview_styles() { wp_enqueue_style('wp-color-picker'); // Load Chosen CSS wp_register_style($this->plugin_slug . '-chosen-css', Easy_Google_Fonts::get_css_url() . '/chosen.css', false, '1.3.0'); wp_enqueue_style($this->plugin_slug . '-chosen-css'); // Load CSS to style custom customizer controls wp_register_style($this->plugin_slug . '-customizer-css', Easy_Google_Fonts::get_css_url() . '/customizer.css', false, Easy_Google_Fonts::VERSION); wp_enqueue_style($this->plugin_slug . '-customizer-css'); }
/** * Constructor Function * * Initialize the plugin by loading admin scripts & styles and adding a * settings page and menu. * * @uses Easy_Google_Fonts::get_instance() defined in \includes\class-easy-google-fonts.php * * @since 1.2 * @version 1.3.9 * */ function __construct() { /** * Call $plugin_slug from public plugin class. * */ $plugin = Easy_Google_Fonts::get_instance(); $this->plugin_slug = $plugin->get_plugin_slug(); // Setup class variables $this->set_urls(); $this->set_font_controls(); $this->set_screen_state(); // Register actions and filters $this->register_actions(); $this->register_filters(); }
/** * Get Positioning Controls * * Controls: * - Border ( Top, Bottom, Left, Right ) * - Margin ( Top, Bottom, Left, Right ) * - Padding ( Top, Bottom, Left, Right ) * * @since 1.3.4 * @version 1.3.7 * */ public function get_positioning_controls() { // Get path to styles directory. $path = Easy_Google_Fonts::get_views_path() . '/customizer/control/positioning'; $folders = array('margin', 'padding', 'border', 'border-radius'); $file_names = array('start', 'top', 'bottom', 'left', 'right', 'end'); // Include margin and padding controls. foreach ($folders as $folder) { foreach ($file_names as $file_name) { include "{$path}/{$folder}/{$file_name}.php"; } } // Include display control. include "{$path}/display.php"; }
/** * Get Border Controls * * Gets the controls for border top, bottom, * left and right. * * @since 1.2 * @version 1.3.2 * */ public function get_border_controls() { // Get control view include Easy_Google_Fonts::get_views_path() . '/customizer/controls/positioning/border.php'; }
/** * Prepare JSON for Customizer * * Turns JSON options back into their array * equivalent so that they can be used by * the WP_Customize_Setting class. This allows * the customizer to preserve the state of any * font controls that the user has edited even * when they navigate to a different page in the * customizer. * * @param array $options - The options either as JSON or as an array * @return array $options - The options as an array * * @since 1.3.2 * @version 1.3.2 * */ public function prep_option_for_customizer($options = array()) { remove_filter('option_tt_font_theme_options', array($this, 'prep_option_for_customizer'), 5); if (empty($options)) { $options = array(); } // Return the options if we are not in the customizer foreach ($options as $option) { /** * Add font color and background color for this * option to prevent errors parsing JSON when the * user navigates to another page in the customizer. * */ $option['font_color'] = ''; $option['background_color'] = ''; // Convert option to array if it is in JSON format if (is_string($option)) { $option = json_decode($option); } // Convert option to array if it is a StdClass Object if (is_object($option)) { $option = Easy_Google_Fonts::object_to_array($option); } } add_filter('option_tt_font_theme_options', array($this, 'prep_option_for_customizer'), 5); return $options; }
/** * Register and enqueue admin-specific JavaScript. * * @return null Return early if no settings page is registered. * * @since 1.2 * @version 1.3.9 * */ public function enqueue_admin_scripts() { if (!isset($this->plugin_screen_hook_suffix)) { return; } $screen = get_current_screen(); if ($this->plugin_screen_hook_suffix == $screen->id) { // Load jQuery and jQuery UI wp_enqueue_script('jquery'); wp_enqueue_script('utils'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-effects-core'); wp_enqueue_script('jquery-effects-fade'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('jquery-ui-autocomplete'); wp_enqueue_script('jquery-ui-position'); wp_enqueue_script('jquery-ui-widget'); wp_enqueue_script('jquery-ui-mouse'); wp_enqueue_script('jquery-ui-draggable'); wp_enqueue_script('jquery-ui-droppable'); // Load PostBox wp_enqueue_script('postbox'); if (wp_is_mobile()) { wp_enqueue_script('jquery-touch-punch'); } // Load Tag-it script wp_deregister_script($this->plugin_slug . '-tag-it-admin-script'); wp_register_script($this->plugin_slug . '-tag-it-admin-script', Easy_Google_Fonts::get_js_url() . '/tag-it.js', array('jquery'), Easy_Google_Fonts::VERSION); wp_enqueue_script($this->plugin_slug . '-tag-it-admin-script'); // Load admin page js wp_deregister_script($this->plugin_slug . '-admin-script'); wp_register_script($this->plugin_slug . '-admin-script', Easy_Google_Fonts::get_js_url() . '/admin.js', array('jquery', 'jquery-ui-core', 'jquery-ui-widget'), Easy_Google_Fonts::VERSION); wp_enqueue_script($this->plugin_slug . '-admin-script'); // Load in customizer control javascript object wp_localize_script($this->plugin_slug . '-admin-script', 'ttFontl10n', $this->get_l10n()); } }