本文整理汇总了PHP中SucomUtil类的典型用法代码示例。如果您正苦于以下问题:PHP SucomUtil类的具体用法?PHP SucomUtil怎么用?PHP SucomUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SucomUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter_check_head_meta_options
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;
}
示例2: get_config
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;
}
}
示例3: get_rows
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;
}
示例4: ngfb_get_sharing_buttons
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;
}
示例5: get_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";
}
示例6: filter_post_text_rows
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>');
}
示例7: get_config
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;
}
}
示例8: options
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;
}
示例9: options
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
}
示例10: ngfb_get_sharing_buttons
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;
}
示例11: filter_sharing_preset_rows
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;
}
示例12: get_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;
}
示例13: get_config
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;
}
}
示例14: widget
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();
}
示例15: load_lib
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;
}