get_value() public static method

Get the value of a field.
public static get_value ( string $config_id = '', string $field_id = '' ) : string | array
$config_id string The configuration ID. @see Kirki_Config.
$field_id string The field ID.
return string | array
Beispiel #1
0
 /**
  * Get the value of an option from the db.
  *
  * @static
  * @access public
  * @param string $config_id The ID of the configuration corresponding to this field.
  * @param string $field_id  The field_id (defined as 'settings' in the field arguments).
  * @return mixed The saved value of the field.
  */
 public static function get_option($config_id = '', $field_id = '')
 {
     return Kirki_Values::get_value($config_id, $field_id);
 }
 /**
  * Loop through all fields and create an array of style definitions.
  *
  * @static
  * @access public
  * @param string $config_id The configuration ID.
  */
 public static function loop_controls($config_id)
 {
     // Get an instance of the Kirki_Styles_Output_CSS class.
     // This will make sure google fonts and backup fonts are loaded.
     Kirki_Styles_Output_CSS::get_instance();
     $fields = Kirki::$fields;
     $css = array();
     // Early exit if no fields are found.
     if (empty($fields)) {
         return;
     }
     foreach ($fields as $field) {
         // Only process fields that belong to $config_id.
         if ($config_id != $field['kirki_config']) {
             continue;
         }
         // Only continue if field dependencies are met.
         if (!empty($field['required'])) {
             $valid = true;
             foreach ($field['required'] as $requirement) {
                 if (isset($requirement['setting']) && isset($requirement['value']) && isset($requirement['operator'])) {
                     $controller_value = Kirki_Values::get_value($config_id, $requirement['setting']);
                     if (!Kirki_Active_Callback::compare($controller_value, $requirement['value'], $requirement['operator'])) {
                         $valid = false;
                     }
                 }
             }
             if (!$valid) {
                 continue;
             }
         }
         // Only continue if $field['output'] is set.
         if (isset($field['output']) && !empty($field['output']) && 'background' != $field['type']) {
             $css = Kirki_Helper::array_replace_recursive($css, Kirki_Styles_Output_CSS::css($field));
             // Add the globals.
             if (isset(self::$css_array[$config_id]) && !empty(self::$css_array[$config_id])) {
                 Kirki_Helper::array_replace_recursive($css, self::$css_array[$config_id]);
             }
         }
     }
     $css = apply_filters('kirki/' . $config_id . '/styles', $css);
     if (is_array($css)) {
         return Kirki_Styles_Output_CSS::styles_parse(Kirki_Styles_Output_CSS::add_prefixes($css));
     }
     return;
 }