Skip to content

Commit

Permalink
Make sure the index is defined and provide a fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
eliorivero committed Jan 20, 2017
1 parent 1bc9bba commit fe0680a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions _inc/lib/admin-pages/class.jetpack-react-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ function page_admin_scripts() {

// Get last post, to build the link to Customizer in the Related Posts module.
$last_post = get_posts( array( 'posts_per_page' => 1 ) );
if ( $last_post[0] instanceof WP_Post ) {
$last_post = get_permalink( $last_post[0]->ID );
}
$last_post = isset( $last_post[0] ) && $last_post[0] instanceof WP_Post
? get_permalink( $last_post[0]->ID )
: $last_post = get_home_url();

// Add objects to be passed to the initial state of the app
wp_localize_script( 'react-plugin', 'Initial_State', array(
Expand Down

0 comments on commit fe0680a

Please sign in to comment.