Beispiel #1
0
 function __construct()
 {
     parent::__construct();
     require_once dirname(dirname(__FILE__)) . '/styles-font-menu/plugin.php';
     $this->font_menu = SFM_Plugin::get_instance();
     // Defined in parent class.
     // Runs $this->upgrade_site() on single site or all sites in network.
     $this->upgrade_network();
 }
 /**
  * Load Google font specified in $_GET request.
  * 
  * @param string $_GET['font-family'] Required. Name of the font to render
  * @param string $_GET['variant'] Optional. Name of the variant to render
  * @return null Output URL to image as string
  */
 public function wp_ajax_styles_font_preview()
 {
     $plugin = SFM_Plugin::get_instance();
     $font_family = isset($_GET['font-family']) ? $_GET['font-family'] : false;
     // Load font family from Google Fonts
     $this->font = $plugin->google_fonts->get_font_by_name($font_family);
     if (!$this->font) {
         wp_die('Font not found: ' . $this->font_family);
     }
     // Output PNG URL
     if (!$this->font->get_png_url()) {
         $this->generate_image();
     }
     echo $this->font->get_png_url();
     exit;
 }
 public static function get_instance()
 {
     if (!is_a(self::$instance, __CLASS__)) {
         self::$instance = true;
         self::$instance = new self();
         self::$instance->init();
     }
     return self::$instance;
 }
 public function get_file_paths()
 {
     if (isset($this->file_paths)) {
         return $this->file_paths;
     }
     $plugin = SFM_Plugin::get_instance();
     $uploads = wp_upload_dir();
     $fonts_dir = '/styles-fonts';
     $ThemeURL = get_template_directory_uri();
     $ThemePATH = get_template_directory();
     $URL_image = $ThemeURL . '/framework/ilenframework/assets/lib/styles-fonts-select';
     $PATH_image = $ThemePATH . '/framework/ilenframework/assets/lib/styles-fonts-select';
     $this->file_paths = array('plugin' => array('path' => $PATH_image . $fonts_dir, 'url' => $URL_image . $fonts_dir), 'uploads' => array('path' => $uploads['basedir'] . $fonts_dir, 'url' => $uploads['baseurl'] . $fonts_dir));
     return $this->file_paths;
 }
Description: Display an up-to-date menu of Google Fonts. Include it in your own plugins and themes, or install as a plugin for testing and a live demo. Uses the Chosen library to allow menu search and styles.
Version: 1.0.2
Author: Brainstorm Media
Author URI: http://brainstormmedia.com
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
/**
 * Only include library in admin by default. Override with the filter
 *
 * @example add_filter( 'styles_font_menu_include_on_frontend', '__return_true' );
 */
if (apply_filters('styles_font_menu_include_on_frontend', is_admin()) && !class_exists('SFM_Plugin') && version_compare($GLOBALS['wp_version'], '3.4', '>=')) {
    require_once dirname(__FILE__) . '/classes/sfm-plugin.php';
    if (did_action('init')) {
        SFM_Plugin::get_instance();
    } else {
        add_action('init', 'SFM_Plugin::get_instance');
    }
} else {
    if (version_compare($GLOBALS['wp_version'], '3.4', '<') && apply_filters('styles_font_menu_exit_on_php_version_error', true) && !function_exists('styles_font_menu_wp_version_notice')) {
        /**
         * Exit and warn by default. Use the filter to disable exiting,
         * or add your own behavior and return false.
         *
         * @example add_filter( 'styles_font_menu_include_on_frontend', '__return_false' );
         */
        function styles_font_menu_wp_version_notice()
        {
            echo sprintf('<div class="error"><p>%s<a href="http://codex.wordpress.org/Upgrading_WordPress">%s</a></p></div>', __('Styles Font Menu requires WordPress 3.4 or newer.', 'styles-font-menu'), __('Please update.', 'styles-font-menu'));
        }
 public function get_file_paths()
 {
     if (isset($this->file_paths)) {
         return $this->file_paths;
     }
     $plugin = SFM_Plugin::get_instance();
     $uploads = wp_upload_dir();
     $fonts_dir = '/styles-fonts';
     $this->file_paths = array('plugin' => array('path' => $plugin->plugin_directory . $fonts_dir, 'url' => $plugin->plugin_url . $fonts_dir), 'uploads' => array('path' => $uploads['basedir'] . $fonts_dir, 'url' => $uploads['baseurl'] . $fonts_dir));
     return $this->file_paths;
 }
 public function get_selector()
 {
     $plugin = SFM_Plugin::get_instance();
     return '.' . $plugin->menu_class . ' .' . $this->get_classname();
 }