From ef30cc89a8efe5589ebbbf1abf8d702a8fe749cb Mon Sep 17 00:00:00 2001 From: Knut Sparhell Date: Sat, 13 May 2023 11:56:49 +0200 Subject: [PATCH] Do not save type when string By declaring 'string' as the default and saving the type only when not the default, the number of extra table rows may be acceptable. --- functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions.php b/functions.php index f672944..b2059d7 100644 --- a/functions.php +++ b/functions.php @@ -60,7 +60,7 @@ function update_option( string $option, $value, $autoload = null, ?string $type } $upd = \update_option( $option, $value, $autoload ); - if ( $upd && ! \str_contains( $type, 'str' ) ) { + if ( $upd && ! \str_starts_with( $type, 'str' ) ) { \update_option( $type_prefix . $option, $type, $autoload ); } return (bool) $upd; @@ -98,7 +98,7 @@ function add_term_meta( int $term_id, string $meta_key, $meta_value, bool $uniqu } $res = \add_term_meta( $term_id, $meta_key, $meta_value ); - if ( $no_pre && ! \is_wp_error( $res ) && ! \str_contains( $type, 'str' ) ) { + if ( $no_pre && ! \is_wp_error( $res ) && ! \str_starts_with( $type, 'str' ) ) { \update_term_meta( $term_id, $type_prefix . $meta_key, $type ); } return $res; @@ -117,7 +117,7 @@ function update_term_meta( int $term_id, string $meta_key, $meta_value, ?string } $res = \update_term_meta( $term_id, $meta_key, $meta_value, $prev_value ); - if ( ! \is_wp_error( $res ) && ! \str_contains( $type, 'str' ) ) { + if ( ! \is_wp_error( $res ) && ! \str_starts_with( $type, 'str' ) ) { \update_term_meta( $term_id, $type_prefix . $meta_key, $type ); } return $res;