Skip to content

Commit

Permalink
Merge pull request #360 from michael-sumner/trunk
Browse files Browse the repository at this point in the history
Fix Possible NULL Value of `duplicate_post_taxonomies_blacklist`
  • Loading branch information
enricobattocchi authored Mar 22, 2024
2 parents 3d28586 + f9a33fe commit 9ab8957
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,13 @@ function duplicate_post_plugin_upgrade() {
);
add_option( 'duplicate_post_show_link_in', $show_links_in_defaults );

$taxonomies_blacklist = get_option( 'duplicate_post_taxonomies_blacklist' );
if ( $taxonomies_blacklist === '' ) {
$taxonomies_blacklist = get_option( 'duplicate_post_taxonomies_blacklist', [] );
if ( empty( $taxonomies_blacklist ) ) {
$taxonomies_blacklist = [];
}
elseif ( ! is_array( $taxonomies_blacklist ) ) {
$taxonomies_blacklist = [ $taxonomies_blacklist ];
}
if ( in_array( 'post_format', $taxonomies_blacklist, true ) ) {
update_option( 'duplicate_post_copyformat', 0 );
$taxonomies_blacklist = array_diff( $taxonomies_blacklist, [ 'post_format' ] );
Expand Down Expand Up @@ -293,10 +296,13 @@ function duplicate_post_copy_post_taxonomies( $new_id, $post ) {
$post_taxonomies[] = 'post_format';
}

$taxonomies_blacklist = get_option( 'duplicate_post_taxonomies_blacklist' );
if ( $taxonomies_blacklist === '' ) {
$taxonomies_blacklist = get_option( 'duplicate_post_taxonomies_blacklist', [] );
if ( empty( $taxonomies_blacklist ) ) {
$taxonomies_blacklist = [];
}
elseif ( ! is_array( $taxonomies_blacklist ) ) {
$taxonomies_blacklist = [ $taxonomies_blacklist ];
}
if ( intval( get_option( 'duplicate_post_copyformat' ) ) === 0 ) {
$taxonomies_blacklist[] = 'post_format';
}
Expand Down

0 comments on commit 9ab8957

Please sign in to comment.