Skip to content

Commit

Permalink
Do not save type when string
Browse files Browse the repository at this point in the history
By declaring 'string' as the default and saving the type only when not the default, the number of extra table rows may be acceptable.
  • Loading branch information
knutsp authored May 13, 2023
1 parent 5ccfca6 commit ef30cc8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit ef30cc8

Please sign in to comment.