Ejemplo n.º 1
0
/**
 * Loads the stylesheet files for proper screens.
 *
 * @since 1.0.0
 * @access public
 * @return void
 */
function hoot_admin_enqueue_styles($hook)
{
    $options_page = 'appearance_page_' . hootoptions_option_name();
    if ($options_page == $hook) {
        wp_enqueue_style('hoot-font-awesome');
    }
}
Ejemplo n.º 2
0
/**
 * Helper function to return the theme option value.
 * If no value has been saved, it returns $default.
 * If no $default provided, it checks the default options array.
 * 
 * @since 1.0.0
 * @access public
 * @param string $name
 * @param mixed $default
 * @return mixed
 */
function hoot_get_option($name, $default = NULL)
{
    /*** Return option value if set ***/
    static $options = NULL;
    // cache
    // Get the values from database
    if ($options === NULL) {
        $option_name = hootoptions_option_name();
        $options = get_option($option_name);
    }
    // Ideally, this should not have any expensive function, as hoot_get_option() is used quite often.
    $options = apply_filters('hoot_get_option', $options);
    if (isset($options[$name])) {
        // Add exceptions: If a value has been set but is empty, this gives the option to return default values in such cases. Simply return $override as (bool)true.
        $override = apply_filters('hoot_get_option_empty_values', false, $options[$name]);
        if ($override !== true) {
            return $options[$name];
        }
    }
    /*** Return default if provided ***/
    if ($default !== NULL) {
        return $default;
    }
    /*** Return default theme option value ***/
    static $defaults = NULL;
    // cache
    // Get the default values from options array
    if ($defaults === NULL) {
        $options_array = hoot_get_theme_options_array();
        // $defaults is created similar to get_default_values() in class-hoot-options-admin
        if ($options_array) {
            foreach ($options_array as $op) {
                if (isset($op['id']) && isset($op['std']) && isset($op['type'])) {
                    if (has_filter('hoot_of_sanitize_' . $op['type'])) {
                        $defaults[$op['id']] = apply_filters('hoot_of_sanitize_' . $op['type'], $op['std'], $op);
                    } else {
                        $defaults[$op['id']] = $op['std'];
                    }
                }
            }
        }
    }
    if (isset($defaults[$name])) {
        return $defaults[$name];
    }
    /*** We dont have anything! ***/
    return false;
}
Ejemplo n.º 3
0
 /**
  * Init migration
  *
  * @since 2.0.0
  * @access public
  * @return void
  */
 public function init()
 {
     $migrated = get_option(THEME_SLUG . '-migrated');
     if (!$migrated) {
         $optionsname = function_exists('hootoptions_option_name') ? hootoptions_option_name() : THEME_SLUG . '-options';
         $optionsvalue = get_option($optionsname);
         if ($optionsvalue) {
             $this->migrate($optionsvalue);
             update_option(THEME_SLUG . '-migrated', 'complete');
             $migrated = 'complete';
         } else {
             update_option(THEME_SLUG . '-migrated', 'not-required');
             $migrated = 'not-required';
         }
     }
     if ($migrated == 'complete') {
         $dismissed = get_option(THEME_SLUG . '-migration-notice-dismissed');
         if (!$dismissed) {
             add_action('admin_enqueue_scripts', array($this, 'enqueue'));
             add_action('admin_head', array($this, 'inline_css'));
             add_action('admin_notices', array($this, 'notice'));
         }
     }
 }
 /**
  * Enqueue scripts for file uploader if options page
  *
  * @since 1.0.0
  */
 function hootoptions_media_scripts($hook)
 {
     $options_page = 'appearance_page_' . hootoptions_option_name();
     if ($options_page == $hook) {
         $this->enqueue_admin_options_media_scripts();
     }
 }
Ejemplo n.º 5
0
 static function menu_settings()
 {
     $menu = array('mode' => 'submenu', 'page_title' => __('Theme Options', 'dispatch'), 'menu_title' => __('Theme Options', 'dispatch'), 'capability' => 'edit_theme_options', 'menu_slug' => hootoptions_option_name(), 'parent_slug' => 'themes.php', 'icon_url' => 'dashicons-admin-generic', 'position' => '61');
     return apply_filters('hootoptions_menu', $menu);
 }
 /**
  * Gets option name
  *
  * @since 1.0.0
  */
 static function _get_option_name()
 {
     return hootoptions_option_name();
 }