From 679682f87a787d8ffb6a03a5294114c81ef8eb5e Mon Sep 17 00:00:00 2001 From: themefuse Date: Mon, 15 Sep 2014 23:12:07 +0300 Subject: [PATCH] Version 1.1.1 --- .../extensions/portfolio/helpers.php | 13 --- .../extensions/portfolio/hooks.php | 29 +++++ .../extensions/sidebars/config.php | 44 ++++---- .../theme/options/demo-2.php | 4 +- .../theme/options/demo.php | 4 +- .../theme/options/taxonomies/category.php | 2 +- .../widgets/social/class-fw-widget-social.php | 2 +- .../framework/core/components/backend.php | 11 ++ .../slider/class-fw-extension-slider.php | 26 ++--- .../extensions/seo/class-fw-extension-seo.php | 5 +- .../framework/extensions/sidebars/config.php | 29 +++++ .../class-fw-extension-sidebars-config.php | 4 +- .../class-fw-extension-sidebars-frontend.php | 11 +- ...ss-fw-extension-sidebars-model-sidebar.php | 5 +- scratch-parent/framework/helpers/general.php | 104 ------------------ .../framework/static/js/ie-fixes.js | 4 + 16 files changed, 126 insertions(+), 171 deletions(-) create mode 100644 scratch-parent/framework-customizations/extensions/portfolio/hooks.php create mode 100644 scratch-parent/framework/extensions/sidebars/config.php diff --git a/scratch-parent/framework-customizations/extensions/portfolio/helpers.php b/scratch-parent/framework-customizations/extensions/portfolio/helpers.php index 323a9322..2c595afa 100644 --- a/scratch-parent/framework-customizations/extensions/portfolio/helpers.php +++ b/scratch-parent/framework-customizations/extensions/portfolio/helpers.php @@ -78,16 +78,3 @@ function fw_ext_portfolio_get_sort_classes( $items, $taxonomy, $categories, $pre return $classes; } - -function _fw_ext_portfolio_theme_action_set_posts_per_page( $query ) { - if( !$query->is_main_query() ) { - return; - } - - if( isset( $query->query['post_type'] ) && $query->query['post_type'] != fw()->extensions->get('portfolio')->get_post_type_name()){ - return; - } - - $query->set( 'posts_per_page', -1 ); -} -add_action( 'pre_get_posts', '_fw_ext_portfolio_theme_action_set_posts_per_page' ); \ No newline at end of file diff --git a/scratch-parent/framework-customizations/extensions/portfolio/hooks.php b/scratch-parent/framework-customizations/extensions/portfolio/hooks.php new file mode 100644 index 00000000..8c6b5ff7 --- /dev/null +++ b/scratch-parent/framework-customizations/extensions/portfolio/hooks.php @@ -0,0 +1,29 @@ +is_main_query()) { + return; + } + + /** + * @var FW_Extension_Portfolio $portfolio + */ + $portfolio = fw()->extensions->get('portfolio'); + + $is_portfolio_taxonomy = $query->is_tax( $portfolio->get_taxonomy_name() ); + $is_portfolio_archive = $query->is_archive() + && isset( $query->query['post_type'] ) + && $query->query['post_type'] == $portfolio->get_post_type_name(); + + if ($is_portfolio_taxonomy || $is_portfolio_archive) { + $query->set( 'posts_per_page', -1 ); + } +} +add_action( 'pre_get_posts', '_fw_ext_portfolio_theme_action_set_posts_per_page' ); \ No newline at end of file diff --git a/scratch-parent/framework-customizations/extensions/sidebars/config.php b/scratch-parent/framework-customizations/extensions/sidebars/config.php index 87ccc469..91883fac 100644 --- a/scratch-parent/framework-customizations/extensions/sidebars/config.php +++ b/scratch-parent/framework-customizations/extensions/sidebars/config.php @@ -2,30 +2,28 @@ $cfg = array( 'sidebar_positions' => array( - 'full' => array( - 'icon_url' => 'full.png', - 'sidebars_number' => 0 - - ), - 'left' => array( - 'icon_url' => 'left.png', - 'sidebars_number' => 1 - - ), - 'right' => array( - 'icon_url' => 'right.png', - 'sidebars_number' => 1 - ), - 'left_right' => array( - 'icon_url' => 'left_right.png', - 'sidebars_number' => 2 - ), + 'full' => array( + 'icon_url' => 'full.png', + 'sidebars_number' => 0 + ), + 'left' => array( + 'icon_url' => 'left.png', + 'sidebars_number' => 1 + ), + 'right' => array( + 'icon_url' => 'right.png', + 'sidebars_number' => 1 + ), + 'left_right' => array( + 'icon_url' => 'left_right.png', + 'sidebars_number' => 2 + ), ), 'dynamic_sidebar_args' => array( - 'before_widget' => '', - 'before_title' => '

', - 'after_title' => '

', - ), + 'before_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + ), ); \ No newline at end of file diff --git a/scratch-parent/framework-customizations/theme/options/demo-2.php b/scratch-parent/framework-customizations/theme/options/demo-2.php index 02dfafb4..3807da33 100644 --- a/scratch-parent/framework-customizations/theme/options/demo-2.php +++ b/scratch-parent/framework-customizations/theme/options/demo-2.php @@ -34,7 +34,7 @@ 'desc' => __('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'fw'), 'help' => array( 'icon' => 'video', - 'html' => '' + 'html' => '' ), ), 'demo_wp_editor_2' => array( @@ -512,7 +512,7 @@ 'desc' => __('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'fw'), 'help' => array( 'icon' => 'video', - 'html' => '' + 'html' => '' ), ), ), diff --git a/scratch-parent/framework-customizations/theme/options/demo.php b/scratch-parent/framework-customizations/theme/options/demo.php index 2ff025a0..fd94adbd 100644 --- a/scratch-parent/framework-customizations/theme/options/demo.php +++ b/scratch-parent/framework-customizations/theme/options/demo.php @@ -34,7 +34,7 @@ 'desc' => __('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'fw'), 'help' => array( 'icon' => 'video', - 'html' => '' + 'html' => '' ), ), 'demo_wp_editor' => array( @@ -511,7 +511,7 @@ 'desc' => __('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'fw'), 'help' => array( 'icon' => 'video', - 'html' => '' + 'html' => '' ), ), ), diff --git a/scratch-parent/framework-customizations/theme/options/taxonomies/category.php b/scratch-parent/framework-customizations/theme/options/taxonomies/category.php index 2c8848f4..2c3cebb0 100644 --- a/scratch-parent/framework-customizations/theme/options/taxonomies/category.php +++ b/scratch-parent/framework-customizations/theme/options/taxonomies/category.php @@ -34,7 +34,7 @@ 'desc' => __('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'fw'), 'help' => array( 'icon' => 'video', - 'html' => '' + 'html' => '' ), ), 'demo_wp_editor' => array( diff --git a/scratch-parent/framework-customizations/theme/widgets/social/class-fw-widget-social.php b/scratch-parent/framework-customizations/theme/widgets/social/class-fw-widget-social.php index eb7ee275..3f1582fa 100644 --- a/scratch-parent/framework-customizations/theme/widgets/social/class-fw-widget-social.php +++ b/scratch-parent/framework-customizations/theme/widgets/social/class-fw-widget-social.php @@ -57,7 +57,7 @@ function form( $instance ) { foreach ( $instance as $key => $value ) { ?>

- + diff --git a/scratch-parent/framework/core/components/backend.php b/scratch-parent/framework/core/components/backend.php index 6c1a908c..434cbf8e 100644 --- a/scratch-parent/framework/core/components/backend.php +++ b/scratch-parent/framework/core/components/backend.php @@ -164,6 +164,16 @@ private function register_static() return; } + /** + * Register styles/scripts only in admin area, on frontend it's not allowed to use styles/scripts from framework backend core + * because they are meant to be used only in backend and can be changed in the future. + * If you want to use a style/script from framework backend core, copy it to your theme and enqueue as a theme style/script. + */ + if (!is_admin()) { + $this->static_registered = true; + return; + } + wp_register_script( 'fw-events', FW_URI .'/static/js/fw-events.js', @@ -171,6 +181,7 @@ private function register_static() fw()->manifest->get_version(), true ); + wp_register_script( 'fw-ie-fixes', FW_URI .'/static/js/ie-fixes.js', diff --git a/scratch-parent/framework/extensions/media/extensions/slider/class-fw-extension-slider.php b/scratch-parent/framework/extensions/media/extensions/slider/class-fw-extension-slider.php index 3a30b05d..f578b539 100644 --- a/scratch-parent/framework/extensions/media/extensions/slider/class-fw-extension-slider.php +++ b/scratch-parent/framework/extensions/media/extensions/slider/class-fw-extension-slider.php @@ -169,16 +169,16 @@ function _admin_filter_change_updated_messages($messages) $messages[$post_type] = array( 0 => '', // Unused. Messages start at index 1. - 1 => sprintf(__($singular . ' updated. View ' . strtolower($singular) . ''), esc_url(get_permalink($post->ID))), - 2 => __('Custom field updated.'), - 3 => __('Custom field deleted.'), - 4 => __($singular . ' updated.'), - 5 => isset($_GET['revision']) ? sprintf(__($singular . ' restored to revision from %s'), wp_post_revision_title((int)$_GET['revision'], false)) : false, - 6 => sprintf(__($singular . ' published. View ' . strtolower($singular) . ''), esc_url(get_permalink($post->ID))), - 7 => __('Page saved.'), - 8 => sprintf(__($singular . ' submitted. Preview ' . strtolower($singular) . ''), esc_url(add_query_arg('preview', 'true', get_permalink($post->ID)))), - 9 => sprintf(__($singular . ' scheduled for: %1$s. Preview ' . strtolower($singular) . ''), date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)), esc_url(get_permalink($post->ID))), - 10 => sprintf(__($singular . ' draft updated. Preview ' . strtolower($singular) . ''), esc_url(add_query_arg('preview', 'true', get_permalink($post->ID)))), + 1 => sprintf(__('%s updated. View %s', 'fw'), $singular, esc_url(get_permalink($post->ID)), strtolower($singular)), + 2 => __('Custom field updated.', 'fw'), + 3 => __('Custom field deleted.', 'fw'), + 4 => sprintf(__('%s updated.', 'fw'), $singular), + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'fw'), $singular, wp_post_revision_title((int)$_GET['revision'], false)) : false, + 6 => sprintf(__('%s published. View %s'), $singular, esc_url(get_permalink($post->ID)), strtolower($singular)), + 7 => __('Page saved.', 'fw'), + 8 => sprintf(__('%s submitted. Preview %s'), $singular, esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))), strtolower($singular)), + 9 => sprintf(__('%s scheduled for: %1$s. Preview %s'), $singular, date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)), esc_url(get_permalink($post->ID)), strtolower($singular)), + 10 => sprintf(__('%s draft updated. Preview %s'), $singular, esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))), strtolower($singular)), ); } @@ -257,7 +257,7 @@ public function load_post_edit_options() array( 'slider-sidebar-metabox' => array( 'context' => 'side', - 'title' => __(ucfirst($this->get_name()) . ' Configuration', 'fw'), + 'title' => __('Slider Configuration', 'fw'), 'type' => 'box', 'options' => array( 'populated' => array( @@ -266,7 +266,7 @@ public function load_post_edit_options() ), 'title' => array( 'type' => 'text', - 'label' => __(ucfirst($this->get_name()) . ' Title', 'fw'), + 'label' => __('Slider Title', 'fw'), 'value' => $title_value, 'desc' => 'Choose a title for your slider only for internal use: Ex: "Homepage".' ) @@ -319,7 +319,7 @@ public function load_post_new_options() { return array( 'general' => array( - 'title' => __(ucfirst($this->get_name()) . ' Settings', 'fw'), + 'title' => __('Slider Settings', 'fw'), 'type' => 'box', 'options' => array( $this->get_name() => array( diff --git a/scratch-parent/framework/extensions/seo/class-fw-extension-seo.php b/scratch-parent/framework/extensions/seo/class-fw-extension-seo.php index 7f9c829c..be4b395c 100644 --- a/scratch-parent/framework/extensions/seo/class-fw-extension-seo.php +++ b/scratch-parent/framework/extensions/seo/class-fw-extension-seo.php @@ -46,11 +46,12 @@ public function _init() { * @internal */ public function _admin_action_add_settings_menu() { - add_options_page( + add_theme_page( $this->name, __( 'Search Engines', 'fw' ), 'manage_options', $this->get_name() . '-settings', - array( $this, 'get_settings_page' ) ); + array( $this, 'get_settings_page' ) + ); } public function _admin_action_add_static() { diff --git a/scratch-parent/framework/extensions/sidebars/config.php b/scratch-parent/framework/extensions/sidebars/config.php new file mode 100644 index 00000000..91883fac --- /dev/null +++ b/scratch-parent/framework/extensions/sidebars/config.php @@ -0,0 +1,29 @@ + array( + 'full' => array( + 'icon_url' => 'full.png', + 'sidebars_number' => 0 + ), + 'left' => array( + 'icon_url' => 'left.png', + 'sidebars_number' => 1 + ), + 'right' => array( + 'icon_url' => 'right.png', + 'sidebars_number' => 1 + ), + 'left_right' => array( + 'icon_url' => 'left_right.png', + 'sidebars_number' => 2 + ), + ), + + 'dynamic_sidebar_args' => array( + 'before_widget' => '

', + 'before_title' => '

', + 'after_title' => '

', + ), +); \ No newline at end of file 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 9cbec253..fc49bdbb 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 @@ -302,13 +302,13 @@ public function get_label_grouped($type, $sub_type) } /** - * Retrive info about registered post_types or taxonomies + * Retrieve info about registered post_types or taxonomies */ protected function get_name_from_db($slug, $type_key, $is_singular) { $result = $slug; $get_object = ($type_key === self::POST_TYPES_PREFIX ? 'get_post_type_object' : 'get_taxonomy' ); - $obj = $get_object($slug); + $obj = call_user_func_array($get_object, array($slug)); if($obj) { if($is_singular) { //singular name 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 328507e3..47409700 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 @@ -68,10 +68,11 @@ public function render_sidebar($color) } /** - * Generate current page requirements and return array with avaible sidebars for current page + * Generate current page requirements and return array with available sidebars for current page */ - public function get_current_page_preset(){ - //check if current_page_preset doesn't get before + 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; } @@ -125,7 +126,7 @@ public function get_current_page_preset(){ foreach($conditional_tags as $key => $cond_tag) { - $function = null; + $function = null; if (isset($cond_tag['conditional_tag'])) { $function = isset($cond_tag['conditional_tag']['callback']) ? $cond_tag['conditional_tag']['callback'] : ''; @@ -150,7 +151,7 @@ public function get_current_page_preset(){ } else { $function = $key; if (is_callable($function)) { - if ($function()){ + if (call_user_func($function)){ $data['type'] = $this->config->get_type_by_prefix(_FW_Extension_Sidebars_Config::CONDITIONAL_TAGS_PREFIX); $data['sub_type'] = $key; diff --git a/scratch-parent/framework/extensions/sidebars/includes/model/class-fw-extension-sidebars-model-sidebar.php b/scratch-parent/framework/extensions/sidebars/includes/model/class-fw-extension-sidebars-model-sidebar.php index 8f4d7a4e..81c1dba2 100644 --- a/scratch-parent/framework/extensions/sidebars/includes/model/class-fw-extension-sidebars-model-sidebar.php +++ b/scratch-parent/framework/extensions/sidebars/includes/model/class-fw-extension-sidebars-model-sidebar.php @@ -26,9 +26,8 @@ public function __construct($sidebar) foreach ($sidebar as $key => $value) { $method = 'set_' . $key; - if(method_exists($this, $method)) - { - $this->$method($value); + if(method_exists($this, $method)) { + call_user_func_array(array($this, $method), array($value)); } } diff --git a/scratch-parent/framework/helpers/general.php b/scratch-parent/framework/helpers/general.php index e1585f02..b1b34c56 100644 --- a/scratch-parent/framework/helpers/general.php +++ b/scratch-parent/framework/helpers/general.php @@ -950,107 +950,3 @@ function fw_oembed_get($url, $args = array()) { return $html; } - -/** - * Try everything to create and make a path (file or directory) writable - * Works only within /wp-content dir, cannot make writable something outside it - * @param string $path - * @return bool - * @deprecated It's not safe to make files writable or create files as php user. Use http://codex.wordpress.org/Filesystem_API - */ -function fw_try_make_writable($path) { - static $root_dir = null; - - if ($root_dir === null) { - $root_dir = fw_fix_path(WP_CONTENT_DIR); - } - - $chmod_writable_dir = 0777; - $chmod_writable_file = 0666; - - do { - if (is_writable($path)) - return true; - - $path = fw_fix_path($path); - - // Extract relative path: '/root/dir' . $relPath - { - $rel_path = explode($root_dir, $path); - - if (!empty($rel_path[0])) - break; // is not located in root dir - - array_shift($rel_path); // remove first empty element - - $rel_path = implode($root_dir, $rel_path); - } - - $rel_path_arr = explode('/', $rel_path); - array_shift($rel_path_arr); // remove first empty element - - if (empty($rel_path_arr)) - break; - - $file_name = ''; - if (!is_dir($path)) { - if (file_exists($path)) { - // file exists, we can only try to make it writable - if (@chmod($path, $chmod_writable_file)) { - true; - } else { - break; - } - } - - $file_name = array_pop($rel_path_arr); - } - - if (!empty($rel_path_arr)) { - // check if parent directories exists, if not, create and make writable - - $dir_path = $root_dir .'/'. implode('/', $rel_path_arr); - - if (!file_exists($dir_path)) { - $created = @mkdir( - $dir_path, - $chmod_writable_dir, - true - ); - - if (!$created) { - break; - } - } - - if (!is_writable($dir_path)) { - if (@chmod($dir_path, $chmod_writable_dir)) { - true; - } else { - break; - } - } - } - - if ($file_name) { - // file not exists, need to create - if (false === file_put_contents($path, '')) { - break; - } - - if (is_writable($path)) { - return true; - } - - if (@chmod($path, $chmod_writable_file)) { - true; - } else { - break; - } - } - - return true; - } while(false); - - return false; -} diff --git a/scratch-parent/framework/static/js/ie-fixes.js b/scratch-parent/framework/static/js/ie-fixes.js index 9fb01138..1408b175 100644 --- a/scratch-parent/framework/static/js/ie-fixes.js +++ b/scratch-parent/framework/static/js/ie-fixes.js @@ -1,3 +1,7 @@ +/** + * IE fixes for jQuery plugins to not throw errors + */ + if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (searchElement, fromIndex) { if ( this === undefined || this === null ) {