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


PHP WP_Error::get_error_code方法代码示例

本文整理汇总了PHP中WP_Error::get_error_code方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Error::get_error_code方法的具体用法?PHP WP_Error::get_error_code怎么用?PHP WP_Error::get_error_code使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_Error的用法示例。


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

示例1: compare

 private function compare()
 {
     if (version_compare($this->php, self::PHP, '<')) {
         $this->e->add('error', 'Dana Don Boom Boom Doo plugin cannot be activated.');
     }
     if (version_compare($this->wp, self::WP, '<')) {
         $this->e->add('error', 'Dana Don Boom Boom Doo plugin cannot be activated.');
     }
     if ($this->e->get_error_code()) {
         add_action('admin_init', [$this, 'error_message']);
         return false;
     }
     return true;
 }
开发者ID:mimosafa,项目名称:dana-don-boom-boom-doo,代码行数:14,代码来源:dana-don-boom-boom-doo.php

示例2: retrieve_password

/**
 * Handles sending password retrieval email to user.
 *
 * @uses $wpdb WordPress Database object
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    global $wpdb;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    do_action('retreive_password', $user_login);
    // Misspelled and deprecated
    do_action('retrieve_password', $user_login);
    $allow = apply_filters('allow_password_reset', true, $user_data->ID);
    if (!$allow) {
        return new WP_Error('no_password_reset', __('Password reset is not allowed for this user'));
    } else {
        if (is_wp_error($allow)) {
            return $allow;
        }
    }
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE user_login = %s", $user_login));
    if (empty($user)) {
        return new WP_Error('invalid_key', __('Invalid key'));
    }
    $new_pass = wp_generate_password(12, false);
    do_action('password_reset', $user, $new_pass);
    wp_set_password($new_pass, $user->ID);
    update_usermeta($user->ID, 'default_password_nag', true);
    //Set up the Password change nag.
    $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
    $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
    $message .= site_url() . '/?ptype=affiliate' . "\r\n";
    $title = sprintf(__('[%s] Your new password'), get_option('blogname'));
    $title = apply_filters('password_reset_title', $title);
    $message = apply_filters('password_reset_message', $message, $new_pass);
    if ($message && !wp_mail($user_email, $title, $message)) {
        die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
    }
    return true;
}
开发者ID:annguyenit,项目名称:getdeal,代码行数:67,代码来源:affiliate_login.php

示例3: retrieve_password

/**
 * Handles sending password retrieval email to user.
 *
 * @uses $wpdb WordPress Database object
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    global $wpdb;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'templatic'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'templatic'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'templatic'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    do_action('retreive_password', $user_login);
    // Misspelled and deprecated
    do_action('retrieve_password', $user_login);
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_login like \"{$user_login}\" or user_email like \"{$user_login}\"");
    if (empty($user)) {
        return new WP_Error('invalid_key', __('Invalid key', 'templatic'));
    }
    $new_pass = wp_generate_password(12, false);
    do_action('password_reset', $user, $new_pass);
    wp_set_password($new_pass, $user->ID);
    update_usermeta($user->ID, 'default_password_nag', true);
    //Set up the Password change nag.
    $message = '<p><b>Your login Information :</b></p>';
    $message .= '<p>' . sprintf(__('Username: %s', 'templatic'), $user->user_login) . "</p>";
    $message .= '<p>' . sprintf(__('Password: %s', 'templatic'), $new_pass) . "</p>";
    $message .= '<p>You can login to : <a href="' . site_url() . '/?ptype=login' . "\">Login</a> or the URL is :  " . site_url() . "/?ptype=login</p>";
    $message .= '<p>Thank You,<br> ' . get_option('blogname') . '</p>';
    $user_email = $user_data->user_email;
    $user_name = $user_data->user_nicename;
    $fromEmail = get_site_emailId();
    $fromEmailName = get_site_emailName();
    $title = sprintf(__('[%s] Your new password', 'templatic'), get_option('blogname'));
    $title = apply_filters('password_reset_title', $title);
    $message = apply_filters('password_reset_message', $message, $new_pass);
    if (get_option('pttthemes_send_mail') == 'Enable' || get_option('pttthemes_send_mail') == '') {
        templ_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '');
        ///forgot password email
    }
    return true;
}
开发者ID:annguyenit,项目名称:getdeal,代码行数:66,代码来源:registration.php

示例4: found_temporary_error

 /**
  * Determine if rescheduling is suggested based on the job result.
  *
  * @since 1.3.0
  *
  * @return bool
  */
 public function found_temporary_error()
 {
     if ($this->is_service_unavailable()) {
         return true;
     }
     if (!is_wp_error($this->job_result)) {
         return false;
     }
     if ('http_request_failed' != $this->job_result->get_error_code()) {
         return false;
     }
     $error_message_patterns = array('Failed to connect', 'Couldn\'t resolve host', 'name lookup timed out', 'couldn\'t connect to host', 'Connection refused', 'Empty reply from server');
     $error_message_pattern = '/(' . implode('|', $error_message_patterns) . ')/';
     if (!preg_match($error_message_pattern, $this->job_result->get_error_message())) {
         return false;
     }
     return true;
 }
开发者ID:postmatic,项目名称:beta-dist,代码行数:25,代码来源:rescheduler.php

示例5: retrieve_password

/**
 * Handles sending password retrieval email to user.
 *
 * @uses $wpdb WordPress Database object
 *
 * @return bool|WP_Error True: when finish. WP_Error on error
 */
function retrieve_password()
{
    global $wpdb, $General, $Cart, $Product;
    $errors = new WP_Error();
    if (empty($_POST['user_login']) && empty($_POST['user_email'])) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
    }
    if (strpos($_POST['user_login'], '@')) {
        $user_data = get_user_by_email(trim($_POST['user_login']));
        if (empty($user_data)) {
            $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
        }
    } else {
        $login = trim($_POST['user_login']);
        $user_data = get_userdatabylogin($login);
    }
    do_action('lostpassword_post');
    if ($errors->get_error_code()) {
        return $errors;
    }
    if (!$user_data) {
        $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
        return $errors;
    }
    // redefining user_login ensures we return the right case in the email
    $user_login = $user_data->user_login;
    $user_email = $user_data->user_email;
    //do_action('retreive_password', $user_login);  // Misspelled and deprecated
    //do_action('retrieve_password', $user_login);
    //$allow = apply_filters('allow_password_reset', true, $user_data->ID);
    ////////////////////////////////////
    //forget pw changed on 1st april 2010 start//
    $user_email = $_POST['user_email'];
    $user_login = $_POST['user_login'];
    $user = $wpdb->get_row("SELECT * FROM {$wpdb->users} WHERE user_login = \"{$user_login}\" or user_email = \"{$user_login}\"");
    $new_pass = wp_generate_password(12, false);
    wp_set_password($new_pass, $user->ID);
    if ($General->is_send_forgot_pw_email()) {
        $message = '<p>' . sprintf(__('Username: %s'), $user_data->user_login) . '</p>';
        $message .= '<p>' . sprintf(__('Password: %s'), $new_pass) . "</p>";
        $message .= '<p>You can <a href="' . $General->get_url_login(site_url('/?ptype=login')) . '">Login</a> now</p>';
        $title = sprintf(__('[%s] Your new password'), get_option('blogname'));
        $user_email = $user_data->user_email;
        $user_login = $user_data->user_login;
        $title = apply_filters('password_reset_title', $title);
        $message = apply_filters('password_reset_message', $message, $new_pass);
        //forget pw changed on 1st april 2010 end//
        global $General;
        $fromEmail = $General->get_site_emailId();
        $fromEmailName = $General->get_site_emailName();
        $General->sendEmail($fromEmail, $fromEmailName, $user_email, $user_login, $title, $message, $extra = '');
        ///To clidne email
    }
    return true;
}
开发者ID:exploit86,项目名称:Devoncha,代码行数:62,代码来源:registration.php

示例6: retrieve_password

function retrieve_password() {
	global $wpdb;

	$errors = new WP_Error();

	if ( empty( $_POST['user_login'] ) && empty( $_POST['user_email'] ) )
		$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));

	if ( strstr($_POST['user_login'], '@') ) {
		$user_data = get_user_by_email(trim($_POST['user_login']));
		if ( empty($user_data) )
			$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
	} else {
		$login = trim($_POST['user_login']);
		$user_data = get_userdatabylogin($login);
	}

	do_action('lostpassword_post');

	if ( $errors->get_error_code() )
		return $errors;

	if ( !$user_data ) {
		$errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.'));
		return $errors;
	}

	// redefining user_login ensures we return the right case in the email
	$user_login = $user_data->user_login;
	$user_email = $user_data->user_email;

	do_action('retreive_password', $user_login);  // Misspelled and deprecated
	do_action('retrieve_password', $user_login);

	$key = $wpdb->get_var($wpdb->prepare("SELECT user_activation_key FROM $wpdb->users WHERE user_login = %s", $user_login));
	if ( empty($key) ) {
		// Generate something random for a key...
		$key = wp_generate_password();
		do_action('retrieve_password_key', $user_login, $key);
		// Now insert the new md5 key into the db
		$wpdb->query($wpdb->prepare("UPDATE $wpdb->users SET user_activation_key = %s WHERE user_login = %s", $key, $user_login));
	}
	$message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
	$message .= get_option('siteurl') . "\r\n\r\n";
	$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
	$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
	$message .= get_option('siteurl') . "/wp-login.php?action=rp&key=$key\r\n";

	if ( !wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_option('blogname')), $message) )
		die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');

	return true;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:53,代码来源:wp-login.php

示例7: __construct

 /**
  * WordPress exception constructor.
  *
  * The class constructor accepts either the traditional `\Exception` creation
  * parameters or a `\WP_Error` instance in place of the previous exception.
  *
  * If a `\WP_Error` instance is given in this way, the `$message` and `$code`
  * parameters are ignored in favour of the message and code provided by the
  * `\WP_Error` instance.
  *
  * Depending on whether a `\WP_Error` instance was received, the instance is kept
  * or a new one is created from the provided parameters.
  *
  * @param string               $message  Exception message (optional, defaults to empty).
  * @param string               $code     Exception code (optional, defaults to empty).
  * @param \Exception|\WP_Error $previous Previous exception or error (optional).
  *
  * @uses \WP_Error
  * @uses \WP_Error::get_error_code()
  * @uses \WP_Error::get_error_message()
  *
  * @codeCoverageIgnore
  */
 public function __construct($message = '', $code = '', $previous = null)
 {
     $exception = $previous;
     $wp_error = null;
     if ($previous instanceof \WP_Error) {
         $code = $previous->get_error_code();
         $message = $previous->get_error_message($code);
         $wp_error = $previous;
         $exception = null;
     }
     parent::__construct($message, null, $exception);
     $this->code = $code;
     $this->wp_error = $wp_error;
 }
开发者ID:goblindegook,项目名称:syllables,代码行数:37,代码来源:WP_Exception.php

示例8:

 /**
  * @ticket 28092
  */
 function test_remove_error()
 {
     $error = new WP_Error();
     $error->add('foo', 'This is the first error message', 'some error data');
     $error->add('foo', 'This is the second error message');
     $error->add('bar', 'This is another error');
     $error->remove('foo');
     // Check the error has been removed.
     $this->assertEmpty($error->get_error_data('foo'));
     $this->assertEmpty($error->get_error_messages('foo'));
     // The 'bar' error should now be the 'first' error retrieved.
     $this->assertEquals('bar', $error->get_error_code());
     $this->assertEmpty($error->get_error_data());
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:17,代码来源:errors.php

示例9: registrar_usuario

function registrar_usuario($parametros)
{
    $errors = new WP_Error();
    if ($parametros['email'] == NULL) {
        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
        //return $errors;
    }
    if (!es_email($parametros['email'])) {
        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
        //return $errors;
    }
    if (email_exists($parametros['email'])) {
        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
        //return $errors;
    }
    if ($parametros['nombre'] == NULL) {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
        //return $errors;
    }
    if ($parametros['empresa'] == NULL) {
        $errors->add('empty_empresa', '<strong>ERROR</strong>: Por favor introduce una empresa.');
    }
    if ($errors->get_error_code()) {
        return $errors;
    }
    $user_pass = $parametros['clave'] == NULL ? wp_generate_password(12, false) : $parametros['clave'];
    $user_id = wp_create_user($parametros['nombre'], $user_pass, $parametros['email']);
    if (!$user_id) {
        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
        return $errors;
    }
    update_user_option($user_id, 'default_password_nag', true, true);
    //Set up the Password change nag.
    wp_new_user_notification($user_id, $user_pass);
    //actualizo la empresa
    global $wpdb;
    $sql = "update wp_users set empresa = '" . $parametros['empresa'] . "' where ID = '" . $user_id . "'";
    $result = $wpdb->query($sql);
    if ($result === false) {
        $errors->add('empty_empresa', '<strong>ERROR</strong>: No se ha asignado la empresa.');
    }
    return $user_id;
}
开发者ID:Esleelkartea,项目名称:herramienta_para_autodiagnostico_ADEADA,代码行数:43,代码来源:acciones.php

示例10: array

 function populate_global($email = '', $global_name = '')
 {
     global $wpdb;
     $errors = new WP_Error();
     if (empty($global_name)) {
         $errors->add('empty_global_name', __('You must provide a name for your global multinetwork.', 'global-admin'));
     }
     if (!is_email($email)) {
         $errors->add('invalid_email', __('You must provide a valid email address.', 'global-admin'));
     }
     if ($errors->get_error_code()) {
         return $errors;
     }
     $user = get_user_by('email', $email);
     if (false === $user) {
         $user = wp_get_current_user();
     }
     $user->add_global_role('administrator');
     $global_options = array('global_name' => $global_name, 'admin_email' => $email);
     /**
      * Filters options for the global admin on creation.
      *
      * @since 1.0.0
      *
      * @param array $global_options Associative array of global keys and values to be inserted.
      */
     $global_options = apply_filters('populate_global_options', $global_options);
     $insert = '';
     foreach ($global_options as $key => $value) {
         if (is_array($value)) {
             $value = serialize($value);
         }
         if (!empty($insert)) {
             $insert .= ', ';
         }
         $insert .= $wpdb->prepare("( %s, %s, %s)", $key, $value, 'yes');
     }
     $wpdb->query("INSERT INTO {$wpdb->global_options} ( option_name, option_value, autoload ) VALUES " . $insert);
     return true;
 }
开发者ID:felixarntz,项目名称:global-admin,代码行数:40,代码来源:schema.php

示例11: wpsc_add_new_user

/**
 * WPSC add new user function, validates and adds a new user, for the 
 *
 * @since 3.7
 *
 * @param string $user_login The user's username.
 * @param string $password The user's password.
 * @param string $user_email The user's email (optional).
 * @return int The new user's ID.
 */
function wpsc_add_new_user($user_login, $user_pass, $user_email)
{
    require_once ABSPATH . WPINC . '/registration.php';
    $errors = new WP_Error();
    $user_login = sanitize_user($user_login);
    $user_email = apply_filters('user_registration_email', $user_email);
    // Check the username
    if ($user_login == '') {
        $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
    } elseif (!validate_username($user_login)) {
        $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.'));
        $user_login = '';
    } elseif (username_exists($user_login)) {
        $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
    }
    // Check the e-mail address
    if ($user_email == '') {
        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
    } elseif (!is_email($user_email)) {
        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
        $user_email = '';
    } elseif (email_exists($user_email)) {
        $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'));
    }
    if ($errors->get_error_code()) {
        return $errors;
    }
    $user_id = wp_create_user($user_login, $user_pass, $user_email);
    if (!$user_id) {
        $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')));
        return $errors;
    }
    $credentials = array('user_login' => $user_login, 'user_password' => $user_pass, 'remember' => true);
    $user = wp_signon($credentials);
    return $user;
    //wp_new_user_notification($user_id, $user_pass);
}
开发者ID:BGCX261,项目名称:zombie-craft-svn-to-git,代码行数:47,代码来源:misc.functions.php

示例12: wpmp_switcher_login_header

function wpmp_switcher_login_header($title, $message = '', $wp_error = '')
{
    global $error;
    if (empty($wp_error)) {
        $wp_error = new WP_Error();
    }
    include_once 'mobile.php';
    wpmp_ms_mobile_top($title);
    if (!empty($message)) {
        echo apply_filters('login_message', $message) . "\n";
    }
    if (!empty($error)) {
        $wp_error->add('error', $error);
        unset($error);
    }
    if ($wp_error->get_error_code()) {
        $errors = '';
        $messages = '';
        foreach ($wp_error->get_error_codes() as $code) {
            $severity = $wp_error->get_error_data($code);
            foreach ($wp_error->get_error_messages($code) as $error) {
                if ('message' == $severity) {
                    $messages .= '	' . $error . "<br />\n";
                } else {
                    $errors .= '	' . $error . "<br />\n";
                }
            }
        }
        if (!empty($errors)) {
            echo '<div id="login_error">' . apply_filters('login_errors', $errors) . "</div>\n";
        }
        if (!empty($messages)) {
            echo '<p class="message">' . apply_filters('login_messages', $messages) . "</p>\n";
        }
    }
}
开发者ID:nil-vn,项目名称:beautysite,代码行数:36,代码来源:mobile_login.php

示例13: populate_network

/**
 * populate network settings
 *
 * @since 3.0.0
 *
 * @param int $network_id id of network to populate
 * @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful,
 * 	so the error code must be checked) or failure.
 */
function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {
	global $wpdb, $current_site, $wp_db_version, $wp_rewrite;

	$errors = new WP_Error();
	if ( '' == $domain )
		$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
	if ( '' == $site_name )
		$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );

	// check for network collision
	if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
		$errors->add( 'siteid_exists', __( 'The network already exists.' ) );

	$site_user = get_user_by_email( $email );
	if ( ! is_email( $email ) )
		$errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) );

	if ( $errors->get_error_code() )
		return $errors;

	// set up site tables
	$template = get_option( 'template' );
	$stylesheet = get_option( 'stylesheet' );
	$allowed_themes = array( $stylesheet => true );
	if ( $template != $stylesheet )
		$allowed_themes[ $template ] = true;
	if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template )
		$allowed_themes[ WP_DEFAULT_THEME ] = true;

	if ( 1 == $network_id ) {
		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) );
		$network_id = $wpdb->insert_id;
	} else {
		$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) );
	}

	if ( !is_multisite() ) {
		$site_admins = array( $site_user->user_login );
		$users = get_users_of_blog();
		if ( $users ) {
			foreach ( $users as $user ) {
				if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) )
					$site_admins[] = $user->user_login;
			}
		}
	} else {
		$site_admins = get_site_option( 'site_admins' );
	}

	$welcome_email = __( '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
Login Here: BLOG_URLwp-login.php

We hope you enjoy your new site.
Thanks!

--The Team @ SITE_NAME' );

	$sitemeta = array(
		'site_name' => $site_name,
		'admin_email' => $site_user->user_email,
		'admin_user_id' => $site_user->ID,
		'registration' => 'none',
		'upload_filetypes' => 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf',
		'blog_upload_space' => 10,
		'fileupload_maxk' => 1500,
		'site_admins' => $site_admins,
		'allowedthemes' => $allowed_themes,
		'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ),
		'wpmu_upgrade_site' => $wp_db_version,
		'welcome_email' => $welcome_email,
		'first_post' => __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ),
		// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
		'siteurl' => get_option( 'siteurl' ) . '/',
		'add_new_users' => '0',
		'upload_space_check_disabled' => '0',
		'subdomain_install' => intval( $subdomain_install ),
		'global_terms_enabled' => global_terms_enabled() ? '1' : '0'
	);
	if ( !intval( $subdomain_install ) )
		$sitemeta['illegal_names'][] = 'blog';

	$insert = '';
	foreach ( $sitemeta as $meta_key => $meta_value ) {
		$meta_key = $wpdb->escape( $meta_key );
//.........这里部分代码省略.........
开发者ID:realfluid,项目名称:umbaugh,代码行数:101,代码来源:schema.php

示例14: login_header

/**
 * Output the login page header.
 *
 * @param string   $title    Optional. WordPress login Page title to display in the `<title>` element.
 *                           Default 'Log In'.
 * @param string   $message  Optional. Message to display in header. Default empty.
 * @param WP_Error $wp_error Optional. The error to pass. Default empty.
 */
function login_header($title = 'Log In', $message = '', $wp_error = '')
{
    global $error, $interim_login, $action;
    // Don't index any of these forms
    add_action('login_head', 'wp_no_robots');
    if (wp_is_mobile()) {
        add_action('login_head', 'wp_login_viewport_meta');
    }
    if (empty($wp_error)) {
        $wp_error = new WP_Error();
    }
    // Shake it!
    $shake_error_codes = array('empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password');
    /**
     * Filter the error codes array for shaking the login form.
     *
     * @since 3.0.0
     *
     * @param array $shake_error_codes Error codes that shake the login form.
     */
    $shake_error_codes = apply_filters('shake_error_codes', $shake_error_codes);
    if ($shake_error_codes && $wp_error->get_error_code() && in_array($wp_error->get_error_code(), $shake_error_codes)) {
        add_action('login_head', 'wp_shake_js', 12);
    }
    ?>
<!DOCTYPE html>
	<!--[if IE 8]>
		<html xmlns="http://www.w3.org/1999/xhtml" class="ie8" <?php 
    language_attributes();
    ?>
>
	<![endif]-->
	<!--[if !(IE 8) ]><!-->
		<html xmlns="http://www.w3.org/1999/xhtml" <?php 
    language_attributes();
    ?>
>
	<!--<![endif]-->
	<head>
	<meta http-equiv="Content-Type" content="<?php 
    bloginfo('html_type');
    ?>
; charset=<?php 
    bloginfo('charset');
    ?>
" />
	<title><?php 
    bloginfo('name');
    ?>
 &rsaquo; <?php 
    echo $title;
    ?>
</title>
	<?php 
    wp_admin_css('login', true);
    /*
     * Remove all stored post data on logging out.
     * This could be added by add_action('login_head'...) like wp_shake_js(),
     * but maybe better if it's not removable by plugins
     */
    if ('loggedout' == $wp_error->get_error_code()) {
        ?>
		<script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script>
		<?php 
    }
    /**
     * Enqueue scripts and styles for the login page.
     *
     * @since 3.1.0
     */
    do_action('login_enqueue_scripts');
    /**
     * Fires in the login page header after scripts are enqueued.
     *
     * @since 2.1.0
     */
    do_action('login_head');
    if (is_multisite()) {
        $login_header_url = network_home_url();
        $login_header_title = get_current_site()->site_name;
    } else {
        $login_header_url = __('https://wordpress.org/');
        $login_header_title = __('Powered by WordPress');
    }
    /**
     * Filter link URL of the header logo above login form.
     *
     * @since 2.1.0
     *
     * @param string $login_header_url Login header logo URL.
     */
    $login_header_url = apply_filters('login_headerurl', $login_header_url);
//.........这里部分代码省略.........
开发者ID:neruub,项目名称:shop_sda,代码行数:101,代码来源:wp-login.php

示例15: update_core


//.........这里部分代码省略.........
        }
    }
    // If we're using the direct method, we can predict write failures that are due to permissions.
    if ($check_is_writable && 'direct' === $wp_filesystem->method) {
        $files_writable = array_filter($check_is_writable, array($wp_filesystem, 'is_writable'));
        if ($files_writable !== $check_is_writable) {
            $files_not_writable = array_diff_key($check_is_writable, $files_writable);
            foreach ($files_not_writable as $relative_file_not_writable => $file_not_writable) {
                // If the writable check failed, chmod file to 0644 and try again, same as copy_dir().
                $wp_filesystem->chmod($file_not_writable, FS_CHMOD_FILE);
                if ($wp_filesystem->is_writable($file_not_writable)) {
                    unset($files_not_writable[$relative_file_not_writable]);
                }
            }
            // Store package-relative paths (the key) of non-writable files in the WP_Error object.
            $error_data = version_compare($old_wp_version, '3.7-beta2', '>') ? array_keys($files_not_writable) : '';
            if ($files_not_writable) {
                return new WP_Error('files_not_writable', __('The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.'), implode(', ', $error_data));
            }
        }
    }
    /** This filter is documented in wp-admin/includes/update-core.php */
    apply_filters('update_feedback', __('Enabling Maintenance mode&#8230;'));
    // Create maintenance file to signal that we are upgrading
    $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
    $maintenance_file = $to . '.maintenance';
    $wp_filesystem->delete($maintenance_file);
    $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE);
    /** This filter is documented in wp-admin/includes/update-core.php */
    apply_filters('update_feedback', __('Copying the required files&#8230;'));
    // Copy new versions of WP files into place.
    $result = _copy_dir($from . $distro, $to, $skip);
    if (is_wp_error($result)) {
        $result = new WP_Error($result->get_error_code(), $result->get_error_message(), substr($result->get_error_data(), strlen($to)));
    }
    // Since we know the core files have copied over, we can now copy the version file
    if (!is_wp_error($result)) {
        if (!$wp_filesystem->copy($from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true)) {
            $wp_filesystem->delete($from, true);
            $result = new WP_Error('copy_failed_for_version_file', __('The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.'), 'wp-includes/version.php');
        }
        $wp_filesystem->chmod($to . 'wp-includes/version.php', FS_CHMOD_FILE);
    }
    // Check to make sure everything copied correctly, ignoring the contents of wp-content
    $skip = array('wp-content');
    $failed = array();
    if (isset($checksums) && is_array($checksums)) {
        foreach ($checksums as $file => $checksum) {
            if ('wp-content' == substr($file, 0, 10)) {
                continue;
            }
            if (!file_exists($working_dir_local . $file)) {
                continue;
            }
            if (file_exists(ABSPATH . $file) && md5_file(ABSPATH . $file) == $checksum) {
                $skip[] = $file;
            } else {
                $failed[] = $file;
            }
        }
    }
    // Some files didn't copy properly
    if (!empty($failed)) {
        $total_size = 0;
        foreach ($failed as $file) {
            if (file_exists($working_dir_local . $file)) {
开发者ID:rlgod,项目名称:WordPress,代码行数:67,代码来源:update-core.php


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