/** * 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'); }
/** * Add colums to blog view * * @since 0.1 * @param $column_name string * @param $blog_id integer * @uses switch_to_blog, mlp_get_available_languages_titles, _e, network_admin_url * mlp_get_language_flag, restore_current_blog, apply_filters * @return $column_name string */ public function add_columns($column_name, $blog_id) { //render column value if ('mlp_interlinked' === $column_name) { switch_to_blog($blog_id); $interlinked = mlp_get_available_languages_titles(); if (count($interlinked) < 2 || !is_array($interlinked)) { _e('nothing', 'multilingualpress'); return; } $linked_blogs = array(); echo '<div class="mlp_interlinked_blogs">'; foreach ($interlinked as $interlinked_blog_id => $interlinked_blog_title) { if ($interlinked_blog_id == $blog_id) { continue; } $linked_blogs[] = sprintf('<a href="%1$s">%2$s</a>', get_blogaddress_by_id($interlinked_blog_id), esc_html($interlinked_blog_title)); } empty($linked_blogs) || (print join(' | ', $linked_blogs)); echo '</div>'; restore_current_blog(); } $column_name = apply_filters('mlp_add_custom_columns', $column_name, $blog_id); return $column_name; }
/** * Gets the URL for the blog with the given ID. * * This gets the URL for the requested blog when in multisite mode, or * for the root blog when running a standard installation. * * @param int $blog_id the ID of a blog * @return string the URL for the blog * * @since 0.4 */ public static function get_blogaddress_by_id($blog_id) { if (function_exists('get_blogaddress_by_id')) { return get_blogaddress_by_id($blog_id); } else { return home_url(); } }
/** * Display information about a blog in a particular format * * */ function bw_display_blog($id, $atts, $content) { $bloginfo = bw_get_bloginfo($id); if ($bloginfo) { if (is_numeric($id)) { $url = get_blogaddress_by_id($id); } else { $url = get_blogaddress_by_name($id); } $blog = $bloginfo->blog_id; switch_to_blog($blog); if ($content) { e(bw_do_shortcode($content)); } else { alink(null, $url, $bloginfo->blogname); } restore_current_blog(); } }
} else { printf(__('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, wp_lostpassword_url()); } echo '</p>'; } else { ?> <h2><?php _e('An error occurred during the activation'); ?> </h2> <?php echo '<p>' . $result->get_error_message() . '</p>'; } } else { extract($result); $url = get_blogaddress_by_id((int) $blog_id); $user = get_userdata((int) $user_id); ?> <h2><?php _e('Your account is now active!'); ?> </h2> <div id="signup-welcome"> <p><span class="h3"><?php _e('Username:'); ?> </span> <?php echo $user->user_login; ?> </p>
/** * Notify a user that her blog activation has been successful. * * Filter 'wpmu_welcome_notification' to disable or bypass. * * Filter 'update_welcome_email' and 'update_welcome_subject' to * modify the content and subject line of the notification email. * * @since MU * * @param int $blog_id * @param int $user_id * @param string $password * @param string $title The new blog's title * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. * @return bool */ function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = '') { global $current_site; if (!apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta)) { return false; } $welcome_email = stripslashes(get_site_option('welcome_email')); if ($welcome_email == false) { $welcome_email = stripslashes(__('Dear User, Your new SITE_NAME site has been successfully set up at: BLOG_URL You can log in to the administrator account with the following information: Username: USERNAME Password: PASSWORD Log in here: BLOG_URLwp-login.php We hope you enjoy your new site. Thanks! --The Team @ SITE_NAME')); } $url = get_blogaddress_by_id($blog_id); $user = new WP_User($user_id); $welcome_email = str_replace('SITE_NAME', $current_site->site_name, $welcome_email); $welcome_email = str_replace('BLOG_TITLE', $title, $welcome_email); $welcome_email = str_replace('BLOG_URL', $url, $welcome_email); $welcome_email = str_replace('USERNAME', $user->user_login, $welcome_email); $welcome_email = str_replace('PASSWORD', $password, $welcome_email); $welcome_email = apply_filters('update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta); $admin_email = get_site_option('admin_email'); if ($admin_email == '') { $admin_email = 'support@' . $_SERVER['SERVER_NAME']; } $from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name')); $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; $message = $welcome_email; if (empty($current_site->site_name)) { $current_site->site_name = 'WordPress'; } $subject = apply_filters('update_welcome_subject', sprintf(__('New %1$s Site: %2$s'), $current_site->site_name, stripslashes($title))); wp_mail($user->user_email, $subject, $message, $message_headers); return true; }
/** * Get array of subsite simple urls keyed by their ID. * * @return array */ public function subsites_list() { $subsites = array(); if (!is_multisite()) { return $subsites; } $sites = wp_get_sites(array('limit' => 0)); if (!empty($sites)) { foreach ($sites as $subsite) { $subsites[$subsite['blog_id']] = $this->simple_site_url(get_blogaddress_by_id($subsite['blog_id'])); } } return $subsites; }
/** * Notify a user that their blog activation has been successful. * * Filter 'wpmu_welcome_notification' to disable or bypass. * * Filter 'update_welcome_email' and 'update_welcome_subject' to * modify the content and subject line of the notification email. * * @since MU * * @param int $blog_id * @param int $user_id * @param string $password * @param string $title The new blog's title * @param array $meta Optional. Not used in the default function, but is passed along to hooks for customization. * @return bool */ function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = array()) { $current_site = get_current_site(); /** * Filter whether to bypass the welcome email after site activation. * * Returning false disables the welcome email. * * @since MU * * @param int|bool $blog_id Blog ID. * @param int $user_id User ID. * @param string $password User password. * @param string $title Site title. * @param array $meta Signup meta data. */ if (!apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta)) { return false; } $welcome_email = get_site_option('welcome_email'); if ($welcome_email == false) { /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */ $welcome_email = __('Howdy USERNAME, Your new SITE_NAME site has been successfully set up at: BLOG_URL You can log in to the administrator account with the following information: Username: USERNAME Password: PASSWORD Log in here: BLOG_URLwp-login.php We hope you enjoy your new site. Thanks! --The Team @ SITE_NAME'); } $url = get_blogaddress_by_id($blog_id); $user = get_userdata($user_id); $welcome_email = str_replace('SITE_NAME', $current_site->site_name, $welcome_email); $welcome_email = str_replace('BLOG_TITLE', $title, $welcome_email); $welcome_email = str_replace('BLOG_URL', $url, $welcome_email); $welcome_email = str_replace('USERNAME', $user->user_login, $welcome_email); $welcome_email = str_replace('PASSWORD', $password, $welcome_email); /** * Filter the content of the welcome email after site activation. * * Content should be formatted for transmission via wp_mail(). * * @since MU * * @param string $welcome_email Message body of the email. * @param int $blog_id Blog ID. * @param int $user_id User ID. * @param string $password User password. * @param string $title Site title. * @param array $meta Signup meta data. */ $welcome_email = apply_filters('update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta); $admin_email = get_site_option('admin_email'); if ($admin_email == '') { $admin_email = 'support@' . $_SERVER['SERVER_NAME']; } $from_name = get_site_option('site_name') == '' ? 'WordPress' : esc_html(get_site_option('site_name')); $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; $message = $welcome_email; if (empty($current_site->site_name)) { $current_site->site_name = 'WordPress'; } /** * Filter the subject of the welcome email after site activation. * * @since MU * * @param string $subject Subject of the email. */ $subject = apply_filters('update_welcome_subject', sprintf(__('New %1$s Site: %2$s'), $current_site->site_name, wp_unslash($title))); wp_mail($user->user_email, wp_specialchars_decode($subject), $message, $message_headers); return true; }
} break; } update_option('allowedthemes', $allowed_themes); restore_current_blog(); wp_safe_redirect(add_query_arg(array('id' => $id, $action => $n), $referer)); exit; } if (isset($_GET['action']) && 'update-site' == $_GET['action']) { wp_safe_redirect($referer); exit; } add_thickbox(); add_screen_option('per_page', array('label' => _x('Themes', 'themes per page (screen options)'))); $site_url_no_http = preg_replace('#^http(s)?://#', '', get_blogaddress_by_id($id)); $title_site_url_linked = sprintf(__('Edit Site: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id($id), $site_url_no_http); $title = sprintf(__('Edit Site: %s'), $site_url_no_http); $parent_file = 'sites.php'; $submenu_file = 'sites.php'; require ABSPATH . 'wp-admin/admin-header.php'; ?> <div class="wrap"> <?php screen_icon('ms-admin'); ?> <h2 id="edit-site"><?php echo $title_site_url_linked; ?> </h2> <h3 class="nav-tab-wrapper">
printf(__('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.'), network_site_url('wp-login.php', 'login'), $signup->user_login, $signup->user_email, wp_lostpassword_url()); } else { printf(__('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, wp_lostpassword_url()); } echo '</p>'; } else { ?> <h2><?php _e('An error occurred during the activation'); ?> </h2> <?php echo '<p>' . $result->get_error_message() . '</p>'; } } else { $url = isset($result['blog_id']) ? get_blogaddress_by_id((int) $result['blog_id']) : ''; $user = get_userdata((int) $result['user_id']); ?> <h2><?php _e('Your account is now active!'); ?> </h2> <div id="signup-welcome"> <p><span class="h3"><?php _e('Username:'); ?> </span> <?php echo $user->user_login; ?> </p>
public function rpr_preprocess_signup_form() { global $active_signup, $stage; switch ($stage) { case 'user-signup': if ($active_signup == 'all' || $_POST['signup_for'] == 'blog' && $active_signup == 'blog' || $_POST['signup_for'] == 'user' && $active_signup == 'user') { /* begin validate_user_signup stage */ // validate signup form, do wpmu_validate_user_signup action $result = wpmu_validate_user_signup(isset($_POST['user_name']) ? (string) $_POST['user_name'] : "", isset($_POST['user_email']) ? (string) $_POST['user_email'] : ""); extract($result); if ($errors->get_error_code()) { echo "signup_user"; signup_user($user_name, $user_email, $errors); do_action('after_signup_form'); get_footer(); exit; } if ('blog' === $_POST['signup_for']) { echo "signup_blog"; signup_blog($user_name, $user_email); do_action('after_signup_form'); get_footer(); exit; } // collect meta, commit user to database, send email wpmu_signup_user($user_name, $user_email, apply_filters('add_signup_meta', array())); // previously, displayed confirm_user_signup message before signup_finished action do_action('signup_finished'); /* end validate_user_signup stage */ } else { _e('User registration has been disabled.'); ?> </div> </div> <?php do_action('after_signup_form'); get_footer(); exit; } break; case 'blog-signup': if ($active_signup == 'all' || $active_signup == 'blog') { /* begin validate_blog_signup stage */ $result = wpmu_validate_user_signup(isset($_POST['user_name']) ? (string) $_POST['user_name'] : "", isset($_POST['user_email']) ? (string) $_POST['user_email'] : ""); extract($result); if ($errors->get_error_code()) { echo "signup_user"; signup_user($user_name, $user_email, $errors); do_action('after_signup_form'); get_footer(); exit; } $result = wpmu_validate_blog_signup(isset($_POST['blogname']) ? (string) $_POST['blogname'] : "", isset($_POST['blog_title']) ? (string) $_POST['blog_title'] : ""); extract($result); if ($errors->get_error_code()) { signup_blog($user_name, $user_email, $blogname, $blog_title, $errors); do_action('after_signup_form'); get_footer(); exit; } // collect meta, commit user to database, send email $meta = array('lang_id' => 1, 'public' => (int) $_POST['blog_public']); wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, apply_filters('add_signup_meta', $meta)); // previously, displayed confirm_blog_signup message before signup_finished action do_action('signup_finished'); /* end validate_blog_signup stage */ } else { _e('Site registration has been disabled.'); ?> </div> </div> <?php do_action('after_signup_form'); get_footer(); exit; } break; default: return; } /* begin wp-activate page */ $key = (string) $_REQUEST['key']; // wpmu_create_user, wpmu_welcome_user_notification, add_new_user_to_blog, do wpmu_activate_user action $result = wpmu_activate_signup($key); if (is_wp_error($result)) { if ('already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code()) { $signup = $result->get_error_data(); ?> <h2><?php _e('Your account is now active!'); ?> </h2> <?php echo '<p class="lead-in">'; if ($signup->domain . $signup->path == '') { printf(__('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.'), network_site_url('wp-login.php', 'login'), $signup->user_login, $signup->user_email, wp_lostpassword_url()); } else { printf(__('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, wp_lostpassword_url()); } echo '</p>'; } else { ?> <h2><?php _e('An error occurred during the activation'); ?> </h2> <?php echo '<p>' . $result->get_error_message() . '</p>'; } } else { //TODO: Why not reference $result->blog_id? extract($result); if (isset($blog_id)) { $url = get_blogaddress_by_id((int) $blog_id); } $user = get_userdata((int) $user_id); ?> <h2><?php _e('Your account is now active!'); ?> </h2> <div id="signup-welcome"> <p><span class="h3"><?php _e('Username:'******'Password:'******'', 'http')) { ?> <p class="view"><?php printf(__('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>'), $url, $url . 'wp-login.php'); ?> </p> <?php } else { ?> <p class="view"><?php printf(__('Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.'), network_site_url('wp-login.php', 'login'), network_home_url()); ?> </p> <?php } } ?> </div> <script type="text/javascript"> var key_input = document.getElementById('key'); key_input && key_input.focus(); </script> <?php get_footer(); ?> <?php exit; }
/** * Outputs the activation page * * @since 6.1 * @access public * * @param object $template Theme_My_Login_Template object */ public function tml_display_activate(&$template) { global $blog_id; echo '<div class="login" id="theme-my-login' . esc_attr($template->get_option('instance')) . '">'; if (empty($_GET['key']) && empty($_POST['key'])) { ?> <h2><?php _e('Activation Key Required', 'theme-my-login'); ?> </h2> <form name="activateform" id="activateform" method="post" action="<?php $template->the_action_url('activate'); ?> "> <p> <label for="key<?php $template->the_instance(); ?> "><?php _e('Activation Key:', 'theme-my-login'); ?> </label> <br /><input type="text" name="key<?php $template->the_instance(); ?> " id="key" value="" size="50" /> </p> <p class="submit"> <input id="submit<?php $template->the_instance(); ?> " type="submit" name="Submit" class="submit" value="<?php esc_attr_e('Activate', 'theme-my-login'); ?> " /> </p> </form> <?php } else { $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key']; $result = wpmu_activate_signup($key); if (is_wp_error($result)) { if ('already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code()) { $signup = $result->get_error_data(); ?> <h2><?php _e('Your account is now active!', 'theme-my-login'); ?> </h2> <?php echo '<p class="lead-in">'; if ($signup->domain . $signup->path == '') { printf(__('Your account has been activated. You may now <a href="%1$s">login</a> to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.', 'theme-my-login'), network_site_url('wp-login.php', 'login'), $signup->user_login, $signup->user_email, network_site_url('wp-login.php?action=lostpassword', 'login')); } else { printf(__('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.', 'theme-my-login'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, network_site_url('wp-login.php?action=lostpassword')); } echo '</p>'; } else { ?> <h2><?php _e('An error occurred during the activation', 'theme-my-login'); ?> </h2> <?php echo '<p>' . $result->get_error_message() . '</p>'; } } else { extract($result); $url = get_blogaddress_by_id((int) $blog_id); $user = new WP_User((int) $user_id); ?> <h2><?php _e('Your account is now active!', 'theme-my-login'); ?> </h2> <div id="signup-welcome"> <p><span class="h3"><?php _e('Username:'******'theme-my-login'); ?> </span> <?php echo $user->user_login; ?> </p> <p><span class="h3"><?php _e('Password:'******'theme-my-login'); ?> </span> <?php echo $password; ?> </p> </div> <?php if ($url != network_home_url('', 'http')) { switch_to_blog((int) $blog_id); ?> <p class="view"><?php printf(__('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Login</a>', 'theme-my-login'), $url, wp_login_url()); ?> </p> <?php restore_current_blog(); } else { ?> <p class="view"><?php printf(__('Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.', 'theme-my-login'), network_site_url('wp-login.php', 'login'), network_home_url()); ?> </p> <?php } } } echo '</div>'; }
/** * Tests returning the appropriate response for a invalid id given. */ function test_get_blogaddress_by_id_with_invalid_id() { $blogaddress = get_blogaddress_by_id(42); $this->assertEquals('', $blogaddress); }
/** * Display Edit Site Section of Settings Page */ function edit_site_Network_Admin_GForms_TMP() { $unauthorized = false; if (!is_multisite()) { $unauthorized = __('Multisite support is not enabled.'); } if (!current_user_can('manage_sites')) { $unauthorized = __('You do not have sufficient permissions to edit this site.'); } $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; if (!$id) { $unauthorized = __('Invalid site ID.'); } $details = get_blog_details($id); if (!can_edit_network($details->site_id)) { $unauthorized = __('You do not have permission to access this page.'); } if ($unauthorized) { echo "<p>{$unauthorized}</p>\n"; return; } $site_url_no_http = preg_replace('#^http(s)?://#', '', get_blogaddress_by_id($id)); $title_site_url_linked = sprintf(__('API Enabled: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id($id), $site_url_no_http); $gforms_tmp_admin_client_id = \get_blog_option($id, 'gforms_tmp_admin_client_id', false); $gforms_tmp_admin_client_name = \get_blog_option($id, 'gforms_tmp_admin_client_name', false); $gforms_tmp_active = \get_blog_option($id, 'gforms_tmp_active', false); $gforms_tmp_last_update = \get_blog_option($id, 'gforms_tmp_last_update', false); $date = 'Y/m/d g:i:s a'; $is_main_site = \is_main_site($id); if (isset($_GET['update'])) { $messages = array(); if ('updated' == $_GET['update']) { $messages[1] = __('Site updated.'); } else { $messages[0] = __('Site could not be updated.'); } } if (!empty($messages)) { foreach ($messages as $status => $msg) { echo '<div id="message" class="' . ($status ? 'updated' : 'error') . '"><p>' . $msg . '</p></div>'; } } ?> <div class="wrap"> <div id="icon-options-general" class="icon32"> <br> </div> <h2 id="edit-site"><?php echo $title_site_url_linked; ?> </h2> <br /> <form method="post" action="<?php echo network_admin_url('admin.php?page=' . $this::slug . '&action=edit'); ?> "> <?php wp_nonce_field('gforms-tmp-edit-site'); ?> <input type="hidden" name="id" value="<?php echo esc_attr($id); ?> " /> <input type="hidden" name="action" value="site_update_network_admin_gforms_tmp" /> <table class="form-table"> <tr class="form-field form-required"> <th scope="row"><?php _e('Domain'); ?> </th> <?php $protocol = is_ssl() ? 'https://' : 'http://'; if ($is_main_site) { ?> <td><code><?php echo $protocol; echo esc_attr($details->domain); ?> </code></td> <?php } else { ?> <td><?php echo $protocol; ?> <input type="text" id="domain" value="<?php echo esc_attr($details->domain); ?> " size="33" readonly="readonly" /></td> <?php } ?> </tr> <tr class="form-field"> <th scope="row"><?php _e('Ten Street Client Name'); ?> </th> <td><input type="text" name="gforms_tmp_admin_client_name" id="gforms_tmp_admin_client_name" value="<?php echo $gforms_tmp_admin_client_name; ?> " /></td> </tr> <tr class="form-field"> <th scope="row"><?php _e('Ten Street Client ID'); ?> </th> <td><input type="text" name="gforms_tmp_admin_client_id" id="gforms_tmp_admin_client_id" value="<?php echo $gforms_tmp_admin_client_id; ?> " size="4" style="width: 50px;" /></td> </tr> <?php $attributes = array(); $attributes['archived'] = $details->archived; $attributes['spam'] = $details->spam; $attributes['deleted'] = $details->deleted; ?> <tr> <th scope="row"><?php _e('Enable API'); ?> </th> <td><label><input type="checkbox" name="gforms_tmp_active" value="1" <?php checked((bool) $gforms_tmp_active, true); disabled(in_array(1, $attributes)); ?> /> </label><br /></td> </tr> <tr class="form-field"> <th scope="row"><?php _e('Last Updated'); ?> </th> <td><label><?php echo !$gforms_tmp_last_update ? __('Never') : mysql2date($date, date('Y-m-d h:i:s', $gforms_tmp_last_update)); ?> </label> <input name="gforms_tmp_last_update" type="hidden" id="gforms_tmp_last_update" value="<?php echo $gforms_tmp_last_update; ?> " /></td> </tr> </table> <?php submit_button(); ?> </form> </div> <?php }
function author_gravatar_tag($authorID, $tags = '', $width = '') { global $gravatar_width, $profile_picture_options; if ($authorID != 0) { $path = author_image_path($authorID, false, 'absolute'); $width = $width != '' ? $width : $gravatar_width; //$height = author_image_dimensions($path, 'height') * ($gravatar_width / author_image_dimensions($path, 'width'));// not needed $tag = '<img src="' . author_image_path($authorID, false, 'url') . '" width=' . $width . ' ' . $tags . ' hspace=10 />'; if ($profile_picture_options['link_profile'] == 'yes') { $primary_blog = get_usermeta($authorID, 'primary_blog'); if ($primary_blog != '') { $url = get_blogaddress_by_id($primary_blog); } else { $url = get_blogaddress_by_id(1); } $tag = '<a href="' . $url . '?author=' . $authorID . '">' . $tag . '</a>'; } return $tag; } else { return false; } }
function xpress_primary_blog_link() { global $xoops_config; global $current_user; global $blog_id; $ret = array(); if (xpress_is_multiblog() && is_user_logged_in()){ $blog_list = get_blog_list(); $root_path = get_blog_status(1,'path'); $primary_blog_id = @$current_user->primary_blog; if(empty($primary_blog_id)) return $ret; $primary_path = get_blog_status($primary_blog_id,'path'); $script = str_replace($root_path, "", $primary_path); if ($primary_blog_id !== $blog_id){ $ret['url'] = get_blogaddress_by_id($primary_blog_id); $ret['menu_url'] = $script; $ret['title'] = __('Your Primary Blog','xpressme'); $ret['link'] = '<a href="' . $ret['url'] . '">' . $ret['title'] . '</a>'; } } return $ret; }
</code></td> <?php } else { switch_to_blog($id); ?> <th scope="row"><label for="path"><?php _e('Path'); ?> </label></th> <td> <input name="blog[path]" type="text" id="path" value="<?php echo esc_attr($details->path); ?> " /><br /> <input type="checkbox" name="update_home_url" id="update_home_url" value="update" <?php if (get_option('siteurl') == untrailingslashit(get_blogaddress_by_id($id)) || get_option('home') == untrailingslashit(get_blogaddress_by_id($id))) { echo 'checked="checked"'; } ?> /> <label for="update_home_url"><?php _e('Update <code>siteurl</code> and <code>home</code> as well.'); ?> </label> </td> <?php restore_current_blog(); } ?> </tr> <tr class="form-field"> <th scope="row"><label for="blog_registered"><?php
/** * Get array of subsite simple urls keyed by their ID. * * @return array */ public function subsites_list() { $subsites = array(); if (!is_multisite()) { return $subsites; } if (version_compare($GLOBALS['wp_version'], '4.6', '>=')) { $sites = get_sites(array('limit' => 0)); } else { $sites = wp_get_sites(array('limit' => 0)); } if (!empty($sites)) { foreach ((array) $sites as $subsite) { $subsite = (array) $subsite; $subsites[$subsite['blog_id']] = $this->simple_site_url(get_blogaddress_by_id($subsite['blog_id'])); } } return $subsites; }
/** * Add a new network * * @since 1.3 * * @param string $domain Domain name for new network - for VHOST=no, this * should be FQDN, otherwise domain only * @param string $path Path to root of network hierarchy - should be '/' unless * WP is cohabiting with another product on a domain * @param string $site_name Name of the root blog to be created on the new * network * @param integer $clone_network ID of network whose networkmeta values are * to be copied - default NULL * @param array $options_to_clone Override default network meta options to copy * when cloning - default NULL * @return integer ID of newly created network */ function add_network($domain, $path, $site_name = false, $clone_network = false, $options_to_clone = false) { global $wpdb, $sites; // Set a default site name if one isn't set if (false == $site_name) { $site_name = __('New Network Root', 'wp-multi-network'); } // If no options, fallback on defaults if (empty($options_to_clone)) { $options_to_clone = array_keys(network_options_to_copy()); } // Check for existing network $sql = "SELECT * FROM {$wpdb->site} WHERE domain = %s AND path = %s LIMIT 1"; $query = $wpdb->prepare($sql, $domain, $path); $network = $wpdb->get_row($query); if (!empty($network)) { return new WP_Error('network_exists', __('Network already exists.', 'wp-multi-network')); } // Insert new network $wpdb->insert($wpdb->site, array('domain' => $domain, 'path' => $path)); $new_network_id = $wpdb->insert_id; // Update global network list $sites = $wpdb->get_results("SELECT * FROM {$wpdb->site}"); // If network was created, create a blog for it too if (!empty($new_network_id)) { if (!defined('WP_INSTALLING')) { define('WP_INSTALLING', true); } // there's an ongoing error with wpmu_create_blog that throws a warning if meta is not defined: // http://core.trac.wordpress.org/ticket/20793 // temporary fix -- set from current blog's value // Looks like a fix is in for 3.7 $new_blog_id = wpmu_create_blog($domain, $path, $site_name, get_current_user_id(), array('public' => get_option('blog_public', false)), (int) $new_network_id); // Bail if blog could not be created if (is_a($new_blog_id, 'WP_Error')) { return $new_blog_id; } /** * Fix upload_path for main sites on secondary networks * This applies only to new installs (WP 3.5+) */ // Switch to main network (if it exists) if (defined('SITE_ID_CURRENT_SITE') && network_exists(SITE_ID_CURRENT_SITE)) { switch_to_network(SITE_ID_CURRENT_SITE); $use_files_rewriting = get_site_option('ms_files_rewriting'); restore_current_network(); } else { $use_files_rewriting = get_site_option('ms_files_rewriting'); } global $wp_version; // Create the upload_path and upload_url_path values if (!$use_files_rewriting && version_compare($wp_version, '3.7', '<')) { // WP_CONTENT_URL is locked to the current site and can't be overridden, // so we have to replace the hostname the hard way $current_siteurl = get_option('siteurl'); $new_siteurl = untrailingslashit(get_blogaddress_by_id($new_blog_id)); $upload_url = str_replace($current_siteurl, $new_siteurl, WP_CONTENT_URL); $upload_url = $upload_url . '/uploads'; $upload_dir = WP_CONTENT_DIR; if (0 === strpos($upload_dir, ABSPATH)) { $upload_dir = substr($upload_dir, strlen(ABSPATH)); } $upload_dir .= '/uploads'; if (defined('MULTISITE')) { $ms_dir = '/sites/' . $new_blog_id; } else { $ms_dir = '/' . $new_blog_id; } $upload_dir .= $ms_dir; $upload_url .= $ms_dir; update_blog_option($new_blog_id, 'upload_path', $upload_dir); update_blog_option($new_blog_id, 'upload_url_path', $upload_url); } } // Clone the network meta from an existing network if (!empty($clone_network) && network_exists($clone_network)) { $options_cache = array(); $clone_network = (int) $clone_network; switch_to_network($clone_network); foreach ($options_to_clone as $option) { $options_cache[$option] = get_site_option($option); } restore_current_network(); switch_to_network($new_network_id); foreach ($options_to_clone as $option) { if (isset($options_cache[$option])) { // Fix for strange bug that prevents writing the ms_files_rewriting value for new networks if ($option === 'ms_files_rewriting') { $wpdb->insert($wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $options_cache[$option])); } else { add_site_option($option, $options_cache[$option]); } } } unset($options_cache); restore_current_network(); } do_action('add_network', $new_network_id); return $new_network_id; }
/** * Create a new network * * @uses site_exists() * @uses wpmu_create_blog() * @uses switch_to_site() * @uses restore_current_site() * * @param string $domain domain name for new network - for subdirectory installs, this should be a FQDN, otherwise domain only * @param string $path path to root of network hierarchy - should be '/' unless WordPress is sharing a domain with normal web pages * @param string $blog_name Name of the root blog to be created on the new network or FALSE to skip creating a root blog * @param integer $cloneSite ID of network whose sitemeta values are to be copied - default NULL * @param array $options_to_clone override default sitemeta options to copy when cloning - default NULL * @return integer ID of newly created network */ function add_site($domain, $path = '/', $blog_name = NULL, $cloneSite = NULL, $options_to_clone = NULL) { global $wpdb, $sites, $options_to_copy, $url_dependent_site_options, $current_site; $skip_blog_setup = $blog_name === false; if ($blog_name == NULL) { $blog_name = __('New Network Created', 'njsl-networks'); } $options_to_clone = wp_parse_args($options_to_clone, array_keys($options_to_copy)); $domain = untrailingslashit($domain); if ($path != '/') { $path = trim($path, '/'); $path = trailingslashit('/' . $path); } $query = "SELECT * FROM {$wpdb->site} WHERE domain='" . $wpdb->escape($domain) . "' AND path='" . $wpdb->escape($path) . "' LIMIT 1"; $site = $wpdb->get_row($query); if ($site) { return new WP_Error('site_exists', __('Network already exists!', 'njsl-networks')); } $wpdb->insert($wpdb->site, array('domain' => $domain, 'path' => $path)); $new_site_id = $wpdb->insert_id; /* update site list */ $sites = $wpdb->get_results('SELECT * FROM ' . $wpdb->site); if ($new_site_id) { add_site_option('siteurl', $domain . $path); /* prevent ugly database errors - #184 */ if (!defined('WP_INSTALLING')) { define('WP_INSTALLING', TRUE); } if (!$skip_blog_setup) { // there's an ongoing error with wpmu_create_blog that throws a warning if meta is not defined: // http://core.trac.wordpress.org/ticket/20793 // temporary fix -- set from current blog's value $new_blog_visibility = get_option('blog_public', false); $new_blog_id = wpmu_create_blog($domain, $path, $blog_name, get_current_user_id(), array('public' => $new_blog_visibility), (int) $new_site_id); if (is_a($new_blog_id, 'WP_Error')) { return $new_blog_id; } // Fix upload_path for main sites on secondary networks // This applies only to new installs (WP 3.5+) // Switch to main network (if it exists) if (site_exists(1)) { switch_to_site(1); $use_files_rewriting = get_site_option('ms_files_rewriting'); restore_current_site(); } else { $use_files_rewriting = get_site_option('ms_files_rewriting'); } // Create the upload_path and upload_url_path values for WP 3.5 - 3.6.1 global $wp_version; if (!$use_files_rewriting && version_compare($wp_version, '3.7', '<')) { // WP_CONTENT_URL is locked to the current site and can't be overridden, // so we have to replace the hostname the hard way $current_siteurl = get_option('siteurl'); $new_siteurl = untrailingslashit(get_blogaddress_by_id($new_blog_id)); $upload_url = str_replace($current_siteurl, $new_siteurl, WP_CONTENT_URL); $upload_url = $upload_url . '/uploads'; $upload_dir = WP_CONTENT_DIR; if (0 === strpos($upload_dir, ABSPATH)) { $upload_dir = substr($upload_dir, strlen(ABSPATH)); } $upload_dir .= '/uploads'; if (defined('MULTISITE')) { $ms_dir = '/sites/' . $new_blog_id; } else { $ms_dir = '/' . $new_blog_id; } $upload_dir .= $ms_dir; $upload_url .= $ms_dir; update_blog_option($new_blog_id, 'upload_path', $upload_dir); update_blog_option($new_blog_id, 'upload_url_path', $upload_url); } } } /** if selected, copy the sitemeta from an existing site */ if (!is_null($cloneSite) && site_exists($cloneSite)) { $optionsCache = array(); switch_to_site((int) $cloneSite); foreach ($options_to_clone as $option) { $optionsCache[$option] = get_site_option($option); } $oldsite_domain = $current_site->domain; $oldsite_path = $current_site->path; restore_current_site(); switch_to_site($new_site_id); foreach ($options_to_clone as $option) { if ($optionsCache[$option] !== false) { if (in_array($option, $url_dependent_site_options)) { $optionsCache[$option] = str_replace($oldsite_domain . $oldsite_path, $domain . $path, $optionsCache[$option]); } // Fix for strange bug that prevents writing the ms_files_rewriting value for new networks if ($option == 'ms_files_rewriting') { $wpdb->insert($wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $optionsCache[$option])); } else { add_site_option($option, $optionsCache[$option]); } } } unset($optionsCache); restore_current_site(); } do_action('wpmu_add_site', $new_site_id); do_action('wpms_add_network', $new_site_id); return $new_site_id; }
?> </a> <?php } else { ?> <a href="<?php echo wp_logout_url(); ?> " class=""><?php _e('logout', 'pressbooks'); ?> </a> <?php if (get_current_user_id() == $pb_user_id || is_super_admin()) { $user_info = get_userdata($pb_user_id); $admin_url = get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin/index.php?page=pb_catalog'; if (is_super_admin() && get_current_user_id() != $pb_user_id) { $admin_url .= "&user_id={$pb_user_id}"; } ?> <a href="<?php echo $admin_url; ?> "><?php _e('Admin', 'pressbooks'); ?> </a><?php } ?> <?php }
if (is_super_admin() || is_user_member_of_blog()) { ?> <a href="<?php echo get_option('home'); ?> /wp-admin" class="btn btn-primary btn-sm"><?php _e('Admin', 'pressbooks'); ?> </a> <?php } $user_info = get_userdata(get_current_user_id()); if ($user_info->primary_blog) { ?> <a href="<?php echo get_blogaddress_by_id($user_info->primary_blog); ?> wp-admin/index.php?page=pb_catalog" class="btn btn-primary btn-sm"><?php _e('My Books', 'pressbooks'); ?> </a> <?php } ?> <a href="<?php echo wp_logout_url(); ?> " class="btn btn-primary btn-sm"><?php _e('Sign Out', 'pressbooks'); ?> </a>
} else { printf(__('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, network_site_url('wp-login.php?action=lostpassword')); } echo '</p>'; } else { ?> <h2><?php _e('An error occurred during the activation'); ?> </h2> <?php echo '<p>' . $result->get_error_message() . '</p>'; } } else { extract($result); $url = is_multisite() ? get_blogaddress_by_id((int) $blog_id) : home_url('', 'http'); $user = new WP_User((int) $user_id); ?> <h2><?php _e('Your account is now active!'); ?> </h2> <div id="signup-welcome"> <p><span class="h3"><?php _e('Username:'); ?> </span> <?php echo $user->user_login; ?> </p>
/** * Add a new network * * @since 1.3 * * @param array $args { * Array of arguments. * @type string $domain Domain name for new network - for VHOST=no, * this should be FQDN, otherwise domain only. * @type string $path Path to root of network hierarchy - should * be '/' unless WP is cohabiting with another * product on a domain. * @type string $site_name Name of the root blog to be created on * the new network. * @type integer $user_id ID of the user to add as the site owner. * Defaults to current user ID. * @type array $meta Array of metadata to save to this network. * Defaults to array( 'public' => false ). * @type integer $clone_network ID of network whose networkmeta values are * to be copied - default NULL. * @type array $options_to_clone Override default network meta options to copy * when cloning - default NULL. * } * * @return integer ID of newly created network */ function add_network($args = array()) { global $wpdb; // Backward compatibility with old method of passing arguments if (!is_array($args) || func_num_args() > 1) { _deprecated_argument(__METHOD__, '1.7.0', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'wp-multi-network'), __METHOD__, __FILE__)); // Juggle function parameters $func_args = func_get_args(); $old_args_keys = array(0 => 'domain', 1 => 'path', 2 => 'site_name', 3 => 'clone_network', 4 => 'options_to_clone'); // Reset array $args = array(); // Rejig args foreach ($old_args_keys as $arg_num => $arg_key) { if (isset($func_args[$arg_num])) { $args[$arg_key] = $func_args[$arg_num]; } } } // Parse args $r = wp_parse_args($args, array('domain' => '', 'path' => '/', 'site_name' => __('New Network', 'wp-multi-network'), 'user_id' => get_current_user_id(), 'meta' => array('public' => get_option('blog_public', false)), 'clone_network' => false, 'options_to_clone' => array_keys(network_options_to_copy()))); // Bail if no user with this ID if (empty($r['user_id']) || !get_userdata($r['user_id'])) { return new WP_Error('network_user', __('User does not exist.', 'wp-multi-network')); } // Permissive sanitization for super admin usage $r['domain'] = str_replace(' ', '', strtolower($r['domain'])); $r['path'] = str_replace(' ', '', strtolower($r['path'])); // Check for existing network $network = get_network_by_path($r['domain'], $r['path']); if (!empty($network)) { return new WP_Error('network_exists', __('Network already exists.', 'wp-multi-network')); } // Insert new network $wpdb->insert($wpdb->site, array('domain' => $r['domain'], 'path' => $r['path'])); $new_network_id = $wpdb->insert_id; // If network was created, create a blog for it too if (!empty($new_network_id)) { if (!defined('WP_INSTALLING')) { define('WP_INSTALLING', true); } // Create the site for the root of this network $new_blog_id = wpmu_create_blog($r['domain'], $r['path'], $r['site_name'], $r['user_id'], $r['meta'], $new_network_id); // Bail if blog could not be created if (is_a($new_blog_id, 'WP_Error')) { return $new_blog_id; } /** * Fix upload_path for main sites on secondary networks * This applies only to new installs (WP 3.5+) */ // Switch to main network (if it exists) if (defined('SITE_ID_CURRENT_SITE') && wp_get_network(SITE_ID_CURRENT_SITE)) { switch_to_network(SITE_ID_CURRENT_SITE); $use_files_rewriting = get_site_option('ms_files_rewriting'); restore_current_network(); } else { $use_files_rewriting = get_site_option('ms_files_rewriting'); } global $wp_version; // Create the upload_path and upload_url_path values if (!$use_files_rewriting && version_compare($wp_version, '3.7', '<')) { // WP_CONTENT_URL is locked to the current site and can't be overridden, // so we have to replace the hostname the hard way $current_siteurl = get_option('siteurl'); $new_siteurl = untrailingslashit(get_blogaddress_by_id($new_blog_id)); $upload_url = str_replace($current_siteurl, $new_siteurl, WP_CONTENT_URL); $upload_url = $upload_url . '/uploads'; $upload_dir = WP_CONTENT_DIR; if (0 === strpos($upload_dir, ABSPATH)) { $upload_dir = substr($upload_dir, strlen(ABSPATH)); } $upload_dir .= '/uploads'; if (defined('MULTISITE')) { $ms_dir = '/sites/' . $new_blog_id; } else { $ms_dir = '/' . $new_blog_id; } $upload_dir .= $ms_dir; $upload_url .= $ms_dir; update_blog_option($new_blog_id, 'upload_path', $upload_dir); update_blog_option($new_blog_id, 'upload_url_path', $upload_url); } } // Clone the network meta from an existing network if (!empty($r['clone_network']) && wp_get_network($r['clone_network'])) { $options_cache = array(); // Old network switch_to_network($r['clone_network']); foreach ($r['options_to_clone'] as $option) { $options_cache[$option] = get_site_option($option); } restore_current_network(); // New network switch_to_network($new_network_id); foreach ($r['options_to_clone'] as $option) { if (isset($options_cache[$option])) { // Fix for bug that prevents writing the ms_files_rewriting // value for new networks. if ('ms_files_rewriting' === $option) { $wpdb->insert($wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $options_cache[$option])); } else { add_site_option($option, $options_cache[$option]); } } } unset($options_cache); restore_current_network(); } do_action('add_network', $new_network_id); return $new_network_id; }
/** * Expose public information about a book * * @param array $args * @return array of book information */ protected function getBooksById(array $args) { $book = array(); if (empty($args['id'])) { foreach ($this->public_books as $book_id) { @$book[$book_id]; $book[$book_id]['book_id'] = $book_id; $book[$book_id]['book_url'] = get_blogaddress_by_id($book_id); $book[$book_id]['book_meta'] = \PressBooks\Book::getBookInformation(intval($book_id)); $book_structure = \PressBooks\Book::getBookStructure(intval($book_id)); $book[$book_id]['book_toc'] = $this->getToc($book_structure, $book_id); } } else { // check if blog_id is in the collection if (!in_array($args['id'], $this->public_books)) { return $this->apiErrors('empty'); } $book[$args['id']]['book_id'] = $args['id']; $book[$args['id']]['book_url'] = get_blogaddress_by_id($args['id']); $book[$args['id']]['book_meta'] = \PressBooks\Book::getBookInformation(intval($args['id'])); $book_structure = \PressBooks\Book::getBookStructure(intval($args['id'])); $book[$args['id']]['book_toc'] = $this->getToc($book_structure, $args['id']); } return $book; }
} // no need to refresh blog details yet $c++; } do_action('wpmu_update_blog_options'); restore_current_blog(); wp_redirect(add_query_arg(array('update' => 'updated', 'id' => $id), 'site-settings.php')); exit; } if (isset($_GET['update'])) { $messages = array(); if ('updated' == $_GET['update']) { $messages[] = __('Site options updated.'); } } $title = sprintf(__('Edit Site: %s'), get_blogaddress_by_id($id)); $parent_file = 'sites.php'; $submenu_file = 'sites.php'; require '../admin-header.php'; ?> <div class="wrap"> <?php screen_icon('ms-admin'); ?> <h2 id="edit-site"><?php echo $title; ?> </h2> <h3 class="nav-tab-wrapper"> <?php
<th scope="row"><?php _e( 'Domain' ) ?></th> <?php $protocol = is_ssl() ? 'https://' : 'http://'; if ( $is_main_site ) { ?> <td><code><?php echo $protocol; echo esc_attr( $details->domain ) ?></code></td> <?php } else { ?> <td><?php echo $protocol; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td> <?php } ?> </tr> <tr class="form-field form-required"> <th scope="row"><?php _e( 'Path' ) ?></th> <?php if ( $is_main_site ) { ?> <td><code><?php echo esc_attr( $details->path ) ?></code></td> <?php } else { ?> <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' /> <br /><input type="checkbox" style="width:20px;" name="update_home_url" value="update" <?php if ( get_blog_option( $id, 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_blog_option( $id, 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td> <?php } ?> </tr> <tr class="form-field"> <th scope="row"><?php _ex( 'Registered', 'site' ) ?></th> <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td> </tr> <tr class="form-field"> <th scope="row"><?php _e( 'Last Updated' ); ?></th> <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td> </tr> <?php $attribute_fields = array( 'public' => __( 'Public' ) ); if ( ! $is_main_site ) { $attribute_fields['archived'] = __( 'Archived' ); $attribute_fields['spam'] = _x( 'Spam', 'site' );
function wpmu_welcome_notification($blog_id, $user_id, $password, $title, $meta = '') { global $current_site; if (!apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta)) { return false; } $welcome_email = stripslashes(get_site_option('welcome_email')); if ($welcome_email == false) { $welcome_email = stripslashes(__("Dear User,\n\nYour new SITE_NAME blog has been successfully set up at:\nBLOG_URL\n\nYou can log in to the administrator account with the following information:\nUsername: USERNAME\nPassword: PASSWORD\nLogin Here: BLOG_URLwp-login.php\n\nWe hope you enjoy your new weblog.\nThanks!\n\n--The WordPress Team\nSITE_NAME")); } $url = get_blogaddress_by_id($blog_id); $user = new WP_User($user_id); $welcome_email = str_replace("SITE_NAME", $current_site->site_name, $welcome_email); $welcome_email = str_replace("BLOG_URL", $url, $welcome_email); $welcome_email = str_replace("USERNAME", $user->user_login, $welcome_email); $welcome_email = str_replace("PASSWORD", $password, $welcome_email); $welcome_email = apply_filters("update_welcome_email", $welcome_email, $blog_id, $user_id, $password, $title, $meta); $admin_email = get_site_option("admin_email"); if ($admin_email == '') { $admin_email = 'support@' . $_SERVER['SERVER_NAME']; } $from_name = get_site_option("site_name") == '' ? 'WordPress' : wp_specialchars(get_site_option("site_name")); $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; $message = $welcome_email; if (empty($current_site->site_name)) { $current_site->site_name = "WordPress MU"; } $subject = apply_filters('update_welcome_subject', sprintf(__('New %1$s Blog: %2$s'), $current_site->site_name, stripslashes($title))); wp_mail($user->user_email, $subject, $message, $message_headers); return true; }
} break; } update_option('allowedthemes', $allowed_themes); restore_current_blog(); wp_safe_redirect(add_query_arg(array('id' => $id, $action => $n), $referer)); exit; } if (isset($_GET['action']) && 'update-site' == $_GET['action']) { wp_safe_redirect($referer); exit; } add_thickbox(); add_screen_option('per_page'); $site_url_no_http = preg_replace('#^http(s)?://#', '', get_blogaddress_by_id($id)); $title_site_url_linked = sprintf(__('Edit Site: %s'), '<a href="' . get_blogaddress_by_id($id) . '">' . $site_url_no_http . '</a>'); $title = sprintf(__('Edit Site: %s'), $site_url_no_http); $parent_file = 'sites.php'; $submenu_file = 'sites.php'; require ABSPATH . 'wp-admin/admin-header.php'; ?> <div class="wrap"> <h1 id="edit-site"><?php echo $title_site_url_linked; ?> </h1> <h3 class="nav-tab-wrapper"> <?php $tabs = array('site-info' => array('label' => __('Info'), 'url' => 'site-info.php'), 'site-users' => array('label' => __('Users'), 'url' => 'site-users.php'), 'site-themes' => array('label' => __('Themes'), 'url' => 'site-themes.php'), 'site-settings' => array('label' => __('Settings'), 'url' => 'site-settings.php')); foreach ($tabs as $tab_id => $tab) {
/** * @ticket 14867 */ function test_get_blogaddress_by_id_scheme_is_unaffected_by_request() { $blog = self::factory()->blog->create(); $this->assertFalse(is_ssl()); $this->assertSame('http', parse_url(get_blogaddress_by_id($blog), PHP_URL_SCHEME)); $_SERVER['HTTPS'] = 'on'; $is_ssl = is_ssl(); $address = parse_url(get_blogaddress_by_id($blog), PHP_URL_SCHEME); $this->assertTrue($is_ssl); $this->assertSame('http', $address); }