restore_previous_locale example

/** * Filters the inline instructions inserted before the dynamically generated content. * * @since 5.3.0 * * @param string[] $instructions Array of lines with inline instructions. * @param string $marker The marker being inserted. */
    $instructions = apply_filters( 'insert_with_markers_inline_instructions', $instructions$marker );

    if ( $switched_locale ) {
        restore_previous_locale();
    }

    $insertion = array_merge( $instructions$insertion );

    $start_marker = "# BEGIN {$marker}";
    $end_marker   = "# END {$marker}";

    $fp = fopen( $filename, 'r+' );

    if ( ! $fp ) {
        return false;
    }

        $message_headers = apply_filters( 'comment_notification_headers', $message_headers$comment->comment_ID );

        foreach ( $emails as $email ) {
            wp_mail( $emailwp_specialchars_decode( $subject )$notify_message$message_headers );
        }

        if ( $switched_locale ) {
            restore_previous_locale();
        }

        return true;
    }
endif;

if ( ! function_exists( 'wp_notify_moderator' ) ) :
    /** * Notifies the moderator of the site about a new comment that is awaiting approval. * * @since 1.0.0 * * @global wpdb $wpdb WordPress database abstraction object. * * Uses the {@see 'notify_moderator'} filter to determine whether the site moderator * should be notified, overriding the site setting. * * @param int $comment_id Comment ID. * @return true Always returns true. */

    public function export_preview_data() {
        global $wp_registered_sidebars$wp_registered_widgets;

        $switched_locale = switch_to_user_locale( get_current_user_id() );

        $l10n = array(
            'widgetTooltip' => __( 'Shift-click to edit this widget.' ),
        );

        if ( $switched_locale ) {
            restore_previous_locale();
        }

        $rendered_sidebars = array_filter( $this->rendered_sidebars );
        $rendered_widgets  = array_filter( $this->rendered_widgets );

        // Prepare Customizer settings to pass to JavaScript.         $settings = array(
            'renderedSidebars'            => array_fill_keys( array_keys( $rendered_sidebars ), true ),
            'renderedWidgets'             => array_fill_keys( array_keys( $rendered_widgets ), true ),
            'registeredSidebars'          => array_values( $wp_registered_sidebars ),
            'registeredWidgets'           => $wp_registered_widgets,
            

            $new_user_email = apply_filters( 'invited_user_email', $new_user_email$user_id$role$newuser_key );

            wp_mail(
                $new_user_email['to'],
                $new_user_email['subject'],
                $new_user_email['message'],
                $new_user_email['headers']
            );

            if ( $switched_locale ) {
                restore_previous_locale();
            }

            $redirect = add_query_arg( array( 'update' => 'add' ), 'user-new.php' );
        }
    }
    wp_redirect( $redirect );
    die();
} elseif ( isset( $_REQUEST['action'] ) && 'createuser' === $_REQUEST['action'] ) {
    check_admin_referer( 'create-user', '_wpnonce_create-user' );

    if ( ! current_user_can( 'create_users' ) ) {
        

function restore_previous_locale() {
    /* @var WP_Locale_Switcher $wp_locale_switcher */
    global $wp_locale_switcher;

    if ( ! $wp_locale_switcher ) {
        return false;
    }

    return $wp_locale_switcher->restore_previous_locale();
}

/** * Restores the translations according to the original locale. * * @since 4.7.0 * * @global WP_Locale_Switcher $wp_locale_switcher WordPress locale switcher object. * * @return string|false Locale on success, false on error. */

    $headers = apply_filters( 'wp_privacy_personal_data_email_headers', $headers$subject$content$request_id$email_data );

    $mail_success = wp_mail( $request_email$subject$content$headers );

    if ( $switched_locale ) {
        restore_previous_locale();
    }

    if ( ! $mail_success ) {
        return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export email.' ) );
    }

    return true;
}

/** * Intercept personal data exporter page Ajax responses in order to assemble the personal data export file. * * @since 4.9.6 * * @see 'wp_privacy_personal_data_export_page' * * @param array $response The response from the personal data exporter for the given page. * @param int $exporter_index The index of the personal data exporter. Begins at 1. * @param string $email_address The email address of the user whose personal data this is. * @param int $page The page of personal data for this exporter. Begins at 1. * @param int $request_id The request ID for this personal data export. * @param bool $send_as_email Whether the final results of the export should be emailed to the user. * @param string $exporter_key The slug (key) of the exporter. * @return array The filtered response. */
$user_email,
            $key,
            $meta
        ),
        $from_name,
        esc_url( 'http://' . $domain . $path )
    );

    wp_mail( $user_emailwp_specialchars_decode( $subject )$message$message_headers );

    if ( $switched_locale ) {
        restore_previous_locale();
    }

    return true;
}

/** * Sends a confirmation request email to a user when they sign up for a new user account (without signing up for a site * at the same time). The user account will not become active until the confirmation link is clicked. * * This is the notification function used when no new site has * been requested. * * Filter {@see 'wpmu_signup_user_notification'} to bypass this function or * replace it with your own notification behavior. * * Filter {@see 'wpmu_signup_user_notification_email'} and * {@see 'wpmu_signup_user_notification_subject'} to change the content * and subject line of the email sent to newly registered users. * * @since MU (3.0.0) * * @param string $user_login The user's login name. * @param string $user_email The user's email address. * @param string $key The activation key created in wpmu_signup_user() * @param array $meta Optional. Signup meta data. Default empty array. * @return bool */

            $allowed_hosts[] = $host;
        }

        $switched_locale = switch_to_user_locale( get_current_user_id() );
        $l10n            = array(
            'shiftClickToEdit'  => __( 'Shift-click to edit this element.' ),
            'linkUnpreviewable' => __( 'This link is not live-previewable.' ),
            'formUnpreviewable' => __( 'This form is not live-previewable.' ),
        );
        if ( $switched_locale ) {
            restore_previous_locale();
        }

        $settings = array(
            'changeset'         => array(
                'uuid'      => $this->changeset_uuid(),
                'autosaved' => $this->autosaved(),
            ),
            'timeouts'          => array(
                'selectiveRefresh' => 250,
                'keepAliveSend'    => 1000,
            ),
            
$switched_locale = switch_to_user_locale( get_current_user_id() );
        $l10n            = array(
            'shiftClickToEdit' => __( 'Shift-click to edit this element.' ),
            'clickEditMenu'    => __( 'Click to edit this menu.' ),
            'clickEditWidget'  => __( 'Click to edit this widget.' ),
            'clickEditTitle'   => __( 'Click to edit the site title.' ),
            'clickEditMisc'    => __( 'Click to edit this element.' ),
            /* translators: %s: document.write() */
            'badDocumentWrite' => sprintf( __( '%s is forbidden' ), 'document.write()' ),
        );
        if ( $switched_locale ) {
            restore_previous_locale();
        }

        $exports = array(
            'partials'       => $partials,
            'renderQueryVar' => self::RENDER_QUERY_VAR,
            'l10n'           => $l10n,
        );

        // Export data to JS.         printf( '<script>var _customizePartialRefreshExports = %s;</script>', wp_json_encode( $exports ) );
    }

    
$email = apply_filters( 'recovery_mode_email', $email$url );

        $sent = wp_mail(
            $email['to'],
            wp_specialchars_decode( sprintf( $email['subject']$blogname ) ),
            $email['message'],
            $email['headers'],
            $email['attachments']
        );

        if ( $switched_locale ) {
            restore_previous_locale();
        }

        return $sent;
    }

    /** * Gets the email address to send the recovery mode link to. * * @since 5.2.0 * * @return string Email address to send recovery mode link to. */
$email_change_email['message'] = str_replace( '###USERNAME###', $user['user_login']$email_change_email['message'] );
        $email_change_email['message'] = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' )$email_change_email['message'] );
        $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $userdata['user_email']$email_change_email['message'] );
        $email_change_email['message'] = str_replace( '###EMAIL###', $user['user_email']$email_change_email['message'] );
        $email_change_email['message'] = str_replace( '###SITENAME###', $blog_name$email_change_email['message'] );
        $email_change_email['message'] = str_replace( '###SITEURL###', home_url()$email_change_email['message'] );

        wp_mail( $email_change_email['to']sprintf( $email_change_email['subject']$blog_name )$email_change_email['message']$email_change_email['headers'] );
    }

    if ( $switched_locale ) {
        restore_previous_locale();
    }

    // Update the cookies if the password changed.     $current_user = wp_get_current_user();
    if ( $current_user->ID == $user_id ) {
        if ( isset( $plaintext_pass ) ) {
            wp_clear_auth_cookie();

            /* * Here we calculate the expiration length of the current auth cookie and compare it to the default expiration. * If it's greater than this, then we know the user checked 'Remember Me' when they logged in. */
wp_mail(
        get_option( 'admin_email' ),
        sprintf(
            /* translators: %s: Site title. */
            __( '[%s] Delete My Site' ),
            wp_specialchars_decode( get_option( 'blogname' ) )
        ),
        $content
    );

    if ( $switched_locale ) {
        restore_previous_locale();
    }
    ?> <p><?php _e( 'Thank you. Please check your email for a link to confirm your action. Your site will not be deleted until this link is clicked.' ); ?></p> <?php } else {
    ?> <p> <?php         printf(
            

    public function restore_current_locale() {
        if ( empty( $this->stack ) ) {
            return false;
        }

        $this->stack = array( array( $this->original_locale, false ) );

        return $this->restore_previous_locale();
    }

    /** * Whether switch_to_locale() is in effect. * * @since 4.7.0 * * @return bool True if the locale has been switched, false otherwise. */
    public function is_switched() {
        return ! empty( $this->stack );
    }
Home | Imprint | This part of the site doesn't use cookies.