public static function add_field($config_id, $args) { if (is_array($config_id) && empty($args)) { $args = $config_id; $config_id = 'global'; } $config_id = '' == $config_id ? 'global' : $config_id; /** * Get the configuration options */ if (!isset(Nova::$config[$config_id])) { $config_id = 'global'; } $config = Nova::$config[$config_id]; /** * If we've set an option in the configuration * then make sure we're using options and not theme_mods */ if ('' != $config['option_name']) { $config['option_type'] = 'option'; } /** * If no option name has been set for the field, * use the one from the configuration */ if (!isset($args['option_name'])) { $args['option_name'] = $config['option_name']; } /** * If no capability has been set for the field, * use the one from the configuration */ if (!isset($args['capability'])) { $args['capability'] = $config['capability']; } /** * Check if [settings] is set. * If not set, check for [setting] */ if (!isset($args['settings']) && isset($args['setting'])) { $args['settings'] = $args['setting']; } /** * If no option-type has been set for the field, * use the one from the configuration */ if (!isset($args['option_type'])) { $args['option_type'] = $config['option_type']; } /** * Add the field to the static $fields variable properly indexed */ Nova::$fields[Nova_Field_Sanitize::sanitize_settings($args)] = $args; if ('background' == $args['type']) { /** * Build the background fields */ Nova::$fields = Nova_Explode_Background_Field::process_fields(Nova::$fields); } }