' . esc_html__( 'Here is your access link for the content you purchased. Open the link below and you can read everything you bought.', 'acs-content-for-woocommerce' ) . '
', '' . esc_html__( 'Open the content', 'acs-content-for-woocommerce' ) . '
', '' . sprintf( /* translators: %s: expiry date and time */ esc_html__( 'This link is valid until %s and can be used once.', 'acs-content-for-woocommerce' ), esc_html( $expires_text ) ) . '
', '' . esc_html__( 'Once you have opened the link, you can keep reading in the same browser without entering it again.', 'acs-content-for-woocommerce' ) . '
', '' . esc_html__( 'If you did not ask for this email, please discard it. Nothing happens unless the link is opened.', 'acs-content-for-woocommerce' ) . '
', ); $message = implode( "\n", $lines ); /** * アクセスリンクメールの件名。 * * @since 3.0.0 * * @param string $subject 件名。 */ $subject = apply_filters( 'acscw_access_link_email_subject', $subject ); /** * アクセスリンクメールの見出し(WooCommerce テンプレートのヘッダー部)。 * * @since 3.0.0 * * @param string $heading 見出し。 */ $heading = apply_filters( 'acscw_access_link_email_heading', $heading ); /** * アクセスリンクメールの本文(HTML)。 * * @since 3.0.0 * * @param string $message 本文 HTML。 * @param string $url ワンタイムリンク。 */ $message = apply_filters( 'acscw_access_link_email_body', $message, $url ); return $this->send( $email, $subject, $message, $heading ); } /** * 送信する。 * * @param string $to 宛先。 * @param string $subject 件名。 * @param string $message 本文 HTML。 * @param string $heading WooCommerce テンプレートの見出し。 * @return bool */ public function send( $to, $subject, $message, $heading = '' ) { /** * 送信ヘッダー。 * * @since 3.0.0 * * @param string[] $headers ヘッダー配列。 */ $headers = apply_filters( 'acscw_access_link_email_headers', array( 'Content-Type: text/html; charset=UTF-8' ) ); $wrapped = $this->wrap_message( $heading, $message ); if ( function_exists( 'WC' ) ) { $wc = WC(); if ( is_object( $wc ) && method_exists( $wc, 'mailer' ) ) { $mailer = $wc->mailer(); if ( is_object( $mailer ) && method_exists( $mailer, 'send' ) ) { return (bool) $mailer->send( $to, $subject, $wrapped, $headers ); } } } return (bool) wp_mail( $to, $subject, $wrapped, $headers ); } /** * WooCommerce のメールテンプレートで本文を包む。 * * WooCommerce が使えない場合は本文をそのまま返す。 * * @param string $heading 見出し。 * @param string $message 本文 HTML。 * @return string */ private function wrap_message( $heading, $message ) { if ( ! function_exists( 'WC' ) ) { return $message; } $wc = WC(); if ( ! is_object( $wc ) || ! method_exists( $wc, 'mailer' ) ) { return $message; } $mailer = $wc->mailer(); if ( ! is_object( $mailer ) || ! method_exists( $mailer, 'wrap_message' ) ) { return $message; } return (string) $mailer->wrap_message( $heading, $message ); } }