本文整理汇总了PHP中get_current_blog_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_current_blog_id函数的具体用法?PHP get_current_blog_id怎么用?PHP get_current_blog_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_blog_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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');
}
}
示例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}");
}
}
示例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;
}
示例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;
}
示例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');
}
示例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;
}
示例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';
}
示例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));
}
}
示例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;
}
}
}
示例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;
}
示例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']));
}
}
});
}
}
}
示例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);
}
示例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;
}
示例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;
}