/** * Get header classes * * @since 1.0.0 */ function of_get_header_classes_array() { global $of_options; of_options(); foreach ($of_options as $value) { if ($value['type'] == 'heading') { $hooks[] = str_replace(' ', '', strtolower($value['name'])); } } return $hooks; }
/** * Ajax Save Options * * @uses get_option() * * @since 1.0.0 */ function of_ajax_callback() { global $of_options, $options_machine; $nonce = $_POST['security']; if (!wp_verify_nonce($nonce, 'of_ajax_nonce')) { die('-1'); } //get options array from db $all = of_get_options(); $save_type = $_POST['type']; //Uploads if ($save_type == 'upload') { $clickedID = $_POST['data']; // Acts as the name $filename = $_FILES[$clickedID]; $filename['name'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', $filename['name']); $override['test_form'] = false; $override['action'] = 'wp_handle_upload'; $uploaded_file = wp_handle_upload($filename, $override); $upload_tracking[] = $clickedID; //update $options array w/ image URL $upload_image = $all; //preserve current data $upload_image[$clickedID] = $uploaded_file['url']; of_save_options($upload_image); if (!empty($uploaded_file['error'])) { echo 'Upload Error: ' . esc_js($uploaded_file['error']); } else { echo esc_attr($uploaded_file['url']); } // Is the Response } elseif ($save_type == 'image_reset') { $id = $_POST['data']; // Acts as the name $delete_image = $all; //preserve rest of data $delete_image[$id] = ''; //update array key with empty value of_save_options($delete_image); } elseif ($save_type == 'backup_options') { $backup = $all; $backup['backup_log'] = date('r'); of_save_options($backup, OF_BACKUPS); die('1'); } elseif ($save_type == 'restore_options') { $smof_data = get_option(OF_BACKUPS); update_option(OF_OPTIONS, $smof_data); of_save_options($smof_data); die('1'); } elseif ($save_type == 'import_options') { $smof_data = $_POST['data']; $smof_data = unserialize(base64_decode($smof_data)); //100% safe - ignore theme check nag of_save_options($smof_data); die('1'); } elseif ($save_type == 'save') { wp_parse_str(stripslashes($_POST['data']), $smof_data); unset($smof_data['security']); unset($smof_data['of_save']); of_save_options($smof_data); die('1'); } elseif ($save_type == 'reset') { of_options(); $options_machine = new Options_Machine($of_options); of_save_options($options_machine->Defaults()); die('1'); //options reset } die; }
public function migrate_theme_options() { // Getting Options global $smof_data, $of_options; if (!isset($of_options) or empty($of_options)) { // Forcing options to be loaded even before the main init remove_action('init', 'of_options'); of_options(); } $options_changed = FALSE; foreach ($this->translators as $version => $translator) { if (method_exists($translator, 'translate_theme_options')) { $options_changed = ($translator->translate_theme_options($smof_data) or $options_changed); } } if ($options_changed) { // Filling the missed options with default values $options_machine = new Options_Machine($of_options); $smof_data = array_merge($options_machine->Defaults, $smof_data); $smof_data['generate_css_file'] = FALSE; // Saving the changed options of_save_options($smof_data); //update_option( OPTIONS, $smof_data ); us_save_styles($smof_data); } }