PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,224 @@
/* Options Framework Admin Styles */
#optionsframework {
max-width:840px;
background:#fff;
}
#optionsframework h3 {
cursor: default;
background-color: #f1f1f1;
border-bottom: 1px solid #ddd;
}
#optionsframework p {
margin-bottom:0;
padding-bottom:10px;
}
#optionsframework .section {
padding:10px 10px 0;
}
#optionsframework .group {
padding-bottom:40px;
}
#optionsframework .section .controls {
float: left;
min-width:350px;
width: 54%;
padding-right:2%;
}
#optionsframework .section .explain {
max-width:38%;
float: left;
font-size: 12px;
line-height:16px;
color: #777;
}
#optionsframework .section-checkbox .controls {
width: 98%;
}
#optionsframework .section-checkbox .explain {
max-width:94%;
}
#optionsframework .controls input[type=text] {
width:100%;
}
#optionsframework .controls input[type=text].wp-color-picker {
width: 65px;
}
#optionsframework .controls select, #optionsframework .controls textarea {
margin-bottom:10px;
width:100%;
}
#optionsframework .section-radio label, #optionsframework .section-multicheck label {
float:left;
max-width:90%;
line-height: 16px;
margin-bottom: 5px;
}
#optionsframework input.checkbox, #optionsframework input.of-radio {
margin: 0 10px 5px 0;
float:left;
clear:both;
}
#optionsframework .section-typography .controls {
float:none;
width:auto;
}
#optionsframework .section-typography .explain {
float:none;
width:auto;
}
#optionsframework .controls .of-typography-size {
width:80px;
float:left
}
#optionsframework .controls .of-typography-unit {
width:50px;
margin-left:5px;
float:left
}
#optionsframework .controls .of-typography-face {
width:100px;
margin-left:5px;
float:left
}
#optionsframework .controls .of-typography-style {
width:80px;
margin-left:5px;
margin-right:5px;
float:left
}
#optionsframework .section-typography .wp-picker-container {
margin-top:2px;
}
#optionsframework .of-background-properties {
clear:both;
margin-top: 18px;
}
#optionsframework .controls .of-background-repeat {
width:125px;
margin-right:5px;
float:left
}
#optionsframework .controls .of-background-position {
width:125px;
margin-right:5px;
float:left
}
#optionsframework .controls .of-background-attachment {
width:125px;
margin-right:5px;
float:left
}
#optionsframework .section-background .wp-picker-container {
margin-bottom:10px;
}
#optionsframework .controls .of-radio-img-img {
border:3px solid #f9f9f9;
margin:0 5px 10px 0;
display:none;
cursor:pointer;
float:left;
}
#optionsframework .controls .of-radio-img-selected {
border:3px solid #ccc
}
#optionsframework .controls .of-radio-img-img:hover {
opacity:.8;
}
#optionsframework .controls .of-border-width {
width:80px;
float:left
}
#optionsframework .controls .of-border-style {
width:120px;
float:left
}
#optionsframework .hide {
display:none;
}
#optionsframework .of-option-image {
max-width:340px;
margin:3px 0 18px 0;
}
#optionsframework .mini .controls select, #optionsframework .section .mini .controls {
width: 140px;
}
#optionsframework .mini .controls input, #optionsframework .mini .controls {
min-width:140px;
width: 140px;
}
#optionsframework .mini .explain {
max-width:74%;
}
/* Editor */
#optionsframework .section-editor .explain {
max-width: 98%;
float:none;
margin-bottom:5px;
}
/* Image Uploader */
#optionsframework .controls input.upload {
width:80%;
}
#optionsframework .screenshot {
float:left;
margin-left:1px;
position:relative;
width:344px;
margin-top:3px;
}
#optionsframework .screenshot img {
background:#fafafa;
border-color:#ccc #eee #eee #ccc;
border-style:solid;
border-width:1px;
float:left;
max-width:334px;
padding:4px;
margin-bottom:10px;
}
#optionsframework .screenshot .remove-image {
background:url("../images/ico-delete.png") no-repeat;
border:medium none;
bottom:4px;
display:block;
float:left;
height:16px;
padding:0;
position:absolute;
left:-4px;
text-indent:-9999px;
width:16px;
}
#optionsframework .screenshot .no_image .file_link {
margin-left: 20px;
}
#optionsframework .screenshot .no_image .remove-button {
bottom: 0px;
}
#optionsframework .reset-button {
float:left;
cursor:pointer;
}
/* Bottom Section */
#optionsframework-submit {
padding: 7px 10px;
border-top: 1px solid #ddd;
background-color: #f1f1f1;
}
#optionsframework .button-primary {
float:right;
}
#optionsframework .section:after {
content: "";
display: table;
}
#optionsframework .section:after {
clear: both;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

View File

@ -0,0 +1,350 @@
<?php
/**
* @package Options_Framework
* @author Devin Price <devin@wptheming.com>
* @license GPL-2.0+
* @link http://wptheming.com
* @copyright 2010-2014 WP Theming
*/
class Options_Framework_Admin {
/**
* Page hook for the options screen
*
* @since 1.7.0
* @type string
*/
protected $options_screen = null;
/**
* Hook in the scripts and styles
*
* @since 1.7.0
*/
public function init() {
// Gets options to load
$options = & Options_Framework::_optionsframework_options();
// Checks if options are available
if ( $options ) {
// Add the options page and menu item.
add_action( 'admin_menu', array( $this, 'add_custom_options_page' ) );
// Add the required scripts and styles
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
// Settings need to be registered after admin_init
add_action( 'admin_init', array( $this, 'settings_init' ) );
// Adds options menu to the admin bar
add_action( 'wp_before_admin_bar_render', array( $this, 'optionsframework_admin_bar' ) );
}
}
/**
* Registers the settings
*
* @since 1.7.0
*/
function settings_init() {
// Get the option name
$options_framework = new Options_Framework;
$name = $options_framework->get_option_name();
// Registers the settings fields and callback
register_setting( 'optionsframework', $name, array ( $this, 'validate_options' ) );
// Displays notice after options save
add_action( 'optionsframework_after_validate', array( $this, 'save_options_notice' ) );
}
/*
* Define menu options
*
* Examples usage:
*
* add_filter( 'optionsframework_menu', function( $menu ) {
* $menu['page_title'] = 'The Options';
* $menu['menu_title'] = 'The Options';
* return $menu;
* });
*
* @since 1.7.0
*
*/
static function menu_settings() {
$menu = array(
// Modes: submenu, menu
'mode' => 'submenu',
// Submenu default settings
'page_title' => __( 'Theme Options', 'myoos' ),
'menu_title' => __( 'Theme Options', 'myoos' ),
'capability' => 'edit_theme_options',
'menu_slug' => 'options-framework',
'parent_slug' => 'themes.php',
// Menu default settings
'icon_url' => 'dashicons-admin-generic',
'position' => '61'
);
return apply_filters( 'optionsframework_menu', $menu );
}
/**
* Add a subpage called "Theme Options" to the appearance menu.
*
* @since 1.7.0
*/
function add_custom_options_page() {
$menu = $this->menu_settings();
// If you want a top level menu, see this Gist:
// https://gist.github.com/devinsays/884d6abe92857a329d99
// Code removed because it conflicts with .org theme check.
$this->options_screen = add_theme_page(
$menu['page_title'],
$menu['menu_title'],
$menu['capability'],
$menu['menu_slug'],
array( $this, 'options_page' )
);
}
/**
* Loads the required stylesheets
*
* @since 1.7.0
*/
function enqueue_admin_styles( $hook ) {
if ( $this->options_screen != $hook )
return;
wp_enqueue_style( 'optionsframework', OPTIONS_FRAMEWORK_DIRECTORY . 'css/optionsframework.css', array(), Options_Framework::VERSION );
wp_enqueue_style( 'wp-color-picker' );
}
/**
* Loads the required javascript
*
* @since 1.7.0
*/
function enqueue_admin_scripts( $hook ) {
if ( $this->options_screen != $hook )
return;
// Enqueue custom option panel JS
wp_enqueue_script(
'options-custom',
OPTIONS_FRAMEWORK_DIRECTORY . 'js/options-custom.js',
array( 'jquery','wp-color-picker' ),
Options_Framework::VERSION
);
// Inline scripts from options-interface.php
add_action( 'admin_head', array( $this, 'of_admin_head' ) );
}
function of_admin_head() {
// Hook to add custom scripts
do_action( 'optionsframework_custom_scripts' );
}
/**
* Builds out the options panel.
*
* If we were using the Settings API as it was intended we would use
* do_settings_sections here. But as we don't want the settings wrapped in a table,
* we'll call our own custom optionsframework_fields. See options-interface.php
* for specifics on how each individual field is generated.
*
* Nonces are provided using the settings_fields()
*
* @since 1.7.0
*/
function options_page() { ?>
<div id="optionsframework-wrap" class="wrap">
<?php $menu = $this->menu_settings(); ?>
<h2><?php echo esc_html( $menu['page_title'] ); ?></h2>
<h2 class="nav-tab-wrapper">
<?php echo Options_Framework_Interface::optionsframework_tabs(); ?>
</h2>
<?php settings_errors( 'options-framework' ); ?>
<div id="optionsframework-metabox" class="metabox-holder">
<div id="optionsframework" class="postbox">
<form action="options.php" method="post">
<?php settings_fields( 'optionsframework' ); ?>
<?php Options_Framework_Interface::optionsframework_fields(); /* Settings */ ?>
<div id="optionsframework-submit">
<input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options', 'myoos' ); ?>" />
<input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults', 'myoos' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!', 'myoos' ) ); ?>' );" />
<div class="clear"></div>
</div>
</form>
</div> <!-- / #container -->
</div>
<?php do_action( 'optionsframework_after' ); ?>
</div> <!-- / .wrap -->
<?php
}
/**
* Validate Options.
*
* This runs after the submit/reset button has been clicked and
* validates the inputs.
*
* @uses $_POST['reset'] to restore default options
*/
function validate_options( $input ) {
/*
* Restore Defaults.
*
* In the event that the user clicked the "Restore Defaults"
* button, the options defined in the theme's options.php
* file will be added to the option for the active theme.
*/
if ( isset( $_POST['reset'] ) ) {
add_settings_error( 'options-framework', 'restore_defaults', __( 'Default options restored.', 'myoos' ), 'updated fade' );
return $this->get_default_values();
}
/*
* Update Settings
*
* This used to check for $_POST['update'], but has been updated
* to be compatible with the theme customizer introduced in WordPress 3.4
*/
$clean = array();
$options = & Options_Framework::_optionsframework_options();
foreach ( $options as $option ) {
if ( ! isset( $option['id'] ) ) {
continue;
}
if ( ! isset( $option['type'] ) ) {
continue;
}
$id = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower( $option['id'] ) );
// Set checkbox to false if it wasn't sent in the $_POST
if ( 'checkbox' == $option['type'] && ! isset( $input[$id] ) ) {
$input[$id] = false;
}
// Set each item in the multicheck to false if it wasn't sent in the $_POST
if ( 'multicheck' == $option['type'] && ! isset( $input[$id] ) ) {
foreach ( $option['options'] as $key => $value ) {
$input[$id][$key] = false;
}
}
// For a value to be submitted to database it must pass through a sanitization filter
if ( has_filter( 'of_sanitize_' . $option['type'] ) ) {
$clean[$id] = apply_filters( 'of_sanitize_' . $option['type'], $input[$id], $option );
}
}
// Hook to run after validation
do_action( 'optionsframework_after_validate', $clean );
return $clean;
}
/**
* Display message when options have been saved
*/
function save_options_notice() {
add_settings_error( 'options-framework', 'save_options', __( 'Options saved.', 'myoos' ), 'updated fade' );
}
/**
* Get the default values for all the theme options
*
* Get an array of all default values as set in
* options.php. The 'id','std' and 'type' keys need
* to be defined in the configuration array. In the
* event that these keys are not present the option
* will not be included in this function's output.
*
* @return array Re-keyed options configuration array.
*
*/
function get_default_values() {
$output = array();
$config = & Options_Framework::_optionsframework_options();
foreach ( (array) $config as $option ) {
if ( ! isset( $option['id'] ) ) {
continue;
}
if ( ! isset( $option['std'] ) ) {
continue;
}
if ( ! isset( $option['type'] ) ) {
continue;
}
if ( has_filter( 'of_sanitize_' . $option['type'] ) ) {
$output[$option['id']] = apply_filters( 'of_sanitize_' . $option['type'], $option['std'], $option );
}
}
return $output;
}
/**
* Add options menu item to admin bar
*/
function optionsframework_admin_bar() {
$menu = $this->menu_settings();
global $wp_admin_bar;
if ( 'menu' == $menu['mode'] ) {
$href = admin_url( 'admin.php?page=' . $menu['menu_slug'] );
} else {
$href = admin_url( 'themes.php?page=' . $menu['menu_slug'] );
}
$args = array(
'parent' => 'appearance',
'id' => 'of_theme_options',
'title' => $menu['menu_title'],
'href' => $href
);
$wp_admin_bar->add_menu( apply_filters( 'optionsframework_admin_bar', $args ) );
}
}

View File

@ -0,0 +1,96 @@
<?php
/**
* @package Options_Framework
* @author Devin Price <devin@wptheming.com>
* @license GPL-2.0+
* @link http://wptheming.com
* @copyright 2010-2014 WP Theming
*/
class Options_Framework {
/**
* Plugin version, used for cache-busting of style and script file references.
*
* @since 1.7.0
* @type string
*/
const VERSION = '1.9.1';
/**
* 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 );
}
/**
* Wrapper for optionsframework_options()
*
* Allows for manipulating or setting options via 'of_options' filter
* For example:
*
* <code>
* add_filter( 'of_options', function( $options ) {
* $options[] = array(
* 'name' => 'Input Text Mini',
* 'desc' => 'A mini text input field.',
* 'id' => 'example_text_mini',
* 'std' => 'Default',
* 'class' => 'mini',
* 'type' => 'text'
* );
*
* return $options;
* });
* </code>
*
* Also allows for setting options via a return statement in the
* options.php file. For example (in options.php):
*
* <code>
* return array(...);
* </code>
*
* @return array (by reference)
*/
static function &_optionsframework_options() {
static $options = null;
if ( !$options ) {
// Load options from options.php file (if it exists)
$location = apply_filters( 'options_framework_location', array( 'options.php' ) );
if ( $optionsfile = locate_template( $location ) ) {
$maybe_options = load_template( $optionsfile );
if ( is_array( $maybe_options ) ) {
$options = $maybe_options;
} else if ( function_exists( 'optionsframework_options' ) ) {
$options = optionsframework_options();
}
}
// Allow setting/manipulating options via filters
$options = apply_filters( 'of_options', $options );
}
return $options;
}
}

View File

@ -0,0 +1,421 @@
<?php
/**
* @package Options_Framework
* @author Devin Price <devin@wptheming.com>
* @license GPL-2.0+
* @link http://wptheming.com
* @copyright 2010-2014 WP Theming
*/
class Options_Framework_Interface {
/**
* Generates the tabs that are used in the options menu
*/
static function optionsframework_tabs() {
$counter = 0;
$options = & Options_Framework::_optionsframework_options();
$menu = '';
foreach ( $options as $value ) {
// Heading for Navigation
if ( $value['type'] == "heading" ) {
$counter++;
$class = '';
$class = ! empty( $value['id'] ) ? $value['id'] : $value['name'];
$class = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower($class) ) . '-tab';
$menu .= '<a id="options-group-'. $counter . '-tab" class="nav-tab ' . $class .'" title="' . esc_attr( $value['name'] ) . '" href="' . esc_attr( '#options-group-'. $counter ) . '">' . esc_html( $value['name'] ) . '</a>';
}
}
return $menu;
}
/**
* Generates the options fields that are used in the form.
*/
static function optionsframework_fields() {
global $allowedtags;
$options_framework = new Options_Framework;
$option_name = $options_framework->get_option_name();
$settings = get_option( $option_name );
$options = & Options_Framework::_optionsframework_options();
$counter = 0;
$menu = '';
foreach ( $options as $value ) {
$val = '';
$select_value = '';
$output = '';
// Wrap all options
if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) {
// Keep all ids lowercase with no spaces
$value['id'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['id']) );
$id = 'section-' . $value['id'];
$class = 'section';
if ( isset( $value['type'] ) ) {
$class .= ' section-' . $value['type'];
}
if ( isset( $value['class'] ) ) {
$class .= ' ' . $value['class'];
}
$output .= '<div id="' . esc_attr( $id ) .'" class="' . esc_attr( $class ) . '">'."\n";
if ( isset( $value['name'] ) ) {
$output .= '<h4 class="heading">' . esc_html( $value['name'] ) . '</h4>' . "\n";
}
if ( $value['type'] != 'editor' ) {
$output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
}
else {
$output .= '<div class="option">' . "\n" . '<div>' . "\n";
}
}
// Set default value to $val
if ( isset( $value['std'] ) ) {
$val = $value['std'];
}
// If the option is already saved, override $val
if ( ( $value['type'] != 'heading' ) && ( $value['type'] != 'info') ) {
if ( isset( $settings[($value['id'])]) ) {
$val = $settings[($value['id'])];
// Striping slashes of non-array options
if ( !is_array($val) ) {
$val = stripslashes( $val );
}
}
}
// If there is a description save it for labels
$explain_value = '';
if ( isset( $value['desc'] ) ) {
$explain_value = $value['desc'];
}
// Set the placeholder if one exists
$placeholder = '';
if ( isset( $value['placeholder'] ) ) {
$placeholder = ' placeholder="' . esc_attr( $value['placeholder'] ) . '"';
}
if ( has_filter( 'optionsframework_' . $value['type'] ) ) {
$output .= apply_filters( 'optionsframework_' . $value['type'], $option_name, $value, $val );
}
switch ( $value['type'] ) {
// Basic text input
case 'text':
$output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="text" value="' . esc_attr( $val ) . '"' . $placeholder . ' />';
break;
// Password input
case 'password':
$output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="password" value="' . esc_attr( $val ) . '" />';
break;
// Textarea
case 'textarea':
$rows = '8';
if ( isset( $value['settings']['rows'] ) ) {
$custom_rows = $value['settings']['rows'];
if ( is_numeric( $custom_rows ) ) {
$rows = $custom_rows;
}
}
$val = stripslashes( $val );
$output .= '<textarea id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" rows="' . $rows . '"' . $placeholder . '>' . esc_textarea( $val ) . '</textarea>';
break;
// Select Box
case 'select':
$output .= '<select class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '">';
foreach ($value['options'] as $key => $option ) {
$output .= '<option'. selected( $val, $key, false ) .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
}
$output .= '</select>';
break;
// Radio Box
case "radio":
$name = $option_name .'['. $value['id'] .']';
foreach ($value['options'] as $key => $option) {
$id = $option_name . '-' . $value['id'] .'-'. $key;
$output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" '. checked( $val, $key, false) .' /><label for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label>';
}
break;
// Image Selectors
case "images":
$name = $option_name .'['. $value['id'] .']';
foreach ( $value['options'] as $key => $option ) {
$selected = '';
if ( $val != '' && ($val == $key) ) {
$selected = ' of-radio-img-selected';
}
$output .= '<input type="radio" id="' . esc_attr( $value['id'] .'_'. $key) . '" class="of-radio-img-radio" value="' . esc_attr( $key ) . '" name="' . esc_attr( $name ) . '" '. checked( $val, $key, false ) .' />';
$output .= '<div class="of-radio-img-label">' . esc_html( $key ) . '</div>';
$output .= '<img src="' . esc_url( $option ) . '" alt="' . $option .'" class="of-radio-img-img' . $selected .'" onclick="document.getElementById(\''. esc_attr($value['id'] .'_'. $key) .'\').checked=true;" />';
}
break;
// Checkbox
case "checkbox":
$output .= '<input id="' . esc_attr( $value['id'] ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" '. checked( $val, 1, false) .' />';
$output .= '<label class="explain" for="' . esc_attr( $value['id'] ) . '">' . wp_kses( $explain_value, $allowedtags) . '</label>';
break;
// Multicheck
case "multicheck":
foreach ($value['options'] as $key => $option) {
$checked = '';
$label = $option;
$option = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($key));
$id = $option_name . '-' . $value['id'] . '-'. $option;
$name = $option_name . '[' . $value['id'] . '][' . $option .']';
if ( isset($val[$option]) ) {
$checked = checked($val[$option], 1, false);
}
$output .= '<input id="' . esc_attr( $id ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $name ) . '" ' . $checked . ' /><label for="' . esc_attr( $id ) . '">' . esc_html( $label ) . '</label>';
}
break;
// Color picker
case "color":
$default_color = '';
if ( isset($value['std']) ) {
if ( $val != $value['std'] )
$default_color = ' data-default-color="' .$value['std'] . '" ';
}
$output .= '<input name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '" class="of-color" type="text" value="' . esc_attr( $val ) . '"' . $default_color .' />';
break;
// Uploader
case "upload":
$output .= Options_Framework_Media_Uploader::optionsframework_uploader( $value['id'], $val, null );
break;
// Typography
case 'typography':
unset( $font_size, $font_style, $font_face, $font_color );
$typography_defaults = array(
'size' => '',
'face' => '',
'style' => '',
'color' => ''
);
$typography_stored = wp_parse_args( $val, $typography_defaults );
$typography_options = array(
'sizes' => of_recognized_font_sizes(),
'faces' => of_recognized_font_faces(),
'styles' => of_recognized_font_styles(),
'color' => true
);
if ( isset( $value['options'] ) ) {
$typography_options = wp_parse_args( $value['options'], $typography_options );
}
// Font Size
if ( $typography_options['sizes'] ) {
$font_size = '<select class="of-typography of-typography-size" name="' . esc_attr( $option_name . '[' . $value['id'] . '][size]' ) . '" id="' . esc_attr( $value['id'] . '_size' ) . '">';
$sizes = $typography_options['sizes'];
foreach ( $sizes as $i ) {
$size = $i . 'px';
$font_size .= '<option value="' . esc_attr( $size ) . '" ' . selected( $typography_stored['size'], $size, false ) . '>' . esc_html( $size ) . '</option>';
}
$font_size .= '</select>';
}
// Font Face
if ( $typography_options['faces'] ) {
$font_face = '<select class="of-typography of-typography-face" name="' . esc_attr( $option_name . '[' . $value['id'] . '][face]' ) . '" id="' . esc_attr( $value['id'] . '_face' ) . '">';
$faces = $typography_options['faces'];
foreach ( $faces as $key => $face ) {
$font_face .= '<option value="' . esc_attr( $key ) . '" ' . selected( $typography_stored['face'], $key, false ) . '>' . esc_html( $face ) . '</option>';
}
$font_face .= '</select>';
}
// Font Styles
if ( $typography_options['styles'] ) {
$font_style = '<select class="of-typography of-typography-style" name="'.$option_name.'['.$value['id'].'][style]" id="'. $value['id'].'_style">';
$styles = $typography_options['styles'];
foreach ( $styles as $key => $style ) {
$font_style .= '<option value="' . esc_attr( $key ) . '" ' . selected( $typography_stored['style'], $key, false ) . '>'. $style .'</option>';
}
$font_style .= '</select>';
}
// Font Color
if ( $typography_options['color'] ) {
$default_color = '';
if ( isset($value['std']['color']) ) {
if ( $val != $value['std']['color'] )
$default_color = ' data-default-color="' .$value['std']['color'] . '" ';
}
$font_color = '<input name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" class="of-color of-typography-color type="text" value="' . esc_attr( $typography_stored['color'] ) . '"' . $default_color .' />';
}
// Allow modification/injection of typography fields
$typography_fields = compact( 'font_size', 'font_face', 'font_style', 'font_color' );
$typography_fields = apply_filters( 'of_typography_fields', $typography_fields, $typography_stored, $option_name, $value );
$output .= implode( '', $typography_fields );
break;
// Background
case 'background':
$background = $val;
// Background Color
$default_color = '';
if ( isset( $value['std']['color'] ) ) {
if ( $val != $value['std']['color'] )
$default_color = ' data-default-color="' .$value['std']['color'] . '" ';
}
$output .= '<input name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" class="of-color of-background-color" type="text" value="' . esc_attr( $background['color'] ) . '"' . $default_color .' />';
// Background Image
if ( !isset($background['image']) ) {
$background['image'] = '';
}
$output .= Options_Framework_Media_Uploader::optionsframework_uploader( $value['id'], $background['image'], null, esc_attr( $option_name . '[' . $value['id'] . '][image]' ) );
$class = 'of-background-properties';
if ( '' == $background['image'] ) {
$class .= ' hide';
}
$output .= '<div class="' . esc_attr( $class ) . '">';
// Background Repeat
$output .= '<select class="of-background of-background-repeat" name="' . esc_attr( $option_name . '[' . $value['id'] . '][repeat]' ) . '" id="' . esc_attr( $value['id'] . '_repeat' ) . '">';
$repeats = of_recognized_background_repeat();
foreach ($repeats as $key => $repeat) {
$output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['repeat'], $key, false ) . '>'. esc_html( $repeat ) . '</option>';
}
$output .= '</select>';
// Background Position
$output .= '<select class="of-background of-background-position" name="' . esc_attr( $option_name . '[' . $value['id'] . '][position]' ) . '" id="' . esc_attr( $value['id'] . '_position' ) . '">';
$positions = of_recognized_background_position();
foreach ($positions as $key=>$position) {
$output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['position'], $key, false ) . '>'. esc_html( $position ) . '</option>';
}
$output .= '</select>';
// Background Attachment
$output .= '<select class="of-background of-background-attachment" name="' . esc_attr( $option_name . '[' . $value['id'] . '][attachment]' ) . '" id="' . esc_attr( $value['id'] . '_attachment' ) . '">';
$attachments = of_recognized_background_attachment();
foreach ($attachments as $key => $attachment) {
$output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['attachment'], $key, false ) . '>' . esc_html( $attachment ) . '</option>';
}
$output .= '</select>';
$output .= '</div>';
break;
// Editor
case 'editor':
$output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags ) . '</div>'."\n";
echo $output;
$textarea_name = esc_attr( $option_name . '[' . $value['id'] . ']' );
$default_editor_settings = array(
'textarea_name' => $textarea_name,
'media_buttons' => false,
'tinymce' => array( 'plugins' => 'wordpress,wplink' )
);
$editor_settings = array();
if ( isset( $value['settings'] ) ) {
$editor_settings = $value['settings'];
}
$editor_settings = array_merge( $default_editor_settings, $editor_settings );
wp_editor( $val, $value['id'], $editor_settings );
$output = '';
break;
// Info
case "info":
$id = '';
$class = 'section';
if ( isset( $value['id'] ) ) {
$id = 'id="' . esc_attr( $value['id'] ) . '" ';
}
if ( isset( $value['type'] ) ) {
$class .= ' section-' . $value['type'];
}
if ( isset( $value['class'] ) ) {
$class .= ' ' . $value['class'];
}
$output .= '<div ' . $id . 'class="' . esc_attr( $class ) . '">' . "\n";
if ( isset($value['name']) ) {
$output .= '<h4 class="heading">' . esc_html( $value['name'] ) . '</h4>' . "\n";
}
if ( isset( $value['desc'] ) ) {
$output .= $value['desc'] . "\n";
}
$output .= '</div>' . "\n";
break;
// Heading for Navigation
case "heading":
$counter++;
if ( $counter >= 2 ) {
$output .= '</div>'."\n";
}
$class = '';
$class = ! empty( $value['id'] ) ? $value['id'] : $value['name'];
$class = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($class) );
$output .= '<div id="options-group-' . $counter . '" class="group ' . $class . '">';
$output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n";
break;
}
if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) {
$output .= '</div>';
if ( ( $value['type'] != "checkbox" ) && ( $value['type'] != "editor" ) ) {
$output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags) . '</div>'."\n";
}
$output .= '</div></div>'."\n";
}
echo $output;
}
// Outputs closing div if there tabs
if ( Options_Framework_Interface::optionsframework_tabs() != '' ) {
echo '</div>';
}
}
}

View File

@ -0,0 +1,122 @@
<?php
/**
* @package Options_Framework
* @author Devin Price <devin@wptheming.com>
* @license GPL-2.0+
* @link http://wptheming.com
* @copyright 2010-2014 WP Theming
*/
class Options_Framework_Media_Uploader {
/**
* Initialize the media uploader class
*
* @since 1.7.0
*/
public function init() {
add_action( 'admin_enqueue_scripts', array( $this, 'optionsframework_media_scripts' ) );
}
/**
* Media Uploader Using the WordPress Media Library.
*
* Parameters:
*
* string $_id - A token to identify this field (the name).
* string $_value - The value of the field, if present.
* string $_desc - An optional description of the field.
*
*/
static function optionsframework_uploader( $_id, $_value, $_desc = '', $_name = '' ) {
// Gets the unique option id
$options_framework = new Options_Framework;
$option_name = $options_framework->get_option_name();
$output = '';
$id = '';
$class = '';
$int = '';
$value = '';
$name = '';
$id = strip_tags( strtolower( $_id ) );
// If a value is passed and we don't have a stored value, use the value that's passed through.
if ( $_value != '' && $value == '' ) {
$value = $_value;
}
if ($_name != '') {
$name = $_name;
}
else {
$name = $option_name.'['.$id.']';
}
if ( $value ) {
$class = ' has-file';
}
$output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="'.$name.'" value="' . $value . '" placeholder="' . __('No file chosen', 'myoos') .'" />' . "\n";
if ( function_exists( 'wp_enqueue_media' ) ) {
if ( ( $value == '' ) ) {
$output .= '<input id="upload-' . $id . '" class="upload-button button" type="button" value="' . __( 'Upload', 'myoos' ) . '" />' . "\n";
} else {
$output .= '<input id="remove-' . $id . '" class="remove-file button" type="button" value="' . __( 'Remove', 'myoos' ) . '" />' . "\n";
}
} else {
$output .= '<p><i>' . __( 'Upgrade your version of WordPress for full media support.', 'myoos' ) . '</i></p>';
}
if ( $_desc != '' ) {
$output .= '<span class="of-metabox-desc">' . $_desc . '</span>' . "\n";
}
$output .= '<div class="screenshot" id="' . $id . '-image">' . "\n";
if ( $value != '' ) {
$remove = '<a class="remove-image">Remove</a>';
$image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value );
if ( $image ) {
$output .= '<img src="' . $value . '" alt="" />' . $remove;
} else {
$parts = explode( "/", $value );
for( $i = 0; $i < sizeof( $parts ); ++$i ) {
$title = $parts[$i];
}
// No output preview if it's not an image.
$output .= '';
// Standard generic output if it's not an image.
$title = __( 'View File', 'myoos' );
$output .= '<div class="no-image"><span class="file_link"><a href="' . $value . '" target="_blank" rel="external">'.$title.'</a></span></div>';
}
}
$output .= '</div>' . "\n";
return $output;
}
/**
* Enqueue scripts for file uploader
*/
function optionsframework_media_scripts( $hook ) {
$menu = Options_Framework_Admin::menu_settings();
if ( substr( $hook, -strlen( $menu['menu_slug'] ) ) !== $menu['menu_slug'] )
return;
if ( function_exists( 'wp_enqueue_media' ) )
wp_enqueue_media();
wp_register_script( 'of-media-uploader', OPTIONS_FRAMEWORK_DIRECTORY .'js/media-uploader.js', array( 'jquery' ), Options_Framework::VERSION );
wp_enqueue_script( 'of-media-uploader' );
wp_localize_script( 'of-media-uploader', 'optionsframework_l10n', array(
'upload' => __( 'Upload', 'myoos' ),
'remove' => __( 'Remove', 'myoos' )
) );
}
}

View File

@ -0,0 +1,454 @@
<?php
/**
* @package Options_Framework
* @author Devin Price <devin@wptheming.com>
* @license GPL-2.0+
* @link http://wptheming.com
* @copyright 2010-2014 WP Theming
*/
/**
* Sanitization for text input
*
* @link http://developer.wordpress.org/reference/functions/sanitize_text_field/
*/
add_filter( 'of_sanitize_text', 'sanitize_text_field' );
/**
* Sanitization for password input
*
* @link http://developer.wordpress.org/reference/functions/sanitize_text_field/
*/
add_filter( 'of_sanitize_password', 'sanitize_text_field' );
/**
* Sanitization for select input
*
* Validates that the selected option is a valid option.
*/
add_filter( 'of_sanitize_select', 'of_sanitize_enum', 10, 2 );
/**
* Sanitization for radio input
*
* Validates that the selected option is a valid option.
*/
add_filter( 'of_sanitize_radio', 'of_sanitize_enum', 10, 2 );
/**
* Sanitization for image selector
*
* Validates that the selected option is a valid option.
*/
add_filter( 'of_sanitize_images', 'of_sanitize_enum', 10, 2 );
/**
* Sanitization for textarea field
*
* @param $input string
* @return $output sanitized string
*/
function of_sanitize_textarea( $input ) {
global $allowedposttags;
$output = wp_kses( $input, $allowedposttags );
return $output;
}
add_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' );
/**
* Sanitization for checkbox input
*
* @param $input string (1 or empty) checkbox state
* @return $output '1' or false
*/
function of_sanitize_checkbox( $input ) {
if ( $input ) {
$output = '1';
} else {
$output = false;
}
return $output;
}
add_filter( 'of_sanitize_checkbox', 'of_sanitize_checkbox' );
/**
* Sanitization for multicheck
*
* @param array of checkbox values
* @return array of sanitized values ('1' or false)
*/
function of_sanitize_multicheck( $input, $option ) {
$output = '';
if ( is_array( $input ) ) {
foreach( $option['options'] as $key => $value ) {
$output[$key] = false;
}
foreach( $input as $key => $value ) {
if ( array_key_exists( $key, $option['options'] ) && $value ) {
$output[$key] = '1';
}
}
}
return $output;
}
add_filter( 'of_sanitize_multicheck', 'of_sanitize_multicheck', 10, 2 );
/**
* File upload sanitization.
*
* Returns a sanitized filepath if it has a valid extension.
*
* @param string $input filepath
* @returns string $output filepath
*/
function of_sanitize_upload( $input ) {
$output = '';
$filetype = wp_check_filetype( $input );
if ( $filetype["ext"] ) {
$output = esc_url( $input );
}
return $output;
}
add_filter( 'of_sanitize_upload', 'of_sanitize_upload' );
/**
* Sanitization for editor input.
*
* Returns unfiltered HTML if user has permissions.
*
* @param string $input
* @returns string $output
*/
function of_sanitize_editor( $input ) {
if ( current_user_can( 'unfiltered_html' ) ) {
$output = $input;
}
else {
global $allowedposttags;
$output = wpautop( wp_kses( $input, $allowedposttags ) );
}
return $output;
}
add_filter( 'of_sanitize_editor', 'of_sanitize_editor' );
/**
* Sanitization of input with allowed tags and wpautotop.
*
* Allows allowed tags in html input and ensures tags close properly.
*
* @param string $input
* @returns string $output
*/
function of_sanitize_allowedtags( $input ) {
global $allowedtags;
$output = wpautop( wp_kses( $input, $allowedtags ) );
return $output;
}
/**
* Sanitization of input with allowed post tags and wpautotop.
*
* Allows allowed post tags in html input and ensures tags close properly.
*
* @param string $input
* @returns string $output
*/
function of_sanitize_allowedposttags( $input ) {
global $allowedposttags;
$output = wpautop( wp_kses( $input, $allowedposttags) );
return $output;
}
/**
* Validates that the $input is one of the avilable choices
* for that specific option.
*
* @param string $input
* @returns string $output
*/
function of_sanitize_enum( $input, $option ) {
$output = '';
if ( array_key_exists( $input, $option['options'] ) ) {
$output = $input;
}
return $output;
}
/**
* Sanitization for background option.
*
* @returns array $output
*/
function of_sanitize_background( $input ) {
$output = wp_parse_args( $input, array(
'color' => '',
'image' => '',
'repeat' => 'repeat',
'position' => 'top center',
'attachment' => 'scroll'
) );
$output['color'] = apply_filters( 'of_sanitize_hex', $input['color'] );
$output['image'] = apply_filters( 'of_sanitize_upload', $input['image'] );
$output['repeat'] = apply_filters( 'of_background_repeat', $input['repeat'] );
$output['position'] = apply_filters( 'of_background_position', $input['position'] );
$output['attachment'] = apply_filters( 'of_background_attachment', $input['attachment'] );
return $output;
}
add_filter( 'of_sanitize_background', 'of_sanitize_background' );
/**
* Sanitization for background repeat
*
* @returns string $value if it is valid
*/
function of_sanitize_background_repeat( $value ) {
$recognized = of_recognized_background_repeat();
if ( array_key_exists( $value, $recognized ) ) {
return $value;
}
return apply_filters( 'of_default_background_repeat', current( $recognized ) );
}
add_filter( 'of_background_repeat', 'of_sanitize_background_repeat' );
/**
* Sanitization for background position
*
* @returns string $value if it is valid
*/
function of_sanitize_background_position( $value ) {
$recognized = of_recognized_background_position();
if ( array_key_exists( $value, $recognized ) ) {
return $value;
}
return apply_filters( 'of_default_background_position', current( $recognized ) );
}
add_filter( 'of_background_position', 'of_sanitize_background_position' );
/**
* Sanitization for background attachment
*
* @returns string $value if it is valid
*/
function of_sanitize_background_attachment( $value ) {
$recognized = of_recognized_background_attachment();
if ( array_key_exists( $value, $recognized ) ) {
return $value;
}
return apply_filters( 'of_default_background_attachment', current( $recognized ) );
}
add_filter( 'of_background_attachment', 'of_sanitize_background_attachment' );
/**
* Sanitization for typography option.
*/
function of_sanitize_typography( $input, $option ) {
$output = wp_parse_args( $input, array(
'size' => '',
'face' => '',
'style' => '',
'color' => ''
) );
if ( isset( $option['options']['faces'] ) && isset( $input['face'] ) ) {
if ( !( array_key_exists( $input['face'], $option['options']['faces'] ) ) ) {
$output['face'] = '';
}
}
else {
$output['face'] = apply_filters( 'of_font_face', $output['face'] );
}
$output['size'] = apply_filters( 'of_font_size', $output['size'] );
$output['style'] = apply_filters( 'of_font_style', $output['style'] );
$output['color'] = apply_filters( 'of_sanitize_color', $output['color'] );
return $output;
}
add_filter( 'of_sanitize_typography', 'of_sanitize_typography', 10, 2 );
/**
* Sanitization for font size
*/
function of_sanitize_font_size( $value ) {
$recognized = of_recognized_font_sizes();
$value_check = preg_replace('/px/','', $value);
if ( in_array( (int) $value_check, $recognized ) ) {
return $value;
}
return apply_filters( 'of_default_font_size', $recognized );
}
add_filter( 'of_font_size', 'of_sanitize_font_size' );
/**
* Sanitization for font style
*/
function of_sanitize_font_style( $value ) {
$recognized = of_recognized_font_styles();
if ( array_key_exists( $value, $recognized ) ) {
return $value;
}
return apply_filters( 'of_default_font_style', current( $recognized ) );
}
add_filter( 'of_font_style', 'of_sanitize_font_style' );
/**
* Sanitization for font face
*/
function of_sanitize_font_face( $value ) {
$recognized = of_recognized_font_faces();
if ( array_key_exists( $value, $recognized ) ) {
return $value;
}
return apply_filters( 'of_default_font_face', current( $recognized ) );
}
add_filter( 'of_font_face', 'of_sanitize_font_face' );
/**
* Get recognized background repeat settings
*
* @return array
*/
function of_recognized_background_repeat() {
$default = array(
'no-repeat' => __( 'No Repeat', 'myoos' ),
'repeat-x' => __( 'Repeat Horizontally', 'myoos' ),
'repeat-y' => __( 'Repeat Vertically', 'myoos' ),
'repeat' => __( 'Repeat All', 'myoos' ),
);
return apply_filters( 'of_recognized_background_repeat', $default );
}
/**
* Get recognized background positions
*
* @return array
*/
function of_recognized_background_position() {
$default = array(
'top left' => __( 'Top Left', 'myoos' ),
'top center' => __( 'Top Center', 'myoos' ),
'top right' => __( 'Top Right', 'myoos' ),
'center left' => __( 'Middle Left', 'myoos' ),
'center center' => __( 'Middle Center', 'myoos' ),
'center right' => __( 'Middle Right', 'myoos' ),
'bottom left' => __( 'Bottom Left', 'myoos' ),
'bottom center' => __( 'Bottom Center', 'myoos' ),
'bottom right' => __( 'Bottom Right', 'myoos')
);
return apply_filters( 'of_recognized_background_position', $default );
}
/**
* Get recognized background attachment
*
* @return array
*/
function of_recognized_background_attachment() {
$default = array(
'scroll' => __( 'Scroll Normally', 'myoos' ),
'fixed' => __( 'Fixed in Place', 'myoos')
);
return apply_filters( 'of_recognized_background_attachment', $default );
}
/**
* Sanitize a color represented in hexidecimal notation.
*
* @param string Color in hexidecimal notation. "#" may or may not be prepended to the string.
* @param string The value that this function should return if it cannot be recognized as a color.
* @return string
*/
function of_sanitize_hex( $hex, $default = '' ) {
if ( of_validate_hex( $hex ) ) {
return $hex;
}
return $default;
}
add_filter( 'of_sanitize_color', 'of_sanitize_hex' );
/**
* Get recognized font sizes.
*
* Returns an indexed array of all recognized font sizes.
* Values are integers and represent a range of sizes from
* smallest to largest.
*
* @return array
*/
function of_recognized_font_sizes() {
$sizes = range( 9, 71 );
$sizes = apply_filters( 'of_recognized_font_sizes', $sizes );
$sizes = array_map( 'absint', $sizes );
return $sizes;
}
/**
* Get recognized font faces.
*
* Returns an array of all recognized font faces.
* Keys are intended to be stored in the database
* while values are ready for display in in html.
*
* @return array
*/
function of_recognized_font_faces() {
$default = array(
'arial' => 'Arial',
'verdana' => 'Verdana, Geneva',
'trebuchet' => 'Trebuchet',
'georgia' => 'Georgia',
'times' => 'Times New Roman',
'tahoma' => 'Tahoma, Geneva',
'palatino' => 'Palatino',
'helvetica' => 'Helvetica*'
);
return apply_filters( 'of_recognized_font_faces', $default );
}
/**
* Get recognized font styles.
*
* Returns an array of all recognized font styles.
* Keys are intended to be stored in the database
* while values are ready for display in in html.
*
* @return array
*/
function of_recognized_font_styles() {
$default = array(
'normal' => __( 'Normal', 'myoos' ),
'italic' => __( 'Italic', 'myoos' ),
'bold' => __( 'Bold', 'myoos' ),
'bold italic' => __( 'Bold Italic', 'myoos' )
);
return apply_filters( 'of_recognized_font_styles', $default );
}
/**
* Is a given string a color formatted in hexidecimal notation?
*
* @param string Color in hexidecimal notation. "#" may or may not be prepended to the string.
* @return bool
*/
function of_validate_hex( $hex ) {
$hex = trim( $hex );
/* Strip recognized prefixes. */
if ( 0 === strpos( $hex, '#' ) ) {
$hex = substr( $hex, 1 );
}
elseif ( 0 === strpos( $hex, '%23' ) ) {
$hex = substr( $hex, 3 );
}
/* Regex match. */
if ( 0 === preg_match( '/^[0-9a-fA-F]{6}$/', $hex ) ) {
return false;
}
else {
return true;
}
}

View File

@ -0,0 +1,79 @@
jQuery(document).ready(function($){
var optionsframework_upload;
var optionsframework_selector;
function optionsframework_add_file(event, selector) {
var upload = $(".uploaded-file"), frame;
var $el = $(this);
optionsframework_selector = selector;
event.preventDefault();
// If the media frame already exists, reopen it.
if ( optionsframework_upload ) {
optionsframework_upload.open();
} else {
// Create the media frame.
optionsframework_upload = wp.media.frames.optionsframework_upload = wp.media({
// Set the title of the modal.
title: $el.data('choose'),
// Customize the submit button.
button: {
// Set the text of the button.
text: $el.data('update'),
// Tell the button not to close the modal, since we're
// going to refresh the page when the image is selected.
close: false
}
});
// When an image is selected, run a callback.
optionsframework_upload.on( 'select', function() {
// Grab the selected attachment.
var attachment = optionsframework_upload.state().get('selection').first();
optionsframework_upload.close();
optionsframework_selector.find('.upload').val(attachment.attributes.url);
if ( attachment.attributes.type == 'image' ) {
optionsframework_selector.find('.screenshot').empty().hide().append('<img src="' + attachment.attributes.url + '"><a class="remove-image">Remove</a>').slideDown('fast');
}
optionsframework_selector.find('.upload-button').unbind().addClass('remove-file').removeClass('upload-button').val(optionsframework_l10n.remove);
optionsframework_selector.find('.of-background-properties').slideDown();
optionsframework_selector.find('.remove-image, .remove-file').on('click', function() {
optionsframework_remove_file( $(this).parents('.section') );
});
});
}
// Finally, open the modal.
optionsframework_upload.open();
}
function optionsframework_remove_file(selector) {
selector.find('.remove-image').hide();
selector.find('.upload').val('');
selector.find('.of-background-properties').hide();
selector.find('.screenshot').slideUp();
selector.find('.remove-file').unbind().addClass('upload-button').removeClass('remove-file').val(optionsframework_l10n.upload);
// We don't display the upload button if .upload-notice is present
// This means the user doesn't have the WordPress 3.5 Media Library Support
if ( $('.section-upload .upload-notice').length > 0 ) {
$('.upload-button').remove();
}
selector.find('.upload-button').on('click', function(event) {
optionsframework_add_file(event, $(this).parents('.section'));
});
}
$('.remove-image, .remove-file').on('click', function() {
optionsframework_remove_file( $(this).parents('.section') );
});
$('.upload-button').click( function( event ) {
optionsframework_add_file(event, $(this).parents('.section'));
});
});

View File

@ -0,0 +1,71 @@
/**
* Custom scripts needed for the colorpicker, image button selectors,
* and navigation tabs.
*/
jQuery(document).ready(function($) {
// Loads the color pickers
$('.of-color').wpColorPicker();
// Image Options
$('.of-radio-img-img').click(function(){
$(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected');
$(this).addClass('of-radio-img-selected');
});
$('.of-radio-img-label').hide();
$('.of-radio-img-img').show();
$('.of-radio-img-radio').hide();
// Loads tabbed sections if they exist
if ( $('.nav-tab-wrapper').length > 0 ) {
options_framework_tabs();
}
function options_framework_tabs() {
var $group = $('.group'),
$navtabs = $('.nav-tab-wrapper a'),
active_tab = '';
// Hides all the .group sections to start
$group.hide();
// Find if a selected tab is saved in localStorage
if ( typeof(localStorage) != 'undefined' ) {
active_tab = localStorage.getItem('active_tab');
}
// If active tab is saved and exists, load it's .group
if ( active_tab != '' && $(active_tab).length ) {
$(active_tab).fadeIn();
$(active_tab + '-tab').addClass('nav-tab-active');
} else {
$('.group:first').fadeIn();
$('.nav-tab-wrapper a:first').addClass('nav-tab-active');
}
// Bind tabs clicks
$navtabs.click(function(e) {
e.preventDefault();
// Remove active class from all tabs
$navtabs.removeClass('nav-tab-active');
$(this).addClass('nav-tab-active').blur();
if (typeof(localStorage) != 'undefined' ) {
localStorage.setItem('active_tab', $(this).attr('href') );
}
var selected = $(this).attr('href');
$group.hide();
$(selected).fadeIn();
});
}
});

View File

@ -0,0 +1,94 @@
<?php
/**
* Options Framework
*
* @package Options Framework
* @author Devin Price <devin@wptheming.com>
* @license GPL-2.0+
* @link http://wptheming.com
* @copyright 2010-2014 WP Theming
*
* @wordpress-plugin
* Plugin Name: Options Framework
* Plugin URI: http://wptheming.com
* Description: A framework for building theme options.
* Version: 1.9.1
* Author: Devin Price
* Author URI: http://wptheming.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: optionsframework
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// Don't load if optionsframework_init is already defined
if (is_admin() && ! function_exists( 'optionsframework_init' ) ) :
function optionsframework_init() {
// If user can't edit theme options, exit
if ( ! current_user_can( 'edit_theme_options' ) ) {
return;
}
// Loads the required Options Framework classes.
require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework-admin.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-options-interface.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-options-media-uploader.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-options-sanitization.php';
// Instantiate the options page.
$options_framework_admin = new Options_Framework_Admin;
$options_framework_admin->init();
// Instantiate the media uploader class
$options_framework_media_uploader = new Options_Framework_Media_Uploader;
$options_framework_media_uploader->init();
}
add_action( 'init', 'optionsframework_init', 20 );
endif;
/**
* 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.
*
* Not in a class to support backwards compatibility in themes.
*/
if ( ! function_exists( 'of_get_option' ) ) :
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 );
// Return specific option
if ( isset( $options[$name] ) ) {
return $options[$name];
}
return $default;
}
endif;