WordPress

wtyczki – Dostosuj hak filtra WP

  • 29 lutego, 2024
  • 3 min read
wtyczki – Dostosuj hak filtra WP


ja używam Wtyczka dodatkowa WP Form Locker.

Po potwierdzeniu adresu e-mail wtyczka wyśle ​​do Ciebie wiadomość e-mail z linkiem weryfikacyjnym.

E-mail dociera w języku angielskim.

Chcę, żeby dotarło to do języka arabskiego

To jest hak filtrujący z wtyczki:

private function send_email( $email, $form_id ) {

        $hash              = $this->generate_hash( $form_id, $email );
        $refer_link        = isset( $_SERVER['HTTP_REFERER'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '';
        $refer_link        = remove_query_arg( 'wpforms_locker_email_verification_token' , $refer_link );
        $verification_link = esc_url( add_query_arg( 'wpforms_locker_email_verification_token', $hash, $refer_link ) );
        $subject           = apply_filters( 'wpforms_form_locker_email_send_email_subject', esc_html__( 'Email address confirmation', 'wpforms-form-locker' ) );
        $text              = sprintf(
            '%1$s <a href="' . $refer_link . '" class="break-all">' . $refer_link . '</a><br/><br/>'
            . '%2$s <a href="' . $verification_link . '"> %3$s </a> %4$s <br/><br/>'
            . '%5$s <br/><span class="break-all">' . $verification_link . '</span>',
            esc_html__( 'Email address confirmation is required to access the form at', 'wpforms-form-locker' ),
            esc_html__( 'To confirm your email address and access the form, please ', 'wpforms-form-locker' ),
            esc_html__( 'visit this link to', 'wpforms-form-locker' ),
            esc_html__( 'verify your email address', 'wpforms-form-locker' ),
            esc_html__( 'Alternately, you can copy and paste the following URL in your browser: ', 'wpforms-form-locker' )
        );
        $message           = apply_filters( 'wpforms_form_locker_email_send_email_message', $text );
        $message           = sprintf( '<tr><td class="field-name field-value">%1$s</td></tr>', $message );

        // If it's not a plain text template, replace line breaks.
        if ( Helpers::is_plain_text_template() ) {
            // Replace <br/> tags with line breaks.
            $message = str_replace( '<br/>', "\r\n", $message );
        }

        // Create an argument array for the template.
        $args = [
            'body' => [
                'message' => $message,
            ],
        ];

        /**
         * Filter to customize the email template name independently of the global setting.
         *
         * @since 2.6.0
         *
         * @param string $template_name The template name to be used.
         */
        $template_name  = apply_filters( 'wpforms_locker_lockers_email_template_name', Helpers::get_current_template_name() );
        $template_class = Helpers::get_current_template_class( $template_name );
        $template       = ( new $template_class() )->set_args( $args );

        $content = $template->get();

        if ( ! $content ) {
            return;
        }

        ( new Mailer() )
            ->subject( $subject )
            ->template( $template )
            ->to_email( $email )
            ->send();
    }

Jak to zrobić, gdy strona jest w wersji arabskiej i prowadzić ją w języku angielskim w wersji angielskiej

Warto przeczytać!  tworzenie wtyczek — Jak filtrować niestandardowe dane postów za pomocą AJAX?

Witryna korzysta z www.example.com/ar/ w języku arabskim i www.example.com/en/ w języku angielskim

Używam WPML dla języków.

E-mail weryfikacyjny

Dziękuję bardzo.


Źródło