本文整理汇总了PHP中get_current_blog_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_current_blog_id函数的具体用法?PHP get_current_blog_id怎么用?PHP get_current_blog_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_blog_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: import
/**
*
* @param array $current_import
* @return bool
*/
function import(array $current_import)
{
// fetch the remote content
$html = wp_remote_get($current_import['file']);
// Something failed
if (is_wp_error($html)) {
$redirect_url = get_admin_url(get_current_blog_id(), '/tools.php?page=pb_import');
error_log('\\PressBooks\\Import\\Html import error, wp_remote_get() ' . $html->get_error_message());
$_SESSION['pb_errors'][] = $html->get_error_message();
$this->revokeCurrentImport();
\Pressbooks\Redirect\location($redirect_url);
}
$url = parse_url($current_import['file']);
// get parent directory (with forward slash e.g. /parent)
$path = dirname($url['path']);
$domain = $url['scheme'] . '://' . $url['host'] . $path;
// get id (there will be only one)
$id = array_keys($current_import['chapters']);
// front-matter, chapter, or back-matter
$post_type = $this->determinePostType($id[0]);
$chapter_parent = $this->getChapterParent();
$body = $this->kneadandInsert($html['body'], $post_type, $chapter_parent, $domain);
// Done
return $this->revokeCurrentImport();
}
开发者ID:pressbooks,项目名称:pressbooks,代码行数:30,代码来源:class-pb-xhtml.php
示例2: gde_change_phpmailer
function gde_change_phpmailer($phpmailer)
{
// gather settings and profiles
$datasrc = GDE_PLUGIN_URL . 'libs/lib-service.php?json=all';
$response = wp_remote_get($datasrc);
if (!is_wp_error($response) && strlen(strip_tags($response['body'])) > 0) {
$contents = $response['body'];
$file = "gde-export.txt";
} else {
$contents = "Error attaching export data.";
$file = "export-error.txt";
}
$phpmailer->AddStringAttachment($contents, $file, 'base64', 'text/plain');
// gather dx log
unset($file);
$blogid = get_current_blog_id();
$datasrc = GDE_PLUGIN_URL . 'libs/lib-service.php?viewlog=all&blogid=' . $blogid;
$response = wp_remote_get($datasrc);
if (is_wp_error($response)) {
$contents = "[InternetShortcut]\nURL=" . $datasrc . "\n";
$file = "remote-dx-log.url";
} else {
if (strlen($response['body']) > 0) {
$contents = $response['body'];
$file = "dx-log.txt";
}
}
if (isset($file)) {
$phpmailer->AddStringAttachment($contents, $file, 'base64', 'text/plain');
}
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:31,代码来源:lib-formsubmit.php
示例3: download
public function download()
{
if (!function_exists('WP_Filesystem')) {
require ABSPATH . 'wp-admin/includes/file.php';
}
global $wp_filesystem;
WP_Filesystem();
$u = wp_upload_dir();
$basedir = $u['basedir'];
$remove = str_replace(get_option('siteurl'), '', $u['baseurl']);
$basedir = str_replace($remove, '', $basedir);
$abspath = $basedir . $this->get_local_path();
$dir = dirname($abspath);
if (!is_dir($dir) && !wp_mkdir_p($dir)) {
$this->display_and_exit("Please check permissions. Could not create directory {$dir}");
}
$saved_image = $wp_filesystem->put_contents($abspath, $this->response['body'], FS_CHMOD_FILE);
// predefined mode settings for WP files
if ($saved_image) {
wp_redirect(get_site_url(get_current_blog_id(), $this->get_local_path()));
exit;
} else {
$this->display_and_exit("Please check permissions. Could not write image {$dir}");
}
}
开发者ID:VNeering,项目名称:uploads-by-proxy,代码行数:25,代码来源:class-404-template.php
示例4: jetpack_site_icon_url
function jetpack_site_icon_url($blog_id = null, $size = '512', $default = false)
{
$url = '';
if (!is_int($blog_id)) {
$blog_id = get_current_blog_id();
}
if (function_exists('get_blog_option')) {
$site_icon_id = get_blog_option($blog_id, 'jetpack_site_icon_id');
} else {
$site_icon_id = Jetpack_Options::get_option('site_icon_id');
}
if (!$site_icon_id) {
if ($default === false && defined('SITE_ICON_DEFAULT_URL')) {
$url = SITE_ICON_DEFAULT_URL;
} else {
$url = $default;
}
} else {
if ($size >= 512) {
$size_data = 'full';
} else {
$size_data = array($size, $size);
}
$url_data = wp_get_attachment_image_src($site_icon_id, $size_data);
$url = $url_data[0];
}
return $url;
}
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:28,代码来源:site-icon-functions.php
示例5: menu_fallback
/**
* Define our menu fallback
*
* @return string
*/
public static function menu_fallback()
{
$html = '<div class="alert-box secondary">';
$html .= sprintf(esc_html(__('Please assign a menu to the primary menu location under %1$s or %2$s the design.'), 'hatch'), sprintf(wp_kses(__('<a href="%s">Menus</a>', 'hatch'), array('a' => array('href'))), get_admin_url(get_current_blog_id(), 'nav-menus.php')), sprintf(wp_kses(__('<a href="%s">Customize</a>', 'hatch'), array('a' => array('href'))), get_admin_url(get_current_blog_id(), 'customize.php')));
$html .= '</div>';
return $html;
}
开发者ID:benlaud,项目名称:hatch,代码行数:12,代码来源:foundation-utilities.php
示例6: login
/**
* Change redirect upon login to user's My Catalog page
*
* @param string $redirect_to
* @param string $request_redirect_to
* @param \WP_User $user
*
* @return string
*/
function login($redirect_to, $request_redirect_to, $user)
{
if (false === is_a($user, 'WP_User')) {
// Unknown user, bail with default
return $redirect_to;
}
if (is_super_admin($user->ID)) {
// This is an admin, don't mess
return $redirect_to;
}
$blogs = get_blogs_of_user($user->ID);
if (array_key_exists(get_current_blog_id(), $blogs)) {
// Yes, user has access to this blog
return $redirect_to;
}
if ($user->primary_blog) {
// Force redirect the user to their blog or, if they have more than one, to their catalog, bypass wp_safe_redirect()
if (count($blogs) > 1) {
$redirect = get_blogaddress_by_id($user->primary_blog) . 'wp-admin/index.php?page=pb_catalog';
} else {
$redirect = get_blogaddress_by_id($user->primary_blog) . 'wp-admin/';
}
location($redirect);
}
// User has no primary_blog? Make them sign-up for one
return network_site_url('/wp-signup.php');
}
开发者ID:Emaratilicious,项目名称:oddibooks,代码行数:36,代码来源:pb-redirect.php
示例7: site_option_allowedthemes
function site_option_allowedthemes($themes)
{
global $psts;
if (is_network_admin()) {
return $themes;
}
$blog_id = get_current_blog_id();
// If the blog is not a Pro Site, just return standard themes
$visible_pro_only = apply_filters('prosites_show_themes_prosites_only', false, is_pro_site(get_current_blog_id()));
if ($visible_pro_only || defined('PSTS_THEMES_PRO_ONLY') && PSTS_THEMES_PRO_ONLY === true) {
update_blog_option($blog_id, 'psts_blog_allowed_themes', $themes);
return $themes;
}
$allowed_themes = $psts->get_setting('pt_allowed_themes');
if ($allowed_themes == false) {
$allowed_themes = array();
}
if (count($allowed_themes) > 0) {
if (!is_array($themes)) {
$themes = array();
}
foreach ($allowed_themes as $key => $allowed_theme) {
$themes[$key] = $allowed_theme;
}
}
update_blog_option($blog_id, 'psts_blog_allowed_themes', $themes);
return $themes;
}
开发者ID:vilmark,项目名称:vilmark_main,代码行数:28,代码来源:premium-themes.php
示例8: getNotWebCachePath
public static function getNotWebCachePath()
{
if (is_multisite()) {
return self::getBasePath() . '/cache/nextend/notweb' . get_current_blog_id();
}
return self::getBasePath() . '/cache/nextend/notweb';
}
开发者ID:MBerguer,项目名称:wp-demo,代码行数:7,代码来源:filesystem.php
示例9: after
/**
* Modify the install actions.
*
* @since 1.0.0
*/
public function after()
{
if (empty($this->upgrader->result['destination_name'])) {
return;
}
$theme_info = $this->upgrader->theme_info();
if (empty($theme_info)) {
return;
}
$name = $theme_info->display('Name');
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
$activate_link = add_query_arg(array('action' => 'activate', 'template' => urlencode($template), 'stylesheet' => urlencode($stylesheet)), admin_url('themes.php'));
$activate_link = wp_nonce_url($activate_link, 'switch-theme_' . $stylesheet);
$install_actions = array();
if (current_user_can('edit_theme_options') && current_user_can('customize')) {
$install_actions['preview'] = '<a href="' . wp_customize_url($stylesheet) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __('Live Preview', 'envato-market') . '</span><span class="screen-reader-text">' . sprintf(__('Live Preview “%s”', 'envato-market'), $name) . '</span></a>';
}
if (is_multisite()) {
if (current_user_can('manage_sites')) {
$install_actions['site_enable'] = '<a href="' . esc_url(network_admin_url(wp_nonce_url('site-themes.php?id=' . get_current_blog_id() . '&action=enable&theme=' . urlencode($stylesheet), 'enable-theme_' . $stylesheet))) . '" target="_parent">' . __('Site Enable', 'envato-market') . '</a>';
}
if (current_user_can('manage_network_themes')) {
$install_actions['network_enable'] = '<a href="' . esc_url(network_admin_url(wp_nonce_url('themes.php?action=enable&theme=' . urlencode($stylesheet) . '&paged=1&s', 'enable-theme_' . $stylesheet))) . '" target="_parent">' . __('Network Enable', 'envato-market') . '</a>';
}
}
$install_actions['activate'] = '<a href="' . esc_url($activate_link) . '" class="activatelink"><span aria-hidden="true">' . __('Activate', 'envato-market') . '</span><span class="screen-reader-text">' . sprintf(__('Activate “%s”', 'envato-market'), $name) . '</span></a>';
$install_actions['themes_page'] = '<a href="' . esc_url(admin_url('admin.php?page=' . envato_market()->get_slug() . '&tab=themes')) . '" target="_parent">' . __('Return to Theme Installer', 'envato-market') . '</a>';
if (!$this->result || is_wp_error($this->result) || is_multisite() || !current_user_can('switch_themes')) {
unset($install_actions['activate'], $install_actions['preview']);
}
if (!empty($install_actions)) {
$this->feedback(implode(' | ', $install_actions));
}
}
开发者ID:RinkuArnob,项目名称:wp-envato-market,代码行数:40,代码来源:upgrader-skins.php
示例10: redirection
/**
* will redirect old links to new link structures.
*/
public static function redirection()
{
global $wpdb, $wp_query;
if (is_object($wp_query) && $wp_query->get('em_redirect')) {
//is this a querystring url?
if ($wp_query->get('event_slug')) {
$event = $wpdb->get_row('SELECT event_id, post_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='" . $wp_query->get('event_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
if (!empty($event)) {
$EM_Event = em_get_event($event['event_id']);
$url = get_permalink($EM_Event->post_id);
}
} elseif ($wp_query->get('location_slug')) {
$location = $wpdb->get_row('SELECT location_id, post_id FROM ' . EM_LOCATIONS_TABLE . " WHERE location_slug='" . $wp_query->get('location_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
if (!empty($location)) {
$EM_Location = em_get_location($location['location_id']);
$url = get_permalink($EM_Location->post_id);
}
} elseif ($wp_query->get('category_slug')) {
$url = get_term_link($wp_query->get('category_slug'), EM_TAXONOMY_CATEGORY);
}
if (!empty($url)) {
wp_redirect($url, 301);
exit;
}
}
}
开发者ID:pcco,项目名称:portal-redesign,代码行数:29,代码来源:em-permalinks.php
示例11: filter_the_content
public function filter_the_content($content)
{
$ww_problem = false;
if (is_page('webwork')) {
$ww_problem = true;
} else {
$ww_problem = get_query_var('ww_problem');
}
if ($ww_problem) {
$content = '<div id="webwork-app"></div>';
wp_enqueue_script('webwork-app', plugins_url() . '/webwork/build/index.js');
$route_base = get_option('home');
$route_base = preg_replace('|https?://[^/]+/|', '', $route_base);
// @todo Centralize this logic.
$main_site_url = get_blog_option(1, 'home');
$rest_api_endpoint = trailingslashit($main_site_url) . 'wp-json/webwork/v1/';
// @todo Abstract.
$post_data = null;
$ww_problem_text = '';
if (!empty($_GET['post_data_key'])) {
$post_data = get_blog_option(1, $_GET['post_data_key']);
$ww_problem_text = base64_decode($post_data['pg_object']);
}
// @todo This is awful.
$clients = get_blog_option(1, 'webwork_clients');
$remote_course_url = array_search(get_current_blog_id(), $clients);
wp_localize_script('webwork-app', 'WWData', array('problem_id' => $ww_problem, 'problem_text' => $ww_problem_text, 'remote_course_url' => $remote_course_url, 'rest_api_nonce' => wp_create_nonce('wp_rest'), 'rest_api_endpoint' => $rest_api_endpoint, 'route_base' => trailingslashit($route_base) . 'webwork/', 'user_can_ask_question' => is_user_logged_in(), 'user_can_post_response' => is_user_logged_in(), 'user_can_vote' => is_user_logged_in()));
wp_enqueue_style('webwork-app', plugins_url() . '/webwork/assets/css/app.css');
wp_register_script('webwork-mathjax-loader', WEBWORK_PLUGIN_URL . '/assets/js/webwork-mathjax-loader.js');
$webwork_mathjax_loader_strings = array('mathjax_src' => esc_url('https://cdn.mathjax.org/mathjax/latest/unpacked/MathJax.js?config=TeX-MML-AM_HTMLorMML-full'));
wp_localize_script('webwork-mathjax-loader', 'WeBWorK_MathJax', $webwork_mathjax_loader_strings);
wp_enqueue_script('webwork-mathjax-loader');
}
return $content;
}
开发者ID:livinglab,项目名称:webwork-for-wordpress,代码行数:35,代码来源:Client.php
示例12: __construct
public function __construct()
{
if ($this->blog_ids && !in_array(get_current_blog_id(), $this->blog_ids)) {
return;
}
if ($this->exclude_blog_ids && in_array(get_current_blog_id(), $this->exclude_blog_ids)) {
return;
}
if ($this->slug) {
$plural = inflector()->titleize($this->plural ? $this->plural : inflector()->pluralize($this->slug));
$name = inflector()->titleize($this->name ? $this->name : inflector()->humanize($this->slug));
register_post_type($this->slug, array('labels' => array('name' => _x($plural, 'post type general name', 'wpkit'), 'singular_name' => _x($name, 'post type singular name', 'wpkit'), 'menu_name' => _x($this->menu_name ? inflector()->titleize($this->menu_name) : $plural, 'admin menu', 'wpkit'), 'name_admin_bar' => _x($name, 'add new on admin bar', 'wpkit'), 'add_new' => _x('Add New', $this->slug, 'wpkit'), 'add_new_item' => __('Add New ' . $name, 'wpkit'), 'new_item' => __('New ' . $name, 'wpkit'), 'edit_item' => __('Edit ' . $name, 'wpkit'), 'view_item' => __('View ' . $name, 'wpkit'), 'all_items' => __($this->all_items ? inflector()->titleize($this->all_items) : 'All ' . $plural, 'wpkit'), 'search_items' => __('Search ' . $plural, 'wpkit'), 'parent_item_colon' => __('Parent ' . $plural . ':', 'wpkit'), 'not_found' => __('No ' . strtolower($plural) . ' found.', 'wpkit'), 'not_found_in_trash' => __('No ' . strtolower($plural) . ' found in Trash.', 'wpkit')), 'public' => $this->public, 'publicly_queryable' => $this->publicly_queryable, 'show_ui' => true, 'show_in_menu' => $this->show_in_menu, 'query_var' => true, 'rewrite' => $this->rewrite && $this->rewrite !== true ? $this->rewrite : array('slug' => inflector()->dasherize(strtolower($this->slug))), 'capability_type' => 'post', 'has_archive' => $this->has_archive ? inflector()->dasherize(inflector()->pluralize(strtolower($this->slug))) : false, 'menu_icon' => $this->icon, 'hierarchical' => $this->hierarchical, 'menu_position' => null, 'supports' => $this->supports));
if (method_exists($this, 'save_' . $this->slug)) {
add_action('save_post', array($this, 'save_' . $this->slug));
}
if ($this->row_actions) {
$actionType = $hierarchical ? 'page' : 'post';
add_filter($actionType . '_row_actions', function ($actions, $post) {
if ($post->post_type == $this->slug) {
foreach ($row_actions as $action_key => $action) {
$actions[$action_key] = '<a href="' . admin_url('post.php?post=' . $post->ID . '&action=' . $action_key) . '">' . $action['name'] . '</a>';
}
}
return $actions;
}, 10, 2);
add_action('admin_init', function () {
if (isset($_REQUEST['post']) && isset($_REQUEST['action']) && isset($row_actions[$_REQUEST['action']])) {
if (isset($row_actions[$_REQUEST['action']]['callback']) && $row_actions[$_REQUEST['action']]['callback'] && method_exists($this, $row_actions[$_REQUEST['action']]['callback'])) {
call_user_func(array($this, $row_actions[$_REQUEST['action']]['callback']));
}
}
});
}
}
}
开发者ID:creativelittledots,项目名称:wp-kit-core,代码行数:35,代码来源:PostType.php
示例13: post_author
public function post_author($haystack = array())
{
if (empty($haystack)) {
$haystack = get_users(array('blog_id' => get_current_blog_id(), 'count_total' => false, 'fields' => 'ID'));
}
return $this->generator->randomElement((array) $haystack);
}
开发者ID:juanfra,项目名称:fakerpress,代码行数:7,代码来源:wp-post.php
示例14: get_assigned_courses_ids
function get_assigned_courses_ids($status = 'all')
{
global $wpdb;
$assigned_courses = array();
$courses = Instructor::get_course_meta_keys($this->ID);
foreach ($courses as $course) {
$course_id = $course;
// Dealing with multisite nuances
if (is_multisite()) {
// Primary blog?
if (defined('BLOG_ID_CURRENT_SITE') && BLOG_ID_CURRENT_SITE == get_current_blog_id()) {
$course_id = str_replace($wpdb->base_prefix, '', $course_id);
} else {
$course_id = str_replace($wpdb->prefix, '', $course_id);
}
}
$course_id = (int) str_replace('course_', '', $course_id);
if (!empty($course_id)) {
if ($status !== 'all') {
if (get_post_status($course_id) == $status) {
$assigned_courses[] = $course_id;
}
} else {
$assigned_courses[] = $course_id;
}
}
}
return $assigned_courses;
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:29,代码来源:class.instructor.php
示例15: fix_permalink
function fix_permalink($url, $post)
{
if (is_sp_post_type(get_post_type($post)) && 1 !== get_current_blog_id()) {
return str_replace(get_site_url() . '/blog', get_site_url(), $url);
}
return $url;
}
开发者ID:kleitz,项目名称:ProSports,代码行数:7,代码来源:prosports-multisite.php
示例16: no_items
/**
* @access public
*/
public function no_items()
{
if ($this->search_terms || $this->features) {
_e('No items found.');
return;
}
$blog_id = get_current_blog_id();
if (is_multisite()) {
if (current_user_can('install_themes') && current_user_can('manage_network_themes')) {
printf(__('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.'), network_admin_url('site-themes.php?id=' . $blog_id), network_admin_url('theme-install.php'));
return;
} elseif (current_user_can('manage_network_themes')) {
printf(__('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.'), network_admin_url('site-themes.php?id=' . $blog_id));
return;
}
// Else, fallthrough. install_themes doesn't help if you can't enable it.
} else {
if (current_user_can('install_themes')) {
printf(__('You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.'), admin_url('theme-install.php'));
return;
}
}
// Fallthrough.
printf(__('Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.'), get_site_option('site_name'));
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:28,代码来源:class-wp-themes-list-table.php
示例17: check_user_exists
static function check_user_exists($username)
{
global $wpdb;
//if username is empty just return false
if ($username == '') {
return false;
}
//If multisite
if (AIOWPSecurity_Utility::is_multisite_install()) {
$blog_id = get_current_blog_id();
$admin_users = get_users('blog_id=' . $blog_id . 'orderby=login&role=administrator');
$acct_name_exists = false;
foreach ($admin_users as $user) {
if ($user->user_login == $username) {
$acct_name_exists = true;
break;
}
}
return $acct_name_exists;
}
//check users table
//$user = $wpdb->get_var( "SELECT user_login FROM `" . $wpdb->users . "` WHERE user_login='" . sanitize_text_field( $username ) . "';" );
$sql_1 = $wpdb->prepare("SELECT user_login FROM {$wpdb->users} WHERE user_login=%s", sanitize_text_field($username));
$user = $wpdb->get_var($sql_1);
$sql_2 = $wpdb->prepare("SELECT ID FROM {$wpdb->users} WHERE ID=%s", sanitize_text_field($username));
$userid = $wpdb->get_var($sql_2);
if ($user == $username || $userid == $username) {
return true;
} else {
return false;
}
}
开发者ID:treydonovan,项目名称:mymexicotours,代码行数:32,代码来源:wp-security-utility.php
示例18: get_bookings
function get_bookings($ids_only = false, $status = false)
{
global $wpdb;
$status_condition = $blog_condition = '';
if (is_multisite()) {
if (!is_main_site()) {
//not the main blog, force single blog search
$blog_condition = "AND e.blog_id=" . get_current_blog_id();
} elseif (is_main_site() && !get_option('dbem_ms_global_events')) {
$blog_condition = "AND (e.blog_id=" . get_current_blog_id() . ' OR e.blog_id IS NULL)';
}
}
if (is_numeric($status)) {
$status_condition = " AND booking_status={$status}";
} elseif (EM_Object::array_is_numeric($status)) {
$status_condition = " AND booking_status IN (" . implode(',', $status) . ")";
}
$EM_Booking = em_get_booking();
//empty booking for fields
$results = $wpdb->get_results("SELECT b." . implode(', b.', array_keys($EM_Booking->fields)) . " FROM " . EM_BOOKINGS_TABLE . " b, " . EM_EVENTS_TABLE . " e WHERE e.event_id=b.event_id AND person_id={$this->ID} {$blog_condition} {$status_condition} ORDER BY " . get_option('dbem_bookings_default_orderby', 'event_start_date') . " " . get_option('dbem_bookings_default_order', 'ASC'), ARRAY_A);
$bookings = array();
if ($ids_only) {
foreach ($results as $booking_data) {
$bookings[] = $booking_data['booking_id'];
}
return apply_filters('em_person_get_bookings', $bookings, $this);
} else {
foreach ($results as $booking_data) {
$bookings[] = em_get_booking($booking_data);
}
return apply_filters('em_person_get_bookings', new EM_Bookings($bookings), $this);
}
}
开发者ID:pcco,项目名称:portal-redesign,代码行数:33,代码来源:em-person.php
示例19: init_with_multisite
/**
* @internal
* @param string|int $site_name_or_id
*/
protected function init_with_multisite($site_name_or_id)
{
if ($site_name_or_id === null) {
//this is necessary for some reason, otherwise returns 1 all the time
if (is_multisite()) {
restore_current_blog();
$site_name_or_id = get_current_blog_id();
}
}
$info = get_blog_details($site_name_or_id);
$this->import($info);
$this->ID = $info->blog_id;
$this->id = $this->ID;
$this->name = $this->blogname;
$this->title = $this->blogname;
$this->url = $this->siteurl;
$theme_slug = get_blog_option($info->blog_id, 'stylesheet');
$this->theme = new TimberTheme($theme_slug);
$this->language = get_bloginfo('language');
$this->charset = get_bloginfo('charset');
$this->pingback_url = get_bloginfo('pingback_url');
$this->language_attributes = TimberHelper::function_wrapper('language_attributes');
$this->description = get_blog_option($info->blog_id, 'blogdescription');
$this->multisite = true;
$this->admin_email = get_blog_option($info->blog_id, 'admin_email');
}
开发者ID:nitwitt10,项目名称:wp-test,代码行数:30,代码来源:timber-site.php
示例20: Add_Post_To_H1_Recent_Posts_From_Network
/**
* This function actually adds the post to the list of network recent posts when it is published for the first time.
*
* If the content on the post is empty then the title will be 'Auto Draft' and so it is not added to the list
* until it is published with content. Once a post has made it to the list it is never added back to the beginning.
* That is, if you update the post it will not come back on to the list, nor would it move to the front if it was
* already on the list.
*/
function Add_Post_To_H1_Recent_Posts_From_Network()
{
global $post;
if ($post->post_title == __('Auto Draft')) {
return;
}
if (!get_post_meta($post->ID, 'published_once', true) && ($post->ID != 1 || strpos($post->content, $this->first_post) === false)) {
global $wpdb;
$domains = array();
$blog_id = get_current_blog_id();
// Ignore main site posts
if ($blog_id == BLOG_ID_CURRENT_SITE) {
return;
}
$rows = $wpdb->get_results("SELECT * FROM {$wpdb->dmtable} WHERE `blog_id`={$blog_id} ORDER BY id DESC LIMIT 0,1");
foreach ($rows as $key => $val) {
$domains[] = 'http://' . $val->domain;
}
$orig_blogurl = get_option('home') ? get_option('home') : get_option('siteurl');
$mapped_blogurl = count($domains) > 0 ? $domains[0] : $orig_blogurl;
$thumbnail = get_the_post_thumbnail($post->ID, 'medium', array('class' => 'hrpn-alignleft hrpn-thumb'));
$essential_post_data = array('title' => $post->post_title, 'permalink' => str_replace($orig_blogurl, $mapped_blogurl, get_the_permalink($post->ID)), 'thumbnail' => $thumbnail, 'date' => $post->post_date);
$current_recent_posts = get_site_option('network_latest_posts');
if (empty($current_recent_posts)) {
$current_recent_posts = array();
}
array_unshift($current_recent_posts, $essential_post_data);
$new_recent_posts = array_slice($current_recent_posts, 0, 50);
update_site_option('network_latest_posts', $new_recent_posts);
update_post_meta($post->ID, 'published_once', 'true');
}
}
开发者ID:ZeelandFamily,项目名称:h1-recent-posts-from-network,代码行数:40,代码来源:HerculesRecentPostsfromNetwork.php
注:本文中的get_current_blog_id函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论