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


PHP get_blog_lang_code函数代码示例

本文整理汇总了PHP中get_blog_lang_code函数的典型用法代码示例。如果您正苦于以下问题:PHP get_blog_lang_code函数的具体用法?PHP get_blog_lang_code怎么用?PHP get_blog_lang_code使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: wpcom_fu_wplang

function wpcom_fu_wplang($lang)
{
    if (function_exists('get_blog_lang_code')) {
        $lang = str_replace('-', '_', get_blog_lang_code());
    }
    return $lang;
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:7,代码来源:wpcom-helper.php

示例2: get_locale

 protected function get_locale($key)
 {
     if ('locale' == $key) {
         if (defined('IS_WPCOM') && IS_WPCOM) {
             return (string) get_blog_lang_code();
         } else {
             return get_locale();
         }
     }
     return false;
 }
开发者ID:pcuervo,项目名称:wp-carnival,代码行数:11,代码来源:class.wpcom-json-api-site-settings-v1-2-endpoint.php

示例3: process_locale

 protected function process_locale($key, $is_user_logged_in)
 {
     if ($is_user_logged_in && 'locale' == $key) {
         if (defined('IS_WPCOM') && IS_WPCOM) {
             if (!is_jetpack_site()) {
                 return (string) get_blog_lang_code();
             }
         }
     }
     return false;
 }
开发者ID:pcuervo,项目名称:wp-carnival,代码行数:11,代码来源:class.wpcom-json-api-get-site-v1-2-endpoint.php

示例4: get_base_recaptcha_lang_code

function get_base_recaptcha_lang_code()
{
    $base_recaptcha_lang_code_mapping = array('en' => 'en', 'nl' => 'nl', 'fr' => 'fr', 'fr-be' => 'fr', 'fr-ca' => 'fr', 'fr-ch' => 'fr', 'de' => 'de', 'pt' => 'pt', 'pt-br' => 'pt', 'ru' => 'ru', 'es' => 'es', 'tr' => 'tr');
    $blog_lang_code = function_exists('get_blog_lang_code') ? get_blog_lang_code() : get_bloginfo('language');
    if (isset($base_recaptcha_lang_code_mapping[$blog_lang_code])) {
        return $base_recaptcha_lang_code_mapping[$blog_lang_code];
    }
    // if no base mapping is found return default 'en'
    return 'en';
}
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:10,代码来源:sharing-service.php

示例5: write_post

 function write_post($path, $blog_id, $post_id)
 {
     $new = $this->api->ends_with($path, '/new');
     $args = $this->query_args();
     // unhook publicize, it's hooked again later -- without this, skipping services is impossible
     if (defined('IS_WPCOM') && IS_WPCOM) {
         remove_action('save_post', array($GLOBALS['publicize_ui']->publicize, 'async_publicize_post'), 100, 2);
         add_action('rest_api_inserted_post', array($GLOBALS['publicize_ui']->publicize, 'async_publicize_post'));
     }
     if ($new) {
         $input = $this->input(true);
         // 'future' is an alias for 'publish' for now
         if (isset($input['status']) && 'future' === $input['status']) {
             $input['status'] = 'publish';
         }
         if ('revision' === $input['type']) {
             if (!isset($input['parent'])) {
                 return new WP_Error('invalid_input', 'Invalid request input', 400);
             }
             $input['status'] = 'inherit';
             // force inherit for revision type
             $input['slug'] = $input['parent'] . '-autosave-v1';
         } elseif (!isset($input['title']) && !isset($input['content']) && !isset($input['excerpt'])) {
             return new WP_Error('invalid_input', 'Invalid request input', 400);
         }
         // default to post
         if (empty($input['type'])) {
             $input['type'] = 'post';
         }
         $post_type = get_post_type_object($input['type']);
         if (!$this->is_post_type_allowed($input['type'])) {
             return new WP_Error('unknown_post_type', 'Unknown post type', 404);
         }
         if (!empty($input['author'])) {
             $author_id = parent::parse_and_set_author($input['author'], $input['type']);
             unset($input['author']);
             if (is_wp_error($author_id)) {
                 return $author_id;
             }
         }
         if ('publish' === $input['status']) {
             if (!current_user_can($post_type->cap->publish_posts)) {
                 if (current_user_can($post_type->cap->edit_posts)) {
                     $input['status'] = 'pending';
                 } else {
                     return new WP_Error('unauthorized', 'User cannot publish posts', 403);
                 }
             }
         } else {
             if (!current_user_can($post_type->cap->edit_posts)) {
                 return new WP_Error('unauthorized', 'User cannot edit posts', 403);
             }
         }
     } else {
         $input = $this->input(false);
         if (!is_array($input) || !$input) {
             return new WP_Error('invalid_input', 'Invalid request input', 400);
         }
         // 'future' is an alias for 'publish' for now
         if (isset($input['status']) && 'future' === $input['status']) {
             $input['status'] = 'publish';
         }
         $post = get_post($post_id);
         $_post_type = !empty($input['type']) ? $input['type'] : $post->post_type;
         $post_type = get_post_type_object($_post_type);
         if (!$post || is_wp_error($post)) {
             return new WP_Error('unknown_post', 'Unknown post', 404);
         }
         if (!current_user_can('edit_post', $post->ID)) {
             return new WP_Error('unauthorized', 'User cannot edit post', 403);
         }
         if (!empty($input['author'])) {
             $author_id = parent::parse_and_set_author($input['author'], $_post_type);
             unset($input['author']);
             if (is_wp_error($author_id)) {
                 return $author_id;
             }
         }
         if (isset($input['status']) && 'publish' === $input['status'] && 'publish' !== $post->post_status && !current_user_can('publish_post', $post->ID)) {
             $input['status'] = 'pending';
         }
         $last_status = $post->post_status;
         $new_status = isset($input['status']) ? $input['status'] : $last_status;
         // Make sure that drafts get the current date when transitioning to publish if not supplied in the post.
         $date_in_past = strtotime($post->post_date_gmt) < time();
         if ('publish' === $new_status && 'draft' === $last_status && !isset($input['date_gmt']) && $date_in_past) {
             $input['date_gmt'] = gmdate('Y-m-d H:i:s');
         }
     }
     if (function_exists('wpcom_switch_to_locale')) {
         // fixes calypso-pre-oss #12476: respect blog locale when creating the post slug
         wpcom_switch_to_locale(get_blog_lang_code($blog_id));
     }
     // If date is set, $this->input will set date_gmt, date still needs to be adjusted f
     if (isset($input['date_gmt'])) {
         $gmt_offset = get_option('gmt_offset');
         $time_with_offset = strtotime($input['date_gmt']) + $gmt_offset * HOUR_IN_SECONDS;
         $input['date'] = date('Y-m-d H:i:s', $time_with_offset);
     }
     if (!empty($author_id) && get_current_user_id() != $author_id) {
//.........这里部分代码省略.........
开发者ID:egill,项目名称:jetpack,代码行数:101,代码来源:class.wpcom-json-api-update-post-v1-2-endpoint.php

示例6: wpcom_print_news_sitemap

function wpcom_print_news_sitemap($format)
{
    if (defined('WPCOM_SKIP_DEFAULT_NEWS_SITEMAP') && WPCOM_SKIP_DEFAULT_NEWS_SITEMAP) {
        return;
    }
    global $wpdb;
    $post_types = apply_filters('wpcom_sitemap_news_sitemap_post_types', array('post'));
    if (empty($post_types)) {
        return;
    }
    $post_types_in = array();
    foreach ($post_types as $post_type) {
        $post_types_in[] = $wpdb->prepare('%s', $post_type);
    }
    $post_types_in_string = implode(', ', $post_types_in);
    $limit = apply_filters('wpcom_sitemap_news_sitemap_count', 1000);
    $cur_datetime = current_time('mysql', true);
    $query = $wpdb->prepare("\n\t\tSELECT p.ID, p.post_title, p.post_type, p.post_date, p.post_name, p.post_date_gmt, GROUP_CONCAT(t.name SEPARATOR ', ') AS keywords\n\t\tFROM\n\t\t\t{$wpdb->posts} AS p LEFT JOIN {$wpdb->term_relationships} AS r ON p.ID = r.object_id\n\t\t\tLEFT JOIN {$wpdb->term_taxonomy} AS tt ON r.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = 'post_tag'\n\t\t\tLEFT JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id\n\t\tWHERE\n\t\t\tpost_status='publish' AND post_type IN ( {$post_types_in_string} ) AND post_date_gmt > (%s - INTERVAL 2 DAY)\n\t\tGROUP BY p.ID\n\t\tORDER BY p.post_date_gmt DESC LIMIT %d", $cur_datetime, $limit);
    header('Content-Type: application/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    ?>
<!-- generator="wordpress.com" -->
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
	xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
	xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
	xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
	>
<?php 
    $posts = $wpdb->get_results($query);
    foreach ($posts as $post) {
        // Add in filter to allow skipping specific posts
        if (apply_filters('wpcom_sitemap_news_skip_post', false, $post)) {
            continue;
        }
        $GLOBALS['post'] = $post;
        $url = array();
        $url['loc'] = get_permalink($post->ID);
        $news = array();
        $news['news:publication']['news:name'] = get_bloginfo_rss('name');
        if (function_exists('get_blog_lang_code')) {
            $news['news:publication']['news:language'] = get_blog_lang_code();
        }
        $news['news:publication_date'] = w3cdate_from_mysql($post->post_date_gmt);
        $news['news:title'] = get_the_title_rss();
        if ($post->keywords) {
            $news['news:keywords'] = html_entity_decode(ent2ncr($post->keywords), ENT_HTML5);
        }
        $url['news:news'] = $news;
        // Add image to sitemap
        if (current_theme_supports('post-thumbnails') && has_post_thumbnail($post->ID)) {
            $post_thumbnail_id = get_post_thumbnail_id($post->ID);
            $post_thumbnail_src = wp_get_attachment_image_src($post_thumbnail_id);
            if ($post_thumbnail_src) {
                $url['image:image'] = array('image:loc' => esc_url($post_thumbnail_src[0]));
            }
        }
        $url = apply_filters('wpcom_sitemap_news_sitemap_item', $url, $post);
        if (empty($url)) {
            continue;
        }
        wpcom_print_sitemap_item($url);
    }
    ?>
</urlset>
<?php 
    die;
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:68,代码来源:wpcom-sitemap.php

示例7: jetpack_print_news_sitemap

/**
 * Prints the news XML sitemap conforming to the Sitemaps.org protocol.
 * Outputs an XML list of up to 1000 posts published in the last 2 days.
 *
 * @module sitemaps
 *
 * @link http://sitemaps.org/protocol.php Sitemaps.org protocol.
 */
function jetpack_print_news_sitemap()
{
    $xml = get_transient('jetpack_news_sitemap');
    if ($xml) {
        header('Content-Type: application/xml');
        echo $xml;
        die;
    }
    global $wpdb;
    /**
     * Filter post types to be included in news sitemap.
     *
     * @module sitemaps
     *
     * @since 3.9.0
     *
     * @param array $post_types Array with post types to include in news sitemap.
     */
    $post_types = apply_filters('jetpack_sitemap_news_sitemap_post_types', array('post'));
    if (empty($post_types)) {
        return;
    }
    $post_types_in = array();
    foreach ($post_types as $post_type) {
        $post_types_in[] = $wpdb->prepare('%s', $post_type);
    }
    $post_types_in_string = implode(', ', $post_types_in);
    /**
     * Filter limit of entries to include in news sitemap.
     *
     * @module sitemaps
     *
     * @since 3.9.0
     *
     * @param int $count Number of entries to include in news sitemap.
     */
    $limit = apply_filters('jetpack_sitemap_news_sitemap_count', 1000);
    $cur_datetime = current_time('mysql', true);
    $query = $wpdb->prepare("\n\t\tSELECT p.ID, p.post_title, p.post_type, p.post_date, p.post_name, p.post_date_gmt, GROUP_CONCAT(t.name SEPARATOR ', ') AS keywords\n\t\tFROM\n\t\t\t{$wpdb->posts} AS p LEFT JOIN {$wpdb->term_relationships} AS r ON p.ID = r.object_id\n\t\t\tLEFT JOIN {$wpdb->term_taxonomy} AS tt ON r.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = 'post_tag'\n\t\t\tLEFT JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id\n\t\tWHERE\n\t\t\tpost_status='publish' AND post_type IN ( {$post_types_in_string} ) AND post_date_gmt > (%s - INTERVAL 2 DAY)\n\t\tGROUP BY p.ID\n\t\tORDER BY p.post_date_gmt DESC LIMIT %d", $cur_datetime, $limit);
    // URL to XSLT
    $xsl = get_option('permalink_structure') ? home_url('news-sitemap.xsl') : home_url('/?jetpack-news-sitemap-xsl=true');
    header('Content-Type: application/xml');
    ob_start();
    echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    echo '<?xml-stylesheet type="text/xsl" href="' . esc_url($xsl) . '"?>' . "\n";
    echo '<!-- generator="jetpack-' . JETPACK__VERSION . '" -->' . "\n";
    ?>
	<!-- generator="jetpack" -->
	<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
	        xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
	        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
	        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
		>
		<?php 
    $posts = $wpdb->get_results($query);
    foreach ($posts as $post) {
        /**
         * Filter condition to allow skipping specific posts in news sitemap.
         *
         * @module sitemaps
         *
         * @since 3.9.0
         *
         * @param bool $skip Current boolean. False by default, so no post is skipped.
         * @param WP_POST $post Current post object.
         */
        if (apply_filters('jetpack_sitemap_news_skip_post', false, $post)) {
            continue;
        }
        $GLOBALS['post'] = $post;
        $url = array();
        $url['loc'] = get_permalink($post->ID);
        $news = array();
        $news['news:publication']['news:name'] = get_bloginfo_rss('name');
        if (function_exists('get_blog_lang_code')) {
            $news['news:publication']['news:language'] = get_blog_lang_code();
        }
        $news['news:publication_date'] = jetpack_w3cdate_from_mysql($post->post_date_gmt);
        $news['news:title'] = get_the_title_rss();
        if ($post->keywords) {
            $news['news:keywords'] = html_entity_decode(ent2ncr($post->keywords), ENT_HTML5);
        }
        $url['news:news'] = $news;
        // Add image to sitemap
        $post_thumbnail = Jetpack_PostImages::get_image($post->ID);
        if (isset($post_thumbnail['src'])) {
            $url['image:image'] = array('image:loc' => esc_url($post_thumbnail['src']));
        }
        /**
         * Filter associative array with data to build <url> node and its descendants for current post in news sitemap.
         *
//.........这里部分代码省略.........
开发者ID:misfist,项目名称:missdrepants-network,代码行数:101,代码来源:sitemaps.php


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