Skip to content

Commit

Permalink
Merge pull request #37 from tordans/prevent_notice
Browse files Browse the repository at this point in the history
Prevent notice about $post being a "non-object"
  • Loading branch information
chuckreynolds committed Aug 15, 2014
2 parents 67731eb + eb44ced commit f8f70e2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion wp-facebook-ogp.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ function wpfbogp_namespace($output) {
// function to call first uploaded image in content
function wpfbogp_find_images() {
global $post, $posts;


if( !is_object($post) || get_class($post) != 'WP_Post' ) {
return array();
}

// Grab content and match first image
$content = $post->post_content;
$output = preg_match_all( '/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches );
Expand Down Expand Up @@ -96,6 +100,11 @@ function wpfbogp_flush_ob() {
// build ogp meta
function wpfbogp_build_head() {
global $post;

if( !is_object($post) || get_class($post) != 'WP_Post' ) {
return '';
}

$options = get_option('wpfbogp');
// check to see if you've filled out one of the required fields and announce if not
if ( ( ! isset( $options['wpfbogp_admin_ids'] ) || empty( $options['wpfbogp_admin_ids'] ) ) && ( ! isset( $options['wpfbogp_app_id'] ) || empty( $options['wpfbogp_app_id'] ) ) ) {
Expand Down

0 comments on commit f8f70e2

Please sign in to comment.