From 918f90f15129d4755f148d97bcb7c5d123ecfd9f Mon Sep 17 00:00:00 2001 From: themefuse Date: Sat, 29 Nov 2014 19:06:23 +0200 Subject: [PATCH] Version 1.4.18 --- .../framework/bootstrap-helpers.php | 2 +- .../class-fw-extension-sidebars-config.php | 31 ++++++++++---- .../class-fw-extension-sidebars-frontend.php | 42 ++++++++----------- .../helpers/class-fw-wp-filesystem.php | 8 ++-- .../class-fw-option-type-addable-box.php | 4 +- .../addable-box/static/js/scripts.js | 8 ++-- .../option-types/addable-box/view.php | 17 ++++---- .../addable-option/static/js/scripts.js | 2 +- .../option-types/addable-option/view.php | 17 +++++--- .../class-fw-option-type-addable-popup.php | 4 +- .../addable-popup/static/js/addable-popup.js | 5 ++- .../option-types/addable-popup/views/view.php | 13 ++++-- .../switch/static/adaptive-switch/styles.css | 24 ++++++----- scratch-parent/framework/manifest.php | 2 +- .../framework/static/js/backend-options.js | 7 +--- 15 files changed, 104 insertions(+), 82 deletions(-) diff --git a/scratch-parent/framework/bootstrap-helpers.php b/scratch-parent/framework/bootstrap-helpers.php index 8ad40535..b30cdf9b 100644 --- a/scratch-parent/framework/bootstrap-helpers.php +++ b/scratch-parent/framework/bootstrap-helpers.php @@ -8,7 +8,7 @@ * Convert to Unix style directory separators */ function fw_fix_path($path) { - return str_replace(array('//', '\\'), array('/', '/'), $path); + return untrailingslashit( str_replace(array('//', '\\'), array('/', '/'), $path) ); } /** Child theme related functions */ diff --git a/scratch-parent/framework/extensions/sidebars/includes/class-fw-extension-sidebars-config.php b/scratch-parent/framework/extensions/sidebars/includes/class-fw-extension-sidebars-config.php index 30979a0c..7f504711 100644 --- a/scratch-parent/framework/extensions/sidebars/includes/class-fw-extension-sidebars-config.php +++ b/scratch-parent/framework/extensions/sidebars/includes/class-fw-extension-sidebars-config.php @@ -31,6 +31,7 @@ class _FW_Extension_Sidebars_Config 'front_page_slug' => array( 'order_option' => 1, 'name' => 'Pages with Front-Page template', + 'check_priority' => 'last' // type string 'first' | 'last' 'conditional_tag' => array( 'callback' => 'is_page_template', 'params' => array('page-templates/front-page.php') @@ -82,23 +83,28 @@ private function get_config_defaults() { 'conditional_tags' => array( 'is_front_page' => array( 'name' => __('Home Page', 'fw'), - 'order_option' => 3 + 'order_option' => 3, + 'check_priority' => 'first' ), 'is_search' => array( 'name' => __('Search Page', 'fw'), - 'order_option' => 2 + 'order_option' => 2, + 'check_priority' => 'last' ), 'is_404' => array( 'name' => __('404 Page', 'fw'), - 'order_option' => 4 + 'order_option' => 4, + 'check_priority' => 'last' ), 'is_author' => array( 'name' => __('Author Page', 'fw'), - 'order_option' => 1 + 'order_option' => 1, + 'check_priority' => 'last' ), 'is_archive' => array( 'name' => __('Archive Page','fw'), - 'order_option' => 5 + 'order_option' => 5, + 'check_priority' => 'last' ) ) ) @@ -205,7 +211,7 @@ private function get_post_types() { */ public function get_conditional_tags_labels($with_ordering = false) { - $cts = fw_akg('select_options/conditional_tags', $this->config, array()); + $cts = $this->get_conditional_tags(); if ($with_ordering) { uasort($cts, array($this, 'conditional_tag_cmp')); @@ -388,9 +394,18 @@ public function has_position($position) return (isset($this->config['sidebar_positions'][$position]) and is_array($this->config['sidebar_positions'][$position])); } - public function get_conditional_tags() + public function get_conditional_tags($priority = null) { - return fw_akg('select_options/conditional_tags', $this->config, array()); + $conditional_tags = apply_filters('fw_ext_sidebars_post_types', fw_akg('select_options/conditional_tags', $this->config, array()) ) ; + + if ($priority) { + foreach($conditional_tags as $key => $conditional_tag) { + if ($conditional_tag['check_priority'] != $priority) { + unset($conditional_tags[$key]); + } + } + } + return $conditional_tags; } /** diff --git a/scratch-parent/framework/extensions/sidebars/includes/class-fw-extension-sidebars-frontend.php b/scratch-parent/framework/extensions/sidebars/includes/class-fw-extension-sidebars-frontend.php index 6eb2d2e8..28385daf 100644 --- a/scratch-parent/framework/extensions/sidebars/includes/class-fw-extension-sidebars-frontend.php +++ b/scratch-parent/framework/extensions/sidebars/includes/class-fw-extension-sidebars-frontend.php @@ -72,9 +72,10 @@ public function render_sidebar($color) */ public function get_current_page_preset() { - // check if current_page_preset doesn't get before - if ($this->current_page_preset !== null) { - return $this->current_page_preset; + + $result = $this->check_conditional_tags('first'); + if ($result) { + return $result; } if (is_singular()){ @@ -84,7 +85,7 @@ public function get_current_page_preset() $result = $this->get_preset_sidebars($data); if ( $result ) - return $result; + return $result; } if (is_category()) { @@ -97,20 +98,6 @@ public function get_current_page_preset() return $result; } - //was disabled from config - { - if (is_tag()) { - $term_obj = get_term_by('slug', get_query_var('tag'), 'post_tag'); - $data['type'] = $this->config->get_type_by_prefix(_FW_Extension_Sidebars_Config::TAXONOMIES_PREFIX); - $data['sub_type'] = $term_obj->taxonomy; - $data['id'] = $term_obj->term_id; - - $result = $this->get_preset_sidebars($data); - if ( $result ) - return $result; - } - } - if (is_tax()) { $term_obj = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); $data['type'] = $this->config->get_type_by_prefix(_FW_Extension_Sidebars_Config::TAXONOMIES_PREFIX); @@ -122,7 +109,19 @@ public function get_current_page_preset() return $result; } - $conditional_tags = $this->config->get_conditional_tags(); + $result = $this->check_conditional_tags('last'); + if ($result) { + return $result; + } + + $data['type'] = $this->config->get_type_by_prefix(_FW_Extension_Sidebars_Config::DEFAULT_PREFIX); + $data['sub_type'] = _FW_Extension_Sidebars_Config::DEFAULT_SUB_TYPE; + $result = $this->get_preset_sidebars($data); //return preset default for all pages + return $result; + } + + private function check_conditional_tags($priority) { + $conditional_tags = $this->config->get_conditional_tags($priority); foreach($conditional_tags as $key => $cond_tag) { @@ -164,11 +163,6 @@ public function get_current_page_preset() } } - - $data['type'] = $this->config->get_type_by_prefix(_FW_Extension_Sidebars_Config::DEFAULT_PREFIX); - $data['sub_type'] = _FW_Extension_Sidebars_Config::DEFAULT_SUB_TYPE; - $result = $this->get_preset_sidebars($data); //return preset default for all pages - return $result; } /** diff --git a/scratch-parent/framework/helpers/class-fw-wp-filesystem.php b/scratch-parent/framework/helpers/class-fw-wp-filesystem.php index c17ec3db..03e50384 100644 --- a/scratch-parent/framework/helpers/class-fw-wp-filesystem.php +++ b/scratch-parent/framework/helpers/class-fw-wp-filesystem.php @@ -92,8 +92,8 @@ final public static function real_path_to_filesystem_path($path) { $path = fw_fix_path($path); - $real_abspath = untrailingslashit(fw_fix_path(ABSPATH)); - $wp_filesystem_abspath = untrailingslashit($wp_filesystem->abspath()); + $real_abspath = fw_fix_path(ABSPATH); + $wp_filesystem_abspath = fw_fix_path($wp_filesystem->abspath()); $relative_path = preg_replace('/^'. preg_quote($real_abspath, '/') .'/', '', $path); return $wp_filesystem_abspath . $relative_path; @@ -114,8 +114,8 @@ final public static function filesystem_path_to_real_path($wp_filesystem_path) { $wp_filesystem_path = fw_fix_path($wp_filesystem_path); - $real_abspath = untrailingslashit(fw_fix_path(ABSPATH)); - $wp_filesystem_abspath = untrailingslashit($wp_filesystem->abspath()); + $real_abspath = fw_fix_path(ABSPATH); + $wp_filesystem_abspath = fw_fix_path($wp_filesystem->abspath()); $relative_path = preg_replace('/^'. preg_quote($wp_filesystem_abspath, '/') .'/', '', $wp_filesystem_path); return $real_abspath . $relative_path; diff --git a/scratch-parent/framework/includes/option-types/addable-box/class-fw-option-type-addable-box.php b/scratch-parent/framework/includes/option-types/addable-box/class-fw-option-type-addable-box.php index da8a7e71..cb374f81 100644 --- a/scratch-parent/framework/includes/option-types/addable-box/class-fw-option-type-addable-box.php +++ b/scratch-parent/framework/includes/option-types/addable-box/class-fw-option-type-addable-box.php @@ -87,10 +87,10 @@ protected function _render($id, $option, $data) unset($collected); } - $option['attr']['data-for-js'] = base64_encode(json_encode(array( + $option['attr']['data-for-js'] = json_encode(array( 'options' => $this->transform_options($box_options), 'template' => $option['template'], - ))); + )); return fw_render_view(fw_get_framework_directory('/includes/option-types/'. $this->get_type() .'/view.php'), array( 'id' => $id, diff --git a/scratch-parent/framework/includes/option-types/addable-box/static/js/scripts.js b/scratch-parent/framework/includes/option-types/addable-box/static/js/scripts.js index d5d21b98..41597359 100644 --- a/scratch-parent/framework/includes/option-types/addable-box/static/js/scripts.js +++ b/scratch-parent/framework/includes/option-types/addable-box/static/js/scripts.js @@ -138,9 +138,9 @@ jQuery(document).ready(function ($) { return; } - var data = JSON.parse(atob( + var data = JSON.parse( $box.closest(optionTypeClass).attr('data-for-js') - )); + ); data.template = $.trim(data.template); @@ -221,8 +221,8 @@ jQuery(document).ready(function ($) { var increment = parseInt($button.attr('data-increment')); var $newBox = $( - $option.find('.default-box-template:first').attr('data-template') - .split('###-addable-box-increment-###').join(String(increment)) + $option.find('> .default-box-template').attr('data-template') + .split( $button.attr('data-increment-placeholder') ).join( String(increment) ) ); $button.attr('data-increment', increment + 1); diff --git a/scratch-parent/framework/includes/option-types/addable-box/view.php b/scratch-parent/framework/includes/option-types/addable-box/view.php index 932d869c..26f6ba44 100644 --- a/scratch-parent/framework/includes/option-types/addable-box/view.php +++ b/scratch-parent/framework/includes/option-types/addable-box/view.php @@ -40,7 +40,7 @@ backend->render_box( $data['id_prefix'] . $id .'-'. $i .'-box', - '͏ ', + ' ', ob_get_clean(), array( 'html_after_title' => $controls_html, @@ -69,17 +69,17 @@ $values = array(); // must contain characters that will remain the same after htmlspecialchars() - $increment_template = '###-addable-box-increment-###'; + $increment_placeholder = '###-addable-box-increment-'. fw_rand_md5() .'-###'; echo fw_htmlspecialchars( - '
'. + '
'. fw()->backend->render_box( - $data['id_prefix'] . $id .'-'. $increment_template .'-box', - '͏ ', + $data['id_prefix'] . $id .'-'. $increment_placeholder .'-box', + ' ', '
'. fw()->backend->render_options($box_options, $values, array( - 'id_prefix' => $data['id_prefix'] . $id .'-'. $increment_template .'-', - 'name_prefix' => $data['name_prefix'] .'['. $id .']['. $increment_template .']', + 'id_prefix' => $data['id_prefix'] . $id .'-'. $increment_placeholder .'-', + 'name_prefix' => $data['name_prefix'] .'['. $id .']['. $increment_placeholder .']', )). '
', array( @@ -96,7 +96,8 @@ 'onclick' => 'return false;', 'class' => 'button fw-option-boxes-add-button', 'data-increment' => ++$i, - 'data-limit' => intval($option['limit']) + 'data-increment-placeholder' => $increment_placeholder, + 'data-limit' => intval($option['limit']), ), __('Add', 'fw')); ?>
diff --git a/scratch-parent/framework/includes/option-types/addable-option/static/js/scripts.js b/scratch-parent/framework/includes/option-types/addable-option/static/js/scripts.js index fe14cf00..c5d0ccfe 100644 --- a/scratch-parent/framework/includes/option-types/addable-option/static/js/scripts.js +++ b/scratch-parent/framework/includes/option-types/addable-option/static/js/scripts.js @@ -50,7 +50,7 @@ jQuery(document).ready(function ($) { var $newOption = $( $option.find('.default-addable-option-template:first').attr('data-template') - .split('###-addable-option-increment-###').join(String(increment)) + .split( $button.attr('data-increment-placeholder') ).join( String(increment) ) ); // animation diff --git a/scratch-parent/framework/includes/option-types/addable-option/view.php b/scratch-parent/framework/includes/option-types/addable-option/view.php index 51b3aead..9a097fd5 100644 --- a/scratch-parent/framework/includes/option-types/addable-option/view.php +++ b/scratch-parent/framework/includes/option-types/addable-option/view.php @@ -57,7 +57,7 @@ $values = array(); // must contain characters that will remain the same after htmlspecialchars() - $increment_template = '###-addable-option-increment-###'; + $increment_placeholder = '###-addable-option-increment-'. fw_rand_md5() .'-###'; echo fw_htmlspecialchars( ' @@ -66,7 +66,7 @@ '. fw()->backend->option_type($option['option']['type'])->render( - $increment_template, + $increment_placeholder, $option['option'], array( 'id_prefix' => $data['id_prefix'] . $id .'--option-', @@ -80,9 +80,14 @@ ' ); ?>"> -
- +
'button', + 'class' => 'button fw-option-type-addable-option-add', + 'onclick' => 'return false;', + 'data-increment' => $i, + 'data-increment-placeholder' => $increment_placeholder, + ), __('Add', 'fw')); + ?>
\ No newline at end of file diff --git a/scratch-parent/framework/includes/option-types/addable-popup/class-fw-option-type-addable-popup.php b/scratch-parent/framework/includes/option-types/addable-popup/class-fw-option-type-addable-popup.php index be3700fe..e5a69796 100644 --- a/scratch-parent/framework/includes/option-types/addable-popup/class-fw-option-type-addable-popup.php +++ b/scratch-parent/framework/includes/option-types/addable-popup/class-fw-option-type-addable-popup.php @@ -45,11 +45,11 @@ protected function _render($id, $option, $data) { unset($option['attr']['name'], $option['attr']['value']); - $option['attr']['data-for-js'] = base64_encode(json_encode(array( + $option['attr']['data-for-js'] = json_encode(array( 'title' => empty($option['popup-title']) ? $option['label'] : $option['popup-title'], 'options' => $this->transform_options($option['popup-options']), 'template' => $option['template'] - ))); + )); $sortable_image = fw_get_framework_directory_uri('/static/img/sort-vertically.png'); diff --git a/scratch-parent/framework/includes/option-types/addable-popup/static/js/addable-popup.js b/scratch-parent/framework/includes/option-types/addable-popup/static/js/addable-popup.js index 99597712..53d49abc 100644 --- a/scratch-parent/framework/includes/option-types/addable-popup/static/js/addable-popup.js +++ b/scratch-parent/framework/includes/option-types/addable-popup/static/js/addable-popup.js @@ -11,7 +11,7 @@ return $defaultItem.clone().removeClass('default'); } }, - data = JSON.parse(atob(nodes.$optionWrapper.attr('data-for-js'))), + data = JSON.parse(nodes.$optionWrapper.attr('data-for-js')), utils = { modal: new fw.OptionsModal({ title: data.title, @@ -59,7 +59,8 @@ $clonedInput = $clonedItem.find('.input-wrapper'); var $inputTemplate = $( - $.trim($clonedInput.html()).split('###-addable-popup-increment-###').join(utils.countItems()) + $.trim($clonedInput.html()) + .split( nodes.$addButton.attr('data-increment-placeholder') ).join(utils.countItems()) ); $inputTemplate.attr('value', JSON.stringify(values)); diff --git a/scratch-parent/framework/includes/option-types/addable-popup/views/view.php b/scratch-parent/framework/includes/option-types/addable-popup/views/view.php index 6bdfc3f8..1d1b28d9 100644 --- a/scratch-parent/framework/includes/option-types/addable-popup/views/view.php +++ b/scratch-parent/framework/includes/option-types/addable-popup/views/view.php @@ -8,7 +8,7 @@ $attr = $option['attr']; // must contain characters that will remain the same after htmlspecialchars() -$increment_template = '###-addable-popup-increment-###'; +$increment_placeholder = '###-addable-popup-increment-'. fw_rand_md5() .'-###'; ?>
> @@ -16,7 +16,7 @@
backend->option_type('hidden')->render('', array('value' => '[]'), array( - 'id_prefix' => $data['id_prefix'] . $id . '-' . $increment_template . '-', + 'id_prefix' => $data['id_prefix'] . $id . '-' . $increment_placeholder . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . ']', ));?>
@@ -41,6 +41,13 @@
- + 'button', + 'class' => 'button add-new-item', + 'onclick' => 'return false;', + 'data-increment-placeholder' => $increment_placeholder, + ), __('Add', 'fw')); + ?>
diff --git a/scratch-parent/framework/includes/option-types/switch/static/adaptive-switch/styles.css b/scratch-parent/framework/includes/option-types/switch/static/adaptive-switch/styles.css index f710e099..eb27ed94 100644 --- a/scratch-parent/framework/includes/option-types/switch/static/adaptive-switch/styles.css +++ b/scratch-parent/framework/includes/option-types/switch/static/adaptive-switch/styles.css @@ -13,12 +13,6 @@ overflow: hidden; height: 2em; } -.adaptive-switch, -.adaptive-switch .switch-inner { - -webkit-border-radius: 1000px; - -moz-border-radius: 1000px; - border-radius: 1000px; -} .adaptive-switch label.switch-label { display: block;; @@ -63,6 +57,7 @@ left: 0; height: 100%; width: 100%; + } .adaptive-switch .switch-dot div { width: 2em; @@ -79,10 +74,6 @@ height: 2em; width: 2em; display: inline-block; - - -webkit-border-radius: 50%; - -moz-border-radius: 50%; - border-radius: 50%; } .adaptive-switch .switch-dot, @@ -92,6 +83,19 @@ box-sizing: border-box; } +.adaptive-switch, +.adaptive-switch .switch-inner, +.adaptive-switch .switch-dot { + -webkit-border-radius: 1000px; + -moz-border-radius: 1000px; + border-radius: 1000px; +} +.adaptive-switch .switch-dot div span { + -webkit-border-radius: 50%; + -moz-border-radius: 50%; + border-radius: 50%; +} + .adaptive-switch ::-moz-selection { background: transparent; } diff --git a/scratch-parent/framework/manifest.php b/scratch-parent/framework/manifest.php index 6daad8a8..2ba310ba 100644 --- a/scratch-parent/framework/manifest.php +++ b/scratch-parent/framework/manifest.php @@ -4,6 +4,6 @@ $manifest['name'] = __('Unyson', 'fw'); -$manifest['version'] = '1.4.17'; +$manifest['version'] = '1.4.18'; $manifest['github_update'] = 'ThemeFuse/Unyson-Framework'; diff --git a/scratch-parent/framework/static/js/backend-options.js b/scratch-parent/framework/static/js/backend-options.js index ad91537a..d5de8de6 100644 --- a/scratch-parent/framework/static/js/backend-options.js +++ b/scratch-parent/framework/static/js/backend-options.js @@ -48,14 +48,9 @@ jQuery(document).ready(function($){ function hideBoxEmptyTitles($boxes) { $boxes.find('> h3.hndle > span').each(function(){ var $this = $(this); - var name = $.trim($this.text()); - if (!name.length) { + if (!$.trim($this.html()).length) { $this.closest('.postbox').addClass('fw-postbox-without-name'); - } else if (name == ' ') { - // developer tried to set   but htmlspecialchars made it as text - // make it as html - $this.html(' '); } }); }