Skip to content

Commit

Permalink
fix php notices (fixes #1350)
Browse files Browse the repository at this point in the history
  • Loading branch information
aschweigert committed Mar 3, 2017
1 parent 5f0ba34 commit 78865d0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions inc/featured-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ function largo_get_featured_media( $post = null ) {

$post = get_post( $post );

// make sure we actually have a valid post object before we try to get post meta
if ( ! is_object( $post ) ) {
return;
}

$ret = get_post_meta( $post->ID, 'featured_media', true );

// Check if the post has a thumbnail/featured image set.
Expand Down Expand Up @@ -266,13 +271,18 @@ function largo_enqueue_featured_media_js( $hook ) {
// Run this action on term edit pages
// edit-tags.php for wordpress before 4.5
// term.php for 4.5 and after
if ( in_array( $hook, array( 'edit-tags.php', 'term.php' ) ) && is_numeric( $_GET['tag_ID'] ) ) {
if ( in_array( $hook, array( 'edit-tags.php', 'term.php' ) ) && isset( $_GET['tag_ID'] ) && is_numeric( $_GET['tag_ID'] ) ) {
// After WordPress 4.5, the taxonomy is no longer in the URL
// So to compensate, we get the taxonomy from the current screen
$screen = get_current_screen();
$post = get_post( largo_get_term_meta_post( $screen->taxonomy, $_GET['tag_ID'] ) );
}

// make sure we actually have a valid post object before we try to get post meta
if ( ! is_object( $post ) ) {
return;
}

$featured_image_display = get_post_meta( $post->ID, 'featured-image-display', true );

// The scripts following depend upon the WordPress media APIs
Expand Down Expand Up @@ -454,7 +464,7 @@ function largo_featured_image_metabox_callback( $post, $metabox ) {

$checked = 'false' == get_post_meta( $post->ID, 'featured-image-display', true ) ? 'checked="checked"' : "";
echo wp_nonce_field( basename( __FILE__ ), 'featured_image_display_nonce' );

echo '<a href="#" class="set-featured-media">' . get_the_post_thumbnail() . '</a>';
echo '<a href="#" id="set-featured-media-button" class="button set-featured-media add_media" data-editor="content" title="' . __( $language . ' Featured Media', 'largo' ) . '"></span> ' . __( $language . ' Featured Media', 'largo' ) . '</a> <span class="spinner" style="display: none;"></span>';

Expand Down Expand Up @@ -707,7 +717,7 @@ function largo_content_partial_arguments_filter( $args, $queried_object ) {
* 'right_region' => 'sidebar-main',
* 'per_page' => '10',
* 'post_order' => 'DESC',
* 'show' =>
* 'show' =>
* array (
* 'image' => false,
* 'excerpt' => false,
Expand Down

0 comments on commit 78865d0

Please sign in to comment.