Featured_Content::get_setting PHP Method

get_setting() public static method

Get all settings recognized by this module. This function will return all settings whether or not they have been stored in the database yet. This ensures that all keys are available at all times. In the event that you only require one setting, you may pass its name as the first parameter to the function and only that value will be returned.
public static get_setting ( string $key = 'all' ) : mixed
$key string The key of a recognized setting.
return mixed Array of all settings by default. A single value if passed as first parameter.
        public static function get_setting($key = 'all')
        {
            $saved = (array) get_option('featured-content');
            /**
             * Filter Featured Content's default settings.
             *
             * @module theme-tools
             *
             * @since 2.7.0
             *
             * @param array $args {
             * Array of Featured Content Settings
             *
             * 	@type int hide-tag Default is 1.
             * 	@type int tag-id Default is 0.
             * 	@type string tag-name Default is empty.
             * 	@type int show-all Default is 0.
             * }
             */
            $defaults = apply_filters('featured_content_default_settings', array('hide-tag' => 1, 'tag-id' => 0, 'tag-name' => '', 'show-all' => 0));
            $options = wp_parse_args($saved, $defaults);
            $options = array_intersect_key($options, $defaults);
            if ('all' != $key) {
                return isset($options[$key]) ? $options[$key] : false;
            }
            return $options;
        }

Usage Example

Esempio n. 1
0
 public static function get_jetpack_featured_content_term_id()
 {
     if (!method_exists('Featured_Content', 'get_setting')) {
         return 0;
     }
     $term = get_term_by('name', Featured_Content::get_setting('tag-name'), 'post_tag');
     if (!$term) {
         return 0;
     }
     return $term->term_id;
 }
All Usage Examples Of Featured_Content::get_setting