} /* If the user can't edit theme options, no use running this plugin */ add_action('init', 'optionsframework_rolescheck'); function optionsframework_rolescheck() { if (current_user_can('edit_theme_options')) { // If the user can edit theme options, let the fun begin! add_action('admin_menu', 'optionsframework_add_page'); add_action('admin_init', 'optionsframework_init'); //add_action( 'admin_head', 'optionsframework_mlu_css' ); //add_action( 'admin_head', 'optionsframework_mlu_js' ); } } /* Loads the file for option sanitization */ add_action('init', 'optionsframework_load_sanitization'); function optionsframework_load_sanitization() { require_once get_template_directory() . '/themeOptions/admin/options-sanitize.php'; } /* * Creates the settings in the database by looping through the array * we supplied in options.php. This is a neat way to do it since * we won't have to save settings for headers, descriptions, or arguments. * * Read more about the Settings API in the WordPress codex: * http://codex.wordpress.org/Settings_API * */ function optionsframework_init()
function optionsframework_init() { // Include the required files require_once dirname(__FILE__) . '/featured-listing.php'; require_once dirname(__FILE__) . '/options-interface.php'; require_once dirname(__FILE__) . '/options-medialibrary-uploader.php'; if ($optionsfile = locate_template(array('options.php'))) { require_once $optionsfile; } else { if (file_exists(dirname(__FILE__) . '/options.php')) { require_once dirname(__FILE__) . '/options.php'; } } do_action('optionsframework_after_options_load'); $optionsframework_settings = get_option('optionsframework'); // Updates the unique option id in the database if it has changed optionsframework_option_name(); // Gets the unique id, returning a default if it isn't defined if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } // If the option has no saved data, load the defaults if (!get_option($option_name)) { optionsframework_setdefaults(); } // Registers the settings fields and callback register_setting('optionsframework', $option_name, 'optionsframework_validate'); }
function optionsframework_init() { // Include the required files require_once dirname(__FILE__) . '/options-interface.php'; require_once dirname(__FILE__) . '/options-medialibrary-uploader.php'; // Loads the options array from the theme if ($optionsfile = locate_template(array('options.php'))) { require_once $optionsfile; } else { if (file_exists(dirname(__FILE__) . '/options.php')) { require_once dirname(__FILE__) . '/options.php'; } } $optionsframework_settings = get_option('optionsframework'); // Updates the unique option id in the database if it has changed optionsframework_option_name(); // Gets the unique id, returning a default if it isn't defined if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } // If the option has no saved data, load the defaults if (!get_option($option_name)) { optionsframework_setdefaults(); } // Registers the settings fields and callback register_setting('optionsframework', $option_name, 'optionsframework_validate'); // Change the capability required to save the 'optionsframework' options group. add_filter('option_page_capability_optionsframework', 'optionsframework_page_capability'); }
/** * Sets option defaults * * @since 1.7.0 */ function set_theme_option() { // Load settings $optionsframework_settings = get_option('optionsframework'); // Updates the unique option id in the database if it has changed if (function_exists('optionsframework_option_name')) { optionsframework_option_name(); } elseif (has_action('optionsframework_option_name')) { do_action('optionsframework_option_name'); } else { $default_themename = get_option('stylesheet'); $default_themename = preg_replace("/\\W/", "_", strtolower($default_themename)); $default_themename = 'optionsframework_' . $default_themename; if (isset($optionsframework_settings['id'])) { if ($optionsframework_settings['id'] == $default_themename) { // All good, using default theme id } else { $optionsframework_settings['id'] = $default_themename; update_option('optionsframework', $optionsframework_settings); } } else { $optionsframework_settings['id'] = $default_themename; update_option('optionsframework', $optionsframework_settings); } } }
/** * Get Option. * * Helper function to return the theme option value. * If no value has been saved, it returns $default. * Needed because options are saved as serialized strings. */ function of_get_option($name, $default = false) { $config = get_option(optionsframework_option_name()); if (!isset($config['id'])) { return $default; } $options = get_option($config['id']); if (isset($options[$name])) { return $options[$name]; } return $default; }
/** * Gets option name * * @since 1.9.0 */ function get_option_name() { $name = ''; // Gets option name as defined in the theme if (function_exists('optionsframework_option_name')) { $name = optionsframework_option_name(); } // Fallback if ('' == $name) { $name = get_option('stylesheet'); $name = preg_replace("/\\W/", "_", strtolower($name)); } return apply_filters('options_framework_option_name', $name); }
function onetone_of_get_options($default = false) { //$optionsframework_settings = get_option(ONETONE_OPTIONS_PREFIXED.'optionsframework'); // Gets the unique option id //$option_name = $optionsframework_settings['id']; $option_name = optionsframework_option_name(); if (get_option($option_name)) { $options = get_option($option_name); } if (isset($options)) { return $options; } else { return $default; } }
function optionsframework_init() { // Include the required files require_once dirname(__FILE__) . '/options-interface.php'; require_once dirname(__FILE__) . '/options-media-uploader.php'; // Require Markdown if not loaded if (!function_exists('Markdown')) { require_once dirname(__FILE__) . '/markdown.php'; } // Loads the options array from the theme if ($optionsfile = locate_template(array('options.php'))) { require_once $optionsfile; } else { if (file_exists(dirname(__FILE__) . '/options.php')) { require_once dirname(__FILE__) . '/options.php'; } } // Load settings $optionsframework_settings = get_option('optionsframework'); // Update routine // This code can be removed if you're starting a new project // and don't have legacy users to support if ($optionsframework_settings && !isset($optionsframework_settings['version'])) { require_once dirname(__FILE__) . '/upgrade.php'; optionsframework_upgrade_routine(); } // Updates the unique option id in the database if it has changed optionsframework_option_name(); // Gets the unique id, returning a default if it isn't defined if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'options_framework_theme'; } // If the option has no saved data, load the defaults if (!get_option($option_name)) { optionsframework_setdefaults(); } // Registers the settings fields and callback register_setting('optionsframework', $option_name, 'optionsframework_validate'); // Change the capability required to save the 'optionsframework' options group. add_filter('option_page_capability_optionsframework', 'optionsframework_page_capability'); }
function of_get_option($name, $default = false) { $option_name = ''; // Gets option name as defined in the theme if (function_exists('optionsframework_option_name')) { $option_name = optionsframework_option_name(); } // Fallback option name if ('' == $option_name) { $option_name = get_option('stylesheet'); $option_name = preg_replace("/\\W/", "_", strtolower($option_name)); } // Get option settings from database $options = get_option($option_name); if (isset($options[$name])) { return $options[$name]; } return $default; }
function onetone_of_get_options($default = false) { //$optionsframework_settings = get_option(ONETONE_OPTIONS_PREFIXED.'optionsframework'); // Gets the unique option id //$option_name = $optionsframework_settings['id']; $option_name = optionsframework_option_name(); if (get_option($option_name)) { $options = get_option($option_name); } else { $location = apply_filters('options_framework_location', array('includes/admin-options.php')); if ($optionsfile = locate_template($location)) { $maybe_options = (require_once $optionsfile); if (is_array($maybe_options)) { $options = $maybe_options; } else { if (function_exists('optionsframework_options')) { $options = optionsframework_options(); } } } $options = apply_filters('of_options', $options); $config = $options; foreach ((array) $config as $option) { if (!isset($option['id'])) { continue; } if (!isset($option['std'])) { continue; } if (!isset($option['type'])) { continue; } $output[$option['id']] = apply_filters('of_sanitize_' . $option['type'], $option['std'], $option); } $options = $output; } if (isset($options)) { return $options; } else { return $default; } }
function optionsframework_init() { // Include the required files require_once dirname(__FILE__) . '/options-interface.php'; require_once dirname(__FILE__) . '/options-media-uploader.php'; // Optionally Loads the options file from the theme $location = apply_filters('options_framework_location', array('options.php')); $optionsfile = locate_template($location); // Load settings $optionsframework_settings = get_option('optionsframework'); // Updates the unique option id in the database if it has changed if (function_exists('optionsframework_option_name')) { optionsframework_option_name(); } elseif (has_action('optionsframework_option_name')) { do_action('optionsframework_option_name'); } else { $default_themename = get_option('stylesheet'); $default_themename = preg_replace("/\\W/", "_", strtolower($default_themename)); $default_themename = 'optionsframework_' . $default_themename; if (isset($optionsframework_settings['id'])) { if ($optionsframework_settings['id'] == $default_themename) { // All good, using default theme id } else { $optionsframework_settings['id'] = $default_themename; update_option('optionsframework', $optionsframework_settings); } } else { $optionsframework_settings['id'] = $default_themename; update_option('optionsframework', $optionsframework_settings); } } $optionsframework_settings = get_option('optionsframework'); $saved_settings = get_option($optionsframework_settings['id']); // If the option has no saved data, load the defaults if (!$saved_settings) { optionsframework_setdefaults(); } // Registers the settings fields and callback register_setting('optionsframework', $optionsframework_settings['id'], 'optionsframework_validate'); // Change the capability required to save the 'optionsframework' options group. add_filter('option_page_capability_optionsframework', 'optionsframework_page_capability'); }
function hs_optionsframework_init() { // Include the required files require_once dirname(__FILE__) . '/options-interface.php'; require_once dirname(__FILE__) . '/options-medialibrary-uploader.php'; // Loads the options array from the theme if ($optionsfile = locate_template(array('options.php'))) { require_once $optionsfile; } else { if (file_exists(dirname(__FILE__) . '/options.php')) { require_once dirname(__FILE__) . '/options.php'; } } $optionsframework_settings = get_option('optionsframework'); // Updates the unique option id in the database if it has changed optionsframework_option_name(); // Gets the unique id, returning a default if it isn't defined if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } // If the option has no saved data, load the defaults if (!get_option($option_name)) { optionsframework_setdefaults(); } // Registers the settings fields and callback if (!isset($_POST['OptionsFramework-backup-import'])) { register_setting('optionsframework', $option_name, 'optionsframework_validate'); } if (isset($_GET['buckupsuccess']) && $_GET['buckupsuccess'] == 'true') { add_settings_error('options-framework', 'save_options', __('All options are restored successfully.', HS_CURRENT_THEME), 'updated fade'); } // Registers the settings fields and callback register_setting('optionsframework', $option_name, 'optionsframework_validate'); // Change the capability required to save the 'optionsframework' options group. add_filter('option_page_capability_optionsframework', 'optionsframework_page_capability'); }
function optionsframework_init() { // Include the required files require_once dirname(__FILE__) . '/options-sanitize.php'; require_once dirname(__FILE__) . '/options-interface.php'; require_once dirname(__FILE__) . '/options-medialibrary-uploader.php'; // Loads the options array from the theme if ($optionsfile = locate_template(array('options.php'))) { $optionsfile = locate_template($location); } else { if (file_exists(dirname(__FILE__) . '/options.php')) { require_once dirname(__FILE__) . '/options.php'; } } $optionsframework_settings = get_option('optionsframework'); // Updates the unique option id in the database if it has changed optionsframework_option_name(); // Gets the unique id, returning a default if it isn't defined $option_name = $optionsframework_settings['id']; // Set the option defaults in case they have changed optionsframework_setdefaults(); // Registers the settings fields and callback register_setting('optionsframework', $option_name, 'optionsframework_validate'); }
function cordillera_of_get_options($default = false) { // Gets the unique option id $option_name = optionsframework_option_name(); if (get_option($option_name)) { $options = get_option($option_name); } if (isset($options)) { return $options; } else { return $default; } }
function onetone_of_get_options($default = false) { global $options_saved, $onetone_default_options; $options_saved = false; //$optionsframework_settings = get_option(ONETONE_OPTIONS_PREFIXED.'optionsframework'); $default_options = optionsframework_options(); foreach ((array) $default_options as $option) { if (!isset($option['id'])) { continue; } if (!isset($option['std'])) { continue; } if (!isset($option['type'])) { continue; } $onetone_default_options[$option['id']] = apply_filters('of_sanitize_' . $option['type'], $option['std'], $option); } // Gets the unique option id //$option_name = $optionsframework_settings['id']; $option_name = optionsframework_option_name(); if (get_option($option_name)) { $options = get_option($option_name); $options_saved = true; } else { $options = $onetone_default_options; } if (isset($options)) { return $options; } else { return $default; } }
function torch_of_get_options($default = FALSE) { // Gets the unique option id $option_name = optionsframework_option_name(); if (get_option($option_name)) { $options = get_option($option_name); } if (isset($options)) { return $options; } else { return $default; } }
function optionsframework_init() { // Include the required files require_once dirname(__FILE__) . '/options-interface.php'; require_once dirname(__FILE__) . '/options-medialibrary-uploader.php'; require_once OPTIONS_FRAMEWORK_ROOT . 'options-data.php'; $optionsframework_settings = get_option('optionsframework'); // Updates the unique option id in the database if it has changed optionsframework_option_name(); // Gets the unique id, returning a default if it isn't defined if (isset($optionsframework_settings['id'])) { $option_name = $optionsframework_settings['id']; } else { $option_name = 'optionsframework'; } //Check if theme has data $theme_data_status = get_option($option_name . '_init'); if ($theme_data_status != "") { //OK } else { options_setdefaults(); update_option($option_name . '_init', '1'); } // If the option has no saved data, load the defaults //if ( ! get_option($option_name) ) { // optionsframework_setdefaults(); //} // Registers the settings fields and callback //if (!isset( $_POST['OptionsFramework-backup-import'] )) { // register_setting( 'optionsframework', $option_name, 'optionsframework_validate' ); //} if (isset($_POST['mtheme_options_nonce'])) { if (empty($_POST) || !wp_verify_nonce($_POST['mtheme_options_nonce'], basename(__FILE__))) { // Don't pass me by print 'Sorry, your nonce did not verify.'; } else { if (isset($_POST['update'])) { $clean = array(); $options = optionsframework_options(); $exportpack = "array("; $update_values = true; //print_r($options); // IMPORT user entered export data pack. $importpack = array(); $importpack = $_POST[$option_name]['importpack']; if ($importpack != "" && is_serialized($importpack)) { add_settings_error('options-framework', 'restore_defaults', __('Options Imported!', 'mthemelocal'), 'updated fade'); $update_values = false; $import_value = ""; $importpack = stripslashes_deep($importpack); $imported_values = array(); $imported_values = unserialize($importpack); //var_export($imported_values); foreach ($imported_values as $key => $value) { //echo $key; //echo $value; foreach ($value as $store_key => $store_value) { //echo $store_key; //echo $store_value; update_option('mtheme_' . $store_key, $store_value); if (is_array($store_value) && $store_key == "header_section_order") { //update('mtheme_' . $home_key, $store_value ); foreach ($store_value as $home_key => $home_value) { //echo $home_key; //echo $home_value; } } } } update_option('mtheme_exportpack', $importpack); } elseif ($importpack != "" && !is_serialized($importpack)) { add_settings_error('options-framework', 'restore_defaults', __('Invalid Import', 'mthemelocal'), 'error fade'); } else { add_settings_error('options-framework', 'restore_defaults', __('Options Saved!', 'mthemelocal'), 'updated fade'); } if ($update_values) { $countarray = 0; $export_options = array(); foreach ($options as $value) { if (isset($value['id']) && !empty($value['id'])) { if (isset($_POST[$option_name][$value['id']])) { $hold_save_value = $_POST[$option_name][$value['id']]; if ($value['type'] == "text") { $hold_save_value = stripslashes_deep($hold_save_value); } if (!isset($option)) { $option = ""; } if ($value['type'] == "dragdrop_sorter") { $sort_array = $hold_save_value; $save_value = array(); foreach ($sort_array as $sortkey => $sortstate) { $save_value[] = $sortkey; } } else { $save_value = apply_filters('of_sanitize_' . $value['type'], $hold_save_value, $option); } } if ($value['type'] == "checkbox") { if (isset($_POST[$option_name][$value['id']])) { $save_value = '1'; } else { $save_value = false; } } // Skip the export pack and import pack values. Store everything else. if ($value['id'] != "exportpack" && $value['id'] != "importpack") { update_option('mtheme_' . $value['id'], $save_value); if ($value['type'] == "dragdrop_sorter") { $export_options[] = array($value['id'] => $save_value); } else { $export_options[] = array($value['id'] => $save_value); } } } } $exportpack = serialize($export_options); update_option('mtheme_exportpack', $exportpack); } } if (isset($_POST['reset'])) { options_setdefaults(); } } // End of Nonce Check } }