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.
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;
 }
Esempio n. 2
0
 /**
  * Twenty Fourteen
  * Rewrites the function Featured_Content::get_featured_post_ids()
  *
  * @since 1.4
  *
  * @param array $ids featured posts ids
  * @return array modified featured posts ids ( include all languages )
  */
 public function twenty_fourteen_featured_content_ids($featured_ids)
 {
     if (!did_action('pll_init') || false !== $featured_ids) {
         return $featured_ids;
     }
     $settings = Featured_Content::get_setting();
     if (!($term = get_term_by('name', $settings['tag-name'], 'post_tag'))) {
         return $featured_ids;
     }
     // Get featured tag translations
     $tags = PLL()->model->term->get_translations($term->term_id);
     $ids = array();
     // Query for featured posts in all languages
     // One query per language to get the correct number of posts per language
     foreach ($tags as $tag) {
         $_ids = get_posts(array('lang' => 0, 'fields' => 'ids', 'numberposts' => Featured_Content::$max_posts, 'tax_query' => array(array('taxonomy' => 'post_tag', 'terms' => (int) $tag))));
         $ids = array_merge($ids, $_ids);
     }
     $ids = array_map('absint', $ids);
     set_transient('featured_content_ids', $ids);
     return $ids;
 }