diff --git a/lib/block-supports/duotone.php b/lib/block-supports/duotone.php index d12582b6a768cc..5cb7fb7cfc5ac6 100644 --- a/lib/block-supports/duotone.php +++ b/lib/block-supports/duotone.php @@ -16,14 +16,14 @@ * @return float Value in the range [0,1]. */ function gutenberg_tinycolor_bound01( $n, $max ) { - if ( 'string' === gettype( $n ) && false !== strpos( $n, '.' ) && 1 === (float) $n ) { + if ( 'string' === gettype( $n ) && str_contains( $n, '.' ) && 1 === (float) $n ) { $n = '100%'; } $n = min( $max, max( 0, (float) $n ) ); // Automatically convert percentage into number. - if ( 'string' === gettype( $n ) && false !== strpos( $n, '%' ) ) { + if ( 'string' === gettype( $n ) && str_contains( $n, '%' ) ) { $n = (int) ( $n * $max ) / 100; } diff --git a/lib/block-supports/elements.php b/lib/block-supports/elements.php index 47c12dc9dcbb3e..0b6e31db3d66d3 100644 --- a/lib/block-supports/elements.php +++ b/lib/block-supports/elements.php @@ -58,7 +58,7 @@ function gutenberg_render_elements_support( $block_content, $block ) { $first_element = $html_element_matches[0][0]; // If the first HTML element has a class attribute just add the new class // as we do on layout and duotone. - if ( strpos( $first_element, 'class="' ) !== false ) { + if ( str_contains( $first_element, 'class="' ) ) { $content = preg_replace( '/' . preg_quote( 'class="', '/' ) . '/', 'class="' . $class_name . ' ', diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index 990e78996e045e..7047b4a3a28f0f 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -106,7 +106,7 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support } if ( $gap_value && ! $should_skip_gap_serialization ) { // Get spacing CSS variable from preset value if provided. - if ( is_string( $gap_value ) && strpos( $gap_value, 'var:preset|spacing|' ) !== false ) { + if ( is_string( $gap_value ) && str_contains( $gap_value, 'var:preset|spacing|' ) ) { $index_to_splice = strrpos( $gap_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $gap_value, $index_to_splice ) ); $gap_value = "var(--wp--preset--spacing--$slug)"; @@ -164,7 +164,7 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support foreach ( $gap_sides as $gap_side ) { $process_value = is_string( $gap_value ) ? $gap_value : _wp_array_get( $gap_value, array( $gap_side ), $fallback_gap_value ); // Get spacing CSS variable from preset value if provided. - if ( is_string( $process_value ) && strpos( $process_value, 'var:preset|spacing|' ) !== false ) { + if ( is_string( $process_value ) && str_contains( $process_value, 'var:preset|spacing|' ) ) { $index_to_splice = strrpos( $process_value, '|' ) + 1; $slug = _wp_to_kebab_case( substr( $process_value, $index_to_splice ) ); $process_value = "var(--wp--preset--spacing--$slug)"; diff --git a/lib/block-supports/typography.php b/lib/block-supports/typography.php index 8cfeda2b0641b5..6cfae5b8cf07eb 100644 --- a/lib/block-supports/typography.php +++ b/lib/block-supports/typography.php @@ -171,7 +171,7 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) { */ function gutenberg_typography_get_preset_inline_style_value( $style_value, $css_property ) { // If the style value is not a preset CSS variable go no further. - if ( empty( $style_value ) || strpos( $style_value, "var:preset|{$css_property}|" ) === false ) { + if ( empty( $style_value ) || ! str_contains( $style_value, "var:preset|{$css_property}|" ) ) { return $style_value; } @@ -209,7 +209,7 @@ function gutenberg_typography_get_css_variable_inline_style( $attributes, $featu } // If we don't have a preset CSS variable, we'll assume it's a regular CSS value. - if ( strpos( $style_value, "var:preset|{$css_property}|" ) === false ) { + if ( ! str_contains( $style_value, "var:preset|{$css_property}|" ) ) { return sprintf( '%s:%s;', $css_property, $style_value ); } diff --git a/lib/compat/wordpress-6.1/get-global-styles-and-settings.php b/lib/compat/wordpress-6.1/get-global-styles-and-settings.php index 5dd950c627a641..32fde3442577b8 100644 --- a/lib/compat/wordpress-6.1/get-global-styles-and-settings.php +++ b/lib/compat/wordpress-6.1/get-global-styles-and-settings.php @@ -33,7 +33,7 @@ function wp_add_global_styles_for_blocks() { array_filter( $metadata['path'], function ( $item ) { - if ( strpos( $item, 'core/' ) !== false ) { + if ( str_contains( $item, 'core/' ) ) { return true; } return false; diff --git a/lib/experimental/class-wp-webfonts-provider-local.php b/lib/experimental/class-wp-webfonts-provider-local.php index a8c4fa7968961f..9af27fa7c436a7 100644 --- a/lib/experimental/class-wp-webfonts-provider-local.php +++ b/lib/experimental/class-wp-webfonts-provider-local.php @@ -185,9 +185,9 @@ private function build_font_face_css( array $webfont ) { // Wrap font-family in quotes if it contains spaces. if ( - false !== strpos( $webfont['font-family'], ' ' ) && - false === strpos( $webfont['font-family'], '"' ) && - false === strpos( $webfont['font-family'], "'" ) + str_contains( $webfont['font-family'], ' ' ) && + ! str_contains( $webfont['font-family'], '"' ) && + ! str_contains( $webfont['font-family'], "'" ) ) { $webfont['font-family'] = '"' . $webfont['font-family'] . '"'; } diff --git a/packages/block-library/src/calendar/index.php b/packages/block-library/src/calendar/index.php index 9225a6dceb4887..8f6226e943480c 100644 --- a/packages/block-library/src/calendar/index.php +++ b/packages/block-library/src/calendar/index.php @@ -30,8 +30,8 @@ function render_block_core_calendar( $attributes ) { if ( isset( $attributes['month'] ) && isset( $attributes['year'] ) ) { $permalink_structure = get_option( 'permalink_structure' ); if ( - strpos( $permalink_structure, '%monthnum%' ) !== false && - strpos( $permalink_structure, '%year%' ) !== false + str_contains( $permalink_structure, '%monthnum%' ) && + str_contains( $permalink_structure, '%year%' ) ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited $monthnum = $attributes['month']; diff --git a/packages/block-library/src/image/index.php b/packages/block-library/src/image/index.php index 70fa3a0a303793..9a9f175556e814 100644 --- a/packages/block-library/src/image/index.php +++ b/packages/block-library/src/image/index.php @@ -20,7 +20,7 @@ function render_block_core_image( $attributes, $content ) { // which now wraps Image Blocks within innerBlocks. // The data-id attribute is added in a core/gallery `render_block_data` hook. $data_id_attribute = 'data-id="' . esc_attr( $attributes['data-id'] ) . '"'; - if ( false === strpos( $content, $data_id_attribute ) ) { + if ( ! str_contains( $content, $data_id_attribute ) ) { $content = str_replace( ' $value ) { - if ( is_string( $value ) && strpos( $value, 'var:' ) !== false && ! $should_skip_css_vars && ! empty( $style_definition['css_vars'] ) ) { + if ( is_string( $value ) && str_contains( $value, 'var:' ) && ! $should_skip_css_vars && ! empty( $style_definition['css_vars'] ) ) { $value = static::get_css_var_value( $value, $style_definition['css_vars'] ); } @@ -464,7 +464,7 @@ protected static function get_individual_property_css_declarations( $style_value if ( $style_definition && isset( $style_definition['property_keys']['individual'] ) ) { // Set a CSS var if there is a valid preset value. - if ( is_string( $value ) && strpos( $value, 'var:' ) !== false && ! $should_skip_css_vars && ! empty( $individual_property_definition['css_vars'] ) ) { + if ( is_string( $value ) && str_contains( $value, 'var:' ) && ! $should_skip_css_vars && ! empty( $individual_property_definition['css_vars'] ) ) { $value = static::get_css_var_value( $value, $individual_property_definition['css_vars'] ); } $individual_css_property = sprintf( $style_definition['property_keys']['individual'], $individual_property_key );