diff --git a/lib/class-wp-icons-registry-gutenberg.php b/lib/class-wp-icons-registry-gutenberg.php index 1ba92121c43be8..d7ddc477922c8e 100644 --- a/lib/class-wp-icons-registry-gutenberg.php +++ b/lib/class-wp-icons-registry-gutenberg.php @@ -34,7 +34,7 @@ public function register( $icon_name, $icon_properties ) { return false; } - if ( false === strpos( $icon_name, '/' ) ) { + if ( ! str_contains( $icon_name, '/' ) ) { _doing_it_wrong( __METHOD__, __( 'Icon name must be namespaced in the form "collection/icon-name".', 'gutenberg' ), @@ -289,7 +289,7 @@ function gutenberg_override_wp_icons_registry() { // the `core/` namespace onto the Gutenberg registry so they are not lost. if ( null !== $original_registry ) { foreach ( $original_registry->get_registered_icons() as $icon ) { - if ( strpos( $icon['name'], 'core/' ) === 0 ) { + if ( str_starts_with( $icon['name'], 'core/' ) ) { continue; } $icon_properties = array( 'label' => $icon['label'] ); diff --git a/lib/experimental/knowledge/knowledge.php b/lib/experimental/knowledge/knowledge.php index 687a34b3d2f3c9..3e1507ae81790a 100644 --- a/lib/experimental/knowledge/knowledge.php +++ b/lib/experimental/knowledge/knowledge.php @@ -179,7 +179,7 @@ function wp_knowledge_ensure_default_type_term( int $post_id ): void { return; } - if ( 0 === strpos( $post->post_name, 'guideline-' ) ) { + if ( str_starts_with( $post->post_name, 'guideline-' ) ) { $term_id = wp_knowledge_get_or_create_type_term( 'guideline' ); if ( null !== $term_id ) { wp_set_object_terms( $post_id, $term_id, 'wp_knowledge_type' ); @@ -337,7 +337,7 @@ function wp_knowledge_maybe_map_term_label( array $data, string $taxonomy ): arr * @return string|null Scope key, or null if not a registry scope. */ function wp_guideline_scope_from_slug( string $slug ): ?string { - if ( 0 !== strpos( $slug, 'guideline-' ) || 0 === strpos( $slug, 'guideline-block-' ) ) { + if ( ! str_starts_with( $slug, 'guideline-' ) || str_starts_with( $slug, 'guideline-block-' ) ) { return null; } @@ -383,7 +383,7 @@ function wp_knowledge_guard_guideline_row( $prepared_post, $request ) { // phpcs } } - if ( 0 !== strpos( (string) $slug, 'guideline-' ) ) { + if ( ! str_starts_with( (string) $slug, 'guideline-' ) ) { return $prepared_post; } diff --git a/lib/experimental/rest-api-overrides.php b/lib/experimental/rest-api-overrides.php index 75cd408e353f0a..bddab7fe88cebf 100644 --- a/lib/experimental/rest-api-overrides.php +++ b/lib/experimental/rest-api-overrides.php @@ -32,7 +32,7 @@ function gutenberg_boot_allow_auto_draft_in_rest_api() { foreach ( $post_types as $post_type ) { $supports_editor = post_type_supports( $post_type->name, 'editor' ); $supports_title = post_type_supports( $post_type->name, 'title' ); - $is_wp_core_system = strpos( $post_type->name, 'wp_' ) === 0; + $is_wp_core_system = str_starts_with( $post_type->name, 'wp_' ); $is_attachment = 'attachment' === $post_type->name; // Only add auto-draft to content post types: diff --git a/packages/block-library/src/rss/index.php b/packages/block-library/src/rss/index.php index 5ab990bbcbcee9..c33bafaf762c6c 100644 --- a/packages/block-library/src/rss/index.php +++ b/packages/block-library/src/rss/index.php @@ -97,7 +97,7 @@ function render_block_core_rss( $attributes ) { $excerpt = esc_attr( wp_trim_words( $excerpt, $attributes['excerptLength'], ' […]' ) ); // Change existing [...] to […]. - if ( '[...]' === substr( $excerpt, -5 ) ) { + if ( str_ends_with( $excerpt, '[...]' ) ) { $excerpt = substr( $excerpt, 0, -5 ) . '[…]'; }