id = 'emails';
$this->label = esc_html__( 'Emails', 'give' );
$this->default_tab = 'donor-email';
parent::__construct();
$this->enable_save = ! ( Give_Admin_Settings::is_setting_page( 'emails', 'donor-email' ) || Give_Admin_Settings::is_setting_page( 'emails', 'admin-email' ) );
add_action( 'give_admin_field_email_notification', array( $this, 'email_notification_setting' ) );
add_action( 'give_admin_field_give_sendwp_button', [ $this, '_render_give_sendwp_button' ], 10, 3 );
}
/**
* Render give_currency_code_preview field type
*
* @since 2.33.4 added nonce to give_sendwp_remote_install
* @since 2.3.0
* @access public
*
* @param array $field Field Attributes array.
*
* @return void
*/
public function _render_give_sendwp_button( $field, $value ) {
// Connection status partial label based on the state of the SendWP email sending setting (Tools -> SendWP)
$connected = '';
$connected .= __( 'Access your SendWP account', 'give' );
$connected .= '.';
$disconnected = sprintf(
__( 'Note: Email sending is currently disabled. Click here to enable it.', 'give' ),
esc_url( admin_url( '/tools.php?page=sendwp' ) )
);
// Checks if SendWP is connected
$client_connected = function_exists( 'sendwp_client_connected' ) && sendwp_client_connected() ? true : false;
// Checks if email sending is enabled in SendWP
$forwarding_enabled = function_exists( 'sendwp_forwarding_enabled' ) && sendwp_forwarding_enabled() ? true : false;
// Output the appropriate button and label based on connection status
if( $client_connected ) :
?>
>
|
|
|
>
|
|
', '' ); ?>
|
'give_title_email_settings_1',
'type' => 'title',
),
array(
'id' => 'email_template',
'name' => esc_html__( 'Email Template', 'give' ),
'desc' => esc_html__( 'Choose your template from the available registered template types.', 'give' ),
'type' => 'select',
'options' => give_get_email_templates(),
),
array(
'id' => 'email_logo',
'name' => esc_html__( 'Logo', 'give' ),
'desc' => esc_html__( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ),
'type' => 'file',
),
array(
'id' => 'from_name',
'name' => esc_html__( 'From Name', 'give' ),
'desc' => esc_html__( 'The name which appears in the "From" field in all GiveWP donation emails.', 'give' ),
'default' => get_bloginfo( 'name' ),
'type' => 'text',
),
array(
'id' => 'from_email',
'name' => esc_html__( 'From Email', 'give' ),
'desc' => esc_html__( 'Email address from which all GiveWP emails are sent from. This will act as the "from" and "reply-to" email address.', 'give' ),
'default' => get_bloginfo( 'admin_email' ),
'type' => 'text',
),
array(
'id' => 'sendwp',
'name' => esc_html__( 'SendWP', 'give' ),
'desc' => esc_html__( 'We recommend SendWP to ensure quick and reliable delivery of all emails sent from your store, such as donation receipts, recurring donation renewal reminders, password resets, and more.', 'give' ),
'type' => 'give_sendwp_button',
),
array(
'name' => esc_html__( 'Donation Notification Settings Docs Link', 'give' ),
'id' => 'donation_notification_settings_docs_link',
'url' => esc_url( 'http://docs.givewp.com/settings-donation-notification' ),
'title' => __( 'Donation Notification Settings', 'give' ),
'type' => 'give_docs_link',
),
array(
'id' => 'give_title_email_settings_3',
'type' => 'sectionend',
),
);
break;
case 'donor-email':
$settings = array(
// Section 1: Donor Email Notification Listing.
array(
'desc' => __( 'Email notifications sent from GiveWP for donor are listed below. Click on an email to configure it.', 'give' ),
'type' => 'title',
'id' => 'give_donor_email_notification_settings',
'table_html' => false,
),
array(
'type' => 'email_notification',
),
array(
'type' => 'sectionend',
'id' => 'give_donor_email_notification_settings',
),
);
break;
case 'admin-email':
$settings = array(
// Section 1: Admin Email Notification Listing.
array(
'desc' => __( 'Email notifications sent from GiveWP for admin are listed below. Click on an email to configure it.', 'give' ),
'type' => 'title',
'id' => 'give_admin_email_notification_settings',
'table_html' => false,
),
array(
'type' => 'email_notification',
),
array(
'type' => 'sectionend',
'id' => 'give_admin_email_notification_settings',
),
);
break;
case 'contact':
$settings = array(
array(
'id' => 'give_title_general_settings_5',
'type' => 'title',
),
array(
'name' => __( 'Admin Email Address', 'give' ),
'id' => 'contact_admin_email',
'desc' => sprintf( '%1$s {admin_email} %2$s', __( 'By default, the', 'give' ), __( 'tag will use your WordPress admin email. If you would like to customize this address you can do so in the field above.', 'give' ) ),
'type' => 'text',
'default' => give_email_admin_email(),
),
array(
'name' => __( 'Offline Mailing Address', 'give' ),
'id' => 'contact_offline_mailing_address',
'desc' => sprintf( '%1$s {offline_mailing_address} %2$s', __( 'Set the mailing address to where you would like your donors to send their offline donations. This will customize the', 'give' ), __( 'email tag for the Offline Donations payment gateway.', 'give' ) ),
'type' => 'wysiwyg',
'default' => ' ' . get_bloginfo( 'sitename' ) . '
111 Not A Real St.
Anytown, CA 12345
',
),
array(
'id' => 'give_title_general_settings_4',
'type' => 'sectionend',
),
);
break;
}// End switch().
/**
* Filter the emails settings.
* Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
*/
$settings = apply_filters( 'give_settings_emails', $settings );
/**
* Filter the settings.
*
* @since 1.8
*
* @param array $settings
*/
$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
// Output.
return $settings;
}
/**
* Get sections.
*
* @since 1.8
* @return array
*/
public function get_sections() {
$sections = array(
'donor-email' => esc_html__( 'Donor Emails', 'give' ),
'admin-email' => esc_html__( 'Admin Emails', 'give' ),
'email-settings' => esc_html__( 'Email Settings', 'give' ),
'contact' => esc_html__( 'Contact Information', 'give' ),
);
return apply_filters( 'give_get_sections_' . $this->id, $sections );
}
/**
* Render email_notification field type
*
* @since 2.0
* @access public
*/
public function email_notification_setting() {
// Load email notification table.
require_once GIVE_PLUGIN_DIR . 'includes/admin/emails/class-email-notification-table.php';
// Init table.
$email_notifications_table = new Give_Email_Notification_Table();
// Print table.
$email_notifications_table->prepare_items();
$email_notifications_table->display();
}
/**
* Output the settings.
*
* Note: if you want to overwrite this function then manage show/hide save button in your class.
*
* @since 1.8
* @return void
*/
public function output() {
if ( $this->enable_save ) {
$GLOBALS['give_hide_save_button'] = apply_filters( 'give_hide_save_button_on_email_admin_setting_page', false );
}
$settings = $this->get_settings();
Give_Admin_Settings::output_fields( $settings, 'give_settings' );
}
}
endif;
return new Give_Settings_Email();