Ejemplo n.º 1
0
 /**
  * Get the value of a field.
  * This is a deprecated function that we in use when there was no API.
  * Please use the Nova::get_option() method instead.
  * Documentation is available for the new method on https://github.com/aristath/nova/wiki/Getting-the-values
  *
  * @return mixed
  */
 function nova_get_option($option = '')
 {
     return Nova::get_option('', $option);
 }
Ejemplo n.º 2
0
 /**
  * Build the variables.
  *
  * @return array 	('variable-name' => value)
  */
 public function get_variables()
 {
     $variables = array();
     /**
      * Loop through all fields
      */
     foreach (Nova::$fields as $field) {
         /**
          * Check if we have variables for this field
          */
         if (isset($field['variables']) && false != $field['variables'] && !empty($field['variables'])) {
             /**
              * Loop through the array of variables
              */
             foreach ($field['variables'] as $field_variable) {
                 /**
                  * Is the variable ['name'] defined?
                  * If yes, then we can proceed.
                  */
                 if (isset($field_variable['name'])) {
                     /**
                      * Sanitize the variable name
                      */
                     $variable_name = esc_attr($field_variable['name']);
                     /**
                      * Do we have a callback function defined?
                      * If not then set $variable_callback to false.
                      */
                     $variable_callback = isset($field_variable['callback']) && is_callable($field_variable['callback']) ? $field_variable['callback'] : false;
                     /**
                      * If we have a variable_callback defined then get the value of the option
                      * and run it through the callback function.
                      * If no callback is defined (false) then just get the value.
                      */
                     if ($variable_callback) {
                         $variables[$variable_name] = call_user_func($field_variable['callback'], Nova::get_option(Nova_Field_Sanitize::sanitize_settings($field)));
                     } else {
                         $variables[$variable_name] = Nova::get_option($field['settings']);
                     }
                 }
             }
         }
     }
     /**
      * Pass the variables through a filter ('nova/variable')
      * and return the array of variables
      */
     return apply_filters('nova/variable', $variables);
 }