当前位置: 首页>>代码示例>>PHP>>正文


PHP SucomUtil::get_locale方法代码示例

本文整理汇总了PHP中SucomUtil::get_locale方法的典型用法代码示例。如果您正苦于以下问题:PHP SucomUtil::get_locale方法的具体用法?PHP SucomUtil::get_locale怎么用?PHP SucomUtil::get_locale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SucomUtil的用法示例。


在下文中一共展示了SucomUtil::get_locale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:christocmp,项目名称:bingopaws,代码行数:25,代码来源:functions.php

示例2: 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;
 }
开发者ID:leotaillard,项目名称:btws2016,代码行数:54,代码来源:functions.php

示例3: 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();
 }
开发者ID:kivivuori,项目名称:jotain,代码行数:49,代码来源:sharing.php

示例4: flush_post_cache

 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;
     }
 }
开发者ID:christocmp,项目名称:bingopaws,代码行数:19,代码来源:util.php

示例5: shortcode

 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();
 }
开发者ID:christocmp,项目名称:bingopaws,代码行数:39,代码来源:sharing.php

示例6: clear_cache

 public function clear_cache($term_id, $term_tax_id = false)
 {
     $post_id = 0;
     $lca = $this->p->cf['lca'];
     $lang = SucomUtil::get_locale();
     $sharing_url = $this->p->util->get_sharing_url(false);
     $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'), 'WpssoMeta::get_mod_column_content' => array('mod:taxonomy_lang:' . $lang . '_id:' . $term_id . '_column:' . $lca . '_og_image'));
     $transients = apply_filters($this->p->cf['lca'] . '_taxonomy_cache_transients', $transients, $term_id, $lang, $sharing_url);
     $deleted = $this->p->util->clear_cache_objects($transients);
     if (!empty($this->p->options['plugin_cache_info']) && $deleted > 0) {
         $this->p->notice->inf($deleted . ' items removed from the WordPress object and transient caches.', true);
     }
     return $term_id;
 }
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:14,代码来源:taxonomy.php

示例7: clear_post_cache

 public function clear_post_cache($post_id)
 {
     switch (get_post_status($post_id)) {
         case 'draft':
         case 'pending':
         case 'future':
         case 'private':
         case 'publish':
             $lca = $this->p->cf['lca'];
             $lang = SucomUtil::get_locale();
             $permalink = get_permalink($post_id);
             $permalink_no_meta = add_query_arg(array('WPSSO_META_TAGS_DISABLE' => 1), $permalink);
             $sharing_url = $this->p->util->get_sharing_url($post_id);
             $transients = array('SucomCache::get' => array('url:' . $permalink, 'url:' . $permalink_no_meta), 'WpssoHead::get_header_array' => array('lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url, 'lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url . '_crawler:pinterest'), 'WpssoMeta::get_mod_column_content' => array('mod:post_lang:' . $lang . '_id:' . $post_id . '_column:' . $lca . '_og_image'));
             $transients = apply_filters($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($lca . '_post_cache_objects', $objects, $post_id, $lang, $sharing_url);
             $deleted = $this->clear_cache_objects($transients, $objects);
             if (!empty($this->p->options['plugin_cache_info']) && $deleted > 0) {
                 $this->p->notice->inf($deleted . ' items removed from the WordPress object and transient caches.', true);
             }
             if (function_exists('w3tc_pgcache_flush_post')) {
                 // w3 total cache
                 w3tc_pgcache_flush_post($post_id);
             }
             if (function_exists('wp_cache_post_change')) {
                 // wp super cache
                 wp_cache_post_change($post_id);
             }
             break;
     }
 }
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:32,代码来源:util.php

示例8: get_array

 public function get_array(&$og = array(), $use_post = false)
 {
     $obj = $this->p->util->get_post_object($use_post);
     $post_id = empty($obj->ID) || empty($obj->post_type) ? 0 : $obj->ID;
     $post_type = '';
     $has_video_image = false;
     $og_max = $this->p->util->get_max_nums($post_id);
     $og = apply_filters($this->p->cf['lca'] . '_og_seed', $og, $use_post);
     if (!isset($og['fb:admins'])) {
         $og['fb:admins'] = $this->p->options['fb_admins'];
     }
     if (!isset($og['fb:app_id'])) {
         $og['fb:app_id'] = $this->p->options['fb_app_id'];
     }
     if (!isset($og['og:locale'])) {
         // get the current or configured language for og:locale
         $lang = empty($this->p->options['fb_lang']) ? SucomUtil::get_locale($post_id) : $this->p->options['fb_lang'];
         $lang = apply_filters($this->p->cf['lca'] . '_lang', $lang, SucomUtil::get_pub_lang('facebook'), $post_id);
         $og['og:locale'] = $lang;
     }
     if (!isset($og['og:site_name'])) {
         // pass options array to allow fallback if locale option does not exist
         $key = SucomUtil::get_locale_key('og_site_name', $this->p->options, $post_id);
         if (!empty($this->p->options[$key])) {
             $og['og:site_name'] = $this->p->options[$key];
         } else {
             $og['og:site_name'] = get_bloginfo('name', 'display');
         }
     }
     if (!isset($og['og:url'])) {
         $og['og:url'] = $this->p->util->get_sharing_url($use_post, true, $this->p->util->get_source_id('opengraph'));
     }
     if (!isset($og['og:title'])) {
         $og['og:title'] = $this->p->webpage->get_title($this->p->options['og_title_len'], '...', $use_post);
     }
     if (!isset($og['og:description'])) {
         $og['og:description'] = $this->p->webpage->get_description($this->p->options['og_desc_len'], '...', $use_post);
     }
     if (!isset($og['og:type'])) {
         // singular posts / pages are articles by default
         // check post_type for exceptions (like product pages)
         if (is_singular() || $use_post !== false) {
             if (!empty($obj->post_type)) {
                 $post_type = $obj->post_type;
             }
             switch ($post_type) {
                 case 'article':
                 case 'book':
                 case 'music.song':
                 case 'music.album':
                 case 'music.playlist':
                 case 'music.radio_station':
                 case 'product':
                 case 'profile':
                 case 'video.episode':
                 case 'video.movie':
                 case 'video.other':
                 case 'video.tv_show':
                 case 'website':
                     $og['og:type'] = $post_type;
                     break;
                 default:
                     $og['og:type'] = 'article';
                     break;
             }
             // check for default author info on indexes and searches
         } elseif (!(is_singular() || $use_post !== false) && !is_search() && !empty($this->p->options['og_def_author_on_index']) && !empty($this->p->options['og_def_author_id']) || is_search() && !empty($this->p->options['og_def_author_on_search']) && !empty($this->p->options['og_def_author_id'])) {
             $og['og:type'] = 'article';
             if (!isset($og['article:author'])) {
                 $og['article:author'] = $this->p->addons['util']['user']->get_article_author($this->p->options['og_def_author_id']);
             }
             // default for everything else is 'website'
         } else {
             $og['og:type'] = 'website';
         }
         $og['og:type'] = apply_filters($this->p->cf['lca'] . '_og_type', $og['og:type'], $use_post);
     }
     // if the page is an article, then define the other article meta tags
     if (isset($og['og:type']) && $og['og:type'] == 'article') {
         if (!isset($og['article:author'])) {
             if (is_singular() || $use_post !== false) {
                 if (!empty($obj->post_author)) {
                     $og['article:author'] = $this->p->addons['util']['user']->get_article_author($obj->post_author);
                 } elseif (!empty($this->p->options['og_def_author_id'])) {
                     $og['article:author'] = $this->p->addons['util']['user']->get_article_author($this->p->options['og_def_author_id']);
                 }
             }
         }
         if (!isset($og['article:publisher'])) {
             $og['article:publisher'] = $this->p->options['og_publisher_url'];
         }
         if (!isset($og['article:tag'])) {
             $og['article:tag'] = $this->p->webpage->get_tags($post_id);
         }
         if (!isset($og['article:section'])) {
             $og['article:section'] = $this->p->webpage->get_section($post_id);
         }
         if (!isset($og['article:published_time'])) {
             $og['article:published_time'] = trim(get_the_date('c'));
         }
//.........这里部分代码省略.........
开发者ID:christocmp,项目名称:bingopaws,代码行数:101,代码来源:opengraph.php

示例9: get_header_array

 public function get_header_array($use_post = false, $read_cache = true, &$meta_og = array())
 {
     $lca = $this->p->cf['lca'];
     $short_aop = $this->p->cf['plugin'][$lca]['short'] . ($this->p->is_avail['aop'] ? ' Pro' : '');
     $obj = $this->p->util->get_post_object($use_post);
     $post_id = empty($obj->ID) || empty($obj->post_type) || !is_singular() && $use_post === false ? 0 : $obj->ID;
     $sharing_url = $this->p->util->get_sharing_url($use_post);
     $author_id = false;
     if ($this->p->debug->enabled) {
         $this->p->debug->log('use_post: ' . ($use_post === false ? 'false' : ($use_post === true ? 'true' : $use_post)));
         $this->p->debug->log('post_id: ' . $post_id);
         $this->p->debug->log('obj post_type: ' . (empty($obj->post_type) ? '' : $obj->post_type));
         $this->p->debug->log('sharing url: ' . $sharing_url);
     }
     $header_array = array();
     if ($this->p->is_avail['cache']['transient']) {
         $cache_salt = __METHOD__ . '(' . apply_filters($lca . '_head_cache_salt', 'lang:' . SucomUtil::get_locale() . '_post:' . $post_id . '_url:' . $sharing_url, $use_post) . ')';
         $cache_id = $lca . '_' . md5($cache_salt);
         $cache_type = 'object cache';
         if ($this->p->debug->enabled) {
             $this->p->debug->log($cache_type . ': transient salt ' . $cache_salt);
         }
         if (apply_filters($lca . '_header_read_cache', $read_cache)) {
             $header_array = get_transient($cache_id);
             if ($header_array !== false) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log($cache_type . ': header array retrieved from transient ' . $cache_id);
                 }
                 return $header_array;
             }
         }
     }
     /**
      * Define an author_id, if one is available
      */
     if (is_singular() || $use_post !== false) {
         if (!empty($obj->post_author)) {
             $author_id = $obj->post_author;
         } elseif (!empty($this->p->options['seo_def_author_id'])) {
             $author_id = $this->p->options['seo_def_author_id'];
         }
     } elseif (SucomUtil::is_author_page()) {
         $author_id = $this->p->util->get_author_object('id');
     } elseif ($this->p->util->force_default_author($use_post, 'seo')) {
         $author_id = $this->p->options['seo_def_author_id'];
     }
     if ($this->p->debug->enabled && $author_id !== false) {
         $this->p->debug->log('author_id: ' . $author_id);
     }
     /**
      * Open Graph, Twitter Card
      *
      * The Twitter Card meta tags are added by the 
      * NgfbHeadTwittercard class using an 'ngfb_og' filter hook.
      */
     $meta_og = $this->p->og->get_array($meta_og, $use_post, $obj);
     /**
      * Name / SEO meta tags
      */
     $meta_name = array();
     if (!empty($this->p->options['add_meta_name_author'])) {
         if (isset($this->p->options['seo_author_name']) && $this->p->options['seo_author_name'] !== 'none') {
             $meta_name['author'] = $this->p->mods['util']['user']->get_author_name($author_id, $this->p->options['seo_author_name']);
         }
     }
     if (!empty($this->p->options['add_meta_name_canonical'])) {
         $meta_name['canonical'] = $sharing_url;
     }
     if (!empty($this->p->options['add_meta_name_description'])) {
         $meta_name['description'] = $this->p->webpage->get_description($this->p->options['seo_desc_len'], '...', $use_post, true, false, true, 'seo_desc');
     }
     // add_hashtags = false
     if (!empty($this->p->options['add_meta_name_p:domain_verify'])) {
         if (!empty($this->p->options['rp_dom_verify'])) {
             $meta_name['p:domain_verify'] = $this->p->options['rp_dom_verify'];
         }
     }
     $meta_name = apply_filters($lca . '_meta_name', $meta_name, $use_post, $obj);
     /**
      * Link relation tags
      */
     $link_rel = array();
     if (!empty($this->p->options['add_link_rel_author'])) {
         if (!empty($author_id)) {
             $link_rel['author'] = $this->p->mods['util']['user']->get_author_website_url($author_id, $this->p->options['seo_author_field']);
         }
     }
     if (!empty($this->p->options['add_link_rel_publisher'])) {
         if (!empty($this->p->options['seo_publisher_url'])) {
             $link_rel['publisher'] = $this->p->options['seo_publisher_url'];
         }
     }
     $link_rel = apply_filters($lca . '_link_rel', $link_rel, $use_post, $obj);
     /**
      * Schema meta tags
      */
     $meta_schema = $this->p->schema->get_meta_array($use_post, $obj, $meta_og);
     /**
      * Combine and return all meta tags
      */
//.........这里部分代码省略.........
开发者ID:jamesvillarrubia,项目名称:uniken-web,代码行数:101,代码来源:head.php

示例10: get_array

 public function get_array($use_post = false, $obj = false, &$og = array())
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->mark();
     }
     if (!is_object($obj)) {
         $obj = $this->p->util->get_post_object($use_post);
     }
     $post_id = empty($obj->ID) || empty($obj->post_type) || !SucomUtil::is_post_page($use_post) ? 0 : $obj->ID;
     // counter for video previews found
     $video_previews = 0;
     // post_id 0 returns the default plugin settings
     $og_max = $this->p->util->get_max_nums($post_id, 'post');
     $og = apply_filters($this->p->cf['lca'] . '_og_seed', $og, $use_post, $obj);
     if (!empty($og) && $this->p->debug->enabled) {
         $this->p->debug->log($this->p->cf['lca'] . '_og_seed filter returned:');
         $this->p->debug->log($og);
     }
     if (!isset($og['fb:admins']) && !empty($this->p->options['fb_admins'])) {
         foreach (explode(',', $this->p->options['fb_admins']) as $fb_admin) {
             $og['fb:admins'][] = trim($fb_admin);
         }
     }
     if (!isset($og['fb:app_id'])) {
         $og['fb:app_id'] = $this->p->options['fb_app_id'];
     }
     if (!isset($og['og:url'])) {
         $og['og:url'] = $this->p->util->get_sharing_url($use_post, true, $this->p->util->get_source_id('opengraph'));
     }
     // define the type after the url
     if (!isset($og['og:type'])) {
         // singular posts / pages are articles by default
         // check the post_type for a match with a known open graph type
         if (SucomUtil::is_post_page($use_post)) {
             if (!empty($obj->post_type) && isset($this->p->cf['head']['og_type_ns'][$obj->post_type])) {
                 $og['og:type'] = $obj->post_type;
             } else {
                 $og['og:type'] = 'article';
             }
             // check for default author info on indexes and searches
         } elseif ($this->p->util->force_default_author($use_post, 'og') && !empty($this->p->options['og_def_author_id'])) {
             $og['og:type'] = 'article';
             // meta tag not defined or value is null
             if (!isset($og['article:author'])) {
                 $og['article:author'] = $this->p->mods['util']['user']->get_article_author($this->p->options['og_def_author_id']);
             }
             // default for everything else is 'website'
         } else {
             $og['og:type'] = 'website';
         }
         $og['og:type'] = apply_filters($this->p->cf['lca'] . '_og_type', $og['og:type'], $use_post);
         // pre-define basic open graph meta tags for this type
         if (isset($this->p->cf['head']['og_type_mt'][$og['og:type']])) {
             foreach ($this->p->cf['head']['og_type_mt'][$og['og:type']] as $mt_name) {
                 if (!isset($og[$mt_name])) {
                     $og[$mt_name] = null;
                     if ($this->p->debug->enabled) {
                         $this->p->debug->log($og['og:type'] . ' pre-defined mt: ' . $mt_name);
                     }
                 }
             }
         }
     }
     if (!isset($og['og:locale'])) {
         // get the current or configured language for og:locale
         $lang = empty($this->p->options['fb_lang']) ? SucomUtil::get_locale($post_id) : $this->p->options['fb_lang'];
         $lang = apply_filters($this->p->cf['lca'] . '_lang', $lang, SucomUtil::get_pub_lang('facebook'), $post_id);
         $og['og:locale'] = $lang;
     }
     if (!isset($og['og:site_name'])) {
         $og['og:site_name'] = $this->get_site_name($post_id);
     }
     if (!isset($og['og:title'])) {
         $og['og:title'] = $this->p->webpage->get_title($this->p->options['og_title_len'], '...', $use_post);
     }
     if (!isset($og['og:description'])) {
         $og['og:description'] = $this->p->webpage->get_description($this->p->options['og_desc_len'], '...', $use_post);
     }
     // if the page is an article, then define the other article meta tags
     if (isset($og['og:type']) && $og['og:type'] == 'article') {
         // meta tag not defined or value is null
         if (!isset($og['article:author'])) {
             if (SucomUtil::is_post_page($use_post)) {
                 if (!empty($obj->post_author)) {
                     $og['article:author'] = $this->p->mods['util']['user']->get_article_author($obj->post_author);
                 } elseif (!empty($this->p->options['og_def_author_id'])) {
                     $og['article:author'] = $this->p->mods['util']['user']->get_article_author($this->p->options['og_def_author_id']);
                 }
             }
         }
         // meta tag not defined or value is null
         if (!isset($og['article:publisher'])) {
             $og['article:publisher'] = $this->p->options['fb_publisher_url'];
         }
         // meta tag not defined or value is null
         if (!isset($og['article:tag'])) {
             $og['article:tag'] = $this->p->webpage->get_tags($post_id);
         }
         // meta tag not defined or value is null
         if (!isset($og['article:section'])) {
//.........这里部分代码省略.........
开发者ID:sonvq,项目名称:passioninvestment,代码行数:101,代码来源:opengraph.php

示例11: get_content

 public function get_content($post_id = 0, $use_post = true, $use_cache = true, $md_idx = null, $src_id = '')
 {
     if ($this->p->debug->enabled) {
         $this->p->debug->args(array('post_id' => $post_id, 'use_post' => $use_post, 'use_cache' => $use_cache, 'md_idx' => $md_idx, 'src_id' => $src_id));
     }
     $content = false;
     // if $post_id is 0, then pass the $use_post (true/false) value instead
     if (($obj = $this->p->util->get_post_object(empty($post_id) ? $use_post : $post_id)) === false) {
         if ($this->p->debug->enabled) {
             $this->p->debug->log('exiting early: invalid object type');
         }
         return $content;
     }
     $post_id = empty($obj->ID) || empty($obj->post_type) ? 0 : $obj->ID;
     if ($this->p->debug->enabled) {
         $this->p->debug->log('using content from object id ' . $post_id);
     }
     $filter_content = $this->p->options['plugin_filter_content'];
     $filter_name = $filter_content ? 'filtered' : 'unfiltered';
     $caption_prefix = isset($this->p->options['plugin_p_cap_prefix']) ? $this->p->options['plugin_p_cap_prefix'] : 'Caption:';
     /*
      * retrieve the content
      */
     if ($filter_content == true) {
         if ($this->p->is_avail['cache']['object']) {
             // if the post id is 0, then add the sharing url to ensure a unique salt string
             $cache_salt = __METHOD__ . '(lang:' . SucomUtil::get_locale() . '_post:' . $post_id . '_' . $filter_name . (empty($post_id) ? '_url:' . $this->p->util->get_sharing_url($use_post, true, $src_id) : '') . ')';
             $cache_id = $this->p->cf['lca'] . '_' . md5($cache_salt);
             $cache_type = 'object cache';
             if ($use_cache === true) {
                 if ($this->p->debug->enabled) {
                     $this->p->debug->log($cache_type . ': wp_cache salt ' . $cache_salt);
                 }
                 $content = wp_cache_get($cache_id, __METHOD__);
                 if ($content !== false) {
                     if ($this->p->debug->enabled) {
                         $this->p->debug->log($cache_type . ': ' . $filter_name . ' content retrieved from wp_cache ' . $cache_id);
                     }
                     return $content;
                 }
             } elseif ($this->p->debug->enabled) {
                 $this->p->debug->log('use_cache = false');
             }
         }
     }
     $content = apply_filters($this->p->cf['lca'] . '_content_seed', '', $post_id, $use_post, $md_idx, $src_id);
     if (!empty($content)) {
         if ($this->p->debug->enabled) {
             $this->p->debug->log('content seed = "' . $content . '"');
         }
     } elseif (!empty($obj->post_content)) {
         $content = $obj->post_content;
     } elseif ($this->p->debug->enabled) {
         $this->p->debug->log('exiting early: empty post content');
     }
     /*
      * modify the content
      */
     // save content length (for comparison) before making changes
     $content_strlen_before = strlen($content);
     // remove singlepics, which we detect and use before-hand
     $content = preg_replace('/\\[singlepic[^\\]]+\\]/', '', $content, -1, $count);
     if ($count > 0) {
         if ($this->p->debug->enabled) {
             $this->p->debug->log($count . ' [singlepic] shortcode(s) removed from content');
         }
     }
     if ($filter_content == true) {
         $filter_removed = apply_filters($this->p->cf['lca'] . '_pre_filter_remove', false, 'the_content');
         // remove all of our shortcodes
         if (isset($this->p->cf['*']['lib']['shortcode']) && is_array($this->p->cf['*']['lib']['shortcode'])) {
             foreach ($this->p->cf['*']['lib']['shortcode'] as $id => $name) {
                 if (array_key_exists($id, $this->shortcode) && is_object($this->shortcode[$id])) {
                     $this->shortcode[$id]->remove();
                 }
             }
         }
         global $post;
         $saved_post = $post;
         // woocommerce can change the $post, so save and restore
         if ($this->p->debug->enabled) {
             $this->p->debug->log('saving $post and applying the_content filters');
         }
         $content = apply_filters('the_content', $content);
         $post = $saved_post;
         // cleanup for NGG pre-v2 album shortcode
         unset($GLOBALS['subalbum']);
         unset($GLOBALS['nggShowGallery']);
         if ($filter_removed) {
             $filter_added = apply_filters($this->p->cf['lca'] . '_post_filter_add', false, 'the_content');
         }
         // add our shortcodes back
         if (isset($this->p->cf['*']['lib']['shortcode']) && is_array($this->p->cf['*']['lib']['shortcode'])) {
             foreach ($this->p->cf['*']['lib']['shortcode'] as $id => $name) {
                 if (array_key_exists($id, $this->shortcode) && is_object($this->shortcode[$id])) {
                     $this->shortcode[$id]->add();
                 }
             }
         }
     } elseif ($this->p->debug->enabled) {
//.........这里部分代码省略.........
开发者ID:leotaillard,项目名称:btws2016,代码行数:101,代码来源:webpage.php

示例12: get_header_array

 public function get_header_array($use_post = false, $read_cache = true, &$meta_og = array())
 {
     $lca = $this->p->cf['lca'];
     $short_aop = $this->p->cf['plugin'][$lca]['short'] . ($this->p->is_avail['aop'] ? ' Pro' : '');
     $obj = $this->p->util->get_post_object($use_post);
     $post_id = empty($obj->ID) || empty($obj->post_type) || !is_singular() && $use_post === false ? 0 : $obj->ID;
     $sharing_url = $this->p->util->get_sharing_url($use_post);
     $author_id = 0;
     $header_array = array();
     if ($this->p->is_avail['cache']['transient']) {
         $cache_salt = __METHOD__ . '(' . apply_filters($lca . '_head_cache_salt', 'lang:' . SucomUtil::get_locale() . '_post:' . $post_id . '_url:' . $sharing_url, $use_post) . ')';
         $cache_id = $lca . '_' . md5($cache_salt);
         $cache_type = 'object cache';
         $this->p->debug->log($cache_type . ': transient salt ' . $cache_salt);
         if ($read_cache) {
             $header_array = get_transient($cache_id);
             if ($header_array !== false) {
                 $this->p->debug->log($cache_type . ': header array retrieved from transient ' . $cache_id);
                 return $header_array;
             }
         }
     }
     /**
      * Define an author_id, if one is available
      */
     if (is_singular() || $use_post !== false) {
         if (!empty($obj->post_author)) {
             $author_id = $obj->post_author;
         } elseif (!empty($this->p->options['seo_def_author_id'])) {
             $author_id = $this->p->options['seo_def_author_id'];
         }
     } elseif (is_author() || is_admin() && ($screen = get_current_screen()) && ($screen->id === 'user-edit' || $screen->id === 'profile')) {
         $author = $this->p->util->get_author_object();
         $author_id = $author->ID;
     } elseif (!(is_singular() || $use_post !== false) && !is_search() && !empty($this->p->options['seo_def_author_on_index']) && !empty($this->p->options['seo_def_author_id']) || is_search() && !empty($this->p->options['seo_def_author_on_search']) && !empty($this->p->options['seo_def_author_id'])) {
         $author_id = $this->p->options['seo_def_author_id'];
     }
     /**
      * Open Graph, Twitter Card
      *
      * The Twitter Card meta tags are added by the NgfbHeadTwittercard class using an 'ngfb_og' filter hook.
      */
     if ($this->p->is_avail['opengraph']) {
         $meta_og = $this->p->og->get_array($meta_og, $use_post);
     }
     /**
      * Name / SEO meta tags
      */
     $meta_name = array();
     if (isset($this->p->options['seo_author_name']) && $this->p->options['seo_author_name'] !== 'none') {
         $meta_name['author'] = $this->p->addons['util']['user']->get_author_name($author_id, $this->p->options['seo_author_name']);
     }
     $meta_name['description'] = $this->p->webpage->get_description($this->p->options['seo_desc_len'], '...', $use_post, true, false, true, 'seo_desc');
     // add_hashtags = false, custom meta = seo_desc
     $meta_name = apply_filters($lca . '_meta_name', $meta_name);
     /**
      * Link relation tags
      */
     $link_rel = array();
     if (!empty($author_id)) {
         $link_rel['author'] = $this->p->addons['util']['user']->get_author_website_url($author_id, $this->p->options['link_author_field']);
     }
     if (!empty($this->p->options['link_publisher_url'])) {
         $link_rel['publisher'] = $this->p->options['link_publisher_url'];
     }
     $link_rel = apply_filters($lca . '_link_rel', $link_rel);
     /**
      * Schema meta tags
      */
     $meta_schema = array();
     $meta_schema['description'] = $this->p->webpage->get_description($this->p->options['og_desc_len'], '...', $use_post, true, true, true, 'schema_desc');
     // custom meta = schema_desc
     $meta_schema = apply_filters($lca . '_meta_schema', $meta_schema);
     /**
      * Combine and return all meta tags
      */
     $header_array = array_merge($this->get_single_tag('meta', 'name', 'generator', $short_aop . ' ' . $this->p->cf['plugin'][$lca]['version'] . ($this->p->check->aop() ? 'L' : ($this->p->is_avail['aop'] ? 'U' : 'G'))), $this->get_tag_array('link', 'rel', $link_rel), $this->get_tag_array('meta', 'name', $meta_name), $this->get_tag_array('meta', 'itemprop', $meta_schema), $this->get_tag_array('meta', 'property', $meta_og));
     if (!empty($this->p->is_avail['cache']['transient'])) {
         set_transient($cache_id, $header_array, $this->p->cache->object_expire);
         $this->p->debug->log($cache_type . ': header array saved to transient ' . $cache_id . ' (' . $this->p->cache->object_expire . ' seconds)');
     }
     return $header_array;
 }
开发者ID:kanvasamsterdam,项目名称:deploykanvas,代码行数:83,代码来源:head.php

示例13: get_array

 public function get_array(&$og = array(), $use_post = false, $obj = false)
 {
     if (!is_object($obj)) {
         $obj = $this->p->util->get_post_object($use_post);
     }
     $post_id = empty($obj->ID) || empty($obj->post_type) || !is_singular() && $use_post === false ? 0 : $obj->ID;
     $post_type = '';
     $video_previews = 0;
     $og_max = $this->p->util->get_max_nums($post_id, 'post');
     // post_id 0 returns the plugin settings
     $og = apply_filters($this->p->cf['lca'] . '_og_seed', $og, $use_post, $obj);
     if (!empty($og) && $this->p->debug->enabled) {
         $this->p->debug->log($this->p->cf['lca'] . '_og_seed filter returned:');
         $this->p->debug->log($og);
     }
     if (!isset($og['fb:admins']) && !empty($this->p->options['fb_admins'])) {
         foreach (explode(',', $this->p->options['fb_admins']) as $fb_admin) {
             $og['fb:admins'][] = trim($fb_admin);
         }
     }
     if (!isset($og['fb:app_id'])) {
         $og['fb:app_id'] = $this->p->options['fb_app_id'];
     }
     if (!isset($og['og:url'])) {
         $og['og:url'] = $this->p->util->get_sharing_url($use_post, true, $this->p->util->get_source_id('opengraph'));
     }
     // define the type after the url
     if (!isset($og['og:type'])) {
         // singular posts / pages are articles by default
         // check the post_type for a match with a known open graph type
         if (is_singular() || $use_post !== false) {
             if (!empty($obj->post_type)) {
                 $post_type = $obj->post_type;
             }
             if (isset($this->p->cf['head']['og_type_ns'][$post_type])) {
                 $og['og:type'] = $post_type;
             } else {
                 $og['og:type'] = 'article';
             }
             // check for default author info on indexes and searches
         } elseif ($this->p->util->force_default_author($use_post, 'og') && !empty($this->p->options['og_def_author_id'])) {
             $og['og:type'] = 'article';
             if (!isset($og['article:author'])) {
                 $og['article:author'] = $this->p->mods['util']['user']->get_article_author($this->p->options['og_def_author_id']);
             }
             // default for everything else is 'website'
         } else {
             $og['og:type'] = 'website';
         }
         $og['og:type'] = apply_filters($this->p->cf['lca'] . '_og_type', $og['og:type'], $use_post);
     }
     if (!isset($og['og:locale'])) {
         // get the current or configured language for og:locale
         $lang = empty($this->p->options['fb_lang']) ? SucomUtil::get_locale($post_id) : $this->p->options['fb_lang'];
         $lang = apply_filters($this->p->cf['lca'] . '_lang', $lang, SucomUtil::get_pub_lang('facebook'), $post_id);
         $og['og:locale'] = $lang;
     }
     if (!isset($og['og:site_name'])) {
         $og['og:site_name'] = $this->get_site_name($post_id);
     }
     if (!isset($og['og:title'])) {
         $og['og:title'] = $this->p->webpage->get_title($this->p->options['og_title_len'], '...', $use_post);
     }
     if (!isset($og['og:description'])) {
         $og['og:description'] = $this->p->webpage->get_description($this->p->options['og_desc_len'], '...', $use_post);
     }
     // if the page is an article, then define the other article meta tags
     if (isset($og['og:type']) && $og['og:type'] == 'article') {
         if (!isset($og['article:author'])) {
             if (is_singular() || $use_post !== false) {
                 if (!empty($obj->post_author)) {
                     $og['article:author'] = $this->p->mods['util']['user']->get_article_author($obj->post_author);
                 } elseif (!empty($this->p->options['og_def_author_id'])) {
                     $og['article:author'] = $this->p->mods['util']['user']->get_article_author($this->p->options['og_def_author_id']);
                 }
             }
         }
         if (!isset($og['article:publisher'])) {
             $og['article:publisher'] = $this->p->options['fb_publisher_url'];
         }
         if (!isset($og['article:tag'])) {
             $og['article:tag'] = $this->p->webpage->get_tags($post_id);
         }
         if (!isset($og['article:section'])) {
             $og['article:section'] = $this->p->webpage->get_section($post_id);
         }
         if (!isset($og['article:published_time'])) {
             $og['article:published_time'] = trim(get_the_date('c'));
         }
         if (!isset($og['article:modified_time'])) {
             $og['article:modified_time'] = trim(get_the_modified_date('c'));
         }
     }
     // get all videos
     // call before getting all images to find / use preview images
     if (!isset($og['og:video'])) {
         if (empty($og_max['og_vid_max'])) {
             if ($this->p->debug->enabled) {
                 $this->p->debug->log('videos disabled: maximum videos = 0');
             }
//.........这里部分代码省略.........
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:101,代码来源:opengraph.php

示例14: get_mod_column_content

 protected function get_mod_column_content($value, $column_name, $id, $mod = '')
 {
     // optimize performance and return immediately if this is not our column
     if (strpos($column_name, $this->p->cf['lca'] . '_') !== 0) {
         return $value;
     }
     // when adding a new category, $screen_id may be false
     $screen_id = SucomUtil::get_screen_id();
     if (!empty($screen_id)) {
         $hidden = get_user_option('manage' . $screen_id . 'columnshidden');
         if (is_array($hidden) && in_array($column_name, $hidden)) {
             return 'Reload to View';
         }
     }
     switch ($column_name) {
         case $this->p->cf['lca'] . '_og_image':
         case $this->p->cf['lca'] . '_og_desc':
             $use_cache = true;
             break;
         default:
             $use_cache = false;
             break;
     }
     if ($use_cache === true && $this->p->is_avail['cache']['transient']) {
         $lang = SucomUtil::get_locale();
         $cache_salt = __METHOD__ . '(mod:' . $mod . '_lang:' . $lang . '_id:' . $id . '_column:' . $column_name . ')';
         $cache_id = $this->p->cf['lca'] . '_' . md5($cache_salt);
         $value = get_transient($cache_id);
         if ($value !== false) {
             return $value;
         }
     }
     switch ($column_name) {
         case $this->p->cf['lca'] . '_og_image':
             // set custom image dimensions for this post/term/user id
             $this->p->util->add_plugin_image_sizes($id, array(), true, $mod);
             break;
     }
     $value = apply_filters($column_name . '_' . $mod . '_column_content', $value, $column_name, $id);
     if ($use_cache === true && $this->p->is_avail['cache']['transient']) {
         set_transient($cache_id, $value, $this->p->options['plugin_object_cache_exp']);
     }
     return $value;
 }
开发者ID:jamesvillarrubia,项目名称:uniken-web,代码行数:44,代码来源:meta.php

示例15: flush_cache

 public function flush_cache($user_id)
 {
     $lang = SucomUtil::get_locale();
     $post_id = 0;
     $sharing_url = $this->p->util->get_sharing_url(false);
     $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'] . '_user_cache_transients', $transients, $post_id, $lang, $sharing_url);
     $this->p->util->flush_cache_objects($transients);
 }
开发者ID:christocmp,项目名称:bingopaws,代码行数:9,代码来源:user.php


注:本文中的SucomUtil::get_locale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。