Skip to content

Commit

Permalink
React to any errors coming up in gutenberg_migrate_menu_to_navigation…
Browse files Browse the repository at this point in the history
…_post (#36461)

* React to any errors coming up in gutenberg_migrate_menu_to_navigation_post

* Lint

* Update lib/navigation.php

Co-authored-by: Dave Smith <getdavemail@gmail.com>

Co-authored-by: Dave Smith <getdavemail@gmail.com>
  • Loading branch information
2 people authored and noisysocks committed Nov 15, 2021
1 parent 9a1dd34 commit c545f20
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ function gutenberg_migrate_menu_to_navigation_post( $new_name, $new_theme, $old_
'post_status' => $post_status,
);
$navigation_post_id = wp_insert_post( $post_data );
// If wp_insert_post fails *at any time*, then bale out of the entire
// migration attempt returning the WP_Error object.
if ( is_wp_error( $navigation_post_id ) ) {
return $navigation_post_id;
}
}

$area_mapping[ $location_name ] = $navigation_post_id;
Expand All @@ -280,7 +285,7 @@ function gutenberg_migrate_menu_to_navigation_post( $new_name, $new_theme, $old_
update_option( 'wp_navigation_areas', $area_mapping );
}

add_action( 'switch_theme', 'gutenberg_migrate_menu_to_navigation_post', 200, 3 );
add_action( 'switch_theme', 'gutenberg_migrate_menu_to_navigation_post', 99, 3 );

/**
* Retrieves navigation areas.
Expand Down

0 comments on commit c545f20

Please sign in to comment.