| 1 |
<?php |
| 2 |
/** |
| 3 |
* Function that creates the Admin Email Customizer menu |
| 4 |
* |
| 5 |
* @since v.2.0 |
| 6 |
* |
| 7 |
* @return void |
| 8 |
*/ |
| 9 |
function wppb_admin_email_customizer_submenu(){ |
| 10 |
$args = array( |
| 11 |
'menu_title' => __( 'Admin Email Customizer', 'profile-builder' ), |
| 12 |
'page_title' => __( 'Admin Email Customizer Settings', 'profile-builder' ), |
| 13 |
'menu_slug' => 'admin-email-customizer', |
| 14 |
'page_type' => 'submenu_page', |
| 15 |
'capability' => 'manage_options', |
| 16 |
'priority' => 10, |
| 17 |
'parent_slug' => 'profile-builder' |
| 18 |
); |
| 19 |
|
| 20 |
new WCK_Page_Creator_PB( $args ); |
| 21 |
} |
| 22 |
add_action( 'admin_menu', 'wppb_admin_email_customizer_submenu', 1 ); |
| 23 |
|
| 24 |
add_action( 'wck_before_meta_boxes', 'wppb_add_tabs_on_top_of_admin_email_page' ); |
| 25 |
function wppb_add_tabs_on_top_of_admin_email_page( $hookname ){ |
| 26 |
if( $hookname == 'profile-builder_page_admin-email-customizer' ){ |
| 27 |
|
| 28 |
if( isset( $_GET['mustache_action'] ) && $_GET['mustache_action'] == 'save' ) { ?> |
| 29 |
<div id="setting-error-settings_updated" class="updated settings-error notice"> |
| 30 |
<p><strong><?php esc_html_e( "Settings saved.", 'profile-builder' ); ?></strong></p> |
| 31 |
</div> |
| 32 |
<?php |
| 33 |
} |
| 34 |
|
| 35 |
wppb_generate_settings_tabs(); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
/* on the init hook add the mustache boxes */ |
| 40 |
add_action( 'init', 'wppb_admin_email_customizer_add_mustache_in_backend', 11 ); |
| 41 |
/** |
| 42 |
* Function that ads the mustache boxes in the backend for admin email customizer |
| 43 |
* |
| 44 |
* @since v.2.0 |
| 45 |
*/ |
| 46 |
function wppb_admin_email_customizer_add_mustache_in_backend(){ |
| 47 |
if( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' ) ) |
| 48 |
require_once( WPPB_PAID_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' ); |
| 49 |
elseif( file_exists( WPPB_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' ) ) |
| 50 |
require_once( WPPB_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' ); |
| 51 |
|
| 52 |
$fields = array( |
| 53 |
array( |
| 54 |
'id' => 'wppb_admin_emailc_common_settings_header', // field id and name |
| 55 |
'type' => 'header', // type of field |
| 56 |
'default' => __( 'These settings are also replicated in the "User Email Customizer" settings-page upon save.', 'profile-builder' ).' '.__( 'Valid tags {{reply_to}} and {{site_name}}', 'profile-builder'), // type of field |
| 57 |
), |
| 58 |
array( |
| 59 |
'label' => __( 'From (name)', 'profile-builder' ), // <label> |
| 60 |
'desc' => '', // description |
| 61 |
'id' => 'wppb_emailc_common_settings_from_name', // field id and name |
| 62 |
'type' => 'text', // type of field |
| 63 |
'default' => '{{site_name}}', // type of field |
| 64 |
'desc' => '', |
| 65 |
), |
| 66 |
array( |
| 67 |
'label' => __( 'From (reply-to email)', 'profile-builder' ), // <label> |
| 68 |
'desc' => '', // description |
| 69 |
'id' => 'wppb_emailc_common_settings_from_reply_to_email', // field id and name |
| 70 |
'type' => 'text', // type of field |
| 71 |
'default' => '{{reply_to}}', // type of field |
| 72 |
'desc' => __( 'Must be a valid email address or the tag {{reply_to}} which defaults to the administrator email', 'profile-builder' ), |
| 73 |
), |
| 74 |
); |
| 75 |
new PB_Mustache_Generate_Admin_Box( 'aec_common_settings', __( 'Common Settings', 'profile-builder' ), 'profile-builder_page_admin-email-customizer', 'core', '', '', $fields ); |
| 76 |
|
| 77 |
|
| 78 |
$registration_default_email_content = __( "<p>New subscriber on {{site_name}}.</p>\n<p>Username:{{username}}</p>\n<p>Email:{{user_email}}</p>\n", 'profile-builder' ); |
| 79 |
$mustache_vars = wppb_email_customizer_generate_merge_tags(); |
| 80 |
|
| 81 |
$fields = array( |
| 82 |
array( |
| 83 |
'label' => __( 'Email Subject', 'profile-builder' ), // <label> |
| 84 |
'desc' => '', // description |
| 85 |
'id' => 'wppb_admin_emailc_default_registration_email_subject', // field id and name |
| 86 |
'type' => 'text', // type of field |
| 87 |
'default' => '[{{site_name}}] '.__( 'A new subscriber has (been) registered!', 'profile-builder' ), // type of field |
| 88 |
), |
| 89 |
array( |
| 90 |
'label' => __( 'Enable email', 'profile-builder' ), // <label> |
| 91 |
'desc' => '', // description |
| 92 |
'id' => 'wppb_admin_emailc_default_registration_email_enabled', // field id and name |
| 93 |
'type' => 'checkbox', // type of field |
| 94 |
'default' => 'on', |
| 95 |
), |
| 96 |
array( // Textarea |
| 97 |
'label' => '', // <label> |
| 98 |
'desc' => '', // description |
| 99 |
'id' => 'wppb_admin_emailc_default_registration_email_content', // field id and name |
| 100 |
'type' => 'textarea', // type of field |
| 101 |
'default' => $registration_default_email_content, // type of field |
| 102 |
) |
| 103 |
); |
| 104 |
|
| 105 |
new PB_Mustache_Generate_Admin_Box( 'aec_default_registration', __( 'Default Registration & Registration with Email Confirmation', 'profile-builder' ), 'profile-builder_page_admin-email-customizer', 'core', $mustache_vars, '', $fields); |
| 106 |
|
| 107 |
if( PROFILE_BUILDER != 'Profile Builder Free' ){ |
| 108 |
$registration_admin_approval_email_content = __( "<p>New subscriber on {{site_name}}.</p>\n<p>Username:{{username}}</p>\n<p>Email:{{user_email}}</p>\n<p>The Admin Approval feature was activated at the time of registration,\nso please remember that you need to approve this user before he/she can log in!</p>", 'profile-builder' ); |
| 109 |
|
| 110 |
$mustache_vars = wppb_email_customizer_generate_merge_tags( 'admin_approval' ); |
| 111 |
|
| 112 |
$fields = array( |
| 113 |
array( |
| 114 |
'label' => __( 'Email Subject', 'profile-builder' ), // <label> |
| 115 |
'desc' => '', // description |
| 116 |
'id' => 'wppb_admin_emailc_registration_with_admin_approval_email_subject', // field id and name |
| 117 |
'type' => 'text', // type of field |
| 118 |
'default' => '[{{site_name}}] A new subscriber has (been) registered!', // type of field |
| 119 |
), |
| 120 |
array( |
| 121 |
'label' => __( 'Enable email', 'profile-builder' ), // <label> |
| 122 |
'desc' => '', // description |
| 123 |
'id' => 'wppb_admin_emailc_registration_with_admin_approval_email_enabled', // field id and name |
| 124 |
'type' => 'checkbox', // type of field |
| 125 |
'default' => 'on', |
| 126 |
), |
| 127 |
array( // Textarea |
| 128 |
'label' => '', // <label> |
| 129 |
'desc' => '', // description |
| 130 |
'id' => 'wppb_admin_emailc_registration_with_admin_approval_email_content', // field id and name |
| 131 |
'type' => 'textarea', // type of field |
| 132 |
'default' => $registration_admin_approval_email_content , // type of field |
| 133 |
) |
| 134 |
); |
| 135 |
|
| 136 |
new PB_Mustache_Generate_Admin_Box( 'aec_reg_with_admin_approval', __( 'Registration with Admin Approval', 'profile-builder' ), 'profile-builder_page_admin-email-customizer', 'core', $mustache_vars, '', $fields ); |
| 137 |
} |
| 138 |
|
| 139 |
$user_password_reset_email_content = __( "<p>{{username}} has requested a password change via the password reset feature.</p>\n", 'profile-builder' ); |
| 140 |
|
| 141 |
$mustache_vars = wppb_email_customizer_generate_merge_tags(); |
| 142 |
|
| 143 |
$fields = array( |
| 144 |
array( |
| 145 |
'label' => __( 'Email Subject', 'profile-builder' ), // <label> |
| 146 |
'desc' => '', // description |
| 147 |
'id' => 'wppb_admin_emailc_user_password_reset_email_subject', // field id and name |
| 148 |
'type' => 'text', // type of field |
| 149 |
'default' => '[{{site_name}}] Password Successfully Reset for {{username}}', // type of field |
| 150 |
), |
| 151 |
array( |
| 152 |
'label' => __( 'Enable email', 'profile-builder' ), // <label> |
| 153 |
'desc' => '', // description |
| 154 |
'id' => 'wppb_admin_emailc_user_password_reset_email_enabled', // field id and name |
| 155 |
'type' => 'checkbox', // type of field |
| 156 |
'default' => 'on', |
| 157 |
), |
| 158 |
array( // Textarea |
| 159 |
'label' => '', // <label> |
| 160 |
'desc' => '', // description |
| 161 |
'id' => 'wppb_admin_emailc_user_password_reset_email_content', // field id and name |
| 162 |
'type' => 'textarea', // type of field |
| 163 |
'default' => $user_password_reset_email_content , // type of field |
| 164 |
) |
| 165 |
); |
| 166 |
|
| 167 |
new PB_Mustache_Generate_Admin_Box( 'aec_user_password_reset', __( 'Admin Notification for User Password Reset', 'profile-builder' ), 'profile-builder_page_admin-email-customizer', 'core', $mustache_vars, '', $fields ); |
| 168 |
|
| 169 |
} |
| 170 |
|