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; }
public static function get_config($idx = '', $filter = false) { if (!isset(self::$cf['config_filtered']) || self::$cf['config_filtered'] !== true) { if ($filter === true) { self::$cf = apply_filters(self::$cf['lca'] . '_get_config', self::$cf); self::$cf['config_filtered'] = true; self::$cf['*'] = array('lib' => array(), 'version' => ''); foreach (self::$cf['plugin'] as $lca => $info) { if (isset($info['lib']) && is_array($info['lib'])) { self::$cf['*']['lib'] = SucomUtil::array_merge_recursive_distinct(self::$cf['*']['lib'], $info['lib']); } if (isset($info['version'])) { self::$cf['*']['version'] .= '-' . $lca . $info['version']; } } self::$cf['*']['version'] = trim(self::$cf['*']['version'], '-'); } } if (!empty($idx)) { if (array_key_exists($idx, self::$cf)) { return self::$cf[$idx]; } else { return false; } } else { return self::$cf; } }
protected function get_rows($metabox, $key) { $rows = array(); switch ($metabox . '-' . $key) { case 'essential-general': $rows[] = '<td></td><td class="subsection top"><h4>' . _x('Site Information', 'metabox title', 'nextgen-facebook') . '</h4></td>'; $rows[] = $this->p->util->get_th(_x('Default Article Topic', 'option label', 'nextgen-facebook'), null, 'og_art_section') . '<td>' . $this->form->get_select('og_art_section', $this->p->util->get_topics()) . '</td>'; $rows[] = $this->p->util->get_th(_x('Site Name', 'option label', 'nextgen-facebook'), null, 'og_site_name', array('is_locale' => true)) . '<td>' . $this->form->get_input(SucomUtil::get_locale_key('og_site_name'), null, null, null, get_bloginfo('name', 'display')) . '</td>'; $rows[] = $this->p->util->get_th(_x('Site Description', 'option label', 'nextgen-facebook'), null, 'og_site_description', array('is_locale' => true)) . '<td>' . $this->form->get_textarea(SucomUtil::get_locale_key('og_site_description'), null, null, null, get_bloginfo('description', 'display')) . '</td>'; $rows[] = '<td></td><td class="subsection"><h4>' . _x('Facebook / Open Graph', 'metabox title', 'nextgen-facebook') . '</h4></td>'; $rows[] = $this->p->util->get_th(_x('Facebook Business Page URL', 'option label', 'nextgen-facebook'), null, 'fb_publisher_url') . '<td>' . $this->form->get_input('fb_publisher_url', 'wide') . '</td>'; $rows[] = $this->p->util->get_th(_x('Facebook Application ID', 'option label', 'nextgen-facebook'), null, 'fb_app_id') . '<td>' . $this->form->get_input('fb_app_id') . '</td>'; $rows[] = $this->p->util->get_th(_x('or Facebook Admin Username(s)', 'option label', 'nextgen-facebook'), null, 'fb_admins') . '<td>' . $this->form->get_input('fb_admins') . '</td>'; $rows[] = $this->p->util->get_th(_x('Default Content Language', 'option label', 'nextgen-facebook'), null, 'fb_lang') . '<td>' . $this->form->get_select('fb_lang', SucomUtil::get_pub_lang('facebook')) . '</td>'; $rows[] = $this->p->util->get_th(_x('Default / Fallback Image ID', 'option label', 'nextgen-facebook'), null, 'og_def_img_id') . '<td>' . $this->form->get_image_upload_input('og_def_img') . '</td>'; $rows[] = $this->p->util->get_th(_x('or Default / Fallback Image URL', 'option label', 'nextgen-facebook'), null, 'og_def_img_url') . '<td>' . $this->form->get_image_url_input('og_def_img') . '</td>'; $rows[] = $this->p->util->get_th(_x('Open Graph Image Dimensions', 'option label', 'nextgen-facebook'), null, 'og_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('og_img', false, false) . '</td>'; $rows[] = '<td></td><td class="subsection"><h4>' . _x('Google / Schema', 'metabox title', 'nextgen-facebook') . '</h4></td>'; $rows[] = $this->p->util->get_th(_x('Google+ Business Page URL', 'option label', 'nextgen-facebook'), null, 'google_publisher_url') . '<td>' . $this->form->get_input('seo_publisher_url', 'wide') . '</td>'; $rows[] = $this->p->util->get_th(_x('Website / Business Logo URL', 'option label', 'nextgen-facebook'), null, 'google_schema_logo_url') . '<td>' . $this->form->get_input('schema_logo_url', 'wide') . '</td>'; $rows[] = '<td></td><td class="subsection"><h4>' . _x('Pinterest', 'metabox title', 'nextgen-facebook') . '</h4></td>'; $rows[] = $this->p->util->get_th(_x('Pinterest Company Page URL', 'option label', 'nextgen-facebook'), null, 'rp_publisher_url') . '<td>' . $this->form->get_input('rp_publisher_url', 'wide') . '</td>'; if (!SucomUtil::get_const('NGFB_RICH_PIN_DISABLE')) { $rows[] = $this->p->util->get_th(_x('Rich Pin Image Dimensions', 'option label', 'nextgen-facebook'), null, 'rp_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('rp_img') . '</td>'; } $rows[] = '<td></td><td class="subsection"><h4>' . _x('Twitter', 'metabox title', 'nextgen-facebook') . '</h4></td>'; $rows[] = $this->p->util->get_th(_x('Twitter Business @username', 'option label', 'nextgen-facebook'), null, 'tc_site') . '<td>' . $this->form->get_input('tc_site') . '</td>'; break; case 'essential-advanced': $rows['plugin_preserve'] = $this->p->util->get_th(_x('Preserve Settings on Uninstall', 'option label', 'nextgen-facebook'), null, 'plugin_preserve') . '<td>' . $this->form->get_checkbox('plugin_preserve') . '</td>'; $rows['plugin_debug'] = $this->p->util->get_th(_x('Add Hidden Debug Messages', 'option label', 'nextgen-facebook'), null, 'plugin_debug') . '<td>' . (defined('NGFB_HTML_DEBUG') && NGFB_HTML_DEBUG ? $this->form->get_no_checkbox('plugin_debug') . ' NGFB_HTML_DEBUG constant enabled' : $this->form->get_checkbox('plugin_debug')) . '</td>'; break; } return $rows; }
function ngfb_get_sharing_buttons($ids = array(), $atts = array()) { global $ngfb; if ($ngfb->is_avail['ssb']) { if ($ngfb->is_avail['cache']['transient']) { $cache_salt = __METHOD__ . '(lang:' . SucomUtil::get_locale() . '_url:' . $ngfb->util->get_sharing_url() . '_ids:' . implode('_', $ids) . '_atts:' . implode('_', $atts) . ')'; $cache_id = $ngfb->cf['lca'] . '_' . md5($cache_salt); $cache_type = 'object cache'; $ngfb->debug->log($cache_type . ': transient salt ' . $cache_salt); $html = get_transient($cache_id); if ($html !== false) { $ngfb->debug->log($cache_type . ': html retrieved from transient ' . $cache_id); return $ngfb->debug->get_html() . $html; } } $html = '<!-- ' . $ngfb->cf['lca'] . ' sharing buttons begin -->' . $ngfb->sharing->get_js('sharing-buttons-header', $ids) . $ngfb->sharing->get_html($ids, $atts) . $ngfb->sharing->get_js('sharing-buttons-footer', $ids) . '<!-- ' . $ngfb->cf['lca'] . ' sharing buttons end -->'; if ($ngfb->is_avail['cache']['transient']) { set_transient($cache_id, $html, $ngfb->cache->object_expire); $ngfb->debug->log($cache_type . ': html saved to transient ' . $cache_id . ' (' . $ngfb->cache->object_expire . ' seconds)'); } } else { $html = '<!-- ' . $ngfb->cf['lca'] . ' sharing sharing buttons disabled -->'; } return $ngfb->debug->get_html() . $html; }
public function get_html($atts = array(), &$opts = array()) { if ($this->p->debug->enabled) { $this->p->debug->mark(); } if (empty($opts)) { $opts =& $this->p->options; } global $post; $prot = empty($_SERVER['HTTPS']) ? 'http:' : 'https:'; $use_post = isset($atts['use_post']) ? $atts['use_post'] : true; $src_id = $this->p->util->get_source_id('twitter', $atts); $atts['add_page'] = isset($atts['add_page']) ? $atts['add_page'] : true; // get_sharing_url argument $long_url = empty($atts['url']) ? $this->p->util->get_sharing_url($use_post, $atts['add_page'], $src_id) : apply_filters($this->p->cf['lca'] . '_sharing_url', $atts['url'], $use_post, $atts['add_page'], $src_id); $short_url = apply_filters($this->p->cf['lca'] . '_shorten_url', $long_url, $opts['plugin_shortener']); if (!array_key_exists('lang', $atts)) { $atts['lang'] = empty($opts['twitter_lang']) ? 'en' : $opts['twitter_lang']; } $atts['lang'] = apply_filters($this->p->cf['lca'] . '_lang', $atts['lang'], SucomUtil::get_pub_lang('twitter')); if (array_key_exists('tweet', $atts)) { $atts['caption'] = $atts['tweet']; } if (!array_key_exists('caption', $atts)) { if (empty($atts['caption'])) { $caption_len = $this->p->util->get_tweet_max_len($long_url, 'twitter', $short_url); $atts['caption'] = $this->p->webpage->get_caption($opts['twitter_caption'], $caption_len, $use_post, true, true, true, 'twitter_desc', $src_id); } } if (!array_key_exists('via', $atts)) { if (!empty($opts['twitter_via']) && $this->p->check->aop('ngfb')) { $atts['via'] = preg_replace('/^@/', '', $opts['tc_site']); } else { $atts['via'] = ''; } } if (!array_key_exists('related', $atts)) { if (!empty($opts['twitter_rel_author']) && !empty($post) && $use_post === true && $this->p->check->aop('ngfb')) { $atts['related'] = preg_replace('/^@/', '', get_the_author_meta($opts['plugin_cm_twitter_name'], $post->author)); } else { $atts['related'] = ''; } } // hashtags are included in the caption instead if (!array_key_exists('hashtags', $atts)) { $atts['hashtags'] = ''; } if (!array_key_exists('dnt', $atts)) { $atts['dnt'] = $opts['twitter_dnt'] ? 'true' : 'false'; } $html = '<!-- Twitter Button --><div ' . $this->p->sharing->get_css('twitter', $atts) . '>'; $html .= '<a href="' . $prot . '//twitter.com/share" class="twitter-share-button" data-lang="' . $atts['lang'] . '" '; $html .= 'data-url="' . $short_url . '" data-counturl="' . $long_url . '" data-text="' . $atts['caption'] . '" '; $html .= 'data-via="' . $atts['via'] . '" data-related="' . $atts['related'] . '" data-hashtags="' . $atts['hashtags'] . '" '; $html .= 'data-count="' . $opts['twitter_count'] . '" data-size="' . $opts['twitter_size'] . '" data-dnt="' . $atts['dnt'] . '"></a></div>'; if ($this->p->debug->enabled) { $this->p->debug->log('returning html (' . strlen($html) . ' chars)'); } return $html . "\n"; }
public function filter_post_text_rows($table_rows, $form, $head, $mod) { if ($this->p->debug->enabled) { $this->p->debug->mark(); } $schema_types = $this->p->schema->get_schema_types_select(); // $add_none = true $title_max_len = $this->p->options['og_title_len']; $desc_max_len = $this->p->options['schema_desc_len']; $headline_max_len = WpssoJsonConfig::$cf['schema']['article']['headline']['max_len']; $org_names = array('none' => '[None]', 'site' => _x('Website', 'option value', 'wpsso-schema-json-ld')); $perf_names = array('none' => '[None]'); $auto_draft_msg = sprintf(__('Save a draft version or publish the %s to update this value.', 'wpsso-schema-json-ld'), SucomUtil::titleize($mod['post_type'])); if (!empty($this->p->cf['plugin']['wpssoorg']) && empty($this->p->cf['plugin']['wpssoorg']['version'])) { $info = $this->p->cf['plugin']['wpssoorg']; $org_req_msg = ' <em><a href="' . $info['url']['download'] . '" target="_blank">' . sprintf(_x('%s extension required', 'option comment', 'wpsso-schema-json-ld'), $info['short']) . '</a></em>'; } else { $org_req_msg = ''; } // javascript hide/show classes for schema type rows $tr_class = array('article' => $this->p->schema->get_schema_type_css_classes('article'), 'event' => $this->p->schema->get_schema_type_css_classes('event'), 'recipe' => $this->p->schema->get_schema_type_css_classes('recipe'), 'review' => $this->p->schema->get_schema_type_css_classes('review')); foreach (array('schema_desc', 'subsection_schema') as $key) { if (isset($table_rows[$key])) { unset($table_rows[$key]); } } $form_rows = array('subsection_schema' => array('td_class' => 'subsection', 'header' => 'h4', 'label' => _x('Google Structured Data / Schema Markup', 'metabox title', 'wpsso-schema-json-ld')), 'schema_title' => array('label' => _x('Schema Item Name', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_title', 'td_class' => 'blank', 'no_auto_draft' => true, 'content' => $form->get_no_input_value($this->p->webpage->get_title($title_max_len, '...', $mod), 'wide')), 'schema_desc' => array('label' => _x('Schema Description', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_desc', 'td_class' => 'blank', 'no_auto_draft' => true, 'content' => $form->get_no_textarea_value($this->p->webpage->get_description($desc_max_len, '...', $mod), '', '', $desc_max_len)), 'schema_is_main' => array('label' => _x('Main Entity of Page', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_is_main', 'td_class' => 'blank', 'content' => $form->get_no_checkbox('schema_is_main')), 'schema_type' => array('label' => _x('Schema Item Type', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_type', 'td_class' => 'blank', 'content' => $form->get_no_select('schema_type', $schema_types, 'long_name', '', true, $form->defaults['schema_type'], 'unhide_rows')), 'schema_pub_org_id' => array('tr_class' => 'schema_type ' . $tr_class['article'], 'label' => _x('Article Publisher', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_pub_org_id', 'td_class' => 'blank', 'content' => $form->get_no_select('schema_pub_org_id', $org_names, 'long_name') . $org_req_msg), 'schema_headline' => array('tr_class' => 'schema_type ' . $tr_class['article'], 'label' => _x('Article Headline', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_headline', 'td_class' => 'blank', 'no_auto_draft' => true, 'content' => $form->get_no_input_value($this->p->webpage->get_title($headline_max_len, '...', $mod), 'wide')), 'schema_event_org_id' => array('tr_class' => 'schema_type ' . $tr_class['event'], 'label' => _x('Event Organizer', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_event_org_id', 'td_class' => 'blank', 'content' => $form->get_no_select('schema_event_org_id', $org_names, 'long_name') . $org_req_msg), 'schema_event_perf_id' => array('tr_class' => 'schema_type ' . $tr_class['event'], 'label' => _x('Event Performer', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_event_perf_id', 'td_class' => 'blank', 'content' => $form->get_no_select('schema_event_perf_id', $perf_names, 'long_name') . $org_req_msg), 'schema_recipe_prep_time' => array('tr_class' => 'schema_type ' . $tr_class['recipe'], 'label' => _x('Recipe Preperation Time', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_recipe_prep_time', 'content' => $form->get_no_input_value('0', 'short') . ' days, ' . $form->get_no_input_value('0', 'short') . ' hours, ' . $form->get_no_input_value('0', 'short') . ' mins, ' . $form->get_no_input_value('0', 'short') . ' secs'), 'schema_recipe_cook_time' => array('tr_class' => 'schema_type ' . $tr_class['recipe'], 'label' => _x('Recipe Cooking Time', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_recipe_cook_time', 'content' => $form->get_no_input_value('0', 'short') . ' days, ' . $form->get_no_input_value('0', 'short') . ' hours, ' . $form->get_no_input_value('0', 'short') . ' mins, ' . $form->get_no_input_value('0', 'short') . ' secs'), 'schema_recipe_total_time' => array('tr_class' => 'schema_type ' . $tr_class['recipe'], 'label' => _x('Recipe Total Time', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_recipe_total_time', 'content' => $form->get_no_input_value('0', 'short') . ' days, ' . $form->get_no_input_value('0', 'short') . ' hours, ' . $form->get_no_input_value('0', 'short') . ' mins, ' . $form->get_no_input_value('0', 'short') . ' secs'), 'schema_recipe_calories' => array('tr_class' => 'schema_type ' . $tr_class['recipe'], 'label' => _x('Recipe Total Calories', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_recipe_calories', 'content' => $form->get_no_input_value('', 'medium')), 'schema_recipe_yield' => array('tr_class' => 'schema_type ' . $tr_class['recipe'], 'label' => _x('Recipe Quantity', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_recipe_yield', 'content' => $form->get_no_input_value('', 'long_name')), 'schema_recipe_ingredients' => array('tr_class' => 'schema_type ' . $tr_class['recipe'], 'label' => _x('Recipe Ingredients', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_recipe_ingredients', 'content' => $form->get_no_input_value('', 'long_name')), 'schema_review_item_type' => array('tr_class' => 'schema_type ' . $tr_class['review'], 'label' => _x('Reviewed Item Type', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_review_item_type', 'td_class' => 'blank', 'content' => $form->get_no_select('schema_review_item_type', $schema_types, 'long_name')), 'schema_review_item_url' => array('tr_class' => 'schema_type ' . $tr_class['review'], 'label' => _x('Reviewed Item URL', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_review_item_url', 'td_class' => 'blank', 'content' => $form->get_no_input_value('', 'wide')), 'schema_review_rating' => array('tr_class' => 'schema_type ' . $tr_class['review'], 'label' => _x('Reviewed Item Rating', 'option label', 'wpsso-schema-json-ld'), 'th_class' => 'medium', 'tooltip' => 'meta-schema_review_rating', 'td_class' => 'blank', 'content' => $form->get_no_input_value($form->defaults['schema_review_rating'], 'short') . ' ' . _x('from', 'option comment', 'wpsso-schema-json-ld') . ' ' . $form->get_no_input_value($form->defaults['schema_review_rating_from'], 'short') . ' ' . _x('to', 'option comment', 'wpsso-schema-json-ld') . ' ' . $form->get_no_input_value($form->defaults['schema_review_rating_to'], 'short'))); $table_rows = $form->get_md_form_rows($table_rows, $form_rows, $head, $mod, $auto_draft_msg); return SucomUtil::get_after_key($table_rows, 'subsection_schema', '', '<td colspan="2">' . $this->p->msgs->get('pro-feature-msg', array('lca' => 'wpssojson')) . '</td>'); }
public static function get_config($idx = '', $filter = false) { if (!isset(self::$cf['config_filtered']) || self::$cf['config_filtered'] !== true) { // remove the sharing libs if social sharing features are disabled if (defined('NGFB_SOCIAL_SHARING_DISABLE') && NGFB_SOCIAL_SHARING_DISABLE) { foreach (self::$cf['plugin'] as $lca => $info) { unset($info['lib']['website'], $info['lib']['submenu']['sharing'], $info['lib']['submenu']['style'], $info['lib']['shortcode']['sharing'], $info['lib']['widget']['sharing'], $info['lib']['gpl']['admin']['sharing'], $info['lib']['gpl']['admin']['style'], $info['lib']['gpl']['admin']['apikeys'], $info['lib']['pro']['admin']['sharing'], $info['lib']['pro']['admin']['style'], $info['lib']['pro']['admin']['apikeys'], $info['lib']['pro']['util']['shorten']); self::$cf['plugin'][$lca] = $info; } } if ($filter === true) { self::$cf = apply_filters(self::$cf['lca'] . '_get_config', self::$cf); self::$cf['config_filtered'] = true; self::$cf['*'] = array('lib' => array(), 'version' => ''); foreach (self::$cf['plugin'] as $lca => $info) { if (isset($info['lib']) && is_array($info['lib'])) { self::$cf['*']['lib'] = SucomUtil::array_merge_recursive_distinct(self::$cf['*']['lib'], $info['lib']); } if (isset($info['version'])) { self::$cf['*']['version'] .= '-' . $lca . $info['version']; } } self::$cf['*']['version'] = trim(self::$cf['*']['version'], '-'); } } if (!empty($idx)) { if (array_key_exists($idx, self::$cf)) { return self::$cf[$idx]; } else { return false; } } else { return self::$cf; } }
public function options($options_name, &$opts = array(), $def_opts = array()) { $opts = SucomUtil::rename_keys($opts, $this->renamed_keys); // custom value changes for regular options if ($options_name == constant($this->p->cf['uca'] . '_OPTIONS_NAME')) { if ($opts['options_version'] <= 270) { foreach ($opts as $key => $val) { if (strpos($key, 'inc_') === 0) { $new_key = ''; switch ($key) { case preg_match('/^inc_(description|twitter:)/', $key) ? true : false: $new_key = preg_replace('/^inc_/', 'add_meta_name_', $key); break; default: $new_key = preg_replace('/^inc_/', 'add_meta_property_', $key); break; } if (!empty($new_key)) { $opts[$new_key] = $val; } unset($opts[$key]); } } } if ($opts['options_version'] <= 260) { if ($opts['og_img_width'] == 1200 && $opts['og_img_height'] == 630 && !empty($opts['og_img_crop'])) { $this->p->notice->inf('Open Graph Image Dimentions have been updated from ' . $opts['og_img_width'] . 'x' . $opts['og_img_height'] . ', ' . ($opts['og_img_crop'] ? '' : 'un') . 'cropped to ' . $def_opts['og_img_width'] . 'x' . $def_opts['og_img_height'] . ', ' . ($def_opts['og_img_crop'] ? '' : 'un') . 'cropped.', true); $opts['og_img_width'] = $def_opts['og_img_width']; $opts['og_img_height'] = $def_opts['og_img_height']; $opts['og_img_crop'] = $def_opts['og_img_crop']; } } if ($opts['options_version'] <= 247) { if (!empty($opts['twitter_shorten'])) { $opts['twitter_shortener'] = 'googl'; unset($opts['twitter_shorten']); } } if ($opts['options_version'] <= 28) { // upgrade the old og_img_size name into width / height / crop values if (array_key_exists('og_img_size', $opts)) { if (!empty($opts['og_img_size']) && $opts['og_img_size'] !== 'medium') { $size_info = $this->p->media->get_size_info($opts['og_img_size']); if ($size_info['width'] > 0 && $size_info['height'] > 0) { $opts['og_img_width'] = $size_info['width']; $opts['og_img_height'] = $size_info['height']; $opts['og_img_crop'] = $size_info['crop']; } } unset($opts['og_img_size']); } } } $opts = $this->sanitize($opts, $def_opts); // cleanup excess options and sanitize return $opts; }
public function options($options_name, &$opts = array(), $def_opts = array()) { // retrieve the first numeric string $opts_version = empty($opts['options_version']) ? 0 : preg_replace('/^[^0-9]*([0-9]*).*$/', '$1', $opts['options_version']); if ($options_name === constant('WPSSO_OPTIONS_NAME')) { $opts = SucomUtil::rename_keys($opts, $this->renamed_keys); if (version_compare($opts_version, 260, '<=')) { if ($opts['og_img_width'] == 1200 && $opts['og_img_height'] == 630 && !empty($opts['og_img_crop'])) { $this->p->notice->inf('Open Graph Image Dimentions have been updated from ' . $opts['og_img_width'] . 'x' . $opts['og_img_height'] . ', ' . ($opts['og_img_crop'] ? '' : 'un') . 'cropped to ' . $def_opts['og_img_width'] . 'x' . $def_opts['og_img_height'] . ', ' . ($def_opts['og_img_crop'] ? '' : 'un') . 'cropped.', true); $opts['og_img_width'] = $def_opts['og_img_width']; $opts['og_img_height'] = $def_opts['og_img_height']; $opts['og_img_crop'] = $def_opts['og_img_crop']; } } if (version_compare($opts_version, 270, '<=')) { foreach ($opts as $key => $val) { if (strpos($key, 'inc_') === 0) { $new_key = ''; switch ($key) { case preg_match('/^inc_(description|twitter:)/', $key) ? true : false: $new_key = preg_replace('/^inc_/', 'add_meta_name_', $key); break; default: $new_key = preg_replace('/^inc_/', 'add_meta_property_', $key); break; } if (!empty($new_key)) { $opts[$new_key] = $val; } unset($opts[$key]); } } } if (version_compare($opts_version, 296, '<=')) { if (empty($opts['plugin_min_shorten']) || $opts['plugin_min_shorten'] < 22) { $opts['plugin_min_shorten'] = 22; } } if (version_compare($opts_version, 373, '<=')) { if (!empty($opts['plugin_head_attr_filter_name']) && $opts['plugin_head_attr_filter_name'] === 'language_attributes') { $opts['plugin_head_attr_filter_name'] = 'head_attributes'; } } } elseif ($options_name === constant('WPSSO_SITE_OPTIONS_NAME')) { $opts = SucomUtil::rename_keys($opts, $this->renamed_site_keys); } if (version_compare($opts_version, 342, '<=')) { if (isset($opts['plugin_file_cache_hrs'])) { $opts['plugin_file_cache_exp'] = $opts['plugin_file_cache_hrs'] * 3600; unset($opts['plugin_file_cache_hrs']); } } return $this->sanitize($opts, $def_opts); // cleanup options and sanitize }
function ngfb_get_sharing_buttons($ids = array(), $atts = array(), $expire = 86400) { $ngfb =& Ngfb::get_instance(); if ($ngfb->is_avail['ssb']) { $cache_salt = __METHOD__ . '(lang:' . SucomUtil::get_locale() . '_url:' . $ngfb->util->get_sharing_url() . '_ids:' . implode('_', $ids) . '_atts:' . implode('_', $atts) . ')'; $cache_id = $ngfb->cf['lca'] . '_' . md5($cache_salt); $cache_type = 'object cache'; // clear the cache if $expire = 0 if (empty($expire)) { if ($ngfb->is_avail['cache']['transient']) { delete_transient($cache_id); } elseif ($ngfb->is_avail['cache']['object']) { wp_cache_delete($cache_id, __METHOD__); } return; } elseif (!isset($atts['read_cache']) || $atts['read_cache']) { if ($ngfb->is_avail['cache']['transient']) { if ($ngfb->debug->enabled) { $ngfb->debug->log($cache_type . ': transient salt ' . $cache_salt); } $html = get_transient($cache_id); } elseif ($ngfb->is_avail['cache']['object']) { if ($ngfb->debug->enabled) { $ngfb->debug->log($cache_type . ': wp_cache salt ' . $cache_salt); } $html = wp_cache_get($cache_id, __METHOD__); } else { $html = false; } } else { $html = false; } if ($html !== false) { if ($ngfb->debug->enabled) { $ngfb->debug->log($cache_type . ': html retrieved from cache ' . $cache_id); } return $ngfb->debug->get_html() . $html; } $html = '<!-- ' . $ngfb->cf['lca'] . ' sharing buttons begin -->' . $ngfb->sharing->get_script('sharing-buttons-header', $ids) . $ngfb->sharing->get_html($ids, $atts) . $ngfb->sharing->get_script('sharing-buttons-footer', $ids) . '<!-- ' . $ngfb->cf['lca'] . ' sharing buttons end -->'; if ($ngfb->is_avail['cache']['transient'] || $ngfb->is_avail['cache']['object']) { if ($ngfb->is_avail['cache']['transient']) { set_transient($cache_id, $html, $expire); } elseif ($ngfb->is_avail['cache']['object']) { wp_cache_set($cache_id, $html, __METHOD__, $expire); } if ($ngfb->debug->enabled) { $ngfb->debug->log($cache_type . ': html saved to cache ' . $cache_id . ' (' . $expire . ' seconds)'); } } } else { $html = '<!-- ' . $ngfb->cf['lca'] . ' sharing sharing buttons disabled -->'; } return $ngfb->debug->get_html() . $html; }
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; }
protected function get_rows($metabox, $key) { $rows = array(); $rows[] = $this->p->util->get_th('Show Button in', 'short') . '<td>' . $this->show_on_checkboxes('gp') . '</td>'; $rows[] = $this->p->util->get_th('Preferred Order', 'short') . '<td>' . $this->form->get_select('gp_order', range(1, count($this->p->admin->submenu['sharing']->website)), 'short') . '</td>'; $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('JavaScript in', 'short') . '<td>' . $this->form->get_select('gp_script_loc', $this->p->cf['form']['script_locations']) . '</td>'; $rows[] = $this->p->util->get_th('Default Language', 'short') . '<td>' . $this->form->get_select('gp_lang', SucomUtil::get_pub_lang('gplus')) . '</td>'; $rows[] = $this->p->util->get_th('Button Type', 'short') . '<td>' . $this->form->get_select('gp_action', array('plusone' => 'G +1', 'share' => 'G+ Share')) . '</td>'; $rows[] = $this->p->util->get_th('Button Size', 'short') . '<td>' . $this->form->get_select('gp_size', array('small' => 'Small [ 15px ]', 'medium' => 'Medium [ 20px ]', 'standard' => 'Standard [ 24px ]', 'tall' => 'Tall [ 60px ]')) . '</td>'; $rows[] = $this->p->util->get_th('Annotation', 'short') . '<td>' . $this->form->get_select('gp_annotation', array('none' => '', 'inline' => 'Inline', 'bubble' => 'Bubble', 'vertical-bubble' => 'Vertical Bubble')) . '</td>'; $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th('Expand to', 'short') . '<td>' . $this->form->get_select('gp_expandto', array('none' => '', 'top' => 'Top', 'bottom' => 'Bottom', 'left' => 'Left', 'right' => 'Right', 'top,left' => 'Top Left', 'top,right' => 'Top Right', 'bottom,left' => 'Bottom Left', 'bottom,right' => 'Bottom Right')) . '</td>'; return $rows; }
public static function get_config($idx = false, $filter = false) { if (!isset(self::$cf['config_filtered']) || self::$cf['config_filtered'] !== true) { // remove the sharing libs if social sharing features are disabled if (defined('NGFB_SOCIAL_SHARING_DISABLE') && NGFB_SOCIAL_SHARING_DISABLE) { foreach (array_keys(self::$cf['plugin']) as $lca) { unset(self::$cf['plugin'][$lca]['lib']['website'], self::$cf['plugin'][$lca]['lib']['submenu']['sharing'], self::$cf['plugin'][$lca]['lib']['submenu']['style'], self::$cf['plugin'][$lca]['lib']['shortcode']['sharing'], self::$cf['plugin'][$lca]['lib']['widget']['sharing'], self::$cf['plugin'][$lca]['lib']['gpl']['admin']['sharing'], self::$cf['plugin'][$lca]['lib']['gpl']['admin']['style'], self::$cf['plugin'][$lca]['lib']['pro']['admin']['sharing'], self::$cf['plugin'][$lca]['lib']['pro']['admin']['style']); } } if ($filter === true) { self::$cf = apply_filters(self::$cf['lca'] . '_get_config', self::$cf); self::$cf['config_filtered'] = true; self::$cf['*'] = array('lib' => array(), 'version' => ''); foreach (self::$cf['plugin'] as $lca => $info) { if (isset($info['lib']) && is_array($info['lib'])) { self::$cf['*']['lib'] = SucomUtil::array_merge_recursive_distinct(self::$cf['*']['lib'], $info['lib']); } if (isset($info['version'])) { self::$cf['*']['version'] .= '-' . $lca . $info['version']; } } self::$cf['*']['version'] = trim(self::$cf['*']['version'], '-'); } // complete relative paths in the image array foreach (self::$cf['plugin'] as $lca => $info) { if (isset($info['base'])) { $base = self::$cf['plugin'][$lca]['base']; // nextgen-facebook/nextgen-facebook.php foreach (array('img') as $sub) { if (isset($info[$sub]) && is_array($info[$sub])) { foreach ($info[$sub] as $id => $url) { if (!empty($url) && strpos($url, '//') === false) { self::$cf['plugin'][$lca][$sub][$id] = trailingslashit(plugins_url('', $base)) . $url; } } } } } } } if ($idx !== false) { if (array_key_exists($idx, self::$cf)) { return self::$cf[$idx]; } else { return false; } } else { return self::$cf; } }
public function widget($args, $instance) { if (is_feed()) { return; } // nothing to do in the feeds if (!empty($_SERVER['NGFB_DISABLE'])) { return; } if (!is_object($this->p)) { return; } if (is_object($this->p->sharing) && $this->p->sharing->is_disabled()) { $this->p->debug->log('widget buttons skipped: sharing buttons disabled'); return; } extract($args); if ($this->p->is_avail['cache']['transient']) { $sharing_url = $this->p->util->get_sharing_url(); $cache_salt = __METHOD__ . '(lang:' . SucomUtil::get_locale() . '_widget:' . $this->id . '_url:' . $sharing_url . ')'; $cache_id = $this->p->cf['lca'] . '_' . md5($cache_salt); $cache_type = 'object cache'; $this->p->debug->log($cache_type . ': transient salt ' . $cache_salt); $html = get_transient($cache_id); if ($html !== false) { $this->p->debug->log($cache_type . ': html retrieved from transient ' . $cache_id); echo $html; $this->p->debug->show_html(); return; } } // sort enabled sharing buttons by their preferred order $sorted_ids = array(); foreach ($this->p->cf['opt']['pre'] as $id => $pre) { if (array_key_exists($id, $instance) && (int) $instance[$id]) { $sorted_ids[$this->p->options[$pre . '_order'] . '-' . $id] = $id; } } ksort($sorted_ids); $atts = array('css_id' => $args['widget_id'], 'filter_id' => 'widget', 'use_post' => false, 'preset_id' => $this->p->options['buttons_preset_widget']); $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $html = '<!-- ' . $this->p->cf['lca'] . ' ' . $args['widget_id'] . ' begin -->' . $before_widget . (empty($title) ? '' : $before_title . $title . $after_title) . $this->p->sharing->get_html($sorted_ids, $atts) . $after_widget . '<!-- ' . $this->p->cf['lca'] . ' ' . $args['widget_id'] . ' end -->' . "\n"; if ($this->p->is_avail['cache']['transient']) { set_transient($cache_id, $html, $this->p->cache->object_expire); $this->p->debug->log($cache_type . ': html saved to transient ' . $cache_id . ' (' . $this->p->cache->object_expire . ' seconds)'); } echo $html; $this->p->debug->show_html(); }
public static function load_lib($ret = false, $filespec = '', $classname = '') { if ($ret === false && !empty($filespec)) { $filepath = WPSSOJSON_PLUGINDIR . 'lib/' . $filespec . '.php'; if (file_exists($filepath)) { require_once $filepath; if (empty($classname)) { return SucomUtil::sanitize_classname('wpssojson' . $filespec, false); } else { return $classname; } } } return $ret; }
protected function get_rows($metabox, $key) { $rows = array(); switch ($metabox . '-' . $key) { case 'image-dimensions-general': $rows[] = $this->p->util->get_th(_x('Facebook / Open Graph', 'option label', 'nextgen-facebook'), null, 'og_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('og_img', false, false) . '</td>'; if (!SucomUtil::get_const('NGFB_RICH_PIN_DISABLE')) { $rows[] = $this->p->util->get_th(_x('Pinterest Rich Pin', 'option label', 'nextgen-facebook'), null, 'rp_img_dimensions') . '<td>' . $this->form->get_image_dimensions_input('rp_img') . '</td>'; } $rows[] = $this->p->util->get_th(_x('Twitter <em>Summary</em> Card', 'option label', 'nextgen-facebook'), null, 'tc_sum_dimensions') . '<td>' . $this->form->get_image_dimensions_input('tc_sum') . '</td>'; $rows[] = $this->p->util->get_th(_x('Twitter <em>Large Image Summary</em> Card', 'option label', 'nextgen-facebook'), null, 'tc_lrgimg_dimensions') . '<td>' . $this->form->get_image_dimensions_input('tc_lrgimg') . '</td>'; break; } return $rows; }
protected function get_rows($metabox, $key) { $rows = array(); $this->form->user_ids = $this->p->addons['util']['user']->get_display_names(); $this->form->author_contact_fields = $this->p->addons['util']['user']->get_contact_fields(); switch ($metabox . '-' . $key) { case 'og-general': $rows[] = $this->p->util->th('Default Article Topic', 'highlight', 'og_art_section') . '<td>' . $this->form->get_select('og_art_section', $this->p->util->get_topics()) . '</td>'; $rows[] = $this->p->util->th('Site Name', null, 'og_site_name', array('is_locale' => true)) . '<td>' . $this->form->get_input(SucomUtil::get_locale_key('og_site_name'), null, null, null, get_bloginfo('name', 'display')) . '</td>'; $rows[] = $this->p->util->th('Site Description', 'highlight', 'og_site_description', array('is_locale' => true)) . '<td>' . $this->form->get_textarea(SucomUtil::get_locale_key('og_site_description'), null, null, null, get_bloginfo('description', 'display')) . '</td>'; break; case 'og-content': $rows[] = $this->p->util->th('Title Separator', null, 'og_title_sep') . '<td>' . $this->form->get_input('og_title_sep', 'short') . '</td>'; break; case 'og-images': $img_id_pre = array('wp' => 'Media Library'); if ($this->p->is_avail['media']['ngg'] == true) { $img_id_pre['ngg'] = 'NextGEN Gallery'; } $rows[] = $this->p->util->th('Max Images to Include', null, 'og_img_max') . '<td>' . $this->form->get_select('og_img_max', range(0, $this->p->cf['form']['max_media_items']), 'short', null, true) . '</td>'; $rows[] = $this->p->util->th('Open Graph Image Dimensions', 'highlight', 'og_img_dimensions') . '<td>Width ' . $this->form->get_input('og_img_width', 'short') . ' x ' . 'Height ' . $this->form->get_input('og_img_height', 'short') . ' ' . 'Crop ' . $this->form->get_checkbox('og_img_crop') . '</td>'; $rows[] = $this->p->util->th('Default Image ID', 'highlight', 'og_def_img_id') . '<td>' . $this->form->get_input('og_def_img_id', 'short') . ' in ' . $this->form->get_select('og_def_img_id_pre', $img_id_pre) . '</td>'; $rows[] = $this->p->util->th('Default Image URL', null, 'og_def_img_url') . '<td>' . (empty($this->p->options['og_def_img_id']) ? $this->form->get_input('og_def_img_url', 'wide') : $this->form->get_no_input('og_def_img_url', 'wide')) . '</td>'; break; case 'og-videos': $rows[] = $this->p->util->th('Max Videos to Include', null, 'og_vid_max') . '<td>' . $this->form->get_select('og_vid_max', range(0, $this->p->cf['form']['max_media_items']), 'short', null, true) . '</td>'; break; case 'og-author': $rows[] = $this->p->util->th('Article Publisher Page URL', 'highlight', 'og_publisher_url') . '<td>' . $this->form->get_input('og_publisher_url', 'wide') . '</td>'; break; case 'pub-facebook': $rows[] = $this->p->util->th('Facebook Admin(s)', 'highlight', 'fb_admins') . '<td>' . $this->form->get_input('fb_admins') . '</td>'; $rows[] = $this->p->util->th('Facebook Application ID', null, 'fb_app_id') . '<td>' . $this->form->get_input('fb_app_id') . '</td>'; $rows[] = $this->p->util->th('Default Language', null, 'fb_lang') . '<td>' . $this->form->get_select('fb_lang', SucomUtil::get_pub_lang('facebook')) . '</td>'; break; case 'pub-google': $rows[] = $this->p->util->th('Publisher Link URL', 'highlight', 'google_publisher_url') . '<td>' . $this->form->get_input('link_publisher_url', 'wide') . '</td>'; break; case 'pub-pinterest': $rows[] = '<td colspan="2" style="padding-bottom:10px;">' . $this->p->msgs->get('info-pub-pinterest') . '</td>'; $rows[] = $this->p->util->th('Rich Pin Image Dimensions', 'highlight', 'rp_img_dimensions') . '<td>Width ' . $this->form->get_input('rp_img_width', 'short') . ' x ' . 'Height ' . $this->form->get_input('rp_img_height', 'short') . ' ' . 'Crop ' . $this->form->get_checkbox('rp_img_crop') . '</td>'; break; } return $rows; }
public static function get_config($idx = false, $filter = false) { if (!isset(self::$cf['config_filtered']) || self::$cf['config_filtered'] !== true) { if ($filter === true) { self::$cf['opt']['version'] .= is_dir(trailingslashit(dirname(__FILE__)) . 'pro/') ? 'pro' : 'gpl'; self::$cf = apply_filters(self::$cf['lca'] . '_get_config', self::$cf); self::$cf['config_filtered'] = true; self::$cf['*'] = array('lib' => array(), 'version' => ''); foreach (self::$cf['plugin'] as $lca => $info) { if (isset($info['lib']) && is_array($info['lib'])) { self::$cf['*']['lib'] = SucomUtil::array_merge_recursive_distinct(self::$cf['*']['lib'], $info['lib']); } if (isset($info['version'])) { self::$cf['*']['version'] .= '-' . $lca . $info['version']; } } self::$cf['*']['version'] = trim(self::$cf['*']['version'], '-'); } // complete relative paths in the image array foreach (self::$cf['plugin'] as $lca => $info) { if (isset($info['base'])) { $base = self::$cf['plugin'][$lca]['base']; // wpsso/wpsso.php foreach (array('img') as $sub) { if (isset($info[$sub]) && is_array($info[$sub])) { foreach ($info[$sub] as $id => $url) { if (!empty($url) && strpos($url, '//') === false) { self::$cf['plugin'][$lca][$sub][$id] = trailingslashit(plugins_url('', $base)) . $url; } } } } } } } if (!empty($idx)) { if (array_key_exists($idx, self::$cf)) { return self::$cf[$idx]; } else { return false; } } else { return self::$cf; } }
public function flush_post_cache($post_id) { switch (get_post_status($post_id)) { case 'draft': case 'pending': case 'future': case 'private': case 'publish': $lang = SucomUtil::get_locale(); $cache_type = 'object cache'; $sharing_url = $this->p->util->get_sharing_url($post_id); $transients = array('WpssoHead::get_header_array' => array('lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url, 'lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url . '_crawler:pinterest')); $transients = apply_filters($this->p->cf['lca'] . '_post_cache_transients', $transients, $post_id, $lang, $sharing_url); $objects = array('SucomWebpage::get_content' => array('lang:' . $lang . '_post:' . $post_id . '_filtered', 'lang:' . $lang . '_post:' . $post_id . '_unfiltered'), 'SucomWebpage::get_hashtags' => array('lang:' . $lang . '_post:' . $post_id)); $objects = apply_filters($this->p->cf['lca'] . '_post_cache_objects', $objects, $post_id, $lang, $sharing_url); $this->flush_cache_objects($transients, $objects); break; } }
public function options($options_name, &$opts = array(), $def_opts = array()) { $opts = SucomUtil::rename_keys($opts, $this->renamed_keys); // custom value changes for regular options if ($options_name == constant($this->p->cf['uca'] . '_OPTIONS_NAME')) { if (version_compare($opts['options_version'], 260, '<=')) { if ($opts['og_img_width'] == 1200 && $opts['og_img_height'] == 630 && !empty($opts['og_img_crop'])) { $this->p->notice->inf('Open Graph Image Dimentions have been updated from ' . $opts['og_img_width'] . 'x' . $opts['og_img_height'] . ', ' . ($opts['og_img_crop'] ? '' : 'un') . 'cropped to ' . $def_opts['og_img_width'] . 'x' . $def_opts['og_img_height'] . ', ' . ($def_opts['og_img_crop'] ? '' : 'un') . 'cropped.', true); $opts['og_img_width'] = $def_opts['og_img_width']; $opts['og_img_height'] = $def_opts['og_img_height']; $opts['og_img_crop'] = $def_opts['og_img_crop']; } } if (version_compare($opts['options_version'], 270, '<=')) { foreach ($opts as $key => $val) { if (strpos($key, 'inc_') === 0) { $new_key = ''; switch ($key) { case preg_match('/^inc_(description|twitter:)/', $key) ? true : false: $new_key = preg_replace('/^inc_/', 'add_meta_name_', $key); break; default: $new_key = preg_replace('/^inc_/', 'add_meta_property_', $key); break; } if (!empty($new_key)) { $opts[$new_key] = $val; } unset($opts[$key]); } } } if (version_compare($opts['options_version'], 296, '<=')) { if ($opts['plugin_min_shorten'] < 22) { $opts['plugin_min_shorten'] = 22; } } } $opts = $this->sanitize($opts, $def_opts); // cleanup excess options and sanitize return $opts; }
public function filter_taxonomy_media_rows($rows, $form, $head_info) { $rows[] = '<td colspan="2" align="center">' . $this->p->msgs->get('pro-feature-msg') . '</td>'; $rows[] = '<td></td><td class="subsection top"><h4>' . _x('All Social Websites / Open Graph', 'metabox title', 'nextgen-facebook') . '</h4></td>'; $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Image Dimensions', 'option label', 'nextgen-facebook'), 'medium', 'og_img_dimensions') . '<td class="blank">' . $form->get_image_dimensions_text('og_img', true) . '</td>'; $rows[] = $this->p->util->get_th(_x('Image ID', 'option label', 'nextgen-facebook'), 'medium', 'meta-og_img_id', $head_info) . '<td class="blank"> </td>'; $rows[] = $this->p->util->get_th(_x('or an Image URL', 'option label', 'nextgen-facebook'), 'medium', 'meta-og_img_url', $head_info) . '<td class="blank"> </td>'; $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Maximum Images', 'option label', 'nextgen-facebook'), 'medium', 'meta-og_img_max', $head_info) . '<td class="blank">' . $this->p->options['og_img_max'] . '</td>'; $rows[] = $this->p->util->get_th(_x('Video Embed HTML', 'option label', 'nextgen-facebook'), 'medium', 'meta-og_vid_embed', $head_info) . '<td class="blank"> </td>'; $rows[] = $this->p->util->get_th(_x('or a Video URL', 'option label', 'nextgen-facebook'), 'medium', 'meta-og_vid_url', $head_info) . '<td class="blank"> </td>'; $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Maximum Videos', 'option label', 'nextgen-facebook'), 'medium', 'meta-og_vid_max', $head_info) . '<td class="blank">' . $this->p->options['og_vid_max'] . '</td>'; $rows[] = $this->p->util->get_th(_x('Include Preview Image(s)', 'option label', 'nextgen-facebook'), 'medium', 'meta-og_vid_prev_img', $head_info) . '<td class="blank">' . $form->get_no_checkbox('og_vid_prev_img') . '</td>'; if (!SucomUtil::get_const('NGFB_RICH_PIN_DISABLE')) { $rows[] = '<tr class="hide_in_basic">' . '<td></td><td class="subsection"><h4>' . _x('Pinterest / Rich Pin', 'metabox title', 'nextgen-facebook') . '</h4></td>'; $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Image Dimensions', 'option label', 'nextgen-facebook'), 'medium', 'rp_img_dimensions') . '<td class="blank">' . $form->get_image_dimensions_text('rp_img', true) . '</td>'; $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('Image ID', 'option label', 'nextgen-facebook'), 'medium', 'meta-rp_img_id', $head_info) . '<td class="blank"> </td>'; $rows[] = '<tr class="hide_in_basic">' . $this->p->util->get_th(_x('or an Image URL', 'option label', 'nextgen-facebook'), 'medium', 'meta-rp_img_url', $head_info) . '<td class="blank"> </td>'; } return $rows; }
public function shortcode($atts, $content = null) { $atts = apply_filters($this->p->cf['lca'] . '_shortcode_' . NGFB_SHARING_SHORTCODE, $atts, $content); if (($obj = $this->p->util->get_post_object()) === false) { $this->p->debug->log('exiting early: invalid object type'); return $content; } $post_id = empty($obj->ID) || empty($obj->post_type) ? 0 : $obj->ID; $atts['url'] = empty($atts['url']) ? $this->p->util->get_sharing_url(true) : $atts['url']; $atts['css_id'] = empty($atts['css_id']) && !empty($post_id) ? 'shortcode' : $atts['css_id']; $atts['css_class'] = empty($atts['css_class']) ? 'button' : $atts['css_class']; $atts['filter_id'] = empty($atts['filter_id']) ? 'shortcode' : $atts['filter_id']; $atts['preset_id'] = empty($atts['preset_id']) ? $this->p->options['buttons_preset_shortcode'] : $atts['preset_id']; $html = ''; if (!empty($atts['buttons'])) { $atts['css_id'] .= '-buttons'; if ($this->p->is_avail['cache']['transient']) { $keys = implode('|', array_keys($atts)); $vals = preg_replace('/[, ]+/', '_', implode('|', array_values($atts))); $cache_salt = __METHOD__ . '(lang:' . SucomUtil::get_locale() . '_post:' . $post_id . '_atts_keys:' . $keys . '_atts_vals:' . $vals . ')'; $cache_id = $this->p->cf['lca'] . '_' . md5($cache_salt); $cache_type = 'object cache'; $this->p->debug->log($cache_type . ': transient salt ' . $cache_salt); $html = get_transient($cache_id); if ($html !== false) { $this->p->debug->log($cache_type . ': html retrieved from transient ' . $cache_id); return $this->p->debug->get_html() . $html; } } $ids = array_map('trim', explode(',', $atts['buttons'])); unset($atts['buttons']); $html .= '<!-- ' . $this->p->cf['lca'] . ' ' . $atts['css_id'] . ' begin -->' . $this->p->sharing->get_js('shortcode-header', $ids) . '<div class="' . $this->p->cf['lca'] . '-' . $atts['css_id'] . '">' . $this->p->sharing->get_html($ids, $atts) . '</div>' . $this->p->sharing->get_js('shortcode-footer', $ids) . '<!-- ' . $this->p->cf['lca'] . ' ' . $atts['css_id'] . ' end -->'; if ($this->p->is_avail['cache']['transient']) { set_transient($cache_id, $html, $this->p->cache->object_expire); $this->p->debug->log($cache_type . ': html saved to transient ' . $cache_id . ' (' . $this->p->cache->object_expire . ' seconds)'); } } return $html . $this->p->debug->get_html(); }
public static function crawler_name($id = '') { if (self::$crawler_name === false) { // optimize perf - only check once $str = $_SERVER['HTTP_USER_AGENT']; switch (true) { // "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" case strpos($str, 'facebookexternalhit/') === 0: self::$crawler_name = 'facebook'; break; // "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" // "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" case strpos($str, 'compatible; Googlebot/') !== false: self::$crawler_name = 'google'; break; // "Pinterest/0.1 +http://pinterest.com/" // "Pinterest/0.1 +http://pinterest.com/" case strpos($str, 'Pinterest/') === 0: self::$crawler_name = 'pinterest'; break; // "Twitterbot/1.0" // "Twitterbot/1.0" case strpos($str, 'Twitterbot/') === 0: self::$crawler_name = 'twitter'; break; // "W3C_Validator/1.3 http://validator.w3.org/services" // "W3C_Validator/1.3 http://validator.w3.org/services" case strpos($str, 'W3C_Validator/') === 0: self::$crawler_name = 'w3c'; break; } } if (!empty($id)) { return $id === self::$crawler_name ? true : false; } else { return self::$crawler_name; } }
public function get_avail() { $ret = array(); $ret['curl'] = function_exists('curl_init') ? true : false; $ret['mbdecnum'] = function_exists('mb_decode_numericentity') ? true : false; $ret['postthumb'] = function_exists('has_post_thumbnail') ? true : false; $ret['metatags'] = (!defined('NGFB_META_TAGS_DISABLE') || defined('NGFB_META_TAGS_DISABLE') && !NGFB_META_TAGS_DISABLE) && empty($_SERVER['NGFB_META_TAGS_DISABLE']) ? true : false; $ret['opengraph'] = (!defined('NGFB_OPEN_GRAPH_DISABLE') || defined('NGFB_OPEN_GRAPH_DISABLE') && !NGFB_OPEN_GRAPH_DISABLE) && empty($_SERVER['NGFB_OPEN_GRAPH_DISABLE']) && file_exists(NGFB_PLUGINDIR . 'lib/opengraph.php') && class_exists($this->p->cf['lca'] . 'opengraph') ? true : false; $ret['aop'] = (!defined('NGFB_PRO_ADDON_DISABLE') || defined('NGFB_PRO_ADDON_DISABLE') && !NGFB_PRO_ADDON_DISABLE) && file_exists(NGFB_PLUGINDIR . 'lib/pro/head/twittercard.php') ? true : false; $ret['ssb'] = (!defined('NGFB_SOCIAL_SHARING_DISABLE') || defined('NGFB_SOCIAL_SHARING_DISABLE') && !NGFB_SOCIAL_SHARING_DISABLE) && empty($_SERVER['NGFB_SOCIAL_SHARING_DISABLE']) && file_exists(NGFB_PLUGINDIR . 'lib/sharing.php') && class_exists($this->p->cf['lca'] . 'sharing') ? true : false; foreach ($this->p->cf['cache'] as $name => $val) { $constant_name = 'NGFB_' . strtoupper($name) . '_CACHE_DISABLE'; $ret['cache'][$name] = defined($constant_name) && constant($constant_name) ? false : true; } foreach (SucomUtil::array_merge_recursive_distinct($this->p->cf['*']['lib']['pro'], self::$mac) as $sub => $lib) { $ret[$sub] = array(); $ret[$sub]['*'] = false; foreach ($lib as $id => $name) { $chk = array(); $ret[$sub][$id] = false; // default value switch ($sub . '-' . $id) { /* * 3rd Party Plugins */ case 'ecom-edd': $chk['class'] = 'Easy_Digital_Downloads'; $chk['plugin'] = 'easy-digital-downloads/easy-digital-downloads.php'; break; case 'ecom-marketpress': $chk['class'] = 'MarketPress'; $chk['plugin'] = 'wordpress-ecommerce/marketpress.php'; break; case 'ecom-woocommerce': $chk['class'] = 'Woocommerce'; $chk['plugin'] = 'woocommerce/woocommerce.php'; break; case 'ecom-wpecommerce': $chk['class'] = 'WP_eCommerce'; $chk['plugin'] = 'wp-e-commerce/wp-shopping-cart.php'; break; case 'forum-bbpress': $chk['class'] = 'bbPress'; $chk['plugin'] = 'bbpress/bbpress.php'; break; case 'lang-polylang': $chk['class'] = 'Polylang'; $chk['plugin'] = 'polylang/polylang.php'; break; case 'media-ngg': $chk['class'] = 'nggdb'; // C_NextGEN_Bootstrap $chk['plugin'] = 'nextgen-gallery/nggallery.php'; break; case 'media-photon': if (class_exists('Jetpack') && method_exists('Jetpack', 'get_active_modules') && in_array('photon', Jetpack::get_active_modules())) { $ret[$sub]['*'] = $ret[$sub][$id] = true; } break; case 'seo-aioseop': $chk['class'] = 'All_in_One_SEO_Pack'; $chk['plugin'] = 'all-in-one-seo-pack/all-in-one-seo-pack.php'; break; case 'seo-headspace2': $chk['class'] = 'HeadSpace_Plugin'; $chk['plugin'] = 'headspace2/headspace.php'; break; case 'seo-seou': $chk['class'] = 'SEO_Ultimate'; $chk['plugin'] = 'seo-ultimate/seo-ultimate.php'; break; case 'seo-wpseo': $chk['function'] = 'wpseo_init'; $chk['plugin'] = 'wordpress-seo/wp-seo.php'; break; case 'social-buddypress': $chk['class'] = 'BuddyPress'; $chk['plugin'] = 'buddypress/bp-loader.php'; break; /* * Pro Version Features / Options */ /* * Pro Version Features / Options */ case 'head-twittercard': $chk['optval'] = 'tc_enable'; break; case 'media-gravatar': $chk['optval'] = 'plugin_gravatar_api'; break; case 'media-slideshare': $chk['optval'] = 'plugin_slideshare_api'; break; case 'media-vimeo': $chk['optval'] = 'plugin_vimeo_api'; break; case 'media-wistia': $chk['optval'] = 'plugin_wistia_api'; break; case 'media-youtube': $chk['optval'] = 'plugin_youtube_api'; break; case 'admin-apikeys': case 'admin-sharing': case 'admin-style': if ($ret['ssb'] === true) { $ret[$sub]['*'] = $ret[$sub][$id] = true; } break; case 'admin-general': case 'admin-advanced': case 'admin-postmeta': case 'admin-user': case 'util-postmeta': case 'util-user': $ret[$sub]['*'] = $ret[$sub][$id] = true; break; case 'util-language': $chk['optval'] = 'plugin_filter_lang'; break; case 'util-shorten': $chk['optval'] = 'twitter_shortener'; break; } if (!empty($chk['function']) && function_exists($chk['function']) || !empty($chk['class']) && class_exists($chk['class']) || !empty($chk['plugin']) && in_array($chk['plugin'], $this->active_plugins) || !empty($chk['optval']) && !empty($this->p->options[$chk['optval']]) && $this->p->options[$chk['optval']] !== 'none') { $ret[$sub]['*'] = $ret[$sub][$id] = true; } } } return $ret; }
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 — 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; }
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; }
public function get_content_images($num = 0, $size_name = 'thumbnail', $post_id = 0, $check_dupes = true, $content = '') { if ($this->p->debug->enabled) { $this->p->debug->args(array('num' => $num, 'size_name' => $size_name, 'post_id' => $post_id, 'check_dupes' => $check_dupes, 'content' => strlen($content) . ' chars')); } $og_ret = array(); $og_image = SucomUtil::meta_image_tags('og'); $size_info = $this->get_size_info($size_name); // allow custom content to be passed as argument if (empty($content)) { $content = $this->p->webpage->get_content($post_id, false); } // use_post = false if (empty($content)) { if ($this->p->debug->enabled) { $this->p->debug->log('exiting early: empty post content'); } return $og_ret; } // img attributes in order of preference // data_tags_preg provides a filter hook for 3rd party modules like ngg to return image information if (preg_match_all('/<(' . $this->data_tags_preg . '[^>]*? ' . $this->data_attr_preg . '=[\'"]([0-9]+)[\'"]|' . '(img)[^>]*? (data-share-src|src)=[\'"]([^\'"]+)[\'"])[^>]*>/s', $content, $match, PREG_SET_ORDER)) { if ($this->p->debug->enabled) { $this->p->debug->log(count($match) . ' x matching <' . $this->data_tags_preg . '/> html tag(s) found'); } foreach ($match as $img_num => $img_arr) { $tag_value = $img_arr[0]; if (empty($img_arr[5])) { $tag_name = $img_arr[2]; // img $attr_name = $img_arr[3]; // data-wp-pid $attr_value = $img_arr[4]; // id } else { $tag_name = $img_arr[5]; // img $attr_name = $img_arr[6]; // data-share-src|src $attr_value = $img_arr[7]; // url } if ($this->p->debug->enabled) { $this->p->debug->log('match ' . $img_num . ': ' . $tag_name . ' ' . $attr_name . '="' . $attr_value . '"'); } switch ($attr_name) { case 'data-wp-pid': list($og_image['og:image'], $og_image['og:image:width'], $og_image['og:image:height'], $og_image['og:image:cropped'], $og_image['og:image:id']) = $this->get_attachment_image_src($attr_value, $size_name, false); break; // filter hook for 3rd party modules to return image information // filter hook for 3rd party modules to return image information case preg_match('/^data-[a-z]+-pid$/', $attr_name) ? true : false: $filter_name = $this->p->cf['lca'] . '_get_content_' . $tag_name . '_' . preg_replace('/-/', '_', $attr_name); list($og_image['og:image'], $og_image['og:image:width'], $og_image['og:image:height'], $og_image['og:image:cropped'], $og_image['og:image:id']) = apply_filters($filter_name, array(null, null, null, null), $attr_value, $size_name, false); break; default: // prevent duplicates by silently ignoring ngg images (already processed by the ngg module) if ($this->p->is_avail['media']['ngg'] === true && !empty($this->p->mods['media']['ngg']) && (strpos($tag_value, " class='ngg-") !== false || preg_match('/^' . $this->p->mods['media']['ngg']->img_src_preg . '$/', $attr_value))) { break; } // stop here // recognize gravatar images in the content if (preg_match('/^https?:\\/\\/([^\\.]+\\.)?gravatar\\.com\\/avatar\\/[a-zA-Z0-9]+/', $attr_value, $match)) { $og_image['og:image'] = $match[0] . '?s=' . $size_info['width'] . '&d=404&r=G'; $og_image['og:image:width'] = $size_info['width']; $og_image['og:image:height'] = $size_info['width']; // square image break; // stop here } $og_image = array('og:image' => $attr_value, 'og:image:width' => -1, 'og:image:height' => -1); // try and get the width and height from the image attributes if (!empty($og_image['og:image'])) { if (preg_match('/ width=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match)) { $og_image['og:image:width'] = $match[1]; } if (preg_match('/ height=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match)) { $og_image['og:image:height'] = $match[1]; } } $is_sufficient_width = $og_image['og:image:width'] >= $size_info['width'] ? true : false; $is_sufficient_height = $og_image['og:image:height'] >= $size_info['height'] ? true : false; // make sure the image width and height are large enough if ($attr_name == 'data-share-src' || $attr_name == 'src' && empty($this->p->options['plugin_ignore_small_img']) || $attr_name == 'src' && $size_info['crop'] === 1 && $is_sufficient_width && $is_sufficient_height || $attr_name == 'src' && $size_info['crop'] !== 1 && ($is_sufficient_width || $is_sufficient_height)) { // data-share-src attribute used and/or image size is acceptable // check for relative urls, just in case $og_image['og:image'] = $this->p->util->fix_relative_url($og_image['og:image']); } else { if ($this->p->debug->enabled) { $this->p->debug->log('image rejected: width / height attributes missing or too small for ' . $size_name); if (is_admin()) { $this->p->notice->err('Image ' . $og_image['og:image'] . ' rejected - width / height missing or too small for ' . $size_name . '.'); } } $og_image = array(); } break; } if (!empty($og_image['og:image']) && ($check_dupes === false || $this->p->util->is_uniq_url($og_image['og:image'], $size_name))) { if ($this->p->util->push_max($og_ret, $og_image, $num)) { return $og_ret; } } } return $og_ret; } if ($this->p->debug->enabled) { $this->p->debug->log('no matching <' . $this->data_tags_preg . '/> html tag(s) found'); } return $og_ret; }
public function get_script($pos = 'id') { if ($this->p->debug->enabled) { $this->p->debug->mark(); } $prot = empty($_SERVER['HTTPS']) ? 'http:' : 'https:'; $app_id = empty($this->p->options['fb_app_id']) ? '' : $this->p->options['fb_app_id']; $lang = empty($this->p->options['fb_lang']) ? 'en_US' : $this->p->options['fb_lang']; $lang = apply_filters($this->p->cf['lca'] . '_lang', $lang, SucomUtil::get_pub_lang('facebook')); // do not use get_cache_file_url() since the facebook javascript does not work when hosted locally $js_url = apply_filters($this->p->cf['lca'] . '_js_url_facebook', $prot . '//connect.facebook.net/' . $lang . '/sdk.js#xfbml=1&version=v2.3&appId=' . $app_id, $pos); $html = '<script type="text/javascript" id="fb-script-' . $pos . '">' . $this->p->cf['lca'] . '_insert_js( "fb-script-' . $pos . '", "' . $js_url . '" );</script>' . "\n"; return $html; }
public function get_content_images($num = 0, $size_name = 'thumbnail', $post_id = 0, $check_dupes = true, $content = '') { if ($this->p->debug->enabled) { $this->p->debug->args(array('num' => $num, 'size_name' => $size_name, 'post_id' => $post_id, 'check_dupes' => $check_dupes, 'content' => strlen($content) . ' chars')); } $og_ret = array(); // allow custom content to be passed as argument if (empty($content)) { $content_provided = false; $content = $this->p->webpage->get_content($post_id, false); // use_post = false } else { $content_provided = true; } if (empty($content)) { if ($this->p->debug->enabled) { $this->p->debug->log('exiting early: empty post content'); } return $og_ret; } $og_image = SucomUtil::meta_image_tags('og'); $size_info = $this->get_size_info($size_name); $img_preg = $this->default_img_preg; // allow the html_tag and pid_attr regex to be modified foreach (array('html_tag', 'pid_attr') as $type) { $filter_name = $this->p->cf['lca'] . '_content_image_preg_' . $type; if (has_filter($filter_name)) { $img_preg[$type] = apply_filters($filter_name, $this->default_img_preg[$type]); if ($this->p->debug->enabled) { $this->p->debug->log('filtered image preg ' . $type . ' = \'' . $img_preg[$type] . '\''); } } } // img attributes in order of preference if (preg_match_all('/<((' . $img_preg['html_tag'] . ')[^>]*? (' . $img_preg['pid_attr'] . ')=[\'"]([0-9]+)[\'"]|' . '(img)[^>]*? (data-share-src|src)=[\'"]([^\'"]+)[\'"])[^>]*>/s', $content, $all_matches, PREG_SET_ORDER)) { if ($this->p->debug->enabled) { $this->p->debug->log(count($all_matches) . ' x matching <' . $img_preg['html_tag'] . '/> html tag(s) found'); } foreach ($all_matches as $img_num => $img_arr) { $tag_value = $img_arr[0]; if (empty($img_arr[5])) { $tag_name = $img_arr[2]; // img $attr_name = $img_arr[3]; // data-wp-pid $attr_value = $img_arr[4]; // id } else { $tag_name = $img_arr[5]; // img $attr_name = $img_arr[6]; // data-share-src|src $attr_value = $img_arr[7]; // url } if ($this->p->debug->enabled) { $this->p->debug->log('match ' . $img_num . ': ' . $tag_name . ' ' . $attr_name . '="' . $attr_value . '"'); } switch ($attr_name) { // wordpress media library image id case 'data-wp-pid': list($og_image['og:image'], $og_image['og:image:width'], $og_image['og:image:height'], $og_image['og:image:cropped'], $og_image['og:image:id']) = $this->get_attachment_image_src($attr_value, $size_name, false); break; // check for other data attributes like 'data-ngg-pid' // check for other data attributes like 'data-ngg-pid' case preg_match('/^' . $img_preg['pid_attr'] . '$/', $attr_name) ? true : false: // build a filter hook for 3rd party modules to return image information $filter_name = $this->p->cf['lca'] . '_get_content_' . $tag_name . '_' . preg_replace('/-/', '_', $attr_name); list($og_image['og:image'], $og_image['og:image:width'], $og_image['og:image:height'], $og_image['og:image:cropped'], $og_image['og:image:id']) = apply_filters($filter_name, array(null, null, null, null, null), $attr_value, $size_name, false); break; default: // prevent duplicates by silently ignoring ngg images (already processed by the ngg module) if ($this->p->is_avail['media']['ngg'] === true && !empty($this->p->mods['media']['ngg']) && (preg_match('/ class=[\'"]ngg[_-]/', $tag_value) || preg_match('/^(' . $img_preg['ngg_src'] . ')$/', $attr_value))) { break; } // stop here // recognize gravatar images in the content if (preg_match('/^https?:\\/\\/([^\\.]+\\.)?gravatar\\.com\\/avatar\\/[a-zA-Z0-9]+/', $attr_value, $match)) { $og_image['og:image'] = $match[0] . '?s=' . $size_info['width'] . '&d=404&r=G'; $og_image['og:image:width'] = $size_info['width']; $og_image['og:image:height'] = $size_info['width']; // square image break; // stop here } // check for image ID in class for old content w/o the data-wp-pid attribute if (preg_match('/class="[^"]+ wp-image-([0-9]+)/', $tag_value, $match)) { list($og_image['og:image'], $og_image['og:image:width'], $og_image['og:image:height'], $og_image['og:image:cropped'], $og_image['og:image:id']) = $this->get_attachment_image_src($match[1], $size_name, false); break; // stop here } else { $og_image = array('og:image' => $attr_value, 'og:image:width' => -1, 'og:image:height' => -1); } // try and get the width and height from the image attributes if (!empty($og_image['og:image'])) { if (preg_match('/ width=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match)) { $og_image['og:image:width'] = $match[1]; } if (preg_match('/ height=[\'"]?([0-9]+)[\'"]?/i', $tag_value, $match)) { $og_image['og:image:height'] = $match[1]; } } $is_sufficient_width = $og_image['og:image:width'] >= $size_info['width'] ? true : false; $is_sufficient_height = $og_image['og:image:height'] >= $size_info['height'] ? true : false; $accept_img_size = apply_filters($this->p->cf['lca'] . '_content_accept_img_size', empty($this->p->options['plugin_ignore_small_img']) ? true : false, $og_image['og:image'], $og_image['og:image:width'], $og_image['og:image:height'], $size_name, $post_id); // make sure the image width and height are large enough if ($attr_name == 'src' && $accept_img_size || $attr_name == 'src' && $size_info['crop'] && ($is_sufficient_width && $is_sufficient_height) || $attr_name == 'src' && !$size_info['crop'] && ($is_sufficient_width || $is_sufficient_height) || $attr_name == 'data-share-src') { // data-share-src attribute used and/or image size is acceptable // check for relative urls, just in case $og_image['og:image'] = $this->p->util->fix_relative_url($og_image['og:image']); } else { if ($this->p->debug->enabled) { $this->p->debug->log('content image rejected: ' . 'width / height missing or too small for ' . $size_name); } if (is_admin()) { $short = $this->p->cf['plugin'][$this->p->cf['lca']]['short']; $size_label = $this->p->util->get_image_size_label($size_name); $msg_id = 'content_' . $og_image['og:image'] . '_' . $size_name . '_rejected'; if (!$content_provided) { $data_wp_pid_msg = ' ' . sprintf(__('%1$s includes an additional \'data-wp-pid\' attribute for images from the Media Library to supplement the width / height information — if this image was selected from the Media Library before %2$s was first activated, try removing and adding the image back to your content.', 'nextgen-facebook'), $short, $short); } else { $data_wp_pid_msg = ''; } $this->p->notice->err(sprintf(__('Content image %1$s has been ignored — the image width / height attributes are missing or too small for the %2$s image dimensions.', 'nextgen-facebook'), $og_image['og:image'], $size_label . ' (' . $size_name . ')') . $data_wp_pid_msg, false, true, $msg_id, true); } $og_image = array(); } break; } if (!empty($og_image['og:image']) && ($check_dupes === false || $this->p->util->is_uniq_url($og_image['og:image'], $size_name))) { if ($this->p->util->push_max($og_ret, $og_image, $num)) { return $og_ret; } } } return $og_ret; } if ($this->p->debug->enabled) { $this->p->debug->log('no matching <' . $img_preg['html_tag'] . '/> html tag(s) found'); } return $og_ret; }
public function get_site_name($get = 'current') { // provide options array to allow fallback if locale option does not exist $key = SucomUtil::get_locale_key('og_site_name', $this->p->options, $get); if (!empty($this->p->options[$key])) { return $this->p->options[$key]; } else { return get_bloginfo('name', 'display'); } }