id = 'wc_square_access_token_email'; $this->customer_email = false; $this->title = __( 'Square Access Token problems', 'woocommerce-square' ); $this->description = __( 'This email is sent when problems with Access Token are encountered', 'woocommerce-square' ); $this->subject = _x( '[WooCommerce] There was a problem with your Square Access Token', 'Email subject', 'woocommerce-square' ); $this->heading = _x( 'There was a problem with your Square Access Token', 'Email heading', 'woocommerce-square' ); $this->body = _x( 'Heads up! There may be a problem with your connection to Square.', 'Square connection problems email body.', 'woocommerce-square' ); $this->enabled_default = 'yes'; // call parent constructor parent::__construct(); // set default recipient $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) ); } /** * Triggers the email. * * @since 2.1.0 */ public function trigger() { if ( ! $this->is_enabled() || ! $this->has_recipients() ) { return; } // send the email at most once a day $already_sent = get_transient( 'wc_square_access_token_email_sent' ); if ( false !== $already_sent ) { return; } set_transient( 'wc_square_access_token_email_sent', true, DAY_IN_SECONDS ); $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); } /** * Gets the arguments that should be passed to an email template. * * @since 2.1.0 * * @param array $args optional associative array with additional arguments * @return array */ protected function get_template_args( $args = array() ) { $html = empty( $args['plain_text'] ); $email_body = $this->body; $square = wc_square(); $settings_url = $square->get_settings_url(); $logs_url = esc_url( admin_url( 'admin.php?page=wc-status&tab=logs' ) ); if ( $html ) { $email_body .= ' ' . sprintf( /* translators: Placeholders: %1$s - opening HTML link tag, %2$s - closing HTML link tag */ esc_html__( 'In order to continue accepting payments, please %1$sdisconnect and re-connect your site%2$s.', 'woocommerce-square' ), '', '' ); if ( $square->get_settings_handler()->is_debug_enabled() ) { $email_body .= '

' . sprintf( /* translators: Placeholders: %1$s - opening HTML link tag, %2$s - closing HTML link tag */ esc_html__( '%1$sInspect status logs%2$s', 'woocommerce-square' ), '', '' ); } } else { $email_body .= ' ' . esc_html__( 'In order to continue accepting payments, please disconnect and re-connect your site at ', 'woocommerce-square' ) . esc_url( $settings_url ); } return array_merge( $args, array( 'email' => $this, 'email_heading' => $this->heading, 'email_body' => $email_body, 'additional_content' => $this->get_additional_content(), ) ); } }