Exemplo n.º 1
0
 public function filter_check_head_meta_options($check_opts, $post_id)
 {
     foreach (SucomUtil::preg_grep_keys('/^meta_name_twitter:/', $check_opts) as $key => $val) {
         unset($check_opts[$key]);
     }
     return $check_opts;
 }
Exemplo n.º 2
0
 public function filter_sharing_preset_rows($rows, $form)
 {
     $presets = array();
     foreach (SucomUtil::preg_grep_keys('/^buttons_preset_/', $this->p->options, false, '') as $key => $val) {
         $presets[$key] = ucwords(preg_replace('/_/', ' ', $key));
     }
     asort($presets);
     $rows[] = '<td colspan="2" align="center">' . $this->p->msgs->get('pro-feature-msg', array('lca' => 'ngfb')) . '</td>';
     foreach ($presets as $filter_id => $filter_name) {
         $rows[] = $this->p->util->th($filter_name . ' Preset', null, 'sharing_preset') . '<td class="blank">' . $form->get_hidden('buttons_preset_' . $filter_id) . $this->p->options['buttons_preset_' . $filter_id] . '</td>';
     }
     return $rows;
 }
Exemplo n.º 3
0
 public function add_header()
 {
     // add various function test results top-most in the debug log
     // hook into ngfb_is_functions to extend the default array of function names
     if ($this->p->debug->is_on()) {
         $is_functions = array('is_author', 'is_archive', 'is_category', 'is_tag', 'is_tax', 'is_home', 'is_search', 'is_singular', 'is_attachment', 'is_product', 'is_product_category', 'is_product_tag');
         $is_functions = apply_filters($this->p->cf['lca'] . '_is_functions', $is_functions);
         foreach ($is_functions as $function) {
             if (function_exists($function) && $function()) {
                 $this->p->debug->log($function . '() = true');
             }
         }
     }
     if ($this->p->is_avail['metatags']) {
         echo $this->get_header_html();
     } else {
         echo "\n<!-- " . $this->p->cf['lca'] . " meta tags are disabled -->\n";
     }
     // include additional information when debug mode is on
     if ($this->p->debug->is_on()) {
         $defined_constants = get_defined_constants(true);
         $defined_constants['user']['NGFB_NONCE'] = '********';
         $this->p->debug->show_html(SucomUtil::preg_grep_keys('/^NGFB_/', $defined_constants['user']), 'ngfb constants');
         $opts = $this->p->options;
         foreach ($opts as $key => $val) {
             switch (true) {
                 case strpos($key, 'buttons_css_') !== false:
                 case strpos($key, 'buttons_js_') !== false:
                 case preg_match('/_key$/', $key):
                 case $key === 'plugin_tid':
                     $opts[$key] = '********';
             }
         }
         $this->p->debug->show_html(print_r($this->p->is_avail, true), 'available features');
         $this->p->debug->show_html(print_r($this->p->check->get_active(), true), 'active plugins');
         $this->p->debug->show_html(null, 'debug log');
         $this->p->debug->show_html($opts, 'ngfb settings');
         if (($obj = $this->p->util->get_post_object()) !== false) {
             $post_id = empty($obj->ID) ? 0 : $obj->ID;
             if (!empty($post_id) && isset($this->p->addons['util']['postmeta'])) {
                 $post_opts = $this->p->addons['util']['postmeta']->get_options($post_id);
                 $this->p->debug->show_html($post_opts, 'ngfb post_id ' . $post_id . ' custom settings');
             }
         }
     }
 }
Exemplo n.º 4
0
 public function add_header()
 {
     $lca = $this->p->cf['lca'];
     if ($this->p->debug->enabled) {
         $this->p->util->log_is_functions();
     }
     if ($this->p->is_avail['metatags']) {
         echo $this->get_header_html(apply_filters($lca . '_header_use_post', false));
     } else {
         echo "\n<!-- " . $lca . " meta tags disabled -->\n";
     }
     // include additional information when debug mode is on
     if ($this->p->debug->enabled) {
         // show debug log
         $this->p->debug->show_html(null, 'debug log');
         // show constants
         $defined_constants = get_defined_constants(true);
         $defined_constants['user']['NGFB_NONCE'] = '********';
         if (is_multisite()) {
             $this->p->debug->show_html(SucomUtil::preg_grep_keys('/^(MULTISITE|^SUBDOMAIN_INSTALL|.*_SITE)$/', $defined_constants['user']), 'multisite constants');
         }
         $this->p->debug->show_html(SucomUtil::preg_grep_keys('/^NGFB_/', $defined_constants['user']), 'ngfb constants');
         // show active plugins
         $this->p->debug->show_html(print_r(NgfbUtil::active_plugins(), true), 'active plugins');
         // show available modules
         $this->p->debug->show_html(print_r($this->p->is_avail, true), 'available features');
         // show all plugin options
         $opts = $this->p->options;
         foreach ($opts as $key => $val) {
             switch (true) {
                 case strpos($key, '_html') !== false:
                 case strpos($key, '_css_') !== false:
                 case strpos($key, '_js_') !== false:
                 case preg_match('/_(key|tid)$/', $key):
                     $opts[$key] = '********';
             }
         }
         $this->p->debug->show_html($opts, 'ngfb settings');
     }
     // end of debug information
 }
Exemplo n.º 5
0
 public function check_post_header($post_id = true, &$obj = false)
 {
     if (empty($this->p->options['plugin_check_head'])) {
         return $post_id;
     }
     if (!is_object($obj) && ($obj = $this->p->util->get_post_object($post_id)) === false) {
         return $post_id;
     }
     // only check publicly available posts
     if (!isset($obj->post_status) || $obj->post_status !== 'publish') {
         return $post_id;
     }
     // only check registered front-end post types (to avoid menu items, product variations, etc.)
     $ptns = $this->p->util->get_post_types('names');
     if (empty($obj->post_type) || !in_array($obj->post_type, $ptns)) {
         return $post_id;
     }
     $charset = get_bloginfo('charset');
     $permalink = get_permalink($post_id);
     $permalink_html = wp_encode_emoji(htmlentities(urldecode($permalink), ENT_QUOTES, $charset, false));
     // double_encode = false
     $permalink_no_meta = add_query_arg(array('NGFB_META_TAGS_DISABLE' => 1), $permalink);
     $check_opts = apply_filters($this->p->cf['lca'] . '_check_head_meta_options', SucomUtil::preg_grep_keys('/^add_/', $this->p->options, false, ''), $post_id);
     if (current_user_can('manage_options')) {
         $notice_suffix = ' (' . sprintf(__('see <a href="%s">Theme Integration</a> settings', 'nextgen-facebook'), $this->p->util->get_admin_url('advanced#sucom-tabset_plugin-tab_integration')) . ')...';
     } else {
         $notice_suffix = '...';
     }
     $this->p->notice->inf(sprintf(__('Checking %1$s webpage header for duplicate meta tags', 'nextgen-facebook'), '<a href="' . $permalink . '">' . $permalink_html . '</a>') . $notice_suffix, true);
     // use the permalink and have get_head_meta() remove our own meta tags
     // to avoid issues with caching plugins that ignore query arguments
     if (($metas = $this->p->util->get_head_meta($permalink, '/html/head/link|/html/head/meta', true)) !== false) {
         foreach (array('link' => array('rel'), 'meta' => array('name', 'itemprop', 'property')) as $tag => $types) {
             if (isset($metas[$tag])) {
                 foreach ($metas[$tag] as $m) {
                     foreach ($types as $t) {
                         if (isset($m[$t]) && $m[$t] !== 'generator' && !empty($check_opts[$tag . '_' . $t . '_' . $m[$t]])) {
                             $this->p->notice->err('Possible conflict detected &mdash; your theme or another plugin is adding a <code>' . $tag . ' ' . $t . '="' . $m[$t] . '"</code> HTML tag to the head section of this webpage.', true);
                         }
                     }
                 }
             }
         }
     }
     return $post_id;
 }
Exemplo n.º 6
0
 public function check_post_header($post_id = true, &$obj = false)
 {
     if (empty($this->p->options['plugin_check_head'])) {
         return $post_id;
     }
     if (!is_object($obj) && ($obj = $this->p->util->get_post_object($post_id)) === false) {
         return $post_id;
     }
     // only check published posts, so we have a permalink to check
     if (!isset($obj->post_status) || $obj->post_status !== 'publish') {
         return $post_id;
     }
     // only check registered front-end post types (to avoid menu items, product variations, etc.)
     $post_types = $this->p->util->get_post_types('frontend', 'names');
     if (empty($obj->post_type) || !in_array($obj->post_type, $post_types)) {
         return $post_id;
     }
     $permalink = get_permalink($post_id);
     $permalink_no_meta = add_query_arg(array('NGFB_META_TAGS_DISABLE' => 1), $permalink);
     $check_opts = apply_filters($this->p->cf['lca'] . '_check_head_meta_options', SucomUtil::preg_grep_keys('/^add_/', $this->p->options, false, ''), $post_id);
     // use the permalink and have get_head_meta() remove our own meta tags
     // to avoid issues with caching plugins that ignore query arguments
     if (($metas = $this->p->util->get_head_meta($permalink, '/html/head/link|/html/head/meta', true)) !== false) {
         foreach (array('link' => array('rel'), 'meta' => array('name', 'itemprop', 'property')) as $tag => $types) {
             if (isset($metas[$tag])) {
                 foreach ($metas[$tag] as $m) {
                     foreach ($types as $t) {
                         if (isset($m[$t]) && $m[$t] !== 'generator' && !empty($check_opts[$tag . '_' . $t . '_' . $m[$t]])) {
                             $this->p->notice->err('Possible conflict detected - your theme or another plugin is adding a <code>' . $tag . ' ' . $t . '="' . $m[$t] . '"</code> HTML tag to the head section of this webpage.', true);
                         }
                     }
                 }
             }
         }
     }
     return $post_id;
 }
Exemplo n.º 7
0
 public function filter_save_post_options($opts, $post_id, $rel_id, $mod)
 {
     $def_opts = $this->filter_get_md_defaults(array(), $mod);
     // only get the schema options
     foreach (SucomUtil::preg_grep_keys('/^schema_recipe_((prep|cook|total)_(days|hours|mins|secs)|calories)$/', $opts) as $key => $value) {
         $opts[$key] = (int) $value;
         if ($opts[$key] === $def_opts[$key]) {
             unset($opts[$key]);
         }
     }
     // renumber recipe ingredients
     $recipe_ingredients = array();
     foreach (SucomUtil::preg_grep_keys('/^schema_recipe_ingredient_[0-9]+$/', $opts) as $key => $value) {
         unset($opts[$key]);
         if (!empty($value)) {
             $recipe_ingredients[] = $value;
         }
     }
     foreach ($recipe_ingredients as $num => $value) {
         $opts['schema_recipe_ingredient_' . $num] = $value;
     }
     if (empty($opts['schema_review_rating'])) {
         foreach (array('schema_review_rating', 'schema_review_rating_from', 'schema_review_rating_to') as $key) {
             unset($opts[$key]);
         }
     } else {
         foreach (array('schema_review_rating_from', 'schema_review_rating_to') as $key) {
             if (empty($opts[$key]) && isset($def_opts[$key])) {
                 $opts[$key] = $def_opts[$key];
             }
         }
     }
     return $opts;
 }
Exemplo n.º 8
0
 public function get_js($pos = 'header', $ids = array())
 {
     if (($obj = $this->p->util->get_post_object()) === false) {
         $this->p->debug->log('exiting early: invalid object type');
         return;
     }
     // determine which (if any) sharing buttons are enabled
     // loop through the sharing button option prefixes (fb, gp, etc.)
     if (empty($ids)) {
         if (!is_admin() && is_singular() && $this->is_disabled()) {
             $this->p->debug->log('exiting early: buttons disabled');
             return;
         } elseif (is_admin() && (empty($obj->filter) || $obj->filter !== 'edit')) {
             $this->p->debug->log('exiting early: admin non-editing page');
             return;
         }
         if (class_exists('NgfbWidgetSharing')) {
             $widget = new NgfbWidgetSharing();
             $widget_settings = $widget->get_settings();
         } else {
             $widget_settings = array();
         }
         foreach ($this->p->cf['opt']['pre'] as $id => $pre) {
             // check for enabled buttons on settings page
             if (is_admin() && !empty($obj)) {
                 foreach (SucomUtil::preg_grep_keys('/^' . $pre . '_on_admin_/', $this->p->options) as $key => $val) {
                     if (!empty($val)) {
                         $ids[] = $id;
                     }
                 }
             } else {
                 if (is_singular() || !is_singular() && !empty($this->p->options['buttons_on_index']) || is_front_page() && !empty($this->p->options['buttons_on_front'])) {
                     // exclude buttons enabled for admin editing pages
                     foreach (SucomUtil::preg_grep_keys('/^' . $pre . '_on_/', $this->p->options) as $key => $val) {
                         if (strpos($key, $pre . '_on_admin_') === false && !empty($val)) {
                             $ids[] = $id;
                         }
                     }
                 }
                 // check for enabled buttons in ACTIVE widget(s)
                 foreach ($widget_settings as $num => $instance) {
                     if (is_object($widget) && is_active_widget(false, $widget->id_base . '-' . $num, $widget->id_base)) {
                         if (array_key_exists($id, $instance) && (int) $instance[$id]) {
                             $ids[] = $id;
                         }
                     }
                 }
             }
         }
         if (empty($ids)) {
             $this->p->debug->log('exiting early: no buttons enabled');
             return;
         }
     }
     natsort($ids);
     $ids = array_unique($ids);
     $js = '<!-- ' . $this->p->cf['lca'] . ' ' . $pos . ' javascript begin -->';
     if (strpos($pos, '-header')) {
         $js_loc = 'header';
     } elseif (strpos($pos, '-footer')) {
         $js_loc = 'footer';
     } else {
         $js_loc = $pos;
     }
     if (!empty($ids)) {
         foreach ($ids as $id) {
             $id = preg_replace('/[^a-z]/', '', $id);
             $opt_name = $this->p->cf['opt']['pre'][$id] . '_js_loc';
             if (method_exists($this->website[$id], 'get_js') && !empty($this->p->options[$opt_name]) && $this->p->options[$opt_name] == $js_loc) {
                 $js .= $this->website[$id]->get_js($pos);
             }
         }
     }
     $js .= '<!-- ' . $this->p->cf['lca'] . ' ' . $pos . ' javascript end -->' . "\n";
     return $js;
 }
Exemplo n.º 9
0
 public static function add_media_data(&$json_data, $mod, $mt_og, $size_name = false)
 {
     $wpsso =& Wpsso::get_instance();
     /*
      * Property:
      *	image as https://schema.org/ImageObject
      */
     $og_image = array();
     $prev_count = 0;
     $max = $wpsso->util->get_max_nums($mod, 'schema');
     if (empty($size_name)) {
         $size_name = $wpsso->cf['lca'] . '-schema';
     }
     // include any video preview images first
     if (!empty($mt_og['og:video']) && is_array($mt_og['og:video'])) {
         // prevent duplicates - exclude text/html videos
         foreach ($mt_og['og:video'] as $num => $og_video) {
             if (isset($og_video['og:video:type']) && $og_video['og:video:type'] !== 'text/html') {
                 if (SucomUtil::get_mt_media_url($og_video, 'og:image')) {
                     $prev_count++;
                 }
                 $og_image[] = SucomUtil::preg_grep_keys('/^og:image/', $og_video);
             }
         }
         if ($prev_count > 0) {
             $max['schema_img_max'] -= $prev_count;
             if ($wpsso->debug->enabled) {
                 $wpsso->debug->log($prev_count . ' video preview images found (og_img_max adjusted to ' . $max['schema_img_max'] . ')');
             }
         }
     }
     $og_image = array_merge($og_image, $wpsso->og->get_all_images($max['schema_img_max'], $size_name, $mod, true, 'schema'));
     if (!empty($og_image)) {
         $images_added = WpssoSchema::add_image_list_data($json_data['image'], $og_image, 'og:image');
     } else {
         $images_added = 0;
     }
     if (!$images_added && $mod['is_post']) {
         $og_image = $wpsso->media->get_default_image(1, $size_name, true);
         $images_added = WpssoSchema::add_image_list_data($json_data['image'], $og_image, 'og:image');
     }
     if (!$images_added) {
         unset($json_data['image']);
     }
     // prevent null assignment
     /*
      * Property:
      *	video as https://schema.org/VideoObject
      */
     if (!empty($mt_og['og:video'])) {
         WpssoJsonSchema::add_video_list_data($json_data['video'], $mt_og['og:video'], 'og:video');
     }
 }
Exemplo n.º 10
0
 public function get_array($use_post = false, $obj = false, &$og = array())
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->mark();
     }
     if (!is_object($obj)) {
         $obj = $this->p->util->get_post_object($use_post);
     }
     $post_id = empty($obj->ID) || empty($obj->post_type) || !is_singular() && $use_post === false ? 0 : $obj->ID;
     $og_max = $this->p->util->get_max_nums($post_id, 'post');
     // post_id 0 returns the plugin settings
     $tc = SucomUtil::preg_grep_keys('/^twitter:/', $og);
     // read any pre-defined twitter card values
     $tc = apply_filters($this->p->cf['lca'] . '_tc_seed', $tc, $use_post, $obj);
     // the twitter:domain is used in place of the 'view on web' text
     if (!isset($tc['twitter:domain']) && !empty($og['og:url'])) {
         $tc['twitter:domain'] = preg_replace('/^.*\\/\\/([^\\/]+).*$/', '$1', $og['og:url']);
     }
     if (!isset($tc['twitter:site']) && !empty($this->p->options['tc_site'])) {
         $tc['twitter:site'] = $this->p->options['tc_site'];
     }
     if (!isset($tc['twitter:title'])) {
         $tc['twitter:title'] = $this->p->webpage->get_title(70, '...', $use_post, true, false, true, 'og_title');
     }
     if (!isset($tc['twitter:description'])) {
         $tc['twitter:description'] = $this->p->webpage->get_description($this->p->options['tc_desc_len'], '...', $use_post, true, true, true, 'tc_desc');
     }
     if (!isset($tc['twitter:creator'])) {
         if (SucomUtil::is_post_page($use_post)) {
             if (!empty($obj->post_author)) {
                 $tc['twitter:creator'] = get_the_author_meta($this->p->options['plugin_cm_twitter_name'], $obj->post_author);
             } elseif (!empty($this->p->options['og_def_author_id'])) {
                 $tc['twitter:creator'] = get_the_author_meta($this->p->options['plugin_cm_twitter_name'], $this->p->options['og_def_author_id']);
             }
         } elseif (SucomUtil::is_author_page()) {
             $author_id = $this->p->util->get_author_object('id');
             $tc['twitter:creator'] = get_the_author_meta($this->p->options['plugin_cm_twitter_name'], $author_id);
         } elseif ($this->p->util->force_default_author($use_post)) {
             $tc['twitter:creator'] = get_the_author_meta($this->p->options['plugin_cm_twitter_name'], $this->p->options['og_def_author_id']);
         }
     }
     /*
      * Player Card
      */
     // player card relies on existing og meta tags - a valid post_id is not required
     if (!isset($tc['twitter:card'])) {
         if ($this->p->debug->enabled) {
             $this->p->debug->log('player card: checking for videos');
         }
         if (isset($og['og:video']) && count($og['og:video']) > 0) {
             foreach ($og['og:video'] as $video) {
                 if (!empty($video['og:video:embed_url'])) {
                     $tc['twitter:card'] = 'player';
                     $tc['twitter:player'] = $video['og:video:embed_url'];
                     if (!empty($video['og:image'])) {
                         $tc['twitter:image'] = $video['og:image'];
                     }
                     if (!empty($video['og:video:width'])) {
                         $tc['twitter:player:width'] = $video['og:video:width'];
                     }
                     if (!empty($video['og:video:height'])) {
                         $tc['twitter:player:height'] = $video['og:video:height'];
                     }
                     break;
                     // only list the first video
                 }
             }
         }
     }
     /*
      * All Image Cards
      */
     if (empty($og_max['og_img_max'])) {
         if ($this->p->debug->enabled) {
             $this->p->debug->log('images disabled: maximum images = 0');
         }
     } else {
         /*
          * Default Image for Indexes
          */
         if (!isset($tc['twitter:card']) && !$use_post) {
             if ($this->p->util->force_default_image()) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('large image card: checking for default image');
                 }
                 $og_image = $this->p->media->get_default_image(1, $this->p->cf['lca'] . '-tc-lrgimg');
                 if (count($og_image) > 0) {
                     $image = reset($og_image);
                     $tc['twitter:card'] = 'summary_large_image';
                     $tc['twitter:image'] = $image['og:image'];
                 }
                 $post_id = 0;
                 // skip additional image checks
             }
         }
         if (empty($post_id)) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('no post_id: image related cards skipped');
             }
         } else {
             // post meta image
             if (!isset($tc['twitter:card'])) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('large image card: checking for post image (meta, featured, attached)');
                 }
                 $og_image = $this->p->media->get_post_images(1, $this->p->cf['lca'] . '-tc-lrgimg', $post_id, false);
                 if (count($og_image) > 0) {
                     $image = reset($og_image);
                     $tc['twitter:card'] = 'summary_large_image';
                     $tc['twitter:image'] = $image['og:image'];
                 }
             }
             // singlepic shortcode image
             if (!isset($tc['twitter:card']) && $this->p->is_avail['media']['ngg'] === true) {
                 if (!empty($this->p->mods['media']['ngg'])) {
                     if ($this->p->debug->enabled) {
                         $this->p->debug->log('large image card: checking for singlepic image');
                     }
                     $og_image = $this->p->mods['media']['ngg']->get_singlepic_images(1, $this->p->cf['lca'] . '-tc-lrgimg', false);
                     if (count($og_image) > 0) {
                         $image = reset($og_image);
                         $tc['twitter:card'] = 'summary_large_image';
                         $tc['twitter:image'] = $image['og:image'];
                     }
                 } elseif ($this->p->debug->enabled) {
                     $this->p->debug->log('large image card: singlepic check skipped - NGG module not available');
                 }
             }
         }
     }
     /*
      * Summary Card (default)
      */
     if (!isset($tc['twitter:card'])) {
         $tc['twitter:card'] = 'summary';
         if (!empty($og_max['og_img_max'])) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('summary card: checking for content image');
             }
             $og_image = $this->p->og->get_all_images(1, $this->p->cf['lca'] . '-tc-summary', $post_id, false);
             if (count($og_image) > 0) {
                 $image = reset($og_image);
                 $tc['twitter:image'] = $image['og:image'];
             }
         }
     }
     return apply_filters($this->p->cf['lca'] . '_tc', $tc, $use_post, $obj);
 }
Exemplo n.º 11
0
 public function get_array($use_post = false, $obj = false, &$og = array())
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->mark();
     }
     if (!is_object($obj)) {
         $obj = $this->p->util->get_post_object($use_post);
     }
     $post_id = empty($obj->ID) || empty($obj->post_type) || !SucomUtil::is_post_page($use_post) ? 0 : $obj->ID;
     // counter for video previews found
     $video_previews = 0;
     // post_id 0 returns the default plugin settings
     $og_max = $this->p->util->get_max_nums($post_id, 'post');
     $og = apply_filters($this->p->cf['lca'] . '_og_seed', $og, $use_post, $obj);
     if (!empty($og) && $this->p->debug->enabled) {
         $this->p->debug->log($this->p->cf['lca'] . '_og_seed filter returned:');
         $this->p->debug->log($og);
     }
     if (!isset($og['fb:admins']) && !empty($this->p->options['fb_admins'])) {
         foreach (explode(',', $this->p->options['fb_admins']) as $fb_admin) {
             $og['fb:admins'][] = trim($fb_admin);
         }
     }
     if (!isset($og['fb:app_id'])) {
         $og['fb:app_id'] = $this->p->options['fb_app_id'];
     }
     if (!isset($og['og:url'])) {
         $og['og:url'] = $this->p->util->get_sharing_url($use_post, true, $this->p->util->get_source_id('opengraph'));
     }
     // define the type after the url
     if (!isset($og['og:type'])) {
         // singular posts / pages are articles by default
         // check the post_type for a match with a known open graph type
         if (SucomUtil::is_post_page($use_post)) {
             if (!empty($obj->post_type) && isset($this->p->cf['head']['og_type_ns'][$obj->post_type])) {
                 $og['og:type'] = $obj->post_type;
             } else {
                 $og['og:type'] = 'article';
             }
             // check for default author info on indexes and searches
         } elseif ($this->p->util->force_default_author($use_post, 'og') && !empty($this->p->options['og_def_author_id'])) {
             $og['og:type'] = 'article';
             // meta tag not defined or value is null
             if (!isset($og['article:author'])) {
                 $og['article:author'] = $this->p->mods['util']['user']->get_author_profile_url($this->p->options['og_def_author_id']);
             }
             // default for everything else is 'website'
         } else {
             $og['og:type'] = 'website';
         }
         $og['og:type'] = apply_filters($this->p->cf['lca'] . '_og_type', $og['og:type'], $use_post);
         // pre-define basic open graph meta tags for this type
         if (isset($this->p->cf['head']['og_type_mt'][$og['og:type']])) {
             foreach ($this->p->cf['head']['og_type_mt'][$og['og:type']] as $mt_name) {
                 if (!isset($og[$mt_name])) {
                     $og[$mt_name] = null;
                     if ($this->p->debug->enabled) {
                         $this->p->debug->log($og['og:type'] . ' pre-defined mt: ' . $mt_name);
                     }
                 }
             }
         }
     }
     if (!isset($og['og:locale'])) {
         // get the current or configured language for og:locale
         $lang = empty($this->p->options['fb_lang']) ? SucomUtil::get_locale($post_id) : $this->p->options['fb_lang'];
         $lang = apply_filters($this->p->cf['lca'] . '_lang', $lang, SucomUtil::get_pub_lang('facebook'), $post_id);
         $og['og:locale'] = $lang;
     }
     if (!isset($og['og:site_name'])) {
         $og['og:site_name'] = $this->get_site_name($post_id);
     }
     if (!isset($og['og:title'])) {
         $og['og:title'] = $this->p->webpage->get_title($this->p->options['og_title_len'], '...', $use_post);
     }
     if (!isset($og['og:description'])) {
         $og['og:description'] = $this->p->webpage->get_description($this->p->options['og_desc_len'], '...', $use_post);
     }
     // if the page is an article, then define the other article meta tags
     if (isset($og['og:type']) && $og['og:type'] == 'article') {
         // meta tag not defined or value is null
         if (!isset($og['article:author'])) {
             if (SucomUtil::is_post_page($use_post)) {
                 if (!empty($obj->post_author)) {
                     $og['article:author'] = $this->p->mods['util']['user']->get_author_profile_url($obj->post_author);
                 } elseif (!empty($this->p->options['og_def_author_id'])) {
                     $og['article:author'] = $this->p->mods['util']['user']->get_author_profile_url($this->p->options['og_def_author_id']);
                 }
             }
         }
         // meta tag not defined or value is null
         if (!isset($og['article:publisher'])) {
             $og['article:publisher'] = $this->p->options['fb_publisher_url'];
         }
         // meta tag not defined or value is null
         if (!isset($og['article:tag'])) {
             $og['article:tag'] = $this->p->webpage->get_tags($post_id);
         }
         // meta tag not defined or value is null
         if (!isset($og['article:section'])) {
             $og['article:section'] = $this->p->webpage->get_section($post_id);
         }
         // meta tag not defined or value is null
         if (!isset($og['article:published_time'])) {
             $og['article:published_time'] = trim(get_post_time('c', null, $post_id));
         }
         // meta tag not defined or value is null
         if (!isset($og['article:modified_time'])) {
             $og['article:modified_time'] = trim(get_post_modified_time('c', null, $post_id));
         }
     }
     // get all videos
     // call before getting all images to find / use preview images
     if (!isset($og['og:video'])) {
         if (empty($og_max['og_vid_max'])) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('videos disabled: maximum videos = 0');
             }
         } else {
             $og['og:video'] = $this->get_all_videos($og_max['og_vid_max'], $post_id, 'post', false, 'og');
             if (!empty($og['og:video']) && is_array($og['og:video'])) {
                 foreach ($og['og:video'] as $val) {
                     if (!empty($val['og:image'])) {
                         $video_previews++;
                     }
                 }
                 if ($video_previews > 0) {
                     $og_max['og_img_max'] -= $video_previews;
                     if ($this->p->debug->enabled) {
                         $this->p->debug->log($video_previews . ' video preview images found (og_img_max adjusted to ' . $og_max['og_img_max'] . ')');
                     }
                 }
             }
         }
     }
     // get all images
     if (!isset($og['og:image'])) {
         if (empty($og_max['og_img_max'])) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('images disabled: maximum images = 0');
             }
         } else {
             $crawler_name = SucomUtil::crawler_name();
             if (!SucomUtil::get_const('NGFB_RICH_PIN_DISABLE')) {
                 if (is_admin()) {
                     $img_sizes = array('rp' => $this->p->cf['lca'] . '-richpin', 'og' => $this->p->cf['lca'] . '-opengraph');
                 } elseif ($crawler_name === 'pinterest') {
                     $img_sizes = array('og' => $this->p->cf['lca'] . '-richpin');
                 }
             } else {
                 $img_sizes = array('og' => $this->p->cf['lca'] . '-opengraph');
             }
             $size_count = count($img_sizes);
             $size_num = 0;
             foreach ($img_sizes as $md_pre => $size_name) {
                 $check_dupes = ++$size_num < $size_count ? false : true;
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log('getting all images for ' . $md_pre . ' (' . $size_name . ')');
                 }
                 $og[$md_pre . ':image'] = $this->get_all_images($og_max['og_img_max'], $size_name, $post_id, $check_dupes, $md_pre);
                 switch ($md_pre) {
                     case 'rp':
                         foreach ($og[$md_pre . ':image'] as $num => $arr) {
                             $og[$md_pre . ':image'][$num] = SucomUtil::preg_grep_keys('/^og:/', $arr, false, 'pinterest:');
                         }
                         break;
                     case 'og':
                         // if there's no image, and no video preview image,
                         // then add the default image for singular webpages
                         if (empty($og[$md_pre . ':image']) && $video_previews === 0 && SucomUtil::is_post_page($use_post)) {
                             $og[$md_pre . ':image'] = $this->p->media->get_default_image($og_max['og_img_max'], $size_name, $check_dupes);
                         }
                         break;
                 }
             }
         }
     }
     return apply_filters($this->p->cf['lca'] . '_og', $og, $use_post, $obj);
 }