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


PHP get_blog_id_from_url函数代码示例

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


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

示例1: lccc_breadcrumb

function lccc_breadcrumb()
{
    $crumb_seperator = ' > ';
    $base_url = get_option('lccc_base_path', '');
    $domain = str_replace("/", "", str_replace("http://", "", network_site_url()));
    if ($base_url == true) {
        $base_url_pieces = explode("/", $base_url);
        $base_breadcrumb = '<a href="/" alt="LCCC Home" class="breadcrumb_crumb">Home</a>' . $crumb_seperator;
        $breadcrumb = $base_breadcrumb;
        foreach ($base_url_pieces as $url_piece) {
            $blog_id = get_blog_id_from_url($domain, "/" . $url_piece . "/");
            $site_details = get_blog_details($blog_id);
            $breadcrumb = $breadcrumb . '<a href="/' . $url_piece . '/" class="breadcrumb_crumb">' . $site_details->blogname . '</a>' . $crumb_seperator;
        }
        return $breadcrumb;
    } else {
        return;
    }
}
开发者ID:lorainccc,项目名称:plugins,代码行数:19,代码来源:breadcrumbs.php

示例2: domainMappingUrlFilter

 /**
  * Filters a URL in order to apply domain mapping.
  *
  * @since 150821 Improving multisite compat.
  *
  * @param string $url The input URL to filter.
  *
  * @return string The filtered URL; else the original URL.
  *
  * @note The return value of this function is NOT cached, but inner portions are.
  */
 public function domainMappingUrlFilter($url)
 {
     $original_url = (string) $url;
     // Preserve.
     $url = trim((string) $url);
     if (!is_multisite() || !$this->canConsiderDomainMapping()) {
         return $original_url;
         // Not possible.
     }
     if (!$url || !($url_parts = $this->parseUrl($url))) {
         return $original_url;
         // Not possible.
     }
     if (empty($url_parts['host'])) {
         return $original_url;
         // Not possible.
     }
     $blog_domain = mb_strtolower($url_parts['host']);
     // In the unfiltered URL.
     $blog_path = $this->hostDirToken(false, false, !empty($url_parts['path']) ? $url_parts['path'] : '/');
     if (!($blog_id = (int) get_blog_id_from_url($blog_domain, $blog_path))) {
         return $original_url;
         // Not possible.
     }
     if (!($domain = $this->domainMappingBlogDomain($blog_id)) || $domain === $blog_domain) {
         return $original_url;
         // Not applicable.
     }
     $url_parts['host'] = $domain;
     // Filter the URL now.
     if (!empty($url_parts['path']) && $url_parts['path'] !== '/') {
         if ($host_base_dir_tokens = trim($this->hostBaseDirTokens(false, false, $url_parts['path']), '/')) {
             $url_parts['path'] = preg_replace('/^\\/' . preg_quote($host_base_dir_tokens, '/') . '(\\/|$)/ui', '${1}', $url_parts['path']);
         }
     }
     return $url = $this->unParseUrl($url_parts);
 }
开发者ID:arobbins,项目名称:sblog,代码行数:48,代码来源:DomainMappingUtils.php

示例3: set_additional_blogs

 /**
  * Set any additional blogs to query along with the current blog
  *
  * This method accepts an array of additional blog names, in the format of vip.wordpress.com,
  * that should be queried.
  * 
  * @param array $domains The additional blogs to query
  */
 public function set_additional_blogs($domains = array())
 {
     $this->additional_indices = array();
     foreach ($domains as $domain) {
         $blog_id = (int) get_blog_id_from_url($domain);
         if ($blog_id) {
             $this->additional_indices[] = array('blog_id' => $blog_id);
         }
     }
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:18,代码来源:wpcom-elasticsearch.php

示例4: folios2eval_profpage

function folios2eval_profpage($atts)
{
    global $wpdb;
    $user = wp_get_current_user();
    $major = get_the_user_major($user->ID);
    $eval_table_name = 'wp_seufolios_evaluations';
    $max_evals = 2;
    //!!HARD CODED!!!
    $return = '';
    $folio_ids = $wpdb->get_results("SELECT blogid FROM wp_seufolios_folios2eval WHERE deptid=" . $major);
    foreach ($folio_ids as $id) {
        $folios[] = get_blog_details($id->blogid);
    }
    $return .= "<style>.folios li{color: #666;}.callout-right{font-size:0.85em;margin:2em;padding:0.5em;float:right; background-color:white;border:thin solid #ccc; width:250px;max-width:40%;box-shadow: 5px 5px 3px #888888;}</style>\n";
    $time = date('Y-m-d H:i:s', time() - 7776000);
    $sql = "SELECT id FROM {$eval_table_name} WHERE profid=" . $user->ID . " AND submittime>'" . $time . "'";
    $result = $wpdb->get_results($sql);
    $return .= "<p>Hi {$user->user_nicename},</p><p>";
    if ($wpdb->num_rows) {
        $return .= "Congratulations! ";
    }
    $return .= "You've completed <strong>" . $wpdb->num_rows . "</strong> evaluations so far this semester";
    $sql = "SELECT id FROM {$eval_table_name} WHERE profid=" . $user->ID;
    $result = $wpdb->get_results($sql);
    $return .= " (and <strong>" . $wpdb->num_rows . "</strong> all time).</p>\n<hr>\n";
    $temp_return = "<p class='callout-right'>When you're ready to give feedback on the portfolio click the <em>Evaluate</em> link in the black admin bar at the top of the screen.<br><br>Oh, and once you've opened the evaluation form please either complete the evaluation or delete your feedback. Otherwise we assume you'll finish it and won't assign it to anyone else.</p>\n\t<p>There's still work to be done, though. The portfoios below need to be evaluated. Mind doing one?</p>\n<ul class='folios'>\n";
    $count = 0;
    foreach ($folios as $folio) {
        $student = get_user_by('email', get_blog_option($folio->blog_id, 'admin_email'));
        $result = $wpdb->get_results("SELECT id FROM {$eval_table_name} WHERE studentid=" . $student->ID);
        if ($max_evals - $wpdb->num_rows > 0) {
            $temp_return .= "<li><a href='http://" . $folio->domain . $folio->path . "' target='_blank'>" . $student->user_nicename . " - " . get_blog_option($folio->blog_id, 'blogname') . "</a>&nbsp;&nbsp;(Needs <strong>" . ($max_evals - $wpdb->num_rows) . "</strong> more evaluation" . ($max_evals - $wpdb->num_rows > 1 ? "s)" : ")") . "</li>\n";
            $count++;
        }
    }
    $temp_return .= "</ul>";
    if ($count) {
        $return .= $temp_return;
    } else {
        $return .= "<p>Looks like the portfolios have all been evaluated this year. You're done!</p>";
    }
    //favorites
    $star_table_name = "wp_seufolios_starred";
    $portfolios = $wpdb->get_results("SELECT * FROM {$star_table_name} WHERE deptid={$major}");
    if ($portfolios) {
        $return .= "<h2>Department's Favorites</h2>\n<ul>";
        //$return .= print_r($portfolios, true);
        foreach ($portfolios as $p) {
            $profs = unserialize($p->profids);
            $p_url = parse_url($p->blogurl);
            if (strlen($p_url['path'])) {
                if (substr($p_url['path'], -1) != '/') {
                    $p_url['path'] = $p_url['path'] . '/';
                }
                $p_blog = get_blog_details(get_blog_id_from_url($p_url['host'], $p_url['path']));
            } else {
                $p_blog = get_blog_details(get_blog_id_from_url($p_url['host']));
            }
            $plist[]['txt'] = "<li><a href='{$p->blogurl}'>{$p_blog->blogname}</a> (" . count($profs) . " favorite" . (count($profs) > 1 ? "s)" : ")") . "</li>";
            $plist[]['count'] = count($profs);
        }
        usort($plist, "cmp_plist");
        foreach ($plist as $pl) {
            $return .= $pl['txt'];
        }
        $return .= "</ul>";
    }
    return $return;
}
开发者ID:ryanshoover,项目名称:seufolios,代码行数:69,代码来源:folios2eval.php

示例5: foreach

<?php

require_once './config.php';
// require_once('./classes/MySQL.class.php');
require_once './classes/MySQL.class.php';
require_once '../wp-load.php';
global $wpdb;
//echo get_blog_id_from_url('lola-fr.restofactory.be');
$resto_details = $wpdb->get_results("SELECT url_resto FROM wp_opengraphy WHERE wp_id_blog IS NULL");
// print_r($resto_details);
foreach ($resto_details as $value) {
    //print_r($value->url_resto."/opengraphy/index.php");
    //file_get_contents($value->url_resto);
    //print_r($value->url_resto);
    $url_resto = explode('//', $value->url_resto);
    $wp_url = $value->url_resto;
    $blog_id = get_blog_id_from_url($url_resto[1]);
    if ($blog_id != '0') {
        $wpdb->query("UPDATE wp_opengraphy SET wp_id_blog = {$blog_id} WHERE url_resto = '{$wp_url}'");
    }
}
//print_r($resto_details);
//opengraphy/index.php
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:23,代码来源:script_update_id.php

示例6: cfgp_get_shadow_blog_id

/**
 * cfgp_get_shadow_blog_id
 *
 * "get_blog_id_from_url" function may return a zero, so we want to force a bool false if that's the case.  Otherwise return the blog id.
 *
 * @return bool/int
 */
function cfgp_get_shadow_blog_id()
{
    /* Allow an override here */
    if (defined('CFGP_BLOG_ID') && CFGP_BLOG_ID) {
        return CFGP_BLOG_ID;
    }
    /* Utilize the domain to get the blog id */
    $cfgp_blog_id = get_blog_id_from_url(CFGP_SITE_DOMAIN);
    return $cfgp_blog_id === 0 ? false : $cfgp_blog_id;
}
开发者ID:bigdawggi,项目名称:wp-cf-global-posts,代码行数:17,代码来源:cf-global-posts.php

示例7: test_get_blog_id_from_url_after_dropped

 /**
  * When deleted with the drop parameter as true, the cache will first be false, then set to
  * -1 after an attempt at `get_blog_id_from_url()` is made.
  */
 function test_get_blog_id_from_url_after_dropped()
 {
     $blog_id = self::factory()->blog->create();
     $details = get_blog_details($blog_id, false);
     $key = md5($details->domain . $details->path);
     wpmu_delete_blog($blog_id, true);
     $this->assertEquals(false, wp_cache_get($key, 'blog-id-cache'));
     $this->assertEquals(0, get_blog_id_from_url($details->domain, $details->path));
     $this->assertEquals(-1, wp_cache_get($key, 'blog-id-cache'));
 }
开发者ID:ntwb,项目名称:wordpress-travis,代码行数:14,代码来源:site.php

示例8: fixLinksAndForms

 /**
  * Fix links and forms
  *
  * @param none
  * @return void
  */
 public function fixLinksAndForms()
 {
     global $wpdb;
     // Update anchor and form tags to appropriate URL's
     preg_match_all('/\\<(a|form)[^>]+[\'"]((http|https):\\/\\/[^\'"]+)[\'"][^>]*>/im', $this->_html, $matches);
     for ($i = 0; $i < sizeof($matches[0]); $i++) {
         $html = $matches[0][$i];
         $type = $matches[1][$i];
         $url = $matches[2][$i];
         $scheme = $matches[3][$i];
         $updated = false;
         $post_id = null;
         $blog_id = null;
         $force_ssl = null;
         $url_path = '/';
         if (!$this->getPlugin()->isUrlLocal($url)) {
             continue;
         }
         if ($url != '' && ($url_parts = parse_url($url)) && isset($url_parts['path'])) {
             if ($this->getPlugin()->getHttpsUrl()->getPath() != '/') {
                 if ($this->getPlugin()->getSetting('ssl_host_diff')) {
                     $url_parts['path'] = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $url_parts['path']);
                 }
                 if ($this->getPlugin()->getHttpUrl()->getPath() != '/') {
                     $url_parts['path'] = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $url_parts['path']);
                 }
             }
             // qTranslate integration - strips language from beginning of url path
             if (defined('QTRANS_INIT') && constant('QTRANS_INIT') == true) {
                 global $q_config;
                 if (isset($q_config['enabled_languages'])) {
                     foreach ($q_config['enabled_languages'] as $language) {
                         $url_parts['path'] = preg_replace('/^\\/' . $language . '\\//', '/', $url_parts['path']);
                     }
                 }
             }
             if (preg_match("/page_id=([\\d]+)/", parse_url($url, PHP_URL_QUERY), $postID)) {
                 $post_id = $postID[1];
             } else {
                 if (isset($url_parts['path']) && ($url_parts['path'] == '' || $url_parts['path'] == '/')) {
                     if (get_option('show_on_front') == 'page') {
                         $post_id = get_option('page_on_front');
                     }
                 } else {
                     if (isset($url_parts['path']) && ($post = get_page_by_path($url_parts['path']))) {
                         $post_id = $post->ID;
                     }
                 }
             }
             if (is_multisite() && isset($url_parts['host'])) {
                 if (is_subdomain_install()) {
                     $blog_id = get_blog_id_from_url($url_parts['host'], '/');
                 } else {
                     $url_path_segments = explode('/', $url_parts['path']);
                     if (sizeof($url_path_segments) > 1) {
                         foreach ($url_path_segments as $url_path_segment) {
                             if (is_null($blog_id) && $url_path_segment != '') {
                                 $url_path .= $url_path_segment . '/';
                                 if (($blog_id = get_blog_id_from_url($url_parts['host'], $url_path)) > 0) {
                                     break;
                                 } else {
                                     $blog_id = null;
                                 }
                             }
                         }
                     }
                 }
                 if (!is_null($blog_id) && $blog_id != $wpdb->blogid) {
                     // URL Filters
                     if (sizeof((array) $this->getPlugin()->getSetting('secure_filter', $blog_id)) > 0) {
                         foreach ($this->getPlugin()->getSetting('secure_filter', $blog_id) as $filter) {
                             if (preg_match('/' . str_replace('/', '\\/', $filter) . '/', $url) === 1) {
                                 $force_ssl = true;
                             }
                         }
                     }
                     if (($this->getPlugin()->getSetting('ssl_admin', $blog_id) || defined('FORCE_SSL_ADMIN') && constant('FORCE_SSL_ADMIN')) && strpos($url_parts['path'], 'wp-admin') !== false && (!$this->getPlugin()->getSetting('ssl_host_diff', $blog_id) || $this->getPlugin()->getSetting('ssl_host_diff', $blog_id) && function_exists('is_user_logged_in') && is_user_logged_in())) {
                         $force_ssl = true;
                     } else {
                         if (is_null($force_ssl) && $this->getPlugin()->getSetting('exclusive_https', $blog_id)) {
                             $force_ssl = false;
                         } else {
                             if (strpos($url, 'https://') === 0) {
                                 $force_ssl = true;
                             }
                         }
                     }
                 }
             }
         }
         // Only apply force_ssl filters for current blog
         if (is_null($blog_id)) {
             $force_ssl = apply_filters('force_ssl', null, isset($post_id) ? $post_id : 0, $url);
         }
//.........这里部分代码省略.........
开发者ID:tommbaker,项目名称:platform-www,代码行数:101,代码来源:Parser.php

示例9: get_blog_id_from_url

 /** RESTful endpoint for this multisite function.
  *
  * Get $_REQUEST options for this endpoint:
  *
  * u (optional) -- Username (if not logged in)
  * p (optional) -- Password (if not logged in)
  * domain (required) full domain we want the blog id for
  * path (optional) path we want the blog id for (defaults to '/')
  *
  */
 public function get_blog_id_from_url()
 {
     global $json_api;
     $this->_verify_admin();
     extract($_REQUEST);
     if (!isset($domain)) {
         $json_api->error(__("You must send the 'domain' parameter."));
     }
     if (!isset($path)) {
         $path = '/';
     }
     if ($blog_id = get_blog_id_from_url($domain, $path)) {
         return array("blog_id" => $blog_id);
     } else {
         $json_api->error(__("No blogs were found for this user."));
     }
 }
开发者ID:vccabral,项目名称:wp-json-api,代码行数:27,代码来源:multisite.php

示例10: strtolower

 if (!is_multisite() || !$self->canConsiderDomainMapping()) {
     return $original_url;
     // Not possible.
 }
 if (!$url || !($url_parts = $self->parseUrl($url))) {
     return $original_url;
     // Not possible.
 }
 if (empty($url_parts['host'])) {
     return $original_url;
     // Not possible.
 }
 $blog_domain = strtolower($url_parts['host']);
 // In the unfiltered URL.
 $blog_path = $self->hostDirToken(false, false, !empty($url_parts['path']) ? $url_parts['path'] : '/');
 if (!($blog_id = (int) get_blog_id_from_url($blog_domain, $blog_path))) {
     return $original_url;
     // Not possible.
 }
 if (!($domain = $self->domainMappingBlogDomain($blog_id)) || $domain === $blog_domain) {
     return $original_url;
     // Not applicable.
 }
 $url_parts['host'] = $domain;
 // Filter the URL now.
 if (!empty($url_parts['path']) && $url_parts['path'] !== '/') {
     if ($host_base_dir_tokens = trim($self->hostBaseDirTokens(false, false, $url_parts['path']), '/')) {
         $url_parts['path'] = preg_replace('/^\\/' . preg_quote($host_base_dir_tokens, '/') . '(\\/|$)/i', '${1}', $url_parts['path']);
     }
 }
 return $url = $self->unParseUrl($url_parts);
开发者ID:raamdev,项目名称:zcpzcldiff,代码行数:31,代码来源:DomainMappingUtils.php

示例11: s4w_build_document

function s4w_build_document($post_info, $domain = NULL, $path = NULL)
{
    global $blog_id;
    global $current_blog;
    $doc = NULL;
    $plugin_s4w_settings = s4w_get_option();
    $exclude_ids = $plugin_s4w_settings['s4w_exclude_pages'];
    $categoy_as_taxonomy = $plugin_s4w_settings['s4w_cat_as_taxo'];
    $index_comments = $plugin_s4w_settings['s4w_index_comments'];
    $index_custom_fields = $plugin_s4w_settings['s4w_index_custom_fields'];
    if ($post_info) {
        # check if we need to exclude this document
        if (is_multisite() && in_array($current_blog->domain . $post_info->ID, (array) $exclude_ids)) {
            return NULL;
        } else {
            if (!is_multisite() && in_array($post_info->ID, (array) $exclude_ids)) {
                return NULL;
            }
        }
        $doc = new Apache_Solr_Document();
        $auth_info = get_userdata($post_info->post_author);
        # wpmu specific info
        if (is_multisite()) {
            // if we get here we expect that we've "switched" what blog we're running
            // as
            if ($domain == NULL) {
                $domain = $current_blog->domain;
            }
            if ($path == NULL) {
                $path = $current_blog->path;
            }
            $blogid = get_blog_id_from_url($domain, $path);
            $doc->setField('id', $domain . $path . $post_info->ID);
            $doc->setField('permalink', get_blog_permalink($blogid, $post_info->ID));
            $doc->setField('blogid', $blogid);
            $doc->setField('blogdomain', $domain);
            $doc->setField('blogpath', $path);
            $doc->setField('wp', 'multisite');
        } else {
            $doc->setField('id', $post_info->ID);
            $doc->setField('permalink', get_permalink($post_info->ID));
            $doc->setField('wp', 'wp');
        }
        $numcomments = 0;
        if ($index_comments) {
            $comments = get_comments("status=approve&post_id={$post_info->ID}");
            foreach ($comments as $comment) {
                $doc->addField('comments', $comment->comment_content);
                $numcomments += 1;
            }
        }
        $doc->setField('title', $post_info->post_title);
        $doc->setField('content', strip_tags($post_info->post_content));
        // rawcontent strips out characters lower than 0x20
        $doc->setField('rawcontent', strip_tags(preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', $post_info->post_content)));
        // contentnoshortcodes also strips characters below 0x20 but also strips shortcodes
        // used in WP to add images or other content, useful if you're pulling this data
        // into another system
        //
        // For example
        //   [caption id="attachment_92495" align="alignright" width="160" caption="Duane Sand"][/caption] FARGO - Republican U.S. Senate...
        //
        // Will become
        //   FARGO - Republican U.S. Senate...
        $doc->setField('contentnoshortcodes', strip_tags(preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', strip_tags(strip_shortcodes($post_info->post_content)))));
        $doc->setField('numcomments', $numcomments);
        $doc->setField('author', $auth_info->display_name);
        $doc->setField('author_s', get_author_posts_url($auth_info->ID, $auth_info->user_nicename));
        $doc->setField('type', $post_info->post_type);
        $doc->setField('date', s4w_format_date($post_info->post_date_gmt));
        $doc->setField('tdate', s4w_format_date($post_info->post_date_gmt));
        $doc->setField('modified', s4w_format_date($post_info->post_modified_gmt));
        $doc->setField('displaydate', $post_info->post_date);
        $doc->setField('displaymodified', $post_info->post_modified);
        $categories = get_the_category($post_info->ID);
        if (!$categories == NULL) {
            foreach ($categories as $category) {
                if ($categoy_as_taxonomy) {
                    $doc->addField('categories', get_category_parents($category->cat_ID, FALSE, '^^'));
                } else {
                    $doc->addField('categories', $category->cat_name);
                }
            }
        }
        //get all the taxonomy names used by wp
        $taxonomies = (array) get_taxonomies(array('_builtin' => FALSE), 'names');
        foreach ($taxonomies as $parent) {
            $terms = get_the_terms($post_info->ID, $parent);
            if ((array) $terms === $terms) {
                //we are creating *_taxonomy as dynamic fields using our schema
                //so lets set up all our taxonomies in that format
                $parent = $parent . "_taxonomy";
                foreach ($terms as $term) {
                    $doc->addField($parent, $term->name);
                }
            }
        }
        $tags = get_the_tags($post_info->ID);
        if (!$tags == NULL) {
            foreach ($tags as $tag) {
//.........这里部分代码省略.........
开发者ID:nrcmedia,项目名称:solr-for-wordpress,代码行数:101,代码来源:solr-for-wordpress.php

示例12: fixLinksAndForms

 /**
  * Fix links and forms
  *
  * @param none
  * @return void
  */
 public function fixLinksAndForms()
 {
     global $wpdb;
     // Update anchor and form tags to appropriate URL's
     preg_match_all('/\\<(a|form)[^>]+[\'"]((http|https):\\/\\/[^\'"]+)[\'"][^>]*>/im', $this->_html, $matches);
     $plugin = $this->getPlugin();
     $path_cache = $plugin->getSetting('path_cache');
     $blog_cache = $plugin->getSetting('blog_cache');
     for ($i = 0; $i < sizeof($matches[0]); $i++) {
         $html = $matches[0][$i];
         $type = $matches[1][$i];
         $url = $matches[2][$i];
         $scheme = $matches[3][$i];
         $updated = false;
         $post_id = null;
         $blog_id = null;
         $force_ssl = null;
         $url_path = null;
         $blog_path = null;
         $blog_url_path = '/';
         if (!$plugin->isUrlLocal($url)) {
             continue;
         }
         if ($url != '' && ($url_parts = parse_url($url)) && isset($url_parts['path'])) {
             if ($plugin->getHttpsUrl()->getPath() != '/') {
                 if ($plugin->getSetting('ssl_host_diff')) {
                     $url_parts['path'] = str_replace($plugin->getHttpsUrl()->getPath(), '', $url_parts['path']);
                 }
                 if ($plugin->getHttpUrl()->getPath() != '/') {
                     $url_parts['path'] = str_replace($plugin->getHttpUrl()->getPath(), '', $url_parts['path']);
                 }
             }
             // qTranslate integration - strips language from beginning of url path
             if (defined('QTRANS_INIT') && constant('QTRANS_INIT') == true) {
                 global $q_config;
                 if (isset($q_config['enabled_languages'])) {
                     foreach ($q_config['enabled_languages'] as $language) {
                         $url_parts['path'] = preg_replace('/^\\/' . $language . '\\//', '/', $url_parts['path']);
                     }
                 }
             }
             if (preg_match("/page_id=([\\d]+)/", parse_url($url, PHP_URL_QUERY), $postID)) {
                 $post_id = $postID[1];
             } else {
                 if (isset($url_parts['path']) && ($url_parts['path'] == '' || $url_parts['path'] == '/')) {
                     if (get_option('show_on_front') == 'page') {
                         $post_id = get_option('page_on_front');
                     }
                 } else {
                     if (isset($url_parts['path'])) {
                         $url_path = $url_parts['path'];
                         if (!array_key_exists($url_path, $path_cache)) {
                             if ($post = get_page_by_path($url_path)) {
                                 $post_id = $post->ID;
                                 $path_cache[$url_path] = $post_id;
                             } else {
                                 $path_cache[$url_path] = 0;
                             }
                         } else {
                             $post_id = $path_cache[$url_path];
                         }
                     }
                 }
             }
             if (is_multisite() && isset($url_parts['host'])) {
                 if (is_subdomain_install()) {
                     $blog_path = $url_parts['host'] . '/';
                     if (array_key_exists($blog_path, $blog_cache)) {
                         $blog_id = $blog_cache[$blog_path];
                     } else {
                         $blog_id = get_blog_id_from_url($url_parts['host'], '/');
                     }
                 } else {
                     $url_path_segments = explode('/', $url_parts['path']);
                     if (sizeof($url_path_segments) > 1) {
                         foreach ($url_path_segments as $url_path_segment) {
                             if (is_null($blog_id) && $url_path_segment != '') {
                                 $blog_url_path .= $url_path_segment . '/';
                                 $blog_path = $url_parts['host'] . $blog_url_path;
                                 if (array_key_exists($blog_path, $blog_cache)) {
                                     $blog_id = $blog_cache[$blog_path];
                                 } else {
                                     $blog_id = $blog_cache[$blog_path] = get_blog_id_from_url($url_parts['host'], $blog_url_path);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // Only apply force_ssl filters for current blog
         if (is_null($blog_id)) {
             $force_ssl = apply_filters('force_ssl', null, isset($post_id) ? $post_id : 0, $url);
         }
//.........这里部分代码省略.........
开发者ID:mkoepke,项目名称:wordpress-https,代码行数:101,代码来源:Parser.php

示例13: cli_init_blog

 private function cli_init_blog($blog)
 {
     if (is_multisite()) {
         if (is_numeric($blog)) {
             $blog_address = get_blogaddress_by_id((int) $blog);
         } else {
             $blog_address = get_blogaddress_by_name($blog);
         }
         if ($blog_address == 'http://' || strstr($blog_address, 'wordpress.com.wordpress.com')) {
             $this->debug_msg(sprintf("the blog_address received from %s looks weird: %s", $blog, $blog_address));
             return false;
         }
         $blog_address = str_replace('http://', '', $blog_address);
         $blog_address = preg_replace('#/$#', '', $blog_address);
         $blog_id = get_blog_id_from_url($blog_address);
     } else {
         $blog_id = 1;
     }
     $home_url = str_replace('http://', '', get_home_url($blog_id));
     $home_url = preg_replace('#/$#', '', $home_url);
     $this->blog_address = $home_url;
     if ($blog_id > 0) {
         $this->debug_msg(sprintf("the blog_address we found is %s (%d)", $this->blog_address, $blog_id));
         $this->args->blog = $blog_id;
         if (function_exists('is_multisite') && is_multisite()) {
             switch_to_blog((int) $blog_id);
         }
         $this->blog_id = (int) $blog_id;
         return true;
     } else {
         $this->debug_msg(sprintf("could not get a blog_id for this address: %s", var_export($blog_id, true)));
         die;
     }
 }
开发者ID:netaustin,项目名称:WordPress-CLI-Exporter,代码行数:34,代码来源:cli-exporter.php

示例14: redirect_user_to_blog

function redirect_user_to_blog()
{
    global $current_user, $current_site;
    $details = get_active_blog_for_user($current_user->ID);
    if ($details == "username only") {
        add_user_to_blog(get_blog_id_from_url($current_site->domain, $current_site->path), $current_user->ID, 'subscriber');
        // Add subscriber permission for first blog.
        wp_redirect('http://' . $current_site->domain . $current_site->path . 'wp-admin/');
        exit;
    } elseif (is_object($details)) {
        wp_redirect("http://" . $details->domain . $details->path . 'wp-admin/');
        exit;
    } else {
        wp_redirect("http://" . $current_site->domain . $current_site->path);
        exit;
    }
    wp_die(__('You do not have sufficient permissions to access this page.'));
}
开发者ID:joelglennwright,项目名称:agencypress,代码行数:18,代码来源:mu.php

示例15: s4wp_build_document

function s4wp_build_document(Solarium\QueryType\Update\Query\Document\Document $doc, $post_info, $domain = NULL, $path = NULL)
{
    $plugin_s4wp_settings = s4wp_get_option();
    $exclude_ids = $plugin_s4wp_settings['s4wp_exclude_pages'];
    if (!is_array($plugin_s4wp_settings['s4wp_exclude_pages'])) {
        $exclude_ids = explode(',', $plugin_s4wp_settings['s4wp_exclude_pages']);
    }
    $categoy_as_taxonomy = $plugin_s4wp_settings['s4wp_cat_as_taxo'];
    $index_comments = $plugin_s4wp_settings['s4wp_index_comments'];
    $index_custom_fields = $plugin_s4wp_settings['s4wp_index_custom_fields'];
    if (!is_array($plugin_s4wp_settings['s4wp_index_custom_fields'])) {
        $index_custom_fields = explode(',', $plugin_s4wp_settings['s4wp_index_custom_fields']);
    }
    if ($post_info) {
        # check if we need to exclude this document
        if (is_multisite() && in_array(substr(site_url(), 7) . $post_info->ID, (array) $exclude_ids)) {
            return NULL;
        } else {
            if (!is_multisite() && in_array($post_info->ID, (array) $exclude_ids)) {
                return NULL;
            }
        }
        $auth_info = get_userdata($post_info->post_author);
        # wpmu specific info
        if (is_multisite()) {
            // if we get here we expect that we've "switched" what blog we're running
            // as
            if ($domain == NULL) {
                $domain = $current_blog->domain;
            }
            if ($path == NULL) {
                $path = $current_blog->path;
            }
            $blogid = get_blog_id_from_url($domain, $path);
            $doc->setField('id', $domain . $path . $post_info->ID);
            $doc->setField('permalink', get_blog_permalink($blogid, $post_info->ID));
            $doc->setField('blogid', $blogid);
            $doc->setField('blogdomain', $domain);
            $doc->setField('blogpath', $path);
            $doc->setField('wp', 'multisite');
        } else {
            $doc->setField('id', $post_info->ID);
            $doc->setField('permalink', get_permalink($post_info->ID));
            $doc->setField('wp', 'wp');
        }
        $numcomments = 0;
        if ($index_comments) {
            $comments = get_comments("status=approve&post_id={$post_info->ID}");
            foreach ($comments as $comment) {
                $doc->addField('comments', $comment->comment_content);
                $numcomments += 1;
            }
        }
        $doc->setField('title', $post_info->post_title);
        $doc->setField('content', strip_tags($post_info->post_content));
        $doc->setField('numcomments', $numcomments);
        if (isset($auth_info->display_name)) {
            $doc->setField('author', $auth_info->display_name);
        }
        if (isset($auth_info->user_nicename)) {
            $doc->setField('author_s', get_author_posts_url($auth_info->ID, $auth_info->user_nicename));
        }
        $doc->setField('type', $post_info->post_type);
        $doc->setField('date', s4wp_format_date($post_info->post_date_gmt));
        $doc->setField('modified', s4wp_format_date($post_info->post_modified_gmt));
        $doc->setField('displaydate', $post_info->post_date);
        $doc->setField('displaymodified', $post_info->post_modified);
        $categories = get_the_category($post_info->ID);
        if (!$categories == NULL) {
            foreach ($categories as $category) {
                if ($categoy_as_taxonomy) {
                    $doc->addField('categories', get_category_parents($category->cat_ID, FALSE, '^^'));
                } else {
                    $doc->addField('categories', $category->cat_name);
                }
            }
        }
        //get all the taxonomy names used by wp
        $taxonomies = (array) get_taxonomies(array('_builtin' => FALSE), 'names');
        foreach ($taxonomies as $parent) {
            $terms = get_the_terms($post_info->ID, $parent);
            if ((array) $terms === $terms) {
                //we are creating *_taxonomy as dynamic fields using our schema
                //so lets set up all our taxonomies in that format
                $parent = $parent . "_taxonomy";
                foreach ($terms as $term) {
                    $doc->addField($parent, $term->name);
                }
            }
        }
        $tags = get_the_tags($post_info->ID);
        if (!$tags == NULL) {
            foreach ($tags as $tag) {
                $doc->addField('tags', $tag->name);
            }
        }
        if (count($index_custom_fields) > 0 && count($custom_fields = get_post_custom($post_info->ID))) {
            foreach ((array) $index_custom_fields as $field_name) {
                // test a php error notice.
                if (isset($custom_fields[$field_name])) {
//.........这里部分代码省略.........
开发者ID:Blueprint-Marketing,项目名称:solr-power,代码行数:101,代码来源:solr-power.php


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