diff -r 346c88efed21 -r 5e2f62d02dcd wp/wp-content/plugins/option-tree/includes/ot-settings-api.php
--- a/wp/wp-content/plugins/option-tree/includes/ot-settings-api.php Mon Jun 08 16:11:51 2015 +0000
+++ b/wp/wp-content/plugins/option-tree/includes/ot-settings-api.php Tue Jun 09 03:35:32 2015 +0200
@@ -49,9 +49,18 @@
* @since 2.0
*/
public function hooks() {
-
+
+ /**
+ * Filter the `admin_menu` action hook priority.
+ *
+ * @since 2.5.0
+ *
+ * @param int $priority The priority. Default '10'.
+ */
+ $priority = apply_filters( 'ot_admin_menu_priority', 10 );
+
/* add pages & menu items */
- add_action( 'admin_menu', array( $this, 'add_page' ) );
+ add_action( 'admin_menu', array( $this, 'add_page' ), $priority );
/* register sections */
add_action( 'admin_init', array( $this, 'add_sections' ) );
@@ -233,20 +242,19 @@
/* update active layout content */
if ( isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ) {
- $layouts = get_option( 'option_tree_layouts' );
+ $layouts = get_option( ot_layouts_id() );
/* has active layout */
if ( isset( $layouts['active_layout'] ) ) {
$option_tree = get_option( $option['id'] );
$layouts[$layouts['active_layout']] = ot_encode( serialize( $option_tree ) );
- update_option( 'option_tree_layouts', $layouts );
+ update_option( ot_layouts_id(), $layouts );
}
}
echo '
';
- screen_icon( ( isset( $page['screen_icon'] ) ? $page['screen_icon'] : 'options-general' ) );
echo '
' . $page['page_title'] . '
';
echo ot_alert_message( $page );
@@ -258,9 +266,12 @@
echo '';
@@ -287,7 +298,7 @@
echo '';
@@ -332,7 +343,7 @@
echo '
';
- echo '';
+ echo '';
echo '
';
@@ -350,7 +361,7 @@
echo '
';
- echo '
';
+ echo '
';
echo '';
@@ -472,6 +483,7 @@
* @since 2.0
*/
public function display_setting( $args = array() ) {
+
extract( $args );
/* get current saved data */
@@ -484,6 +496,9 @@
if ( isset( $std ) ) {
$field_value = ot_filter_std_value( $field_value, $std );
}
+
+ // Allow the descriptions to be filtered before being displayed
+ $desc = apply_filters( 'ot_filter_description', ( isset( $desc ) ? $desc : '' ), $id );
/* build the arguments array */
$_args = array(
@@ -491,12 +506,14 @@
'field_id' => $id,
'field_name' => $get_option . '[' . $id . ']',
'field_value' => $field_value,
- 'field_desc' => isset( $desc ) ? $desc : '',
+ 'field_desc' => $desc,
'field_std' => isset( $std ) ? $std : '',
'field_rows' => isset( $rows ) && ! empty( $rows ) ? $rows : 15,
'field_post_type' => isset( $post_type ) && ! empty( $post_type ) ? $post_type : 'post',
'field_taxonomy' => isset( $taxonomy ) && ! empty( $taxonomy ) ? $taxonomy : 'category',
'field_min_max_step'=> isset( $min_max_step ) && ! empty( $min_max_step ) ? $min_max_step : '0,100,1',
+ 'field_condition' => isset( $condition ) && ! empty( $condition ) ? $condition : '',
+ 'field_operator' => isset( $operator ) && ! empty( $operator ) ? $operator : 'and',
'field_class' => isset( $class ) ? $class : '',
'field_choices' => isset( $choices ) && ! empty( $choices ) ? $choices : array(),
'field_settings' => isset( $settings ) && ! empty( $settings ) ? $settings : array(),
@@ -504,6 +521,12 @@
'get_option' => $get_option,
);
+ // Limit DB queries for Google Fonts.
+ if ( $type == 'google-fonts' ) {
+ ot_fetch_google_fonts();
+ ot_set_google_fonts( $id, $field_value );
+ }
+
/* get the option HTML */
echo ot_display_by_type( $_args );
}
@@ -574,7 +597,7 @@
if ( isset( $setting['type'] ) && isset( $input[$setting['id']] ) ) {
/* get the defaults */
- $current_settings = get_option( 'option_tree_settings' );
+ $current_settings = get_option( ot_settings_id() );
$current_options = get_option( $option['id'] );
/* validate setting */
@@ -632,6 +655,41 @@
}
}
+
+ } else if ( is_array( $input[$setting['id']] ) && $setting['type'] == 'social-links' ) {
+
+ /* get the settings array */
+ $settings = isset( $_POST[$setting['id'] . '_settings_array'] ) ? unserialize( ot_decode( $_POST[$setting['id'] . '_settings_array'] ) ) : array();
+
+ /* settings are empty get the defaults */
+ if ( empty( $settings ) ) {
+ $settings = ot_social_links_settings( $setting['id'] );
+ }
+
+ /* create an empty WPML id array */
+ $wpml_ids = array();
+
+ foreach( $input[$setting['id']] as $k => $setting_array ) {
+
+ foreach( $settings as $sub_setting ) {
+
+ /* setup the WPML ID */
+ $wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k;
+
+ /* add id to array */
+ $wpml_ids[] = $wpml_id;
+
+ /* verify sub setting has a type & value */
+ if ( isset( $sub_setting['type'] ) && isset( $input[$setting['id']][$k][$sub_setting['id']] ) ) {
+
+ /* validate setting */
+ $input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting( $input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'], $wpml_id );
+
+ }
+
+ }
+
+ }
} else {
@@ -672,6 +730,38 @@
}
}
+
+ /* unregister WPML strings that were deleted from social links */
+ if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && $setting['type'] == 'social-links' ) {
+
+ if ( ! isset( $wpml_ids ) )
+ $wpml_ids = array();
+
+ foreach( $current_settings['settings'] as $check_setting ) {
+
+ if ( $setting['id'] == $check_setting['id'] && ! empty( $current_options[$setting['id']] ) ) {
+
+ foreach( $current_options[$setting['id']] as $key => $value ) {
+
+ foreach( $value as $ckey => $cvalue ) {
+
+ $id = $setting['id'] . '_' . $ckey . '_' . $key;
+
+ if ( ! in_array( $id, $wpml_ids ) ) {
+
+ ot_wpml_unregister_string( $id );
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
}
@@ -820,8 +910,36 @@
return;
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
+
+ $conditions = '';
+
+ if ( isset( $field['args']['condition'] ) && ! empty( $field['args']['condition'] ) ) {
+
+ $conditions = ' data-condition="' . $field['args']['condition'] . '"';
+ $conditions.= isset( $field['args']['operator'] ) && in_array( $field['args']['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['args']['operator'] . '"' : '';
+
+ }
- echo '