From 7cc806dcf71394f0ce91160f83f3df68775c25f5 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Fri, 26 Feb 2016 10:59:39 +0200 Subject: [PATCH 01/30] Improved comment form fields to listen to previously set filters. --- lib/templates/fragments/comments.php | 138 +++++++++++++++------------ 1 file changed, 75 insertions(+), 63 deletions(-) diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index dfe4f5bc..4e0260ea 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -482,95 +482,107 @@ function beans_comment_form_fields( $fields ) { $commenter = wp_get_current_commenter(); // Author. - $author = beans_open_markup( 'beans_comment_form[_name]', 'div', array( 'class' => 'uk-width-medium-1-3' ) ); + if ( isset( $fields['author'] ) ) { - /** - * Filter whether the comment form name legend should load or not. - * - * @since 1.0.0 - */ - if ( beans_apply_filters( 'beans_comment_form_legend[_name]', true ) ) { + $author = beans_open_markup( 'beans_comment_form[_name]', 'div', array( 'class' => "uk-width-medium-1-3" ) ); - $author .= beans_open_markup( 'beans_comment_form_legend[_name]', 'legend' ); + /** + * Filter whether the comment form name legend should load or not. + * + * @since 1.0.0 + */ + if ( beans_apply_filters( 'beans_comment_form_legend[_name]', true ) ) { - $author .= beans_output( 'beans_comment_form_legend_text[_name]', __( 'Name', 'tm-beans' ) ); + $author .= beans_open_markup( 'beans_comment_form_legend[_name]', 'legend' ); - $author .= beans_close_markup( 'beans_comment_form_legend[_name]', 'legend' ); + $author .= beans_output( 'beans_comment_form_legend_text[_name]', __( 'Name', 'tm-beans' ) ); - } + $author .= beans_close_markup( 'beans_comment_form_legend[_name]', 'legend' ); - $author .= beans_selfclose_markup( 'beans_comment_form_field[_name]', 'input', array( - 'id' => 'author', - 'class' => 'uk-width-1-1', - 'type' => 'text', - 'value' => esc_attr( $commenter['comment_author'] ), - 'name' => 'author' - ) ); + } + + $author .= beans_selfclose_markup( 'beans_comment_form_field[_name]', 'input', array( + 'id' => 'author', + 'class' => 'uk-width-1-1', + 'type' => 'text', + 'value' => $commenter['comment_author'], // Automatically escaped. + 'name' => 'author' + ) ); - $author .= beans_close_markup( 'beans_comment_form[_name]', 'div' ); + $author .= beans_close_markup( 'beans_comment_form[_name]', 'div' ); + + $fields['author'] = $author; + + } // Email. - $email = beans_open_markup( 'beans_comment_form[_email]', 'div', array( 'class' => 'uk-width-medium-1-3' ) ); + if ( isset( $fields['email'] ) ) { - /** - * Filter whether the comment form email legend should load or not. - * - * @since 1.0.0 - */ - if ( beans_apply_filters( 'beans_comment_form_legend[_email]', true ) ) { + $email = beans_open_markup( 'beans_comment_form[_email]', 'div', array( 'class' => "uk-width-medium-1-3" ) ); - $email .= beans_open_markup( 'beans_comment_form_legend[_email]', 'legend' ); + /** + * Filter whether the comment form email legend should load or not. + * + * @since 1.0.0 + */ + if ( beans_apply_filters( 'beans_comment_form_legend[_email]', true ) ) { - $email .= beans_output( 'beans_comment_form_legend_text[_email]', sprintf( __( 'Email %s', 'tm-beans' ), ( get_option( 'require_name_email' ) ? ' *' : '' ) ) ); + $email .= beans_open_markup( 'beans_comment_form_legend[_email]', 'legend' ); - $email .= beans_close_markup( 'beans_comment_form_legend[_email]', 'legend' ); + $email .= beans_output( 'beans_comment_form_legend_text[_email]', sprintf( __( 'Email %s', 'tm-beans' ), ( get_option( 'require_name_email' ) ? ' *' : '' ) ) ); - } + $email .= beans_close_markup( 'beans_comment_form_legend[_email]', 'legend' ); - $email .= beans_selfclose_markup( 'beans_comment_form_field[_email]', 'input', array( - 'id' => 'email', - 'class' => 'uk-width-1-1', - 'type' => 'text', - 'value' => esc_attr( $commenter['comment_author_email'] ), - 'name' => 'email', - 'required' => get_option( 'require_name_email' ) ? '' : null - ) ); + } + + $email .= beans_selfclose_markup( 'beans_comment_form_field[_email]', 'input', array( + 'id' => 'email', + 'class' => 'uk-width-1-1', + 'type' => 'text', + 'value' => $commenter['comment_author_email'], // Automatically escaped. + 'name' => 'email', + 'required' => get_option( 'require_name_email' ) ? '' : null + ) ); - $email .= beans_close_markup( 'beans_comment_form[_email]', 'div' ); + $email .= beans_close_markup( 'beans_comment_form[_email]', 'div' ); + + $fields['email'] = $email; + + } // Url. - $url = beans_open_markup( 'beans_comment_form[_website]', 'div', array( 'class' => 'uk-width-medium-1-3' ) ); + if ( isset( $fields['url'] ) ) { - /** - * Filter whether the comment form url legend should load or not. - * - * @since 1.0.0 - */ - if ( beans_apply_filters( 'beans_comment_form_legend[_url]', true ) ) { + $url = beans_open_markup( 'beans_comment_form[_website]', 'div', array( 'class' => "uk-width-medium-1-3" ) ); - $url .= beans_open_markup( 'beans_comment_form_legend', 'legend' ); + /** + * Filter whether the comment form url legend should load or not. + * + * @since 1.0.0 + */ + if ( beans_apply_filters( 'beans_comment_form_legend[_url]', true ) ) { - $url .= beans_output( 'beans_comment_form_legend_text[_url]', __( 'Website', 'tm-beans' ) ); + $url .= beans_open_markup( 'beans_comment_form_legend', 'legend' ); - $url .= beans_close_markup( 'beans_comment_form_legend[_url]', 'legend' ); + $url .= beans_output( 'beans_comment_form_legend_text[_url]', __( 'Website', 'tm-beans' ) ); - } + $url .= beans_close_markup( 'beans_comment_form_legend[_url]', 'legend' ); - $url .= beans_selfclose_markup( 'beans_comment_form_field[_url]', 'input', array( - 'id' => 'url', - 'class' => 'uk-width-1-1', - 'type' => 'text', - 'value' => esc_attr( $commenter['comment_author_url'] ), - 'name' => 'url' - ) ); + } - $url .= beans_close_markup( 'beans_comment_form[_website]', 'div' ); + $url .= beans_selfclose_markup( 'beans_comment_form_field[_url]', 'input', array( + 'id' => 'url', + 'class' => 'uk-width-1-1', + 'type' => 'text', + 'value' => $commenter['comment_author_url'], // Automatically escaped. + 'name' => 'url' + ) ); + + $url .= beans_close_markup( 'beans_comment_form[_website]', 'div' ); - $fields = array( - 'author' => $author, - 'email' => $email, - 'url' => $url - ); + $fields['url'] = $url; + + } return $fields; } From 4009e57d4abf81f8b4a1fd2769cb955296529273 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Fri, 26 Feb 2016 11:01:08 +0200 Subject: [PATCH 02/30] Added comment form fields dynamic grid columns. --- lib/templates/fragments/comments.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index 4e0260ea..8519f2ac 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -480,11 +480,12 @@ function beans_comment_before_fields() { function beans_comment_form_fields( $fields ) { $commenter = wp_get_current_commenter(); + $grid = count( (array) $fields ); // Author. if ( isset( $fields['author'] ) ) { - $author = beans_open_markup( 'beans_comment_form[_name]', 'div', array( 'class' => "uk-width-medium-1-3" ) ); + $author = beans_open_markup( 'beans_comment_form[_name]', 'div', array( 'class' => "uk-width-medium-1-$grid" ) ); /** * Filter whether the comment form name legend should load or not. @@ -518,7 +519,7 @@ function beans_comment_form_fields( $fields ) { // Email. if ( isset( $fields['email'] ) ) { - $email = beans_open_markup( 'beans_comment_form[_email]', 'div', array( 'class' => "uk-width-medium-1-3" ) ); + $email = beans_open_markup( 'beans_comment_form[_email]', 'div', array( 'class' => "uk-width-medium-1-$grid" ) ); /** * Filter whether the comment form email legend should load or not. @@ -553,7 +554,7 @@ function beans_comment_form_fields( $fields ) { // Url. if ( isset( $fields['url'] ) ) { - $url = beans_open_markup( 'beans_comment_form[_website]', 'div', array( 'class' => "uk-width-medium-1-3" ) ); + $url = beans_open_markup( 'beans_comment_form[_website]', 'div', array( 'class' => "uk-width-medium-1-$grid" ) ); /** * Filter whether the comment form url legend should load or not. From 3b0abe6da1f7887797cbff0c6376e3b6ecc37459 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Mon, 29 Feb 2016 09:10:24 +0200 Subject: [PATCH 03/30] Fixed post meta conditions string support. --- lib/api/post-meta/functions-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/post-meta/functions-admin.php b/lib/api/post-meta/functions-admin.php index 146db0cd..0926d196 100644 --- a/lib/api/post-meta/functions-admin.php +++ b/lib/api/post-meta/functions-admin.php @@ -52,7 +52,7 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = $fields = apply_filters( "beans_post_meta_fields_{$section}", _beans_pre_standardize_fields( $fields ) ); $conditions = apply_filters( "beans_post_meta_post_types_{$section}", $conditions ); - $_beans_post_meta_conditions = array_merge( $_beans_post_meta_conditions, $conditions ); + $_beans_post_meta_conditions = array_merge( $_beans_post_meta_conditions, (array) $conditions ); // Stop here if the current page isn't concerned. if ( !_beans_is_post_meta_conditions( $conditions ) || !is_admin() ) From cb8e62e2524987c758c7ee4ad6f5f37fbae17f28 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Tue, 1 Mar 2016 07:58:00 +0200 Subject: [PATCH 04/30] Removed no comment notice when closed and empty. --- lib/render/template-parts.php | 2 +- lib/templates/structure/comments.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/render/template-parts.php b/lib/render/template-parts.php index 63b4b0cd..cf340150 100644 --- a/lib/render/template-parts.php +++ b/lib/render/template-parts.php @@ -111,7 +111,7 @@ function beans_comments_template() { global $post; - if ( !post_type_supports( beans_get( 'post_type', $post ), 'comments' ) ) + if ( !( comments_open() || get_comments_number() ) || !post_type_supports( beans_get( 'post_type', $post ), 'comments' ) ) return; comments_template(); diff --git a/lib/templates/structure/comments.php b/lib/templates/structure/comments.php index ebce2856..8fcd83a5 100644 --- a/lib/templates/structure/comments.php +++ b/lib/templates/structure/comments.php @@ -13,7 +13,7 @@ echo beans_open_markup( 'beans_comments', 'div', array( 'id' => 'comments', 'class' => 'tm-comments' . ( current_theme_supports( 'beans-default-styling' ) ? ' uk-panel-box' : null ) ) ); - if ( comments_open( get_the_ID() ) ) : + if ( comments_open() || get_comments_number() ) : if ( have_comments() ) : @@ -48,7 +48,9 @@ */ do_action( 'beans_after_open_comments' ); - else : + endif; + + if ( !comments_open() ) : /** * Fires if comments are closed. From 35ec6cc74916637caac0c49ce1caf7e1691831f5 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Wed, 2 Mar 2016 07:57:59 +0200 Subject: [PATCH 05/30] Fixed post meta not displaying on new posts. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issue only occurred on the ‘post’ post type. --- lib/api/post-meta/functions-admin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/api/post-meta/functions-admin.php b/lib/api/post-meta/functions-admin.php index 0926d196..4bdd0e10 100644 --- a/lib/api/post-meta/functions-admin.php +++ b/lib/api/post-meta/functions-admin.php @@ -81,7 +81,10 @@ function _beans_is_post_meta_conditions( $conditions ) { if ( stripos( $_SERVER['REQUEST_URI'], 'post-new.php' ) !== false ) { if ( !$current_post_type = beans_get( 'post_type' ) ) - return false; + if ( in_array( 'post', (array) $conditions ) ) + return true; + else + return false; } else { From a8976b1f3bddaabe7b64ec44d9db8ff577d30805 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Wed, 2 Mar 2016 15:41:22 +0200 Subject: [PATCH 06/30] Removed commented out code in lessc.php library. --- lib/api/compiler/vendors/lessc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/api/compiler/vendors/lessc.php b/lib/api/compiler/vendors/lessc.php index 3db95e08..68ee6fd7 100644 --- a/lib/api/compiler/vendors/lessc.php +++ b/lib/api/compiler/vendors/lessc.php @@ -687,7 +687,6 @@ protected function compileProp($prop, $block, $out) { $mixins = $this->findBlocks($block, $path, $orderedArgs, $keywordArgs); if ($mixins === null) { - // fwrite(STDERR,"failed to find block: ".implode(" > ", $path)."\n"); break; // throw error here?? } From e9fd6302322c3ad4adfbf7d5b5f16cba9f171f8d Mon Sep 17 00:00:00 2001 From: ThierryA Date: Wed, 2 Mar 2016 15:46:16 +0200 Subject: [PATCH 07/30] Fixed incorrect text-domain. --- lib/api/compiler/class-compiler.php | 12 ++++++------ lib/templates/fragments/footer.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-compiler.php index 7748a0aa..c5bb90aa 100644 --- a/lib/api/compiler/class-compiler.php +++ b/lib/api/compiler/class-compiler.php @@ -565,23 +565,23 @@ public function kill() { $html = beans_output( 'beans_compiler_error_title_text', sprintf( '

%s

', - __( 'Not cool, Beans cannot work its magic :(', 'beans' ) + __( 'Not cool, Beans cannot work its magic :(', 'tm-beans' ) ) ); $html .= beans_output( 'beans_compiler_error_message_text', sprintf( '

%s

', - __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support, we will gladly get you started within 24 - 48 hours (working days).', 'beans' ) + __( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support, we will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' ) ) ); $html .= beans_output( 'beans_compiler_error_contact_text', sprintf( '%s', - __( 'Contact Beans Support', 'beans' ) + __( 'Contact Beans Support', 'tm-beans' ) ) ); $html .= beans_output( 'beans_compiler_error_report_text', sprintf( '

%1$s. %2$s

', - __( 'Send us an automatic report', 'beans' ), - __( 'We respect your time and understand you might not be able to contact us.', 'beans' ) + __( 'Send us an automatic report', 'tm-beans' ), + __( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' ) ) ); wp_die( $html ); @@ -611,7 +611,7 @@ public function report() { // Die and display message. wp_die( beans_output( 'beans_compiler_report_error_text', sprintf( '

%s

', - __( 'Thanks for your contribution by reporting this issue. We hope to hear from you again.', 'beans' ) + __( 'Thanks for your contribution by reporting this issue. We hope to hear from you again.', 'tm-beans' ) ) ) ); } diff --git a/lib/templates/fragments/footer.php b/lib/templates/fragments/footer.php index b68f6f9e..95d25f49 100644 --- a/lib/templates/fragments/footer.php +++ b/lib/templates/fragments/footer.php @@ -33,7 +33,7 @@ function beans_footer_content() { 'rel' => 'designer' ) ); - $framework_link .= beans_output( 'beans_footer_credit_framework_link_text', 'Beans' ); + $framework_link .= beans_output( 'beans_footer_credit_framework_link_text', 'tm-beans' ); $framework_link .= beans_close_markup( 'beans_footer_credit_framework_link', 'a' ); From 99d5a09ba36225354e97e9e8d1cbe9185ef2f9b2 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 5 Mar 2016 18:37:41 +0200 Subject: [PATCH 08/30] Fixed global assets compiling enqueued flag. --- lib/api/compiler/class-page-compiler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/compiler/class-page-compiler.php b/lib/api/compiler/class-page-compiler.php index f92ebbd5..13179861 100644 --- a/lib/api/compiler/class-page-compiler.php +++ b/lib/api/compiler/class-page-compiler.php @@ -96,7 +96,7 @@ private function compile_enqueued( $type, $depedencies = false ) { if ( $args->args != 'all' ) $args->src = add_query_arg( array( 'beans_compiler_media_query' => $args->args ), $args->src ); - wp_dequeue_style( $id ); + $$set_global->done[] = $id; } elseif ( $type == 'script' ) { @@ -135,7 +135,7 @@ public function dequeue_scripts() { if ( isset( $args->extra['data'] ) ) $localized .= $args->extra['data'] . "\n"; - wp_dequeue_script( $id ); + $wp_scripts->done[] = $id; } From c5e3aea699de3204883a2fb1b76fdd043d79274c Mon Sep 17 00:00:00 2001 From: ThierryA Date: Fri, 11 Mar 2016 07:48:14 +0200 Subject: [PATCH 09/30] Added beans_reset_markup and beans_reset_attributes functions. --- lib/api/html/functions.php | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index c9027982..09f4c9c8 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -268,6 +268,29 @@ function beans_remove_markup( $id, $remove_actions = false ) { } +/** + * Reset markup. + * + * This function will automatically reset the opening and the closing HTML tag to its original value. If the markup is self-closed, + * the HTML tag will be reset accordingly. + * + * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very + * easy to find the content ID when inspecting an element in a web browser. + * + * @since next release + * + * @param string $id The markup ID. + * + * @return bool Will always return true. + */ +function beans_reset_markup( $id ) { + + remove_all_filters( $id . '_markup' ); + remove_all_filters( preg_replace( '#(\[|\])#', '', $id ) . '_markup' ); + +} + + /** * Wrap markup. * @@ -380,6 +403,29 @@ function beans_add_attributes( $id, $attributes = array() ) { } +/** + * Reset markup attributes. + * + * This function will reset the targeted markup attributes to their original values. It must be called before + * the targeted markup is called. + * + * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very + * easy to find the content ID when inspecting an element in a web browser. + * + * @since next release + * + * @param string $id The markup ID. + * + * @return bool Will always return true. + */ +function beans_reset_attributes( $id ) { + + remove_all_filters( $id . '_attributes' ); + remove_all_filters( preg_replace( '#(\[|\])#', '', $id ) . '_attributes' ); + +} + + /** * Add attribute to markup. * From 0a3698989b35a7902b5b0a16f3e733cd81cf3177 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sun, 13 Mar 2016 14:42:42 +0200 Subject: [PATCH 10/30] Fixed off-canvas navigation spacing. --- lib/assets/less/uikit-overwrite/panel.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/assets/less/uikit-overwrite/panel.less b/lib/assets/less/uikit-overwrite/panel.less index c112cd1b..749f502d 100644 --- a/lib/assets/less/uikit-overwrite/panel.less +++ b/lib/assets/less/uikit-overwrite/panel.less @@ -13,5 +13,5 @@ } .uk-panel .uk-nav-offcanvas { - margin: 0 -@panel-box-padding; + margin: 0 -15px; } \ No newline at end of file From e3c76ab1572e0236cc7bd1f927416e292724b97c Mon Sep 17 00:00:00 2001 From: ThierryA Date: Mon, 14 Mar 2016 09:04:26 +0200 Subject: [PATCH 11/30] Fixed comment fields responsive grid spacing. --- lib/templates/fragments/comments.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index 8519f2ac..af0bd303 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -458,7 +458,10 @@ function beans_comment_before_fields() { echo beans_open_markup( 'beans_comment_fields_wrap', 'div', array( 'class' => 'uk-width-medium-1-1' ) ); - echo beans_open_markup( 'beans_comment_fields_inner_wrap', 'div', array( 'class' => 'uk-grid' ) ); + echo beans_open_markup( 'beans_comment_fields_inner_wrap', 'div', array( + 'class' => 'uk-grid uk-grid-small', + 'data-uk-grid-margin' => '' + ) ); } From f96e916384bead66f7945cf432ae0615a9aa6092 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Fri, 25 Mar 2016 09:11:46 +0200 Subject: [PATCH 12/30] Removed post loop query unnecessary if statement. --- lib/render/template-parts.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/render/template-parts.php b/lib/render/template-parts.php index cf340150..65f1ddc0 100644 --- a/lib/render/template-parts.php +++ b/lib/render/template-parts.php @@ -73,7 +73,7 @@ function beans_loop_template( $id = false ) { $id = 'main'; // Only run new query if a filter is set. - if ( $_has_filter = beans_has_filters( "beans_loop_query_args[_{$id}]" ) ) : + if ( $_has_filter = beans_has_filters( "beans_loop_query_args[_{$id}]" ) ) { global $wp_query; @@ -82,10 +82,10 @@ function beans_loop_template( $id = false ) { * * @since 1.0.0 */ - if ( $args = beans_apply_filters( "beans_loop_query_args[_{$id}]", false ) ) - $wp_query = new WP_Query( $args ); + $args = beans_apply_filters( "beans_loop_query_args[_{$id}]", false ); + $wp_query = new WP_Query( $args ); - endif; + } // Allow overwrite. Require the default loop.php if not overwrite is found. if ( locate_template( 'loop.php', true, false ) == '' ) From 137558705b723d08cdf67fc8dae60de140716f06 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Fri, 25 Mar 2016 09:27:27 +0200 Subject: [PATCH 13/30] Fixed beans_sanatize_attributes function typo mistake (backwards compatibility applies) --- lib/api/fields/types/activation.php | 2 +- lib/api/fields/types/checkbox.php | 2 +- lib/api/fields/types/image.php | 2 +- lib/api/fields/types/radio.php | 2 +- lib/api/fields/types/select.php | 2 +- lib/api/fields/types/slider.php | 2 +- lib/api/fields/types/text.php | 2 +- lib/api/fields/types/textarea.php | 2 +- lib/api/html/functions.php | 2 +- lib/api/init.php | 1 + lib/api/utilities/deprecated.php | 28 ++++++++++++++++++++++++++++ lib/api/utilities/functions.php | 6 +++--- 12 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 lib/api/utilities/deprecated.php diff --git a/lib/api/fields/types/activation.php b/lib/api/fields/types/activation.php index 18d1277b..b0b4470a 100644 --- a/lib/api/fields/types/activation.php +++ b/lib/api/fields/types/activation.php @@ -28,6 +28,6 @@ function beans_field_activation( $field ) { echo ''; - echo ''; + echo ''; } \ No newline at end of file diff --git a/lib/api/fields/types/checkbox.php b/lib/api/fields/types/checkbox.php index 29d113d9..c3b69dc2 100644 --- a/lib/api/fields/types/checkbox.php +++ b/lib/api/fields/types/checkbox.php @@ -27,7 +27,7 @@ function beans_field_checkbox( $field ) { echo ''; - echo ''; + echo ''; if ( $checkbox_label = beans_get( 'checkbox_label', $field, 'Enable' ) ) echo '' . $checkbox_label . ''; diff --git a/lib/api/fields/types/image.php b/lib/api/fields/types/image.php index 29906aae..c7532801 100644 --- a/lib/api/fields/types/image.php +++ b/lib/api/fields/types/image.php @@ -82,7 +82,7 @@ function beans_field_image( $field ) { echo '

'; - echo ''; + echo ''; echo ''; diff --git a/lib/api/fields/types/radio.php b/lib/api/fields/types/radio.php index 6e8d7bf8..e52bca0b 100644 --- a/lib/api/fields/types/radio.php +++ b/lib/api/fields/types/radio.php @@ -42,7 +42,7 @@ function beans_field_radio( $field ) { if ( $has_image ) echo ''; - echo ''; + echo ''; if ( !$has_image ) echo $radio; diff --git a/lib/api/fields/types/select.php b/lib/api/fields/types/select.php index 19b29bf7..6f574fd6 100644 --- a/lib/api/fields/types/select.php +++ b/lib/api/fields/types/select.php @@ -27,7 +27,7 @@ function beans_field_select( $field ) { if ( empty( $field['options'] ) ) return; - echo ''; foreach ( $field['options'] as $value => $label ) { diff --git a/lib/api/fields/types/slider.php b/lib/api/fields/types/slider.php index f285f437..92d44f87 100644 --- a/lib/api/fields/types/slider.php +++ b/lib/api/fields/types/slider.php @@ -52,7 +52,7 @@ function beans_field_slider( $field ) { echo '
'; // Don't make this a hidden field to prevent triggering issues with wp_customise. - echo ''; + echo ''; echo '
'; diff --git a/lib/api/fields/types/text.php b/lib/api/fields/types/text.php index cbdb679d..af90244a 100644 --- a/lib/api/fields/types/text.php +++ b/lib/api/fields/types/text.php @@ -22,6 +22,6 @@ */ function beans_field_text( $field ) { - echo ''; + echo ''; } \ No newline at end of file diff --git a/lib/api/fields/types/textarea.php b/lib/api/fields/types/textarea.php index 9d1ab3f8..01a2be5d 100644 --- a/lib/api/fields/types/textarea.php +++ b/lib/api/fields/types/textarea.php @@ -22,6 +22,6 @@ */ function beans_field_textarea( $field ) { - echo ''; + echo ''; } \ No newline at end of file diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 09f4c9c8..65c237f9 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -398,7 +398,7 @@ function beans_add_attributes( $id, $attributes = array() ) { $attributes = call_user_func_array( 'beans_apply_filters', $args ); - return beans_sanatize_attributes( $attributes ); + return beans_sanitize_attributes( $attributes ); } diff --git a/lib/api/init.php b/lib/api/init.php index 7b12d2ba..b7f7711c 100644 --- a/lib/api/init.php +++ b/lib/api/init.php @@ -31,6 +31,7 @@ // Load dependencies here as it is used further down. require_once( BEANS_API_PATH . 'utilities/functions.php' ); +require_once( BEANS_API_PATH . 'utilities/deprecated.php' ); require_once( BEANS_API_PATH . 'components.php' ); // Url. diff --git a/lib/api/utilities/deprecated.php b/lib/api/utilities/deprecated.php new file mode 100644 index 00000000..42a17a92 --- /dev/null +++ b/lib/api/utilities/deprecated.php @@ -0,0 +1,28 @@ + Date: Fri, 25 Mar 2016 09:54:19 +0200 Subject: [PATCH 14/30] Added automatic escaping. --- lib/api/utilities/functions.php | 33 +++++++++++++++++-- lib/templates/fragments/breadcrumb.php | 2 +- lib/templates/fragments/comments.php | 6 ++-- lib/templates/fragments/footer.php | 2 +- lib/templates/fragments/header.php | 10 +++--- lib/templates/fragments/menu.php | 2 +- lib/templates/fragments/post-shortcodes.php | 4 +-- lib/templates/fragments/post.php | 32 +++++++++--------- lib/templates/fragments/searchform.php | 2 +- lib/templates/fragments/widget.php | 4 +-- lib/templates/structure/comment.php | 2 +- lib/templates/structure/content.php | 8 ++--- lib/templates/structure/loop.php | 4 +-- lib/templates/structure/sidebar-primary.php | 2 +- lib/templates/structure/sidebar-secondary.php | 2 +- lib/templates/structure/widget-area.php | 2 +- 16 files changed, 73 insertions(+), 44 deletions(-) diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 77ab2650..0404dd78 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -503,12 +503,41 @@ function beans_admin_menu_position( $position ) { */ function beans_sanitize_attributes( $attributes ) { + /** + * Filter attributes escaping methods. + * + * @since 1.3.1 + */ + $methods = apply_filters( 'beans_escape_attributes_methods', array( + 'id' => 'esc_attr', + 'class' => 'esc_attr', + 'name' => 'esc_attr', + 'title' => 'esc_html', + 'alt' => 'esc_html', + 'href' => 'esc_url', + 'src' => 'esc_url', + 'placeholder' => 'esc_html', + 'itemscope' => 'esc_attr', + 'itemprop'=> 'esc_attr', + 'itemtype' => 'esc_url', + 'onclick' => 'esc_js' + ) ); + $string = ''; - foreach ( (array) $attributes as $attribute => $value ) - if ( $value !== null ) + foreach ( (array) $attributes as $attribute => $value ) { + + if ( $value !== null ) { + + if ( $method = beans_get( $attribute, $methods ) ) + $value = call_user_func( $method, $value ); + $string .= $attribute . '="' . $value . '" '; + } + + } + return trim( $string ); } diff --git a/lib/templates/fragments/breadcrumb.php b/lib/templates/fragments/breadcrumb.php index 77d4848e..590c0222 100644 --- a/lib/templates/fragments/breadcrumb.php +++ b/lib/templates/fragments/breadcrumb.php @@ -134,7 +134,7 @@ function beans_breadcrumb() { echo beans_open_markup( 'beans_breadcrumb_item', 'li' ); echo beans_open_markup( 'beans_breadcrumb_item_link', 'a', array( - 'href' => esc_url( $breadcrumb_url ) + 'href' => $breadcrumb_url // Automatically escaped. ) ); // Used for mobile devices. diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index af0bd303..70acc26a 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -205,7 +205,7 @@ function beans_comment_links() { echo beans_open_markup( 'beans_comment_item[_edit]', 'li' ); echo beans_open_markup( 'beans_comment_item_link[_edit]', 'a', array( - 'href' => esc_url( get_edit_comment_link( $comment->comment_ID ) ) + 'href' => get_edit_comment_link( $comment->comment_ID ) // Automatically escaped. ) ); echo beans_output( 'beans_comment_edit_text', __( 'Edit', 'tm-beans' ) ); @@ -220,7 +220,7 @@ function beans_comment_links() { echo beans_open_markup( 'beans_comment_item[_link]', 'li' ); echo beans_open_markup( 'beans_comment_item_link[_link]', 'a', array( - 'href' => esc_url( get_comment_link( $comment->comment_ID ) ) + 'href' => get_comment_link( $comment->comment_ID ) // Automatically escaped. ) ); echo beans_output( 'beans_comment_link_text', __( 'Link', 'tm-beans' ) ); @@ -388,7 +388,7 @@ function beans_comment_cancel_reply_link( $html, $link, $text ) { 'id' => 'cancel-comment-reply-link', 'class' => 'uk-button uk-button-small uk-button-danger uk-margin-small-right', 'style' => isset( $_GET['replytocom'] ) ? '' : 'display:none;', - 'href' => $link + 'href' => $link // Automatically escaped. ) ); echo beans_output( 'beans_comment_cancel_reply_link_text', $text ); diff --git a/lib/templates/fragments/footer.php b/lib/templates/fragments/footer.php index 95d25f49..272b9c72 100644 --- a/lib/templates/fragments/footer.php +++ b/lib/templates/fragments/footer.php @@ -29,7 +29,7 @@ function beans_footer_content() { echo beans_close_markup( 'beans_footer_credit_left', 'span' ); $framework_link = beans_open_markup( 'beans_footer_credit_framework_link', 'a', array( - 'href' => esc_url( 'http://www.getbeans.io' ), + 'href' => 'http://www.getbeans.io', // Automatically escaped. 'rel' => 'designer' ) ); diff --git a/lib/templates/fragments/header.php b/lib/templates/fragments/header.php index 3b424ca2..d73e2d6f 100644 --- a/lib/templates/fragments/header.php +++ b/lib/templates/fragments/header.php @@ -47,11 +47,11 @@ function beans_favicon() { if ( function_exists( 'has_site_icon' ) && has_site_icon() ) return; - $path = file_exists( get_template_directory() . 'favicon.ico' ) ? get_template_directory() . 'favicon.ico' : BEANS_URL . 'favicon.ico'; + $url = file_exists( get_template_directory() . 'favicon.ico' ) ? get_template_directory_uri() . 'favicon.ico' : BEANS_URL . 'favicon.ico'; echo beans_selfclose_markup( 'beans_favicon', 'link', array( 'rel' => 'Shortcut Icon', - 'href' => esc_url( $path ), + 'href' => $url, // Automatically escaped. 'type' => 'image/x-icon', ) ); @@ -96,8 +96,8 @@ function beans_site_branding() { if ( $logo = get_theme_mod( 'beans_logo_image', false ) ) $name = beans_selfclose_markup( 'beans_logo_image', 'img', array( 'class' => 'tm-logo', - 'src' => esc_url( $logo ), - 'alt' => esc_attr( $name ), + 'src' => $logo, // Automatically escaped. + 'alt' => $name, // Automatically escaped. ) ); echo beans_open_markup( 'beans_site_branding', 'div', array( @@ -105,7 +105,7 @@ function beans_site_branding() { ) ); echo beans_open_markup( 'beans_site_title_link', 'a', array( - 'href' => esc_url( home_url() ), + 'href' => home_url(), // Automatically escaped. 'rel' => 'home', 'itemprop' => 'headline' ) ); diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index 2b80f11f..534a5dd2 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -27,7 +27,7 @@ function beans_primary_menu() { 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', 'fallback_cb' => 'beans_no_menu_notice', 'container' => '', - 'menu_class' => $nav_visibility, + 'menu_class' => $nav_visibility, // Automatically escaped. 'echo' => false, 'beans_type' => 'navbar' ) ); diff --git a/lib/templates/fragments/post-shortcodes.php b/lib/templates/fragments/post-shortcodes.php index 478fb924..553fe56b 100644 --- a/lib/templates/fragments/post-shortcodes.php +++ b/lib/templates/fragments/post-shortcodes.php @@ -40,7 +40,7 @@ function beans_post_meta_author_shortcode() { beans_output( 'beans_post_meta_author_prefix', __( 'By ', 'tm-beans' ) ) ; echo beans_open_markup( 'beans_post_meta_author', 'a', array( - 'href' => esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), + 'href' => get_author_posts_url( get_the_author_meta( 'ID' ) ), // Automatically escaped. 'rel' => 'author', 'itemprop' => 'author', 'itemtype' => 'http://schema.org/Person' @@ -77,7 +77,7 @@ function beans_post_meta_comments_shortcode() { $comment_text = beans_output( 'beans_post_meta_comments_text_plurial', __( '%s comments', 'tm-beans' ) ); echo beans_open_markup( 'beans_post_meta_comments', 'a', array( - 'href' => esc_url( get_comments_link() ) + 'href' => get_comments_link() // Automatically escaped. ) ); printf( $comment_text, (int) get_comments_number( $post->ID ) ); diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index 096d364a..a3c21e4e 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -23,7 +23,7 @@ function beans_post_title() { if ( !is_singular() ) { $title_link = beans_open_markup( 'beans_post_title_link', 'a', array( - 'href' => esc_url( get_permalink() ), + 'href' => get_permalink(), // Automatically escaped. 'title' => the_title_attribute( 'echo=0' ), 'rel' => 'bookmark' ) ); @@ -184,7 +184,7 @@ function beans_post_image() { if ( !is_singular() ) echo beans_open_markup( 'beans_post_image_link', 'a', array( - 'href' => esc_url( get_permalink() ), + 'href' => get_permalink(), // Automatically escaped. 'title' => the_title_attribute( 'echo=0' ) ) ); @@ -200,8 +200,8 @@ function beans_post_image() { echo beans_selfclose_markup( 'beans_post_image_item', 'img', array( 'width' => $image->width, 'height' => $image->height, - 'src' => esc_url( $image->src ), - 'alt' => esc_attr( $image->alt ), + 'src' => $image->src, // Automatically escaped. + 'alt' => $image->alt, // Automatically escaped. 'itemprop' => 'image' ), $image ); @@ -268,7 +268,7 @@ function beans_post_more_link() { global $post; $output = beans_open_markup( 'beans_post_more_link', 'a', array( - 'href' => esc_url( get_permalink() ) . "#more-{$post->ID}", + 'href' => get_permalink() . "#more-{$post->ID}", // Automatically escaped. 'class' => 'more-link', ) ); @@ -362,9 +362,9 @@ function beans_previous_post_link( $output, $format, $link, $post ) { $text = strip_tags( $output ); $output = beans_open_markup( 'beans_previous_link[_post_navigation]', 'a', array( - 'href' => esc_url( get_permalink( $post ) ), + 'href' => get_permalink( $post ), // Automatically escaped. 'ref' => 'previous', - 'title' => esc_html( $post->post_title ) + 'title' => $post->post_title // Automatically escaped. ) ); $output .= beans_open_markup( 'beans_previous_icon[_post_navigation]', 'i', array( @@ -398,9 +398,9 @@ function beans_next_post_link( $output, $format, $link, $post ) { $text = strip_tags( $output ); $output = beans_open_markup( 'beans_next_link[_post_navigation]', 'a', array( - 'href' => esc_url( get_permalink( $post ) ), + 'href' => get_permalink( $post ), // Automatically escaped. 'rel' => 'next', - 'title' => esc_html( $post->post_title ) + 'title' => $post->post_title // Automatically escaped. ) ); $output .= beans_output( 'beans_next_text[_post_navigation]', $text ); @@ -513,7 +513,7 @@ function beans_posts_pagination() { echo beans_open_markup( 'beans_posts_pagination_item[_previous]', 'li' ); echo beans_open_markup( 'beans_previous_link[_posts_pagination]', 'a', array( - 'href' => esc_url( previous_posts( false ) ) + 'href' => previous_posts( false ) // Automatically escaped. ), $current ); echo beans_open_markup( 'beans_previous_icon[_posts_pagination]', 'i', array( @@ -582,7 +582,7 @@ function beans_posts_pagination() { echo beans_open_markup( 'beans_posts_pagination_item', 'li' ); echo beans_open_markup( 'beans_posts_pagination_item_link', 'a', array( - 'href' => esc_url( get_pagenum_link( $link ) ) + 'href' => get_pagenum_link( $link ) // Automatically escaped. ), $link ); echo beans_output( 'beans_posts_pagination_item_link_text', $link ); @@ -601,7 +601,7 @@ function beans_posts_pagination() { echo beans_open_markup( 'beans_posts_pagination_item[_next]', 'li' ); echo beans_open_markup( 'beans_next_link[_posts_pagination]', 'a', array( - 'href' => esc_url( next_posts( $count, false ) ) + 'href' => next_posts( $count, false ) // Automatically escaped. ), $current ); echo beans_output( 'beans_next_text[_posts_pagination]', __( 'Next', 'tm-beans' ) ); @@ -692,13 +692,13 @@ function beans_post_password_form() { $output .= beans_open_markup( 'beans_password_form', 'form', array( 'class' => 'uk-form uk-margin-bottom', 'method' => 'post', - 'action' => esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) + 'action' => site_url( 'wp-login.php?action=postpass', 'login_post' ) // Automatically escaped. ) ); $output .= beans_selfclose_markup( 'beans_password_form_input', 'input', array( 'class' => 'uk-margin-small-top uk-margin-small-right', 'type' => 'password', - 'placeholder' => esc_attr( apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ) ), + 'placeholder' => apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ), // Automatically escaped. 'name' => 'post_password' ) ); @@ -828,7 +828,7 @@ function beans_post_gallery( $output, $attr, $instance ) { // WP adds the opening div in the gallery_style filter (weird), so we follow it as don't want to break people's site. $gallery_div = beans_open_markup( "beans_post_gallery[_{$id}]", 'div', array( - 'class' => "uk-grid uk-grid-width-small-1-{$columns} gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}", + 'class' => "uk-grid uk-grid-width-small-1-{$columns} gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}", // Automatically escaped. 'data-uk-grid-margin' => false ), $id, $columns ); @@ -858,7 +858,7 @@ function beans_post_gallery( $output, $attr, $instance ) { $output .= beans_open_markup( "beans_post_gallery_item[_{$attachment_id}]", $atts['itemtag'], array( 'class' => 'gallery-item' ) ); - $output .= beans_open_markup( "beans_post_gallery_icon[_{$attachment_id}]", $atts['icontag'], array( 'class' => "gallery-icon {$orientation}" ) ); + $output .= beans_open_markup( "beans_post_gallery_icon[_{$attachment_id}]", $atts['icontag'], array( 'class' => "gallery-icon {$orientation}" ) ); // Automatically escaped. $output .= beans_output( "beans_post_gallery_icon[_{$attachment_id}]", $image_output, $attachment_id, $atts ); diff --git a/lib/templates/fragments/searchform.php b/lib/templates/fragments/searchform.php index 6a7c151a..47355936 100644 --- a/lib/templates/fragments/searchform.php +++ b/lib/templates/fragments/searchform.php @@ -27,7 +27,7 @@ function beans_search_form() { $output .= beans_selfclose_markup( 'beans_search_form_input', 'input', array( 'class' => 'uk-width-1-1', 'type' => 'search', - 'placeholder' => __( 'Search', 'tm-beans' ), + 'placeholder' => __( 'Search', 'tm-beans' ), // Automatically escaped. 'value' => esc_attr( get_search_query() ), 'name' => 's' ) ); diff --git a/lib/templates/fragments/widget.php b/lib/templates/fragments/widget.php index 7dfa19b7..b1d1f7ca 100644 --- a/lib/templates/fragments/widget.php +++ b/lib/templates/fragments/widget.php @@ -133,10 +133,10 @@ function beans_modify_widget_content_attributes( $attributes ) { $current_class = isset( $attributes['class'] ) ? $attributes['class'] . ' ' : ''; if ( in_array( beans_get_widget( 'type' ), $target ) ) - $attributes['class'] = $current_class . 'uk-list'; + $attributes['class'] = $current_class . 'uk-list'; // Automatically escaped. if ( $type == 'calendar' ) - $attributes['class'] = $current_class . 'uk-table uk-table-condensed'; + $attributes['class'] = $current_class . 'uk-table uk-table-condensed'; // Automatically escaped. return $attributes; diff --git a/lib/templates/structure/comment.php b/lib/templates/structure/comment.php index 2b31d01d..e07037f8 100644 --- a/lib/templates/structure/comment.php +++ b/lib/templates/structure/comment.php @@ -6,7 +6,7 @@ */ echo beans_open_markup( 'beans_comment', 'article', array( - 'id' => 'div-comment-' . get_comment_ID(), + 'id' => 'div-comment-' . get_comment_ID(), // Automatically escaped. 'class' => 'uk-comment', 'itemprop' => 'comment', 'itemscope' => 'itemscope', diff --git a/lib/templates/structure/content.php b/lib/templates/structure/content.php index 497e00e9..09b9b54a 100644 --- a/lib/templates/structure/content.php +++ b/lib/templates/structure/content.php @@ -14,16 +14,16 @@ // Blog specific attributes. if ( is_home() || is_page_template( 'page_blog.php' ) || is_singular( 'post' ) || is_archive() ) { - $content_attributes['itemscope'] = 'itemscope'; - $content_attributes['itemtype'] = 'http://schema.org/Blog'; + $content_attributes['itemscope'] = 'itemscope'; // Automatically escaped. + $content_attributes['itemtype'] = 'http://schema.org/Blog'; // Automatically escaped. } // Blog specific attributes. if ( is_search() ) { - $content_attributes['itemscope'] = 'itemscope'; - $content_attributes['itemtype'] = 'http://schema.org/SearchResultsPage'; + $content_attributes['itemscope'] = 'itemscope'; // Automatically escaped. + $content_attributes['itemtype'] = 'http://schema.org/SearchResultsPage'; // Automatically escaped. } diff --git a/lib/templates/structure/loop.php b/lib/templates/structure/loop.php index 3c09d7dc..08526fe9 100644 --- a/lib/templates/structure/loop.php +++ b/lib/templates/structure/loop.php @@ -29,8 +29,8 @@ while ( have_posts() ) : the_post(); $article_attributes = array( - 'id' => get_the_ID(), - 'class' => implode( ' ', get_post_class( array( 'uk-article', ( current_theme_supports( 'beans-default-styling' ) ? 'uk-panel-box' : null ) ) ) ), + 'id' => get_the_ID(), // Automatically escaped. + 'class' => implode( ' ', get_post_class( array( 'uk-article', ( current_theme_supports( 'beans-default-styling' ) ? 'uk-panel-box' : null ) ) ) ), // Automatically escaped. 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/CreativeWork' ); diff --git a/lib/templates/structure/sidebar-primary.php b/lib/templates/structure/sidebar-primary.php index 5d5864df..b0e6835f 100644 --- a/lib/templates/structure/sidebar-primary.php +++ b/lib/templates/structure/sidebar-primary.php @@ -6,7 +6,7 @@ */ echo beans_open_markup( 'beans_sidebar_primary', 'aside', array( - 'class' => 'tm-secondary ' . beans_get_layout_class( 'sidebar_primary' ), + 'class' => 'tm-secondary ' . beans_get_layout_class( 'sidebar_primary' ), // Automatically escaped. 'role' => 'complementary', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/WPSideBar' diff --git a/lib/templates/structure/sidebar-secondary.php b/lib/templates/structure/sidebar-secondary.php index d62b1b94..d6d0e788 100644 --- a/lib/templates/structure/sidebar-secondary.php +++ b/lib/templates/structure/sidebar-secondary.php @@ -6,7 +6,7 @@ */ echo beans_open_markup( 'beans_sidebar_secondary', 'aside', array( - 'class' => 'tm-tertiary ' . beans_get_layout_class( 'sidebar_secondary' ), + 'class' => 'tm-tertiary ' . beans_get_layout_class( 'sidebar_secondary' ), // Automatically escaped. 'role' => 'complementary', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/WPSideBar' diff --git a/lib/templates/structure/widget-area.php b/lib/templates/structure/widget-area.php index 1f10c230..b59b6424 100644 --- a/lib/templates/structure/widget-area.php +++ b/lib/templates/structure/widget-area.php @@ -15,7 +15,7 @@ if ( beans_get_widget_area( 'beans_type' ) == 'offcanvas' ) { echo beans_open_markup( 'beans_widget_area_offcanvas_wrap' . _beans_widget_area_subfilters(), 'div', array( - 'id' => beans_get_widget_area( 'id' ), + 'id' => beans_get_widget_area( 'id' ), // Automatically escaped. 'class' => 'uk-offcanvas' ) ); From 52345805777ba7c16f4dea6a3b559823e352e720 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 2 Apr 2016 12:02:26 +0200 Subject: [PATCH 15/30] Improved automatic escaping to tighten security. --- lib/api/utilities/functions.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 0404dd78..0a374a80 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -506,19 +506,14 @@ function beans_sanitize_attributes( $attributes ) { /** * Filter attributes escaping methods. * + * For all unspecified selectors, values are automatically escaped using + * {@link http://codex.wordpress.org/Function_Reference/esc_attr esc_attr()}. + * * @since 1.3.1 */ $methods = apply_filters( 'beans_escape_attributes_methods', array( - 'id' => 'esc_attr', - 'class' => 'esc_attr', - 'name' => 'esc_attr', - 'title' => 'esc_html', - 'alt' => 'esc_html', 'href' => 'esc_url', 'src' => 'esc_url', - 'placeholder' => 'esc_html', - 'itemscope' => 'esc_attr', - 'itemprop'=> 'esc_attr', 'itemtype' => 'esc_url', 'onclick' => 'esc_js' ) ); @@ -531,6 +526,8 @@ function beans_sanitize_attributes( $attributes ) { if ( $method = beans_get( $attribute, $methods ) ) $value = call_user_func( $method, $value ); + else + $value = esc_attr( $value ); $string .= $attribute . '="' . $value . '" '; From 5e3897fbf577137529415f01ba14aa7f31d8e09b Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 2 Apr 2016 12:13:58 +0200 Subject: [PATCH 16/30] Removed irritating #more-{$post->ID} anchor (backwards compatibility is affected). Since this has been removed in new WordPress Core themes and requested by many users, we have taken the decision to remove it in Beans Core. --- lib/templates/fragments/post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index a3c21e4e..ebcbaca9 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -268,7 +268,7 @@ function beans_post_more_link() { global $post; $output = beans_open_markup( 'beans_post_more_link', 'a', array( - 'href' => get_permalink() . "#more-{$post->ID}", // Automatically escaped. + 'href' => get_permalink(), // Automatically escaped. 'class' => 'more-link', ) ); From 7b506f568cf2a557c593e7c2b2d4799fd4ab07d9 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 2 Apr 2016 12:23:34 +0200 Subject: [PATCH 17/30] Improved global code formatting. --- lib/admin/assets/js/wp-customize-preview.js | 16 ++++++++-------- lib/api/compiler/class-compiler.php | 2 +- lib/api/compiler/vendors/gzip.php | 3 +-- lib/api/fields/assets/css/fields.css | 1 - lib/api/fields/assets/js/media.js | 6 +++--- lib/api/image/functions.php | 1 - lib/api/uikit/class.php | 2 +- lib/api/uikit/functions.php | 2 +- lib/templates/fragments/breadcrumb.php | 2 +- lib/templates/fragments/comments.php | 2 +- lib/templates/fragments/header.php | 4 ++-- lib/templates/fragments/post.php | 6 +++--- lib/templates/fragments/widget.php | 2 +- 13 files changed, 23 insertions(+), 26 deletions(-) diff --git a/lib/admin/assets/js/wp-customize-preview.js b/lib/admin/assets/js/wp-customize-preview.js index f9c60ea3..d8171797 100644 --- a/lib/admin/assets/js/wp-customize-preview.js +++ b/lib/admin/assets/js/wp-customize-preview.js @@ -16,16 +16,16 @@ viewportWidth: function() { - if ( wp.customize.value('beans_enable_viewport_width')() == true ) - this.wpIframe.css( 'width', wp.customize.value('beans_viewport_width')() ); + if ( wp.customize.value( 'beans_enable_viewport_width' )() == true ) + this.wpIframe.css( 'width', wp.customize.value( 'beans_viewport_width' )() ); else this.wpIframe.css( 'width', '100%' ); }, viewportHeight: function() { - if ( wp.customize.value('beans_enable_viewport_height')() == true ) - this.wpIframe.css( 'height', wp.customize.value('beans_viewport_height')() ); + if ( wp.customize.value( 'beans_enable_viewport_height' )() == true ) + this.wpIframe.css( 'height', wp.customize.value( 'beans_viewport_height' )() ); else this.wpIframe.css( 'height', '100%' ); @@ -49,22 +49,22 @@ var that = this; // Fire viewport width. - wp.customize.value( 'beans_enable_viewport_width').bind( function( to ) { + wp.customize.value( 'beans_enable_viewport_width' ).bind( function( to ) { that.viewportWidth(); } ); // Fire viewport width. - wp.customize.value( 'beans_viewport_width').bind( function( to ) { + wp.customize.value( 'beans_viewport_width' ).bind( function( to ) { that.viewportWidth(); } ); // Fire viewport height. - wp.customize.value( 'beans_enable_viewport_height').bind( function( to ) { + wp.customize.value( 'beans_enable_viewport_height' ).bind( function( to ) { that.viewportHeight(); } ); // Fire viewport height. - wp.customize.value( 'beans_viewport_height').bind( function( to ) { + wp.customize.value( 'beans_viewport_height' ).bind( function( to ) { that.viewportHeight(); } ); diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-compiler.php index c5bb90aa..3ed14206 100644 --- a/lib/api/compiler/class-compiler.php +++ b/lib/api/compiler/class-compiler.php @@ -247,7 +247,7 @@ public function get_url() { $url = trailingslashit( $this->url ) . beans_get( 'filename', $this->compiler ); if ( is_ssl() ) - $url = str_replace('http://', 'https://', $url ); + $url = str_replace( 'http://', 'https://', $url ); return $url; diff --git a/lib/api/compiler/vendors/gzip.php b/lib/api/compiler/vendors/gzip.php index 0f31704b..50bc1177 100644 --- a/lib/api/compiler/vendors/gzip.php +++ b/lib/api/compiler/vendors/gzip.php @@ -26,8 +26,7 @@ $gzip = false; if ( $gzip ) - ob_start('ob_gzhandler'); - + ob_start( 'ob_gzhandler' ); // Include file. if ( ( $id = $_GET['id'] ) && ( $file = $_GET['file'] ) && ( $type = $_GET['type'] ) ) { diff --git a/lib/api/fields/assets/css/fields.css b/lib/api/fields/assets/css/fields.css index dc3a01a4..4390db96 100644 --- a/lib/api/fields/assets/css/fields.css +++ b/lib/api/fields/assets/css/fields.css @@ -255,7 +255,6 @@ } - /* Options fields modifiers ========================================================================== */ .bs-options-form-actions { diff --git a/lib/api/fields/assets/js/media.js b/lib/api/fields/assets/js/media.js index 21f14b3d..ad1a62fe 100644 --- a/lib/api/fields/assets/js/media.js +++ b/lib/api/fields/assets/js/media.js @@ -28,7 +28,7 @@ // Run a callback when an image is selected. media_iframe.on( 'select', function() { - var selection = media_iframe.state().get('selection'); + var selection = media_iframe.state().get( 'selection' ); if ( !selection ) return; @@ -36,14 +36,14 @@ selection.each( function( attachment ) { // Clone the the template field. - var newField = field.find('.bs-image-wrap.bs-image-template') + var newField = field.find( '.bs-image-wrap.bs-image-template' ) .clone() .removeClass( 'bs-image-template' ); var updatedfield = $this.updateImage( newField, attachment ); // Finally append the field - field.find('.bs-images-wrap').append( updatedfield ); + field.find( '.bs-images-wrap' ).append( updatedfield ); // Hide the button if multiple images are not permissible. if ( !$this.isMultiple ) diff --git a/lib/api/image/functions.php b/lib/api/image/functions.php index 5cc4271e..1b3c0010 100644 --- a/lib/api/image/functions.php +++ b/lib/api/image/functions.php @@ -82,7 +82,6 @@ function beans_get_post_attachment( $post_id, $size = 'full' ) { } - /** * Edit post attachment. * diff --git a/lib/api/uikit/class.php b/lib/api/uikit/class.php index 5c3d235f..dfe037dd 100644 --- a/lib/api/uikit/class.php +++ b/lib/api/uikit/class.php @@ -184,7 +184,7 @@ function get_all_components( $type ) { unset( $scandir[0], $scandir[1] ); // Only return the filname and remove empty elements. - $components = array_merge( $components, array_filter( array_map( array( $this, 'to_filename'), $scandir ) ) ); + $components = array_merge( $components, array_filter( array_map( array( $this, 'to_filename' ), $scandir ) ) ); } diff --git a/lib/api/uikit/functions.php b/lib/api/uikit/functions.php index df9581f3..63f550a4 100644 --- a/lib/api/uikit/functions.php +++ b/lib/api/uikit/functions.php @@ -118,7 +118,7 @@ function beans_uikit_register_theme( $id, $path ) { if ( !$path ) return false; - if ( stripos( $path, 'http') !== false ) + if ( stripos( $path, 'http' ) !== false ) $path = beans_url_to_path( $path ); $_beans_uikit_registered_items['themes'][$id] = trailingslashit( $path ); diff --git a/lib/templates/fragments/breadcrumb.php b/lib/templates/fragments/breadcrumb.php index 590c0222..86ab9576 100644 --- a/lib/templates/fragments/breadcrumb.php +++ b/lib/templates/fragments/breadcrumb.php @@ -138,7 +138,7 @@ function beans_breadcrumb() { ) ); // Used for mobile devices. - echo beans_open_markup( 'beans_breadcrumb_item_link_inner', 'span'); + echo beans_open_markup( 'beans_breadcrumb_item_link_inner', 'span' ); echo $breadcrumb; diff --git a/lib/templates/fragments/comments.php b/lib/templates/fragments/comments.php index 70acc26a..1aec53b2 100644 --- a/lib/templates/fragments/comments.php +++ b/lib/templates/fragments/comments.php @@ -359,7 +359,7 @@ function beans_comment_form() { $output .= beans_close_markup( 'beans_comment_form_wrap', 'div' ); - $submit = beans_open_markup( 'beans_comment_form_submit', 'button', array( 'class' => 'uk-button uk-button-primary', 'type' => 'submit') ); + $submit = beans_open_markup( 'beans_comment_form_submit', 'button', array( 'class' => 'uk-button uk-button-primary', 'type' => 'submit' ) ); $submit .= beans_output( 'beans_comment_form_submit_text', __( 'Post Comment', 'tm-beans' ) ); diff --git a/lib/templates/fragments/header.php b/lib/templates/fragments/header.php index d73e2d6f..f7f2fa81 100644 --- a/lib/templates/fragments/header.php +++ b/lib/templates/fragments/header.php @@ -20,7 +20,7 @@ function beans_head_meta() { } -beans_add_smart_action( 'wp_head', 'beans_head_pingback'); +beans_add_smart_action( 'wp_head', 'beans_head_pingback' ); /** * Echo head pingback. @@ -34,7 +34,7 @@ function beans_head_pingback() { } -beans_add_smart_action( 'wp_head', 'beans_favicon'); +beans_add_smart_action( 'wp_head', 'beans_favicon' ); /** * Echo head favicon if no icon was added via the customizer. diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index ebcbaca9..c1a2a2a4 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -61,7 +61,7 @@ function beans_post_search_title() { if ( !is_search() ) return; - echo beans_open_markup( 'beans_search_title', 'h1', array( 'class' => 'uk-article-title') ); + echo beans_open_markup( 'beans_search_title', 'h1', array( 'class' => 'uk-article-title' ) ); echo beans_output( 'beans_search_title_text', __( 'Search results for: ', 'tm-beans' ) ) . get_search_query(); @@ -571,7 +571,7 @@ function beans_posts_pagination() { // Integer. if ( $link == $current ) { - echo beans_open_markup( 'beans_posts_pagination_item[_active]', 'li', array( 'class' => 'uk-active') ); + echo beans_open_markup( 'beans_posts_pagination_item[_active]', 'li', array( 'class' => 'uk-active' ) ); echo '' . $link . ''; @@ -698,7 +698,7 @@ function beans_post_password_form() { $output .= beans_selfclose_markup( 'beans_password_form_input', 'input', array( 'class' => 'uk-margin-small-top uk-margin-small-right', 'type' => 'password', - 'placeholder' => apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ), // Automatically escaped. + 'placeholder' => apply_filters( 'beans_password_form_input_placeholder', __( 'Password', 'tm-beans' ) ), // Automatically escaped. 'name' => 'post_password' ) ); diff --git a/lib/templates/fragments/widget.php b/lib/templates/fragments/widget.php index b1d1f7ca..b0b36c4d 100644 --- a/lib/templates/fragments/widget.php +++ b/lib/templates/fragments/widget.php @@ -159,7 +159,7 @@ function beans_modify_widget_count( $content ) { $count = beans_output( 'beans_widget_count', '$1' ); - if ( beans_get( 'dropdown', beans_get_widget( 'options') ) == true ) { + if ( beans_get( 'dropdown', beans_get_widget( 'options' ) ) == true ) { $output = $count; From 86aa171088309839afdf4cbc52365126aae95f3f Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 2 Apr 2016 12:31:58 +0200 Subject: [PATCH 18/30] Removed article panel box negative margins (backwards compatibility affected). This was causing inconsistency with custom panel box commonly added by users. --- lib/assets/less/style.less | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/assets/less/style.less b/lib/assets/less/style.less index 6f5b0953..74c4232a 100644 --- a/lib/assets/less/style.less +++ b/lib/assets/less/style.less @@ -38,8 +38,6 @@ article header > .tm-article-image:first-child { article.uk-panel-box { padding: 20px 15px; - margin-right: -15px; - margin-left: -15px; } } From 1739753d55f906896f53664e09cb41b9602271ae Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 2 Apr 2016 15:54:05 +0200 Subject: [PATCH 19/30] Improved global PHP inline documentation. --- lib/api/compiler/class-compiler.php | 9 ++++++++ lib/api/options/functions.php | 19 ++++++++++++++++ lib/api/post-meta/functions-admin.php | 25 ++++++++++++++++++--- lib/api/term-meta/functions-admin.php | 25 ++++++++++++++++++--- lib/api/uikit/class.php | 32 +++++++++++++++++++++++++-- lib/api/utilities/functions.php | 2 ++ lib/api/wp-customize/functions.php | 9 ++++++++ lib/templates/fragments/menu.php | 14 ++++++++++++ lib/templates/fragments/post.php | 10 +++++++++ 9 files changed, 137 insertions(+), 8 deletions(-) diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-compiler.php index 3ed14206..3a07db61 100644 --- a/lib/api/compiler/class-compiler.php +++ b/lib/api/compiler/class-compiler.php @@ -136,6 +136,15 @@ public function set_fragments() { if ( $added_fragments = beans_get( $this->compiler['id'], $_beans_compiler_added_fragments[$this->compiler['format']] ) ) $this->compiler['fragments'] = array_merge( $this->compiler['fragments'], $added_fragments ); + /** + * Filter the compiler fragment files. + * + * The dynamic portion of the hook name, $this->compiler['id'], refers to the compiler id used as a reference. + * + * @since 1.0.0 + * + * @param array $fragments An array of fragment files. + */ $this->compiler['fragments'] = apply_filters( 'beans_compiler_fragments_' . $this->compiler['id'], $this->compiler['fragments'] ); } diff --git a/lib/api/options/functions.php b/lib/api/options/functions.php index 8b12c82b..e1dffc85 100644 --- a/lib/api/options/functions.php +++ b/lib/api/options/functions.php @@ -45,7 +45,26 @@ */ function beans_register_options( array $fields, $menu_slug, $section, $args = array() ) { + /** + * Filter the options fields. + * + * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. + * + * @since 1.0.0 + * + * @param array $fields An array of options fields. + */ $fields = apply_filters( "beans_options_fields_{$section}", _beans_pre_standardize_fields( $fields ) ); + + /** + * Filter the options fields menu slug. + * + * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. + * + * @since 1.0.0 + * + * @param array $menu_slug The menu slug. + */ $menu_slug = apply_filters( "beans_options_menu_slug_{$section}", $menu_slug ); // Stop here if the page isn't concerned. diff --git a/lib/api/post-meta/functions-admin.php b/lib/api/post-meta/functions-admin.php index 4bdd0e10..f735ec78 100644 --- a/lib/api/post-meta/functions-admin.php +++ b/lib/api/post-meta/functions-admin.php @@ -31,9 +31,9 @@ * registered should be saved as a group in the database or as individual * entries. Default false. * } - * @param array $conditions Array of 'post types id(s)', 'post id(s)' or 'page template slug(s)' for which the post meta should be registered. - * 'page template slug(s)' must include '.php' file extention. Set to true to display everywhere. - * @param string $section A section id to define the group of fields. + * @param string|array $conditions Array of 'post types id(s)', 'post id(s)' or 'page template slug(s)' for which the post meta should be registered. + * 'page template slug(s)' must include '.php' file extention. Set to true to display everywhere. + * @param string $section A section id to define the group of fields. * @param array $args { * Optional. Array of arguments used to register the fields. * @@ -50,7 +50,26 @@ function beans_register_post_meta( array $fields, $conditions, $section, $args = global $_beans_post_meta_conditions; + /** + * Filter the post meta fields. + * + * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. + * + * @since 1.0.0 + * + * @param array $fields An array of post meta fields. + */ $fields = apply_filters( "beans_post_meta_fields_{$section}", _beans_pre_standardize_fields( $fields ) ); + + /** + * Filter the conditions used to define whether the fields set should be displayed or not. + * + * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. + * + * @since 1.0.0 + * + * @param string|array $conditions Conditions used to define whether the fields set should be displayed or not. + */ $conditions = apply_filters( "beans_post_meta_post_types_{$section}", $conditions ); $_beans_post_meta_conditions = array_merge( $_beans_post_meta_conditions, (array) $conditions ); diff --git a/lib/api/term-meta/functions-admin.php b/lib/api/term-meta/functions-admin.php index 3776a6ee..d32feea1 100644 --- a/lib/api/term-meta/functions-admin.php +++ b/lib/api/term-meta/functions-admin.php @@ -31,15 +31,34 @@ * registered should be saved as a group in the database or as individual * entries. Default false. * } - * @param array $taxonomies Array of taxonomies for which the term meta should be registered. - * @param string $section A section id to define the group of fields. + * @param string|array $taxonomies Array of taxonomies for which the term meta should be registered. + * @param string $section A section id to define the group of fields. * * @return bool True on success, false on failure. */ function beans_register_term_meta( array $fields, $taxonomies, $section ) { + /** + * Filter the term meta fields. + * + * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. + * + * @since 1.0.0 + * + * @param array $fields An array of term meta fields. + */ $fields = apply_filters( "beans_term_meta_fields_{$section}", _beans_pre_standardize_fields( $fields ) ); - $taxonomies = apply_filters( "beans_term_meta_taxonomies_{$section}", $taxonomies ); + + /** + * Filter the taxonomies used to define whether the fields set should be displayed or not. + * + * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. + * + * @since 1.0.0 + * + * @param string|array $taxonomies Taxonomies used to define whether the fields set should be displayed or not. + */ + $taxonomies = apply_filters( "beans_term_meta_taxonomies_{$section}", (array) $taxonomies ); // Stop here if the current page isn't concerned. if ( !_beans_is_admin_term( $taxonomies ) || !is_admin() ) diff --git a/lib/api/uikit/class.php b/lib/api/uikit/class.php index dfe037dd..e9377dcc 100644 --- a/lib/api/uikit/class.php +++ b/lib/api/uikit/class.php @@ -15,12 +15,40 @@ function compile() { global $_beans_uikit_enqueued_items; - // Set filters for third parties, eventhough it should rarely be used. + /** + * Filter UIkit enqueued style components. + * + * @since 1.0.0 + * + * @param array $components An array of UIkit style component files. + */ $styles = apply_filters( 'beans_uikit_euqueued_styles', $this->register_less_components() ); + + /** + * Filter UIkit enqueued script components. + * + * @since 1.0.0 + * + * @param array $components An array of UIkit script component files. + */ $scripts = apply_filters( 'beans_uikit_euqueued_scripts', $this->register_js_components() ); - // Set default args filters for third parties. + /** + * Filter UIkit style compiler arguments. + * + * @since 1.0.0 + * + * @param array $components An array of UIkit style compiler arguments. + */ $styles_args = apply_filters( 'beans_uikit_euqueued_styles_args', array() ); + + /** + * Filter UIkit script compiler arguments. + * + * @since 1.0.0 + * + * @param array $components An array of UIkit script compiler arguments. + */ $scripts_args = apply_filters( 'beans_uikit_euqueued_scripts_args', array( 'depedencies' => array( 'jquery' ) ) ); diff --git a/lib/api/utilities/functions.php b/lib/api/utilities/functions.php index 0a374a80..339cc995 100644 --- a/lib/api/utilities/functions.php +++ b/lib/api/utilities/functions.php @@ -510,6 +510,8 @@ function beans_sanitize_attributes( $attributes ) { * {@link http://codex.wordpress.org/Function_Reference/esc_attr esc_attr()}. * * @since 1.3.1 + * + * @param array $method Associative array of selectors as keys and escaping method as values. */ $methods = apply_filters( 'beans_escape_attributes_methods', array( 'href' => 'esc_url', diff --git a/lib/api/wp-customize/functions.php b/lib/api/wp-customize/functions.php index 55e35477..92f929d4 100644 --- a/lib/api/wp-customize/functions.php +++ b/lib/api/wp-customize/functions.php @@ -48,6 +48,15 @@ */ function beans_register_wp_customize_options( array $fields, $section, $args = array() ) { + /** + * Filter the customizer fields. + * + * The dynamic portion of the hook name, $section, refers to the section id which defines the group of fields. + * + * @since 1.0.0 + * + * @param array $fields An array of customizer fields. + */ $fields = apply_filters( "beans_wp_customize_fields_{$section}", _beans_pre_standardize_fields( $fields ) ); // Stop here if the current page isn't concerned. diff --git a/lib/templates/fragments/menu.php b/lib/templates/fragments/menu.php index 534a5dd2..de16db6c 100644 --- a/lib/templates/fragments/menu.php +++ b/lib/templates/fragments/menu.php @@ -23,6 +23,13 @@ function beans_primary_menu() { 'itemtype' => 'http://schema.org/SiteNavigationElement' ) ); + /** + * Filter the primary menu arguments. + * + * @since 1.0.0 + * + * @param array $args Nav menu arguments. + */ $args = apply_filters( 'beans_primary_menu_args', array( 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', 'fallback_cb' => 'beans_no_menu_notice', @@ -88,6 +95,13 @@ function beans_primary_offcanvas_menu() { 'role' => 'navigation', ) ); + /** + * Filter the off-canvas primary menu arguments. + * + * @since 1.0.0 + * + * @param array $args Off-canvas nav menu arguments. + */ $args = apply_filters( 'beans_primary_offcanvas_menu_args', array( 'theme_location' => has_nav_menu( 'primary' ) ? 'primary' : '', 'fallback_cb' => 'beans_no_menu_notice', diff --git a/lib/templates/fragments/post.php b/lib/templates/fragments/post.php index c1a2a2a4..aab4267a 100644 --- a/lib/templates/fragments/post.php +++ b/lib/templates/fragments/post.php @@ -91,6 +91,16 @@ function beans_post_meta() { echo beans_open_markup( 'beans_post_meta', 'ul', array( 'class' => 'uk-article-meta uk-subnav uk-subnav-line' ) ); + /** + * Filter the post meta actions and order. + * + * A do_action( "beans_post_meta_{$array_key}" ) is called for each array key set. Array values are used to set the priority of + * each actions. The array ordered using asort(); + * + * @since 1.0.0 + * + * @param array $fragments An array of fragment files. + */ $meta_items = apply_filters( 'beans_post_meta_items', array( 'date' => 10, 'author' => 20, From ade8e2fb05fb1fe7a6ea3753e8a0482ee186b916 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 2 Apr 2016 18:34:20 +0200 Subject: [PATCH 20/30] Removed unnecessary javascript semicolon separator. --- lib/api/compiler/class-compiler.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/api/compiler/class-compiler.php b/lib/api/compiler/class-compiler.php index 3a07db61..5a5757f3 100644 --- a/lib/api/compiler/class-compiler.php +++ b/lib/api/compiler/class-compiler.php @@ -284,7 +284,7 @@ public function combine_fragments() { $content = ''; - // Looo through fragments. + // Loop through fragments. foreach ( $this->compiler['fragments'] as $fragment ) { // Stop here if the fragment is empty. @@ -321,16 +321,10 @@ public function combine_fragments() { $get_content = $this->replace_css_url( $get_content ); $get_content = $this->add_content_media_query( $get_content ); - // Add content wrapped in the media query if set. - $content .= $get_content; - - } else { - - // Prevent js conflicts. - $content .= "\n\n" . ";" . $get_content; - } + $content .= ( $content ? "\n\n" : '' ) . $get_content; + } return $this->format_content( $content ); From e62f369d136f7babce6dd196f5550f99f6d4d0dc Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 2 Apr 2016 18:41:14 +0200 Subject: [PATCH 21/30] Added missing internationalization. --- lib/api/compiler/class-options.php | 4 ++-- lib/api/options/class.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/compiler/class-options.php b/lib/api/compiler/class-options.php index 168fb5aa..38264df4 100644 --- a/lib/api/compiler/class-options.php +++ b/lib/api/compiler/class-options.php @@ -68,8 +68,8 @@ public function register() { 'default' => array( 'aggressive' ), 'attributes' => array( 'style' => 'margin: -3px 0 0 -8px;' ), 'options' => array( - 'aggressive' => 'Aggressive', - 'standard' => 'Standard' + 'aggressive' => __( 'Aggressive', 'tm-beans' ), + 'standard' => __( 'Standard', 'tm-beans' ) ) ), ), diff --git a/lib/api/options/class.php b/lib/api/options/class.php index 9bb42096..946056ed 100644 --- a/lib/api/options/class.php +++ b/lib/api/options/class.php @@ -118,8 +118,8 @@ public function page( $page ) { echo '
'; echo '

- - + +

'; echo ''; From 5289568f5dcf24bd05178db3f5b4f4a3679db883 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 9 Apr 2016 14:41:48 +0200 Subject: [PATCH 22/30] Improved API fields escaping and HTML format. --- lib/api/fields/types/activation.php | 9 +++-- lib/api/fields/types/checkbox.php | 14 ++++---- lib/api/fields/types/field.php | 6 ++-- lib/api/fields/types/image.php | 51 ++++++++++++----------------- lib/api/fields/types/radio.php | 36 +++++++++----------- lib/api/fields/types/select.php | 18 ++++------ lib/api/fields/types/slider.php | 17 +++++----- lib/api/fields/types/text.php | 4 ++- lib/api/fields/types/textarea.php | 4 ++- 9 files changed, 72 insertions(+), 87 deletions(-) diff --git a/lib/api/fields/types/activation.php b/lib/api/fields/types/activation.php index b0b4470a..7eb5a56a 100644 --- a/lib/api/fields/types/activation.php +++ b/lib/api/fields/types/activation.php @@ -24,10 +24,9 @@ */ function beans_field_activation( $field ) { - $checked = $field['value'] ? ' checked="checked"' : null; - - echo ''; - - echo ''; + ?> + + /> + '; - - echo ''; - - if ( $checkbox_label = beans_get( 'checkbox_label', $field, 'Enable' ) ) - echo '' . $checkbox_label . ''; + ?> + + /> + + + ' . __( 'More...', 'tm-beans' ) . ''; - echo '
' . $extended . '
'; + ?> +
+
+ '; - echo _n( 'Add Image', 'Add Images', ( $multiple ? 2 : 1 ), 'tm-beans' ); - echo ''; - - echo ''; - - echo '
'; - - foreach ( $images as $id ) { + ?> + > + +
+ '; - - echo ''; - - echo ''; - - echo '
'; - - if ( $multiple ) - echo ''; - - echo ''; - echo ''; - - echo '
'; - - echo '
'; - - } - - echo '
'; + ?> +
+ /> + +
+ + + + + +
+
+ + + + '; + ?> +
+ $radio ) : - $i = 0; foreach ( $field['options'] as $id => $radio ) { - - $checked = ( $id == $field['value'] ) ? ' checked="checked"' : null; $extensions = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ); $has_image = in_array( beans_get( 'extension', pathinfo( $radio ) ), $extensions ) ? 'bs-has-image' : false; - echo ''; - - $i++; - - } - - echo '
'; + ?> + + + + + '; - - foreach ( $field['options'] as $value => $label ) { - - $selected = $value == $field['value'] ? ' selected="selected"' : null; - - echo ''; - - } - - echo ''; + ?> + + '; + ?> +
- // Don't make this a hidden field to prevent triggering issues with wp_customise. - echo ''; + + style="display: none;"/> - echo '
'; + + - echo '' . $field['value'] . ''; - - if ( $field['unit'] ) - echo '' . $field['unit'] . ''; + + + '; + ?> + > + ' . esc_attr( $field['value'] ) . ''; + ?> + + Date: Sat, 9 Apr 2016 14:58:36 +0200 Subject: [PATCH 23/30] Fixed layout option on Posts Page. --- lib/api/layout/functions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index 379bda22..25827d26 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -46,6 +46,9 @@ function beans_get_layout() { if ( is_singular() ) $layout = beans_get_post_meta( 'beans_layout' ); + elseif ( is_home() ) + $layout = beans_get_post_meta( 'beans_layout', false, get_option( 'page_for_posts' ) ); + elseif ( is_category() || is_tag() || is_tax() ) $layout = beans_get_term_meta( 'beans_layout' ); From 96dbc23ae4b5bcc23cef143e0c1e44a5cab356be Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sat, 9 Apr 2016 17:34:35 +0200 Subject: [PATCH 24/30] Updated version to 1.3.1-beta --- lib/api/html/functions.php | 4 ++-- lib/init.php | 2 +- style.css | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/api/html/functions.php b/lib/api/html/functions.php index 65c237f9..0ed512df 100644 --- a/lib/api/html/functions.php +++ b/lib/api/html/functions.php @@ -277,7 +277,7 @@ function beans_remove_markup( $id, $remove_actions = false ) { * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very * easy to find the content ID when inspecting an element in a web browser. * - * @since next release + * @since 1.3.1 * * @param string $id The markup ID. * @@ -412,7 +412,7 @@ function beans_add_attributes( $id, $attributes = array() ) { * The "data-markup-id" is added as a HTML attribute if the development mode is enabled. This makes it very * easy to find the content ID when inspecting an element in a web browser. * - * @since next release + * @since 1.3.1 * * @param string $id The markup ID. * diff --git a/lib/init.php b/lib/init.php index 578476f9..bfe327d6 100644 --- a/lib/init.php +++ b/lib/init.php @@ -16,7 +16,7 @@ function beans_define_constants() { // Define version. - define( 'BEANS_VERSION', '1.3.0' ); + define( 'BEANS_VERSION', '1.3.1-beta' ); // Define paths. if ( !defined( 'BEANS_THEME_PATH' ) ) diff --git a/style.css b/style.css index 6df445f6..01deff0e 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Theme URI: http://www.getbeans.io/themes/beans/ Author: Beans Author URI: http://www.getbeans.io Description: The most innovative theme for WordPress. The real magic is under the hood. -Version: 1.3.0 +Version: 1.3.1-beta Text Domain: tm-beans Tags: white, light, one-column, two-columns, three-columns, right-sidebar, left-sidebar, responsive-layout, fluid-layout, fixed-layout, custom-header, custom-background, custom-menu, editor-style, featured-images, microformats, post-formats, translation-ready License: GNU General Public License v2 or later From ffe18a2e749a9fe4d5ddb9622160fa9c40485ba1 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Fri, 22 Apr 2016 08:00:37 +0200 Subject: [PATCH 25/30] Updated version to 1.3.1-rc --- lib/init.php | 2 +- style.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/init.php b/lib/init.php index bfe327d6..e2896760 100644 --- a/lib/init.php +++ b/lib/init.php @@ -16,7 +16,7 @@ function beans_define_constants() { // Define version. - define( 'BEANS_VERSION', '1.3.1-beta' ); + define( 'BEANS_VERSION', '1.3.1-rc' ); // Define paths. if ( !defined( 'BEANS_THEME_PATH' ) ) diff --git a/style.css b/style.css index 01deff0e..3d4f700e 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Theme URI: http://www.getbeans.io/themes/beans/ Author: Beans Author URI: http://www.getbeans.io Description: The most innovative theme for WordPress. The real magic is under the hood. -Version: 1.3.1-beta +Version: 1.3.1-rc Text Domain: tm-beans Tags: white, light, one-column, two-columns, three-columns, right-sidebar, left-sidebar, responsive-layout, fluid-layout, fixed-layout, custom-header, custom-background, custom-menu, editor-style, featured-images, microformats, post-formats, translation-ready License: GNU General Public License v2 or later From 3987d8d241f3ff90f1f0264d05f9b67144814e45 Mon Sep 17 00:00:00 2001 From: Thierry Muller Date: Sun, 24 Apr 2016 13:52:41 +0200 Subject: [PATCH 26/30] Modified beans_sanitize_attributes function to beans_esc_attributes. No backwards compatibility because beans_sanitize_attributes was introduced in 1.3.1-beta and never in a stable version. --- lib/api/fields/types/activation.php | 2 +- lib/api/fields/types/checkbox.php | 2 +- lib/api/fields/types/image.php | 2 +- lib/api/fields/types/radio.php | 2 +- lib/api/fields/types/select.php | 2 +- lib/api/fields/types/slider.php | 2 +- lib/api/fields/types/text.php | 2 +- lib/api/fields/types/textarea.php | 2 +- lib/api/html/functions.php | 2 +- lib/api/utilities/deprecated.php | 10 +++++----- lib/api/utilities/functions.php | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/api/fields/types/activation.php b/lib/api/fields/types/activation.php index 7eb5a56a..f9ddc7d1 100644 --- a/lib/api/fields/types/activation.php +++ b/lib/api/fields/types/activation.php @@ -26,7 +26,7 @@ function beans_field_activation( $field ) { ?> - /> + /> - /> + />
- /> + />
diff --git a/lib/api/fields/types/radio.php b/lib/api/fields/types/radio.php index 323c9fc2..14f2747e 100644 --- a/lib/api/fields/types/radio.php +++ b/lib/api/fields/types/radio.php @@ -41,7 +41,7 @@ function beans_field_radio( $field ) { - /> + /> diff --git a/lib/api/fields/types/select.php b/lib/api/fields/types/select.php index 49a3bc1a..6d42c08e 100644 --- a/lib/api/fields/types/select.php +++ b/lib/api/fields/types/select.php @@ -28,7 +28,7 @@ function beans_field_select( $field ) { return; ?> - > $label ) : ?> diff --git a/lib/api/fields/types/slider.php b/lib/api/fields/types/slider.php index 1d12b785..eafea5b5 100644 --- a/lib/api/fields/types/slider.php +++ b/lib/api/fields/types/slider.php @@ -53,7 +53,7 @@ function beans_field_slider( $field ) {
- style="display: none;"/> + style="display: none;"/>
diff --git a/lib/api/fields/types/text.php b/lib/api/fields/types/text.php index 970986a4..ce6da8ca 100644 --- a/lib/api/fields/types/text.php +++ b/lib/api/fields/types/text.php @@ -23,7 +23,7 @@ function beans_field_text( $field ) { ?> - > + > - + Date: Sun, 24 Apr 2016 13:59:59 +0200 Subject: [PATCH 27/30] Removed logo image alt output filter (backwards compatibility affected) Removed since the image alt text can be modified using the HTML API --- lib/templates/fragments/header.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/templates/fragments/header.php b/lib/templates/fragments/header.php index f7f2fa81..12a5232c 100644 --- a/lib/templates/fragments/header.php +++ b/lib/templates/fragments/header.php @@ -91,15 +91,6 @@ function beans_header_image() { */ function beans_site_branding() { - $name = beans_output( 'beans_site_title_text', get_bloginfo( 'name' ) ); - - if ( $logo = get_theme_mod( 'beans_logo_image', false ) ) - $name = beans_selfclose_markup( 'beans_logo_image', 'img', array( - 'class' => 'tm-logo', - 'src' => $logo, // Automatically escaped. - 'alt' => $name, // Automatically escaped. - ) ); - echo beans_open_markup( 'beans_site_branding', 'div', array( 'class' => 'tm-site-branding uk-float-left' . ( !get_bloginfo( 'description' ) ? ' uk-margin-small-top' : null ), ) ); @@ -110,7 +101,14 @@ function beans_site_branding() { 'itemprop' => 'headline' ) ); - echo $name; + if ( $logo = get_theme_mod( 'beans_logo_image', false ) ) + echo beans_selfclose_markup( 'beans_logo_image', 'img', array( + 'class' => 'tm-logo', + 'src' => $logo, // Automatically escaped. + 'alt' => get_bloginfo( 'name' ), // Automatically escaped. + ) ); + else + echo beans_output( 'beans_site_title_text', get_bloginfo( 'name' ) ); echo beans_close_markup( 'beans_site_title_link', 'a' ); From 201d89172210c75ace18845bd96c2713e7025598 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Mon, 25 Apr 2016 07:57:26 +0200 Subject: [PATCH 28/30] Updated version to 1.3.1-rc2 --- lib/init.php | 2 +- style.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/init.php b/lib/init.php index e2896760..dcd65dd7 100644 --- a/lib/init.php +++ b/lib/init.php @@ -16,7 +16,7 @@ function beans_define_constants() { // Define version. - define( 'BEANS_VERSION', '1.3.1-rc' ); + define( 'BEANS_VERSION', '1.3.1-rc2' ); // Define paths. if ( !defined( 'BEANS_THEME_PATH' ) ) diff --git a/style.css b/style.css index 3d4f700e..6a75668b 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Theme URI: http://www.getbeans.io/themes/beans/ Author: Beans Author URI: http://www.getbeans.io Description: The most innovative theme for WordPress. The real magic is under the hood. -Version: 1.3.1-rc +Version: 1.3.1-rc2 Text Domain: tm-beans Tags: white, light, one-column, two-columns, three-columns, right-sidebar, left-sidebar, responsive-layout, fluid-layout, fixed-layout, custom-header, custom-background, custom-menu, editor-style, featured-images, microformats, post-formats, translation-ready License: GNU General Public License v2 or later From 55dc0a0cb3e672d5818d3e109427ac5cc666b928 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Wed, 27 Apr 2016 09:18:06 +0200 Subject: [PATCH 29/30] Added submenu type and location subfilters. --- lib/render/menu.php | 4 ++-- lib/render/walker.php | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/render/menu.php b/lib/render/menu.php index da749a6b..835c9141 100644 --- a/lib/render/menu.php +++ b/lib/render/menu.php @@ -110,12 +110,12 @@ function beans_modify_menu_args( $args ) { if ( !$attr['class'] ) $attr['class'] = null; - $location_sub_filter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; + $location_subfilter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; // Force beans menu arguments. $force = array( 'beans_type' => $type, - 'items_wrap' => beans_open_markup( "beans_menu[_{$type}]{$location_sub_filter}", 'ul', $attr, $args ) . '%3$s' . beans_close_markup( "beans_menu[_{$type}]{$location_sub_filter}", 'ul', $args ), + 'items_wrap' => beans_open_markup( "beans_menu[_{$type}]{$location_subfilter}", 'ul', $attr, $args ) . '%3$s' . beans_close_markup( "beans_menu[_{$type}]{$location_subfilter}", 'ul', $args ), ); // Allow walker overwrite. diff --git a/lib/render/walker.php b/lib/render/walker.php index 10448f08..a3b2d2fc 100644 --- a/lib/render/walker.php +++ b/lib/render/walker.php @@ -26,6 +26,7 @@ function start_lvl( &$output, $depth = 0, $args = array() ) { return; $type = beans_get( 'beans_type', $args ); + $location_subfilter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; // Default attributes. $attr = array( @@ -44,7 +45,7 @@ function start_lvl( &$output, $depth = 0, $args = array() ) { $attr['data-uk-nav'] = '{multiple:true}'; // Open sub_menu wrap. - $output .= beans_open_markup( 'beans_sub_menu_wrap', 'div', 'class=uk-dropdown uk-dropdown-navbar', $depth, $args ); + $output .= beans_open_markup( "beans_sub_menu_wrap[_{$type}]{$location_subfilter}", 'div', 'class=uk-dropdown uk-dropdown-navbar', $depth, $args ); } @@ -56,7 +57,7 @@ function start_lvl( &$output, $depth = 0, $args = array() ) { $attr['class'] = null; // Open sub_menu. - $output .= beans_open_markup( "beans_sub_menu", 'ul', $attr, $depth, $args ); + $output .= beans_open_markup( "beans_sub_menu[_{$type}]{$location_subfilter}", 'ul', $attr, $depth, $args ); } @@ -72,12 +73,15 @@ function end_lvl( &$output, $depth = 0, $args = array() ) { if ( $depth < $args->beans_start_level ) return; + $type = beans_get( 'beans_type', $args ); + $location_subfilter = ( $location = beans_get( 'theme_location', $args ) ) ? "[_{$location}]" : null; + // Close sub_menu. - $output .= beans_close_markup( "beans_sub_menu[_depth_{$depth}]", 'ul' ); + $output .= beans_close_markup( "beans_sub_menu[_{$type}]{$location_subfilter}", 'ul' ); // Close sub_menu wrap. - if ( beans_get( 'beans_type', $args ) === 'navbar' && $depth === $args->beans_start_level ) - $output .= beans_close_markup( 'beans_sub_menu_wrap', 'div', $depth, $args ); + if ( $type === 'navbar' && $depth === $args->beans_start_level ) + $output .= beans_close_markup( "beans_sub_menu_wrap[_{$type}]{$location_subfilter}", 'div', $depth, $args ); } From 1adbbcbc7d6b543faedc5b95434042da243e46b1 Mon Sep 17 00:00:00 2001 From: ThierryA Date: Thu, 28 Apr 2016 09:21:25 +0200 Subject: [PATCH 30/30] Updated version to 1.3.1 --- lib/init.php | 2 +- style.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/init.php b/lib/init.php index dcd65dd7..33388219 100644 --- a/lib/init.php +++ b/lib/init.php @@ -16,7 +16,7 @@ function beans_define_constants() { // Define version. - define( 'BEANS_VERSION', '1.3.1-rc2' ); + define( 'BEANS_VERSION', '1.3.1' ); // Define paths. if ( !defined( 'BEANS_THEME_PATH' ) ) diff --git a/style.css b/style.css index 6a75668b..01170777 100644 --- a/style.css +++ b/style.css @@ -4,7 +4,7 @@ Theme URI: http://www.getbeans.io/themes/beans/ Author: Beans Author URI: http://www.getbeans.io Description: The most innovative theme for WordPress. The real magic is under the hood. -Version: 1.3.1-rc2 +Version: 1.3.1 Text Domain: tm-beans Tags: white, light, one-column, two-columns, three-columns, right-sidebar, left-sidebar, responsive-layout, fluid-layout, fixed-layout, custom-header, custom-background, custom-menu, editor-style, featured-images, microformats, post-formats, translation-ready License: GNU General Public License v2 or later