diff --git a/lib/admin/wp-customize.php b/lib/admin/wp-customize.php index 7cd1fba0..a7196b96 100644 --- a/lib/admin/wp-customize.php +++ b/lib/admin/wp-customize.php @@ -16,10 +16,16 @@ * @return void */ function beans_do_enqueue_wp_customize_assets() { - wp_enqueue_script( 'beans-wp-customize-preview', BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', array( - 'jquery', - 'customize-preview', - ), BEANS_VERSION, true ); + wp_enqueue_script( + 'beans-wp-customize-preview', + BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', + array( + 'jquery', + 'customize-preview', + ), + BEANS_VERSION, + true + ); } beans_add_smart_action( 'customize_register', 'beans_do_register_wp_customize_options' ); diff --git a/lib/api/compiler/class-beans-compiler.php b/lib/api/compiler/class-beans-compiler.php index 50d47c5a..d99c263f 100644 --- a/lib/api/compiler/class-beans-compiler.php +++ b/lib/api/compiler/class-beans-compiler.php @@ -164,7 +164,7 @@ private function is_wp_filesystem_direct() { */ private function maybe_make_dir() { - if ( ! @is_dir( $this->dir ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- This is a valid use case. + if ( ! @is_dir( $this->dir ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- This is a valid use case. wp_mkdir_p( $this->dir ); } @@ -224,7 +224,7 @@ public function set_filename() { * @return string */ public function hash( array $given_array ) { - return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. + return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. } /** @@ -432,7 +432,7 @@ public function get_internal_content() { $fragment = beans_url_to_path( $fragment ); // Stop here if it isn't a valid file. - if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. return false; } } @@ -686,7 +686,7 @@ private function get_fragments_filemtime() { } if ( file_exists( $fragment ) ) { - $fragments_filemtime[ $index ] = @filemtime( $fragment ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + $fragments_filemtime[ $index ] = @filemtime( $fragment ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } @@ -742,7 +742,7 @@ private function remove_modified_files( $hash, $filemtime_hash ) { foreach ( $items as $item ) { // Skip this one if it's a directory. - if ( @is_dir( $item ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + if ( @is_dir( $item ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. continue; } @@ -769,7 +769,7 @@ private function remove_modified_files( $hash, $filemtime_hash ) { } // Clean up other modified files. - @unlink( $this->dir . '/' . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + @unlink( $this->dir . '/' . $item ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } @@ -844,26 +844,38 @@ private function kill() { $this->report(); } - $html = beans_output( 'beans_compiler_error_title_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).', '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).', 'tm-beans' ) + ) + ); - $html .= beans_output( 'beans_compiler_error_contact_text', sprintf( - '%s', - __( 'Contact Beans Support', 'tm-beans' ) - ) ); + $html .= beans_output( + 'beans_compiler_error_contact_text', + sprintf( + '%s', + __( 'Contact Beans Support', 'tm-beans' ) + ) + ); - $html .= beans_output( 'beans_compiler_error_report_text', sprintf( - '%1$s. %2$s
', - __( 'Send us an automatic report', 'tm-beans' ), - __( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' ) - ) ); + $html .= beans_output( + 'beans_compiler_error_report_text', + sprintf( + '%1$s. %2$s
', + __( '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( wp_kses_post( $html ) ); } diff --git a/lib/api/compiler/class-beans-page-compiler.php b/lib/api/compiler/class-beans-page-compiler.php index 2ee3150b..a8f18e98 100644 --- a/lib/api/compiler/class-beans-page-compiler.php +++ b/lib/api/compiler/class-beans-page-compiler.php @@ -108,10 +108,14 @@ public function compile_page_scripts() { $this->dequeued_scripts = $scripts; add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 ); - beans_compile_js_fragments( 'beans', $scripts, array( - 'in_footer' => 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ), - 'version' => null, - ) ); + beans_compile_js_fragments( + 'beans', + $scripts, + array( + 'in_footer' => 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ), + 'version' => null, + ) + ); } /** diff --git a/lib/api/compiler/functions.php b/lib/api/compiler/functions.php index 9c3ffb27..9e6c5b3a 100644 --- a/lib/api/compiler/functions.php +++ b/lib/api/compiler/functions.php @@ -217,7 +217,7 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) { foreach ( beans_scandir( $dir ) as $item ) { if ( beans_str_ends_with( $item, ".{$file_format}" ) ) { - @unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + @unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } } } diff --git a/lib/api/fields/class-beans-fields.php b/lib/api/fields/class-beans-fields.php index cedb6e17..99a71603 100644 --- a/lib/api/fields/class-beans-fields.php +++ b/lib/api/fields/class-beans-fields.php @@ -129,14 +129,17 @@ private function add() { * @return array */ private function standardize_field( array $field ) { - $field = array_merge( array( - 'label' => false, - 'description' => false, - 'default' => false, - 'context' => $this->context, - 'attributes' => array(), - 'db_group' => false, - ), $field ); + $field = array_merge( + array( + 'label' => false, + 'description' => false, + 'default' => false, + 'context' => $this->context, + 'attributes' => array(), + 'db_group' => false, + ), + $field + ); // Set the field's name. $field['name'] = 'wp_customize' === $this->context ? $field['id'] : 'beans_fields[' . $field['id'] . ']'; diff --git a/lib/api/fields/functions.php b/lib/api/fields/functions.php index 1e23e5d3..31bda0a5 100644 --- a/lib/api/fields/functions.php +++ b/lib/api/fields/functions.php @@ -98,9 +98,14 @@ function beans_field( array $field ) { $group_field_type = 'group' === $field['type']; - beans_open_markup_e( 'beans_field_wrap', 'div', array( - 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], - ), $field ); + beans_open_markup_e( + 'beans_field_wrap', + 'div', + array( + 'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'], + ), + $field + ); // Set fields loop to cater for groups. if ( $group_field_type ) { @@ -109,26 +114,46 @@ function beans_field( array $field ) { $fields = array( $field ); } - beans_open_markup_e( 'beans_field_inside', 'div', array( - 'class' => 'bs-field-inside', - ), $fields ); + beans_open_markup_e( + 'beans_field_inside', + 'div', + array( + 'class' => 'bs-field-inside', + ), + $fields + ); if ( $group_field_type ) { - beans_open_markup_e( 'beans_field_group_fieldset', 'fieldset', array( - 'class' => 'bs-field-fieldset', - ), $field ); - beans_open_markup_e( 'beans_field_group_legend', 'legend', array( - 'class' => 'bs-field-legend', - ), $field ); + beans_open_markup_e( + 'beans_field_group_fieldset', + 'fieldset', + array( + 'class' => 'bs-field-fieldset', + ), + $field + ); + beans_open_markup_e( + 'beans_field_group_legend', + 'legend', + array( + 'class' => 'bs-field-legend', + ), + $field + ); echo esc_html( $field['label'] ); beans_close_markup_e( 'beans_field_group_legend', 'legend', $field ); } // Loop through fields. foreach ( $fields as $single_field ) { - beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array( - 'class' => 'bs-field bs-' . $single_field['type'], - ), $single_field ); + beans_open_markup_e( + 'beans_field[_' . $single_field['id'] . ']', + 'div', + array( + 'class' => 'bs-field bs-' . $single_field['type'], + ), + $single_field + ); if ( $group_field_type ) { /** diff --git a/lib/api/fields/types/image.php b/lib/api/fields/types/image.php index 6866aa52..6c3dfe9c 100644 --- a/lib/api/fields/types/image.php +++ b/lib/api/fields/types/image.php @@ -63,12 +63,15 @@ function beans_field_image( array $field ) { * @return array */ function _beans_get_image_id_attributes( $id, array $field, $is_multiple ) { - $attributes = array_merge( array( - 'class' => 'image-id', - 'type' => 'hidden', - 'name' => $is_multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple. - 'value' => $id, - ), $field['attributes'] ); + $attributes = array_merge( + array( + 'class' => 'image-id', + 'type' => 'hidden', + 'name' => $is_multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple. + 'value' => $id, + ), + $field['attributes'] + ); if ( 'placeholder' === $id ) { $attributes = array_merge( diff --git a/lib/api/fields/types/radio.php b/lib/api/fields/types/radio.php index d9e936fa..554f7785 100644 --- a/lib/api/fields/types/radio.php +++ b/lib/api/fields/types/radio.php @@ -84,11 +84,14 @@ function _beans_standardize_radio_image( $value, $radio ) { ); } - $radio = array_merge( array( - 'src' => '', - 'alt' => '', - 'screen_reader_text' => '', - ), $radio ); + $radio = array_merge( + array( + 'src' => '', + 'alt' => '', + 'screen_reader_text' => '', + ), + $radio + ); if ( $radio['screen_reader_text'] && $radio['alt'] ) { return $radio; diff --git a/lib/api/fields/types/text.php b/lib/api/fields/types/text.php index ebad377a..15325b8a 100644 --- a/lib/api/fields/types/text.php +++ b/lib/api/fields/types/text.php @@ -22,7 +22,8 @@ * } */ function beans_field_text( array $field ) { - printf( '', + printf( + '', esc_attr( $field['id'] ), esc_attr( $field['name'] ), esc_attr( $field['value'] ), diff --git a/lib/api/fields/types/textarea.php b/lib/api/fields/types/textarea.php index 543495f8..c6bd640a 100644 --- a/lib/api/fields/types/textarea.php +++ b/lib/api/fields/types/textarea.php @@ -22,10 +22,12 @@ * } */ function beans_field_textarea( array $field ) { - printf( '', + printf( + '', esc_attr( $field['id'] ), esc_attr( $field['name'] ), - beans_esc_attributes( $field['attributes'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function. + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function. + beans_esc_attributes( $field['attributes'] ), esc_textarea( $field['value'] ) ); } diff --git a/lib/api/image/class-beans-image-editor.php b/lib/api/image/class-beans-image-editor.php index b80eeb96..2e1088b9 100644 --- a/lib/api/image/class-beans-image-editor.php +++ b/lib/api/image/class-beans-image-editor.php @@ -1,4 +1,4 @@ -grebuilt_path ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case. + list( $width, $height ) = @getimagesize( $this->rebuilt_path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case. } else { $width = null; $height = null; @@ -165,7 +165,7 @@ private function get_image_info( $src, $edited_image_exists = false ) { private function rebuild_image_path() { $upload_dir = beans_get_images_dir(); $info = pathinfo( preg_replace( '#\?.*#', '', $this->src ) ); - $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. + $query = substr( md5( @serialize( $this->args ) ), 0, 7 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case. $extension = $info['extension']; $filename = str_replace( '.' . $extension, '', $info['basename'] ); diff --git a/lib/api/image/class-beans-image-options.php b/lib/api/image/class-beans-image-options.php index ca2e97b4..d93e671c 100644 --- a/lib/api/image/class-beans-image-options.php +++ b/lib/api/image/class-beans-image-options.php @@ -44,7 +44,8 @@ public function register() { return beans_register_options( $this->get_fields_to_register(), 'beans_settings', - 'images_options', array( + 'images_options', + array( 'title' => __( 'Images options', 'tm-beans' ), 'context' => $this->has_metaboxes() ? 'column' : 'normal', ) diff --git a/lib/api/layout/functions.php b/lib/api/layout/functions.php index d1028f16..baa36da7 100644 --- a/lib/api/layout/functions.php +++ b/lib/api/layout/functions.php @@ -103,12 +103,15 @@ function beans_get_layout_class( $id ) { * @type string $breakpoint The UIkit grid breakpoint which may be set to 'small', 'medium' or 'large'. Default 'medium'. * } */ - $args = apply_filters( 'beans_layout_grid_settings', array( - 'grid' => 4, - 'sidebar_primary' => 1, - 'sidebar_secondary' => 1, - 'breakpoint' => 'medium', - ) ); + $args = apply_filters( + 'beans_layout_grid_settings', + array( + 'grid' => 4, + 'sidebar_primary' => 1, + 'sidebar_secondary' => 1, + 'breakpoint' => 'medium', + ) + ); /** * Filter the layout class. @@ -276,13 +279,16 @@ function beans_get_layouts_for_options( $add_default = false ) { return $layouts; } - $layouts = array_merge( array( - 'default_fallback' => sprintf( - // translators: The (%s) placeholder is for the "Modify" hyperlink. - __( 'Use Default Layout (%s)', 'tm-beans' ), - '' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '' + $layouts = array_merge( + array( + 'default_fallback' => sprintf( + // translators: The (%s) placeholder is for the "Modify" hyperlink. + __( 'Use Default Layout (%s)', 'tm-beans' ), + '' . _x( 'Modify', 'Default layout', 'tm-beans' ) . '' + ), ), - ), $layouts ); + $layouts + ); return $layouts; } diff --git a/lib/api/template/functions.php b/lib/api/template/functions.php index 77f871d5..9dd04a89 100644 --- a/lib/api/template/functions.php +++ b/lib/api/template/functions.php @@ -137,7 +137,8 @@ function beans_comment_callback( $comment, array $args, $depth ) { // Render the opening