mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- new Email Templates logic with save template to Theme(Child Theme);
- small fixes;
This commit is contained in:
@@ -1,99 +0,0 @@
|
||||
<?php
|
||||
|
||||
class UM_ADDON_bp_avatar_transfer {
|
||||
|
||||
function __construct() {
|
||||
|
||||
add_action('admin_menu', array(&$this, 'admin_menu'), 1001);
|
||||
|
||||
add_action('admin_init', array(&$this, 'admin_init'), 1);
|
||||
|
||||
add_action('um_admin_addon_hook', array(&$this, 'um_admin_addon_hook') );
|
||||
|
||||
}
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
global $ultimatemember;
|
||||
$this->addon = $ultimatemember->addons['bp_avatar_transfer'];
|
||||
add_submenu_page('ultimatemember', $this->addon[0], $this->addon[0], 'manage_options', 'bp_avatar_transfer', array(&$this, 'content') );
|
||||
|
||||
}
|
||||
|
||||
function um_admin_addon_hook( $hook ) {
|
||||
global $ultimatemember;
|
||||
switch( $hook ) {
|
||||
case 'bp_avatar_transfer':
|
||||
if ( class_exists('BuddyPress') ) {
|
||||
|
||||
$path = bp_core_avatar_upload_path() . '/avatars';
|
||||
|
||||
$files = glob( $path . '/*');
|
||||
$i = 0;
|
||||
foreach( $files as $key ) {
|
||||
$q = (count(glob("$key/*")) === 0) ? 0 : 1;
|
||||
if ( $q == 1 ) {
|
||||
$photo = glob( $key . '/*');
|
||||
foreach( $photo as $file ) {
|
||||
if ( strstr( $file, 'bpfull' ) ) {
|
||||
$get_user_id = explode('/', $file);
|
||||
array_pop($get_user_id);
|
||||
$user_id = end($get_user_id);
|
||||
if ( !file_exists( $ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg' ) ) {
|
||||
$ultimatemember->files->new_user( $user_id );
|
||||
copy( $file, $ultimatemember->files->upload_basedir . $user_id . '/profile_photo.jpg' );
|
||||
update_user_meta($user_id, 'profile_photo', 'profile_photo.jpg');
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->content = '<p><strong>Done. Process completed!</p>';
|
||||
$this->content .= $i . ' user(s) changed.</strong></p>';
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function admin_init() {
|
||||
if ( isset( $_REQUEST['um-addon-hook'] ) ) {
|
||||
$hook = $_REQUEST['um-addon-hook'];
|
||||
do_action("um_admin_addon_hook", $hook);
|
||||
}
|
||||
}
|
||||
|
||||
function content() {
|
||||
|
||||
$this->process_link = add_query_arg('um-addon-hook','bp_avatar_transfer');
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<h2>Ultimate Member <sup style="font-size:15px"><?php echo ultimatemember_version; ?></sup></h2>
|
||||
|
||||
<h3><?php echo $this->addon[0]; ?></h3>
|
||||
|
||||
<?php if ( isset( $this->content ) ) {
|
||||
echo $this->content;
|
||||
} else { ?>
|
||||
|
||||
<p>This tool allows you to move all custom user photos/avatars from BuddyPress to Ultimate Member platform. This can help you If you are switching from BuddyPress.</p>
|
||||
<p>Depending on your users database, this could take a few moments. To start the process, click the following button.</p>
|
||||
|
||||
<p><a href="<?php echo $this->process_link; ?>" class="button button-primary">Start transferring avatars</a></p>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div><div class="clear"></div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$UM_ADDON_bp_avatar_transfer = new UM_ADDON_bp_avatar_transfer();
|
||||
@@ -1,260 +0,0 @@
|
||||
<?php
|
||||
|
||||
class UM_ADDON_generate_random_users {
|
||||
|
||||
function __construct() {
|
||||
|
||||
add_action('admin_menu', array(&$this, 'admin_menu'), 1001);
|
||||
|
||||
add_action('admin_init', array(&$this, 'admin_init'), 1);
|
||||
|
||||
add_action('um_admin_addon_hook', array(&$this, 'um_admin_addon_hook') );
|
||||
|
||||
}
|
||||
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
global $ultimatemember;
|
||||
$this->addon = $ultimatemember->addons['generate_random_users'];
|
||||
add_submenu_page('ultimatemember', $this->addon[0], $this->addon[0], 'manage_options', 'generate_random_users', array(&$this, 'content') );
|
||||
|
||||
}
|
||||
|
||||
function um_admin_addon_hook( $hook ) {
|
||||
switch ( $hook ) {
|
||||
case 'generate_random_users':
|
||||
$json_url = "https://randomuser.me/api/";
|
||||
|
||||
$arr_post_header = array( );
|
||||
|
||||
if( isset( $_GET['gender'] ) ){
|
||||
$gender = $_GET['gender'];
|
||||
if( $gender != 'both' ){
|
||||
$json_url = add_query_arg('gender', $gender, $json_url );
|
||||
$arr_post_header['gender'] = $gender;
|
||||
}
|
||||
}
|
||||
|
||||
if( isset( $_GET['nationality'] ) ){
|
||||
$nationality = implode(",", $_GET['nationality']);
|
||||
if( ! empty( $nationality ) ){
|
||||
$json_url = add_query_arg('nat', $nationality, $json_url );
|
||||
}
|
||||
$arr_post_header['nat'] = $nationality;
|
||||
}
|
||||
|
||||
if( isset( $_GET['total_users'] ) ){
|
||||
$total_users = intval( $_GET['total_users'] );
|
||||
$json_url = add_query_arg('results', $total_users, $json_url );
|
||||
$arr_post_header['results'] = $total_users;
|
||||
}
|
||||
|
||||
|
||||
$response = wp_remote_get( $json_url, array('timeout' => 120 ) );
|
||||
$json = '';
|
||||
|
||||
if( is_array($response) ) {
|
||||
if( isset( $response['body'] ) && ! empty( $response['body'] ) ){
|
||||
$json = json_decode( $response['body'] );
|
||||
}
|
||||
}
|
||||
|
||||
if( is_wp_error( $response ) ){
|
||||
wp_die( $response->get_error_message() );
|
||||
}
|
||||
|
||||
if( ! empty( $json ) ){
|
||||
|
||||
remove_action('um_after_new_user_register', 'um_after_new_user_register', 10, 2);
|
||||
|
||||
$failed_dummies = 0;
|
||||
//$default_role = um_get_option("default_role");
|
||||
$default_role = get_option( "default_role", true );
|
||||
|
||||
foreach( $json->results as $dummy ){
|
||||
|
||||
if( isset( $_GET['password'] ) && ! empty( $_GET['password'] ) ){
|
||||
$password = $_GET['password'];
|
||||
}else{
|
||||
$password = wp_generate_password( 8, false );
|
||||
}
|
||||
|
||||
$site_url = @$_SERVER['SERVER_NAME'];
|
||||
$random_generate = wp_generate_password( 4, false );
|
||||
|
||||
if( username_exists( $dummy->login->username ) ){
|
||||
$dummy->login->username = $dummy->login->username.'_'. $random_generate;
|
||||
}
|
||||
|
||||
$dummy->login->email = $dummy->login->username."_dummy@{$site_url}";
|
||||
|
||||
if( email_exists( $dummy->login->email ) ){
|
||||
$dummy->login->email = $dummy->login->username."_dummy_{$random_generate}@{$site_url}";
|
||||
}
|
||||
|
||||
$userdata = array(
|
||||
'display_name' => ucfirst( $dummy->name->first )." ".ucfirst( $dummy->name->last ),
|
||||
'first_name' => ucfirst( $dummy->name->first ),
|
||||
'last_name' => ucfirst( $dummy->name->last ),
|
||||
'user_email' => $dummy->login->email,
|
||||
'user_login' => $dummy->login->username,
|
||||
'user_pass' => $password,
|
||||
);
|
||||
|
||||
$user_id = wp_insert_user( $userdata );
|
||||
|
||||
if( is_wp_error( $user_id ) ){
|
||||
$failed_dummies++;
|
||||
}
|
||||
|
||||
$usermeta = array(
|
||||
'synced_profile_photo' => $dummy->picture->large,
|
||||
'gender' => ucfirst($dummy->gender),
|
||||
'birth_date' => date("Y/m/d", strtotime( $dummy->dob) ),
|
||||
'_um_last_login' => date("Y/m/d", strtotime( $dummy->registered ) ),
|
||||
'mobile_number' => $dummy->cell,
|
||||
'phone_number' => $dummy->phone,
|
||||
'synced_gravatar_hashed_id' => md5( strtolower( trim( $dummy->email ) ) ),
|
||||
'account_status' => 'approved',
|
||||
'_um_profile_dummy' => true,
|
||||
'role' => isset( $default_role ) ? $default_role: 'subscriber'
|
||||
);
|
||||
|
||||
if( isset( $_GET['add_cover_photo'] ) && $_GET['add_cover_photo'] == 1 ){
|
||||
|
||||
$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
|
||||
$color = $rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];
|
||||
|
||||
$usermeta['synced_cover_photo'] = 'http://placehold.it/650x350/'.$color.'/'.$color;
|
||||
|
||||
}
|
||||
|
||||
foreach ( $usermeta as $key => $value ) {
|
||||
update_user_meta( $user_id, $key, $value );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
wp_redirect( admin_url("admin.php?page=generate_random_users") ); exit;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'remove_random_users':
|
||||
|
||||
$dummies = new WP_User_Query(
|
||||
array(
|
||||
'fields' => array('ID'),
|
||||
'meta_key' => '_um_profile_dummy',
|
||||
'meta_value' => true,
|
||||
'meta_compare' => '='
|
||||
)
|
||||
);
|
||||
|
||||
if( $dummies->total_users > 0 ){
|
||||
foreach ( $dummies->get_results() as $dummy ) {
|
||||
|
||||
if( isset( $dummy->ID ) ){
|
||||
wp_delete_user( $dummy->ID );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
delete_option('um_generated_dumies');
|
||||
wp_redirect( admin_url("admin.php?page=generate_random_users") );
|
||||
exit;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function admin_init() {
|
||||
if ( isset( $_REQUEST['um-addon-hook'] ) ) {
|
||||
$hook = $_REQUEST['um-addon-hook'];
|
||||
do_action("um_admin_addon_hook", $hook );
|
||||
}
|
||||
}
|
||||
|
||||
function content() {
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<h2>Ultimate Member <sup style="font-size:15px"><?php echo ultimatemember_version; ?></sup></h2>
|
||||
|
||||
<h3><?php echo $this->addon[0]; ?></h3>
|
||||
|
||||
<?php if ( isset( $this->content ) ) {
|
||||
echo $this->content;
|
||||
} else { ?>
|
||||
|
||||
<p>This tool allows you to add dummies as Ultimate Member users. </p>
|
||||
<?php
|
||||
$dummies = new WP_User_Query(
|
||||
array(
|
||||
'fields' => array('ID'),
|
||||
'meta_key' => '_um_profile_dummy',
|
||||
'meta_value' => true,
|
||||
'meta_compare' => '='
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?php if( $dummies->total_users > 0 ): ?>
|
||||
<form method="get">
|
||||
<p>
|
||||
<input type="submit" class="button button-secondary" value="Remove Generated Dummies (<?php echo $dummies->total_users;?>)"/>
|
||||
<input type="hidden" name="um-addon-hook" value="remove_random_users"/>
|
||||
<input type="hidden" name="page" value="generate_random_users"/>
|
||||
</form>
|
||||
<br/>
|
||||
<?php endif; ?>
|
||||
<form method="get">
|
||||
<label for="total_users">How many dummies? <br/><input type="text" name="total_users" value="30" /> <br/><br/>
|
||||
<label for="gender">Gender:</label> <br/>
|
||||
<label><input type='radio' name="gender" value="male"/> Male</label> <br/>
|
||||
<label><input type='radio' name="gender" value="female"/> Female</label> <br/>
|
||||
<label><input type='radio' checked="checked" name="gender" value="both"/> Both</label>
|
||||
<br/><br/>
|
||||
<label for="nationality">Available Nationalities:</label><br/>
|
||||
<select style="width:150px" name="nationality[]" multiple>
|
||||
<?php
|
||||
$nationality = array( 'AU', 'BR', 'CA', 'CH', 'DE', 'DK', 'ES', 'FI', 'FR', 'GB', 'IE', 'IR', 'NL', 'NZ', 'TR', 'US' );
|
||||
foreach ($nationality as $code ) {
|
||||
$value = strtolower($code);
|
||||
echo "<option value='".$value."'/> ".$code."</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br/><br/>
|
||||
<label for="add_cover_photo"><input type="checkbox" name="add_cover_photo" value="1" />
|
||||
Add cover photos?</label>
|
||||
<br/><small>Generates random colored cover photos</small>
|
||||
<br/><br/>
|
||||
<label for="password">
|
||||
Account Passwords:
|
||||
<input type="password" name="password" />
|
||||
<br/><small>if you leave this blank, it will generate random strings password</small>
|
||||
</label>
|
||||
<br/>
|
||||
<input type="submit" class="button button-primary" value="Start Generating Dummies"/>
|
||||
<input type="hidden" name="um-addon-hook" value="generate_random_users"/>
|
||||
|
||||
<?php } ?>
|
||||
</form>
|
||||
|
||||
</div><div class="clear"></div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$UM_ADDON_generate_random_users = new UM_ADDON_generate_random_users ();
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
class UM_ADDON_gravatar_transfer {
|
||||
|
||||
function __construct() {
|
||||
|
||||
add_action('admin_menu', array(&$this, 'admin_menu'), 1001);
|
||||
|
||||
add_action('admin_init', array(&$this, 'admin_init'), 1);
|
||||
|
||||
add_action('um_admin_addon_hook', array(&$this, 'um_admin_addon_hook') );
|
||||
|
||||
}
|
||||
|
||||
function gravatar_hash(){
|
||||
global $wpdb;
|
||||
$wpdb->query('DELETE FROM '.$wpdb->usermeta.' WHERE meta_key = "synced_gravatar_hashed_id" ');
|
||||
|
||||
$wpdb->query('INSERT INTO '.$wpdb->usermeta.'(user_id, meta_key, meta_value)
|
||||
SELECT ID, "synced_gravatar_hashed_id", MD5( LOWER( TRIM(user_email) ) ) FROM '.$wpdb->users.' ');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function admin_menu() {
|
||||
|
||||
global $ultimatemember;
|
||||
$this->addon = $ultimatemember->addons['gravatar_transfer'];
|
||||
add_submenu_page('ultimatemember', $this->addon[0], $this->addon[0], 'manage_options', 'gravatar_transfer', array(&$this, 'content') );
|
||||
|
||||
}
|
||||
|
||||
function um_admin_addon_hook( $hook ) {
|
||||
switch( $hook ) {
|
||||
case 'gravatar_transfer':
|
||||
if( $this->gravatar_hash() ){
|
||||
$this->content = '<p><strong>Done. Process completed!</p>';
|
||||
$result = count_users();
|
||||
$this->content .= $result['total_users'] . ' user(s) changed.</strong></p>';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function admin_init() {
|
||||
if ( isset( $_REQUEST['um-addon-hook'] ) ) {
|
||||
$hook = $_REQUEST['um-addon-hook'];
|
||||
do_action("um_admin_addon_hook", $hook);
|
||||
}
|
||||
}
|
||||
|
||||
function content() {
|
||||
|
||||
$this->process_link = add_query_arg('um-addon-hook','gravatar_transfer');
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<h2>Ultimate Member <sup style="font-size:15px"><?php echo ultimatemember_version; ?></sup></h2>
|
||||
|
||||
<h3><?php echo $this->addon[0]; ?></h3>
|
||||
|
||||
<?php if ( isset( $this->content ) ) {
|
||||
echo $this->content;
|
||||
} else { ?>
|
||||
|
||||
<p>This tool allows you to add gravatars to Ultimate Member users. This can help you to link gravatar photos to user accounts with their email address.</p>
|
||||
<p>Depending on your users database, this could take a few moments. To start the process, click the following button.</p>
|
||||
|
||||
<p><a href="<?php echo $this->process_link; ?>" class="button button-primary">Start adding gravatars</a></p>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div><div class="clear"></div>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$UM_ADDON_gravatar_transfer = new UM_ADDON_gravatar_transfer();
|
||||
@@ -139,6 +139,21 @@ textarea.um-forms-field.um-small-field {
|
||||
.um-form-table.um-third-column .um-forms-line th,
|
||||
.um-form-table.um-half-column .um-forms-line th,
|
||||
.um-form-table.um-two-thirds-column .um-forms-line th {
|
||||
float:left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.um-form-table.um-third-column .um-forms-line td,
|
||||
.um-form-table.um-half-column .um-forms-line td,
|
||||
.um-form-table.um-two-thirds-column .um-forms-line td {
|
||||
float:left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.um-form-table.um-third-column .um-forms-line th label,
|
||||
.um-form-table.um-half-column .um-forms-line th label,
|
||||
.um-form-table.um-two-thirds-column .um-forms-line th label {
|
||||
float:left;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,3 +214,36 @@ th.column-email.column-primary {
|
||||
width:50%;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
.email_template_wrapper .copy_button_overlay {
|
||||
position:absolute;
|
||||
top:0;
|
||||
bottom:0;
|
||||
width:calc( 100% - 30px );
|
||||
z-index: 2;
|
||||
background: rgba( 241, 241, 241, 0.95 );
|
||||
text-align: center;
|
||||
padding-top: 30%;
|
||||
padding-right: 20px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.email_template_wrapper .copy_button_overlay > span {
|
||||
color: #444;
|
||||
margin: 0 0 15px 0;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.email_template_wrapper.in_theme .copy_button_overlay {
|
||||
display: none !important;
|
||||
}
|
||||
*/
|
||||
|
||||
.email_template_wrapper .reset_email_template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.email_template_wrapper.in_theme .reset_email_template {
|
||||
display: block;
|
||||
}
|
||||
@@ -1,4 +1,42 @@
|
||||
jQuery( document ).ready( function() {
|
||||
/**
|
||||
* Email templates
|
||||
*/
|
||||
/*jQuery( 'body' ).on( 'click', '.copy_email_template', function() {
|
||||
var obj = jQuery(this);
|
||||
|
||||
jQuery.ajax({
|
||||
url: php_data.copy_email_template,
|
||||
type: 'POST',
|
||||
data: { email_key : obj.parents('.email_template_wrapper').data('key') },
|
||||
success: function(data){
|
||||
obj.parents('.email_template_wrapper').addClass('in_theme');
|
||||
},
|
||||
error: function(data){
|
||||
alert('Something went wrong');
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
jQuery( 'body' ).on( 'click', '.reset_email_template', function() {
|
||||
var obj = jQuery(this);
|
||||
|
||||
jQuery.ajax({
|
||||
url: php_data.delete_email_template,
|
||||
type: 'POST',
|
||||
data: { email_key : obj.parents('.email_template_wrapper').data('key') },
|
||||
success: function(data){
|
||||
obj.parents('.email_template_wrapper').removeClass('in_theme');
|
||||
},
|
||||
error: function(data){
|
||||
alert('Something went wrong');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Licenses
|
||||
*/
|
||||
|
||||
@@ -169,6 +169,7 @@ if ( ! class_exists( 'Admin_Enqueue' ) ) {
|
||||
wp_enqueue_script( 'um_admin_settings' );
|
||||
|
||||
$localize_data = array(
|
||||
'delete_email_template' => UM()->get_ajax_route( 'um\core\Mail', 'delete_email_template' ),
|
||||
'onbeforeunload_text' => __( 'Are sure, maybe some settings not saved', 'ultimate-member' ),
|
||||
'texts' => array(
|
||||
'remove' => __( 'Remove', 'ultimate-member' ),
|
||||
|
||||
@@ -888,5 +888,58 @@ if ( ! class_exists( 'Admin_Forms' ) ) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
function render_email_template( $field_data ) {
|
||||
if ( empty( $field_data['id'] ) )
|
||||
return false;
|
||||
|
||||
$id = ( ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] : '' ) . '_' . $field_data['id'];
|
||||
|
||||
$class = ! empty( $field_data['class'] ) ? $field_data['class'] : '';
|
||||
$class .= ! empty( $field_data['size'] ) ? $field_data['size'] : 'um-long-field';
|
||||
|
||||
$data = array(
|
||||
'field_id' => $field_data['id']
|
||||
);
|
||||
|
||||
$data_attr = '';
|
||||
foreach ( $data as $key => $value ) {
|
||||
$data_attr .= " data-{$key}=\"{$value}\" ";
|
||||
}
|
||||
|
||||
$name = $field_data['id'];
|
||||
$name = ! empty( $this->form_data['prefix_id'] ) ? $this->form_data['prefix_id'] . '[' . $name . ']' : $name;
|
||||
|
||||
$default = isset( $field_data['default'] ) ? $field_data['default'] : '';
|
||||
$value = isset( $field_data['value'] ) ? $field_data['value'] : $default;
|
||||
|
||||
ob_start(); ?>
|
||||
|
||||
<div class="email_template_wrapper <?php echo $field_data['in_theme'] ? 'in_theme' : '' ?>" data-key="<?php echo $field_data['id'] ?>" style="position: relative;">
|
||||
<!-- <input type="button" class="reset_email_template button" value="--><?php //_e( 'Reset Template to Default', 'ultimate-member' ) ?><!--" />-->
|
||||
<!--<div class="copy_button_overlay">
|
||||
<span><?php /*_e( 'Currently UM use default Email Template, you can edit this template after then you copy in to theme', 'ultimate-member' ) */?></span>
|
||||
<input type="button" class="copy_email_template button" value="<?php /*_e( 'Copy Template to Theme', 'ultimate-member' ) */?>" />
|
||||
</div>-->
|
||||
|
||||
<?php wp_editor( $value,
|
||||
$id,
|
||||
array(
|
||||
'textarea_name' => $name,
|
||||
'textarea_rows' => 20,
|
||||
'editor_height' => 425,
|
||||
'wpautop' => false,
|
||||
'media_buttons' => false,
|
||||
'editor_class' => $class
|
||||
)
|
||||
); ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php $html = ob_get_clean();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,9 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
|
||||
add_action( 'um_settings_save', array( $this, 'on_settings_save' ) );
|
||||
|
||||
|
||||
add_filter( 'um_change_settings_before_save', array( $this, 'save_email_templates' ) );
|
||||
|
||||
|
||||
//save licenses options
|
||||
add_action( 'um_settings_before_save', array( $this, 'before_licenses_save' ) );
|
||||
add_action( 'um_settings_save', array( $this, 'licenses_save' ) );
|
||||
@@ -1466,7 +1469,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
|
||||
foreach ( $_POST['um_options'] as $key => $value ) {
|
||||
$edd_action = '';
|
||||
$license_key = '';
|
||||
if ( empty( $this->previous_licenses[$key] ) && ! empty( $value ) ) {
|
||||
if ( empty( $this->previous_licenses[$key] ) && ! empty( $value ) || ( ! empty( $this->previous_licenses[$key] ) && ! empty( $value ) && $this->previous_licenses[$key] != $value ) ) {
|
||||
$edd_action = 'activate_license';
|
||||
$license_key = $value;
|
||||
} elseif ( ! empty( $this->previous_licenses[$key] ) && empty( $value ) ) {
|
||||
@@ -1567,7 +1570,14 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
|
||||
if ( empty( $email_key ) || empty( $emails[$email_key] ) )
|
||||
return $section;
|
||||
|
||||
$in_theme = UM()->mail()->template_in_theme( $email_key );
|
||||
|
||||
$section_fields = array(
|
||||
array(
|
||||
'id' => 'um_email_template',
|
||||
'type' => 'hidden',
|
||||
'value' => $email_key,
|
||||
),
|
||||
array(
|
||||
'id' => $email_key . '_on',
|
||||
'type' => 'checkbox',
|
||||
@@ -1587,12 +1597,13 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
|
||||
),
|
||||
array(
|
||||
'id' => $email_key,
|
||||
'type' => 'wp_editor',
|
||||
'type' => 'email_template',
|
||||
'label' => __( 'Message Body','ultimate-member' ),
|
||||
'conditional' => array( $email_key . '_on', '=', 1 ),
|
||||
'tooltip' => __('This is the content of the e-mail','ultimate-member'),
|
||||
'value' => UM()->um_get_option( $email_key ),
|
||||
'value' => UM()->mail()->get_email_template( $email_key ),
|
||||
'default' => UM()->um_get_default( $email_key ),
|
||||
'in_theme' => $in_theme
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2267,168 +2278,31 @@ Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ?
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render HTML for settings field
|
||||
*
|
||||
* @param $data
|
||||
* @return string
|
||||
*/
|
||||
function render_setting_field( $data ) {
|
||||
if ( empty( $data['type'] ) )
|
||||
return '';
|
||||
function save_email_templates( $settings ) {
|
||||
|
||||
$conditional = ! empty( $data['conditional'] ) ? 'data-conditional="' . esc_attr( json_encode( $data['conditional'] ) ) . '"' : '';
|
||||
if ( empty( $settings['um_email_template'] ) )
|
||||
return $settings;
|
||||
|
||||
$html = '';
|
||||
if ( $data['type'] != 'hidden' )
|
||||
$html .= '<tr class="um-settings-line" ' . $conditional . '><th><label for="um_options_' . $data['id'] . '">' . $data['label'] . '</label></th><td>';
|
||||
$template = $settings['um_email_template'];
|
||||
$content = stripslashes( $settings[$template] );
|
||||
|
||||
$theme_template_path = UM()->mail()->get_template_file( 'theme', $template );
|
||||
|
||||
$option_value = UM()->um_get_option( $data['id'] );
|
||||
$default = ! empty( $data['default'] ) ? $data['default'] : UM()->um_get_default( $data['id'] );
|
||||
|
||||
switch ( $data['type'] ) {
|
||||
case 'hidden':
|
||||
$value = ! empty( $option_value ) ? $option_value : $default;
|
||||
|
||||
if ( empty( $data['is_option'] ) )
|
||||
$html .= '<input type="hidden" id="' . $data['id'] . '" name="' . $data['id'] . '" value="' . $value . '" />';
|
||||
else
|
||||
$html .= '<input type="hidden" id="um_options_' . $data['id'] . '" name="um_options[' . $data['id'] . ']" value="' . $value . '" class="um-option-field" data-field_id="' . $data['id'] . '" />';
|
||||
|
||||
break;
|
||||
case 'text':
|
||||
$value = ! empty( $option_value ) ? $option_value : $default;
|
||||
$field_length = ! empty( $data['size'] ) ? $data['size'] : 'um-long-field';
|
||||
|
||||
$html .= '<input type="text" id="um_options_' . $data['id'] . '" name="um_options[' . $data['id'] . ']" value="' . $value . '" class="um-option-field ' . $field_length . '" data-field_id="' . $data['id'] . '" />';
|
||||
break;
|
||||
case 'multi-text':
|
||||
$values = ! empty( $option_value ) ? $option_value : $default;
|
||||
|
||||
$html .= '<ul class="um-multi-text-list" data-field_id="' . $data['id'] . '">';
|
||||
|
||||
if ( ! empty( $values ) ) {
|
||||
foreach ( $values as $k=>$value ) {
|
||||
$html .= '<li class="um-multi-text-option-line"><input type="text" id="um_options_' . $data['id'] . '-' . $k . '" name="um_options[' . $data['id'] . '][]" value="' . $value . '" class="um-option-field" data-field_id="' . $data['id'] . '" />
|
||||
<a href="javascript:void(0);" class="um-option-delete">' . __( 'Remove', 'ultimate-member' ) . '</a></li>';
|
||||
}
|
||||
$in_theme = UM()->mail()->template_in_theme( $template );
|
||||
if ( ! $in_theme ) {
|
||||
UM()->mail()->copy_email_template( $template );
|
||||
}
|
||||
|
||||
$html .= '</ul><a href="javascript:void(0);" class="button button-primary um-multi-text-add-option" data-name="um_options[' . $data['id'] . '][]">' . $data['add_text'] . '</a>';
|
||||
break;
|
||||
case 'textarea':
|
||||
$value = ! empty( $option_value ) ? $option_value : $default;
|
||||
$field_length = ! empty( $data['size'] ) ? $data['size'] : 'um-long-field';
|
||||
$fp = fopen( $theme_template_path, "w" );
|
||||
$result = fputs( $fp, $content );
|
||||
fclose( $fp );
|
||||
|
||||
$html .= '<textarea id="um_options_' . $data['id'] . '" name="um_options[' . $data['id'] . ']" rows="6" class="um-option-field ' . $field_length . '" data-field_id="' . $data['id'] . '">' . $value . '</textarea>';
|
||||
break;
|
||||
case 'wp_editor':
|
||||
$value = ! empty( $option_value ) ? $option_value : $default;
|
||||
|
||||
ob_start();
|
||||
wp_editor( $value,
|
||||
'um_options_' . $data['id'],
|
||||
array(
|
||||
'textarea_name' => 'um_options[' . $data['id'] . ']',
|
||||
'textarea_rows' => 20,
|
||||
'editor_height' => 425,
|
||||
'wpautop' => false,
|
||||
'media_buttons' => false,
|
||||
'editor_class' => 'um-option-field'
|
||||
)
|
||||
);
|
||||
|
||||
$html .= ob_get_clean();
|
||||
break;
|
||||
case 'checkbox':
|
||||
$value = ( '' !== $option_value ) ? $option_value : $default;
|
||||
|
||||
$html .= '<input type="hidden" id="um_options_' . $data['id'] . '_hidden" name="um_options[' . $data['id'] . ']" value="0" /><input type="checkbox" ' . checked( $value, true, false ) . ' id="um_options_' . $data['id'] . '" name="um_options[' . $data['id'] . ']" value="1" class="um-option-field" data-field_id="' . $data['id'] . '" />';
|
||||
break;
|
||||
case 'multi-checkbox':
|
||||
$value = ( '' !== $option_value ) ? $option_value : $default;
|
||||
$columns = ! empty( $data['columns'] ) ? $data['columns'] : 1;
|
||||
|
||||
$per_column = ceil( count( $data['options'] ) / $columns );
|
||||
|
||||
$html .= '<div class="multi-checkbox-line">';
|
||||
|
||||
$current_option = 1;
|
||||
$iter = 1;
|
||||
foreach ( $data['options'] as $key=>$option ) {
|
||||
if ( $current_option == 1 )
|
||||
$html .= '<div class="multi-checkbox-column" style="width:' . floor( 100/$columns ) . '%;">';
|
||||
|
||||
$html .= '<input type="hidden" id="um_options_' . $data['id'] . '_' . $key . '_hidden" name="um_options[' . $data['id'] . '][' . $key . ']" value="0" />
|
||||
<label><input type="checkbox" ' . checked( $value[$key], true, false ) . ' id="um_options_' . $data['id'] . '" name="um_options[' . $data['id'] . '][' . $key . ']" value="1" class="um-option-field" data-field_id="' . $data['id'] . '" />' . $option . '</label>';
|
||||
|
||||
if ( $current_option == $per_column || $iter == count( $data['options'] ) ) {
|
||||
$current_option = 1;
|
||||
$html .= '</div>';
|
||||
} else {
|
||||
$current_option++;
|
||||
if ( $result !== false ) {
|
||||
unset( $settings['um_email_template'] );
|
||||
unset( $settings[$template] );
|
||||
}
|
||||
|
||||
$iter++;
|
||||
return $settings;
|
||||
}
|
||||
|
||||
$html .= '</div>';
|
||||
|
||||
break;
|
||||
case 'selectbox':
|
||||
$value = ! empty( $option_value ) ? $option_value : $default;
|
||||
|
||||
$html .= '<select ' . ( ! empty( $data['multi'] ) ? 'multiple' : '' ) . ' id="um_options_' . $data['id'] . '" name="um_options[' . $data['id'] . ']' . ( ! empty( $data['multi'] ) ? '[]' : '' ) . '" class="um-option-field" data-field_id="' . $data['id'] . '">';
|
||||
foreach ( $data['options'] as $key=>$option ) {
|
||||
if ( ! empty( $data['multi'] ) ) {
|
||||
$html .= '<option value="' . $key . '" ' . selected( in_array( $key, $value ), true, false ) . '>' . $option . '</option>';
|
||||
} else {
|
||||
$html .= '<option value="' . $key . '" ' . selected( $key == $value, true, false ) . '>' . $option . '</option>';
|
||||
}
|
||||
}
|
||||
$html .= '</select>';
|
||||
|
||||
break;
|
||||
case 'media':
|
||||
$upload_frame_title = ! empty( $data['upload_frame_title'] ) ? $data['upload_frame_title'] : __( 'Select media', 'ultimate-member' );
|
||||
$value = ! empty( $option_value ) ? $option_value : $default;
|
||||
|
||||
$image_id = ! empty( $value['id'] ) ? $value['id'] : '';
|
||||
$image_width = ! empty( $value['width'] ) ? $value['width'] : '';
|
||||
$image_height = ! empty( $value['height'] ) ? $value['height'] : '';
|
||||
$image_thumbnail = ! empty( $value['thumbnail'] ) ? $value['thumbnail'] : '';
|
||||
$image_url = ! empty( $value['url'] ) ? $value['url'] : '';
|
||||
|
||||
$data_default = ! empty( $default ) ? 'data-default="' . esc_attr( $default['url'] ) .'"' : '';
|
||||
|
||||
$html .= '<div class="um-media-upload">' .
|
||||
'<input type="hidden" class="um-media-upload-data-id" name="um_options[' . $data['id'] . '][id]" id="um_options_' . $data['id'] . '_id" value="' . $image_id . '">' .
|
||||
'<input type="hidden" class="um-media-upload-data-width" name="um_options[' . $data['id'] . '][width]" id="um_options_' . $data['id'] . '_width" value="' . $image_width . '">' .
|
||||
'<input type="hidden" class="um-media-upload-data-height" name="um_options[' . $data['id'] . '][height]" id="um_options_' . $data['id'] . '_height" value="' . $image_height . '">' .
|
||||
'<input type="hidden" class="um-media-upload-data-thumbnail" name="um_options[' . $data['id'] . '][thumbnail]" id="um_options_' . $data['id'] . '_thumbnail" value="' . $image_thumbnail . '">' .
|
||||
'<input type="hidden" class="um-option-field um-media-upload-data-url" name="um_options[' . $data['id'] . '][url]" id="um_options_' . $data['id'] . '_url" value="' . $image_url . '" data-field_id="' . $data['id'] . '" ' . $data_default . '>';
|
||||
|
||||
if ( ! isset( $data['preview'] ) || $data['preview'] !== false ) {
|
||||
$html .= '<img src="' . ( ! empty( $value['url'] ) ? $value['url'] : '' ) . '" alt="" class="icon_preview"><div style="clear:both;"></div>';
|
||||
}
|
||||
|
||||
if ( ! empty( $data['url'] ) ) {
|
||||
$html .= '<input type="text" class="um-media-upload-url" readonly value="' . $image_url . '" /><div style="clear:both;"></div>';
|
||||
}
|
||||
|
||||
$html .= '<input type="button" class="um-set-image button button-primary" value="' . __( 'Select', 'ultimate-member' ) . '" data-upload_frame="' . $upload_frame_title . '" />
|
||||
<input type="button" class="um-clear-image button" value="' . __( 'Clear', 'ultimate-member' ) . '" /></div>';
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! empty( $data['description'] ) )
|
||||
$html .= '<div class="description">' . $data['description'] . '</div>';
|
||||
|
||||
$html .= '</td></tr>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -910,7 +910,7 @@ um_remove_option( 'profile_header_icon_hcolor' );
|
||||
//remove duplicates for UM Pages settings
|
||||
delete_option( 'um_core_pages' );
|
||||
|
||||
|
||||
global $wpdb;
|
||||
|
||||
//UM Roles to WP Roles
|
||||
//all UM Roles from post type
|
||||
@@ -1109,6 +1109,9 @@ foreach ( $all_taxonomies as $key => $taxonomy ) {
|
||||
|
||||
|
||||
//for metadata for all UM forms
|
||||
//"use_global" meta change to "_use_custom_settings"
|
||||
|
||||
//also update for forms metadata where "member" or "admin"
|
||||
$forms = get_posts( array(
|
||||
'post_type' => 'um_form',
|
||||
'numberposts' => -1,
|
||||
@@ -1124,5 +1127,10 @@ foreach ( $forms as $form_id ) {
|
||||
|
||||
update_post_meta( $form_id, "_um_{$form_type}_use_custom_settings", $use_custom_settings );
|
||||
delete_post_meta( $form_id, "_um_{$form_type}_use_globals" );
|
||||
|
||||
$role = get_post_meta( $form_id, "_um_{$form_type}_role", true );
|
||||
if ( $role ) {
|
||||
update_post_meta( $form_id, "_um_{$form_type}_role", 'um_' . $role );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@
|
||||
'type' => 'textarea',
|
||||
'name' => '_um_checkmail_message',
|
||||
'label' => __( 'Personalize the custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_checkmail_message'] ) ? $role['_um_checkmail_message'] : '',
|
||||
'value' => ! empty( $role['_um_checkmail_message'] ) ? $role['_um_checkmail_message'] : __('Thank you for registering. Before you can login we need you to activate your account by clicking the activation link in the email we just sent you.','ultimate-member'),
|
||||
'conditional' => array( '_um_checkmail_action', '=', 'show_message' )
|
||||
),
|
||||
array(
|
||||
@@ -104,7 +104,7 @@
|
||||
'type' => 'textarea',
|
||||
'name' => '_um_pending_message',
|
||||
'label' => __( 'Personalize the custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_pending_message'] ) ? $role['_um_pending_message'] : '',
|
||||
'value' => ! empty( $role['_um_pending_message'] ) ? $role['_um_pending_message'] : __('Thank you for applying for membership to our site. We will review your details and send you an email letting you know whether your application has been successful or not.','ultimate-member'),
|
||||
'conditional' => array( '_um_pending_action', '=', 'show_message' )
|
||||
),
|
||||
array(
|
||||
|
||||
+229
-76
@@ -7,21 +7,29 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
if ( ! class_exists( 'Mail' ) ) {
|
||||
class Mail {
|
||||
|
||||
var $email_templates = array();
|
||||
|
||||
function __construct() {
|
||||
|
||||
add_filter('mandrill_nl2br', array(&$this, 'mandrill_nl2br') );
|
||||
$this->path_by_slug = apply_filters( 'um_email_templates_path_by_slug', array() );
|
||||
|
||||
$this->force_plain_text = '';
|
||||
//mandrill compatibility
|
||||
add_filter( 'mandrill_nl2br', array( &$this, 'mandrill_nl2br' ) );
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @mandrill compatibility
|
||||
***/
|
||||
function mandrill_nl2br($nl2br, $message = '') {
|
||||
|
||||
/**
|
||||
* Mandrill compatibility
|
||||
*
|
||||
* @param $nl2br
|
||||
* @param string $message
|
||||
* @return bool
|
||||
*/
|
||||
function mandrill_nl2br( $nl2br, $message = '' ) {
|
||||
|
||||
// text emails
|
||||
if ( !um_get_option('email_html') ) {
|
||||
if ( ! um_get_option( 'email_html' ) ) {
|
||||
$nl2br = true;
|
||||
}
|
||||
|
||||
@@ -29,103 +37,248 @@ if ( ! class_exists( 'Mail' ) ) {
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @check If template exists
|
||||
***/
|
||||
function email_template( $template, $args = array() ) {
|
||||
$lang = '';
|
||||
$template_path = false;
|
||||
|
||||
if ( function_exists('icl_get_current_language') ) {
|
||||
if ( icl_get_current_language() != 'en' ) {
|
||||
$lang = icl_get_current_language() . '/';
|
||||
/**
|
||||
* Send Email function
|
||||
*
|
||||
* @param string $email
|
||||
* @param null $template
|
||||
* @param array $args
|
||||
*/
|
||||
function send( $email, $template, $args = array() ) {
|
||||
|
||||
if ( ! is_email( $email ) ) return;
|
||||
if ( um_get_option( $template . '_on' ) != 1 ) return;
|
||||
|
||||
$this->attachments = null;
|
||||
$this->headers = 'From: '. um_get_option('mail_from') .' <'. um_get_option('mail_from_addr') .'>' . "\r\n";
|
||||
|
||||
$this->subject = um_convert_tags( um_get_option( $template . '_sub' ), $args );
|
||||
|
||||
$this->message = $this->prepare_template( $template, $args );
|
||||
|
||||
add_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) );
|
||||
// Send mail
|
||||
wp_mail( $email, $this->subject, $this->message, $this->headers, $this->attachments );
|
||||
remove_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) );
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
/**
|
||||
* @param $slug
|
||||
* @param $args
|
||||
* @return bool|string
|
||||
*/
|
||||
function get_email_template( $slug, $args = array() ) {
|
||||
|
||||
$located = $this->locate_template( $slug );
|
||||
|
||||
$located = apply_filters( 'um_email_template_path', $located, $slug, $args );
|
||||
|
||||
if ( ! file_exists( $located ) ) {
|
||||
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
|
||||
return false;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
do_action( 'um_before_email_template_part', $slug, $located, $args );
|
||||
|
||||
include( $located );
|
||||
|
||||
do_action( 'um_after_email_template_part', $slug, $located, $args );
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare email template to send
|
||||
*
|
||||
* @param $slug
|
||||
* @param $args
|
||||
* @return mixed|string
|
||||
*/
|
||||
function prepare_template( $slug, $args = array() ) {
|
||||
ob_start(); ?>
|
||||
|
||||
<html>
|
||||
<?php do_action( 'um_before_email_template_body', $slug, $args ); ?>
|
||||
|
||||
<body <?php echo apply_filters( 'um_email_template_body_attrs', 'style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;"', $slug ) ?>>
|
||||
|
||||
<?php echo $this->get_email_template( $slug, $args ); ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php $message = ob_get_clean();
|
||||
|
||||
// Convert tags in email template
|
||||
return um_convert_tags( $message, $args );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locate a template and return the path for inclusion.
|
||||
*
|
||||
* @access public
|
||||
* @param string $template_name
|
||||
* @return string
|
||||
*/
|
||||
function locate_template( $template_name ) {
|
||||
//WPML compatibility and multilingual email templates
|
||||
$lang = get_locale();
|
||||
$arr_english_lang = array('en','en_US','en_NZ','en_ZA','en_AU','en_GB');
|
||||
$arr_english_lang = array( 'en', 'en_US', 'en_NZ', 'en_ZA', 'en_AU', 'en_GB' );
|
||||
|
||||
if( in_array( $lang, $arr_english_lang ) || strpos( $lang , 'en_' ) > -1 || empty( $lang ) || $lang == 0 ){
|
||||
if ( in_array( $lang, $arr_english_lang ) || strpos( $lang , 'en_' ) > -1 || empty( $lang ) || $lang == 0 ) {
|
||||
$lang = '';
|
||||
} else {
|
||||
$lang .= '/';
|
||||
}
|
||||
|
||||
// check if there is template at theme folder
|
||||
$template = locate_template( array(
|
||||
trailingslashit( 'ultimate-member/email' ) . $lang . $template_name . '.php'
|
||||
) );
|
||||
|
||||
//if there isn't template at theme folder get template file from plugin dir
|
||||
if ( ! $template ) {
|
||||
$path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email';
|
||||
$template = trailingslashit( $path ) . $lang . $template_name . '.php';
|
||||
}
|
||||
|
||||
if ( file_exists( get_stylesheet_directory() . '/ultimate-member/templates/email/' . $lang . $template . '.html' ) ) {
|
||||
$template_path = get_stylesheet_directory() . '/ultimate-member/templates/email/' . $lang . $template . '.html';
|
||||
// Return what we found.
|
||||
return apply_filters( 'um_locate_email_template', $template, $template_name );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locate a template and return the path for inclusion.
|
||||
*
|
||||
* @access public
|
||||
* @param string $template_name
|
||||
* @return string
|
||||
*/
|
||||
function template_in_theme( $template_name ) {
|
||||
//WPML compatibility and multilingual email templates
|
||||
$lang = get_locale();
|
||||
$arr_english_lang = array( 'en', 'en_US', 'en_NZ', 'en_ZA', 'en_AU', 'en_GB' );
|
||||
|
||||
if ( in_array( $lang, $arr_english_lang ) || strpos( $lang , 'en_' ) > -1 || empty( $lang ) || $lang == 0 ) {
|
||||
$lang = '';
|
||||
} else {
|
||||
if ( isset( $args['path'] ) ) {
|
||||
$path = $args['path'] . $lang;
|
||||
} else {
|
||||
$path = um_path . 'templates/email/' . $lang;
|
||||
$lang .= '/';
|
||||
}
|
||||
|
||||
if ( file_exists( $path . $template . '.html' ) ) {
|
||||
$template_path = $path . $template . '.html';
|
||||
}
|
||||
}
|
||||
// check if there is template at theme folder
|
||||
$template = locate_template( array(
|
||||
trailingslashit( 'ultimate-member/email' ) . $lang . $template_name . '.php'
|
||||
) );
|
||||
|
||||
return apply_filters( 'um_email_template_path', $template_path, $template, $args );
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @sends an email to any user
|
||||
***/
|
||||
function send( $email, $template=null, $args = array() ) {
|
||||
|
||||
if ( !$template ) return;
|
||||
if ( um_get_option( $template . '_on' ) != 1 ) return;
|
||||
if ( !is_email( $email ) ) return;
|
||||
|
||||
$this->attachments = null;
|
||||
$this->headers = 'From: '. um_get_option('mail_from') .' <'. um_get_option('mail_from_addr') .'>' . "\r\n";
|
||||
|
||||
$this->subject = um_get_option( $template . '_sub' );
|
||||
$this->subject = um_convert_tags( $this->subject, $args );
|
||||
|
||||
if ( isset( $args['admin'] ) || isset( $args['plain_text'] ) ) {
|
||||
$this->force_plain_text = 'forced';
|
||||
// Return what we found.
|
||||
return ! $template ? false : true;
|
||||
}
|
||||
|
||||
|
||||
add_filter( 'wp_mail_content_type', array(&$this, 'set_content_type') );
|
||||
// HTML e-mail or text
|
||||
if ( um_get_option('email_html') && $this->email_template( $template, $args ) ) {
|
||||
$this->message = file_get_contents( $this->email_template( $template, $args ) );
|
||||
} else {
|
||||
$this->message = um_get_option( $template );
|
||||
/**
|
||||
* Method returns expected path for template
|
||||
*
|
||||
* @access public
|
||||
* @param string $location
|
||||
* @param string $template_name
|
||||
* @return string
|
||||
*/
|
||||
function get_template_file( $location, $template_name ) {
|
||||
$template_path = '';
|
||||
switch( $location ) {
|
||||
case 'theme':
|
||||
$template_path = trailingslashit( get_stylesheet_directory() . '/ultimate-member/email' ) . $template_name . '.php';
|
||||
break;
|
||||
case 'plugin':
|
||||
$path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email';
|
||||
$template_path = trailingslashit( $path ) . $template_name . '.php';
|
||||
break;
|
||||
}
|
||||
|
||||
// Convert tags in body
|
||||
$this->message = um_convert_tags( $this->message, $args );
|
||||
|
||||
// Send mail
|
||||
wp_mail( $email, $this->subject, $this->message, $this->headers, $this->attachments );
|
||||
remove_filter( 'wp_mail_content_type', array(&$this, 'set_content_type') );
|
||||
|
||||
// reset globals
|
||||
$this->force_plain_text = '';
|
||||
|
||||
//return apply_filters( 'wpc_client_template_location', $template_path, $location, $template_name, $path );
|
||||
return $template_path;
|
||||
}
|
||||
|
||||
/***
|
||||
*** @maybe sending HTML emails
|
||||
***/
|
||||
|
||||
/**
|
||||
* Set email content type
|
||||
*
|
||||
*
|
||||
* @param $content_type
|
||||
* @return string
|
||||
*/
|
||||
function set_content_type( $content_type ) {
|
||||
return 'text/html';
|
||||
|
||||
/*if ( $this->force_plain_text == 'forced' )
|
||||
if ( um_get_option( 'email_html' ) ) {
|
||||
return 'text/html';
|
||||
} else {
|
||||
return 'text/plain';
|
||||
|
||||
if ( um_get_option( 'email_html' ) )
|
||||
return 'text/html';
|
||||
|
||||
return 'text/plain';*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ajax copy template to the theme
|
||||
*
|
||||
* @param bool $template
|
||||
* @return bool
|
||||
*/
|
||||
function copy_email_template( $template = false ) {
|
||||
|
||||
$in_theme = $this->template_in_theme( $template );
|
||||
if ( $in_theme ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$plugin_template_path = $this->get_template_file( 'plugin', $template );
|
||||
$theme_template_path = $this->get_template_file( 'theme', $template );
|
||||
|
||||
$temp_path = str_replace( trailingslashit( get_stylesheet_directory() ), '', $theme_template_path );
|
||||
$temp_path = str_replace( '/', DIRECTORY_SEPARATOR, $temp_path );
|
||||
$folders = explode( DIRECTORY_SEPARATOR, $temp_path );
|
||||
$folders = array_splice( $folders, 0, count( $folders ) - 1 );
|
||||
$cur_folder = '';
|
||||
$theme_dir = trailingslashit( get_stylesheet_directory() );
|
||||
|
||||
foreach ( $folders as $folder ) {
|
||||
$prev_dir = $cur_folder;
|
||||
$cur_folder .= $folder . DIRECTORY_SEPARATOR;
|
||||
if ( ! is_dir( $theme_dir . $cur_folder ) && wp_is_writable( $theme_dir . $prev_dir ) ) {
|
||||
mkdir( $theme_dir . $cur_folder, 0777 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( copy( $plugin_template_path, $theme_template_path ) ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function delete_email_template() {
|
||||
$template = $_POST['email_key'];
|
||||
|
||||
$in_theme = $this->template_in_theme( $template );
|
||||
if ( ! $in_theme ) {
|
||||
wp_send_json_error( new \WP_Error( 'template_in_theme', __( 'Template does not exists in theme', 'ultimate-member' ) ) );
|
||||
}
|
||||
|
||||
$theme_template_path = $this->get_template_file( 'theme', $template );
|
||||
|
||||
if ( unlink( $theme_template_path ) ) {
|
||||
wp_send_json_success();
|
||||
} else {
|
||||
wp_send_json_error( new \WP_Error( 'template_not_exists', __( 'Can not remove template from theme', 'ultimate-member' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -746,9 +746,9 @@ if ( ! class_exists( 'User' ) ) {
|
||||
*
|
||||
*
|
||||
*/
|
||||
function pending(){
|
||||
$this->set_status('awaiting_admin_review');
|
||||
UM()->mail()->send( um_user('user_email'), 'pending_email' );
|
||||
function pending() {
|
||||
$this->set_status( 'awaiting_admin_review' );
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,7 +84,9 @@
|
||||
*/
|
||||
add_action('um_post_registration_listener', 'um_post_registration_listener', 10, 2);
|
||||
function um_post_registration_listener( $user_id, $args ) {
|
||||
if ( um_user('status') != 'pending' ) {
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
if ( um_user( 'status' ) != 'pending' ) {
|
||||
UM()->mail()->send( um_admin_email(), 'notification_new_user', array( 'admin' => true ) );
|
||||
} else {
|
||||
UM()->mail()->send( um_admin_email(), 'notification_review', array( 'admin' => true ) );
|
||||
|
||||
@@ -5,37 +5,6 @@
|
||||
return 'text/html';
|
||||
}
|
||||
|
||||
function UM_Mail( $user_id_or_email = 1, $subject_line = 'Email Subject', $template, $path = null, $args = array() ) {
|
||||
|
||||
if ( absint( $user_id_or_email ) ) {
|
||||
$user = get_userdata( $user_id_or_email );
|
||||
$email = $user->user_email;
|
||||
} else {
|
||||
$email = $user_id_or_email;
|
||||
}
|
||||
|
||||
$headers = 'From: '. um_get_option('mail_from') .' <'. um_get_option('mail_from_addr') .'>' . "\r\n";
|
||||
$attachments = null;
|
||||
|
||||
if ( file_exists( get_stylesheet_directory() . '/ultimate-member/templates/email/' . get_locale() . '/' . $template . '.html' ) ) {
|
||||
$path_to_email = get_stylesheet_directory() . '/ultimate-member/templates/email/' . get_locale() . '/' . $template . '.html';
|
||||
} else if ( file_exists( get_stylesheet_directory() . '/ultimate-member/templates/email/' . $template . '.html' ) ) {
|
||||
$path_to_email = get_stylesheet_directory() . '/ultimate-member/templates/email/' . $template . '.html';
|
||||
} else {
|
||||
$path_to_email = $path . $template . '.html';
|
||||
}
|
||||
|
||||
if ( um_get_option('email_html') ) {
|
||||
$message = file_get_contents( $path_to_email );
|
||||
add_filter( 'wp_mail_content_type', 'um_mail_content_type' );
|
||||
} else {
|
||||
$message = ( um_get_option('email-' . $template ) ) ? um_get_option('email-' . $template ) : 'Untitled';
|
||||
}
|
||||
|
||||
$message = um_convert_tags( $message, $args );
|
||||
wp_mail( $email, $subject_line, $message, $headers, $attachments );
|
||||
}
|
||||
|
||||
/***
|
||||
*** @Trim string by char length
|
||||
***/
|
||||
@@ -568,6 +537,7 @@
|
||||
***/
|
||||
function um_is_temp_upload( $url ) {
|
||||
|
||||
if ( filter_var( $url, FILTER_VALIDATE_URL ) === false )
|
||||
$url = realpath( $url );
|
||||
|
||||
if ( ! $url )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<body style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;">
|
||||
<?php
|
||||
|
||||
?>
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
<div style="color: #444444;font-weight: normal;">
|
||||
@@ -35,6 +35,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<html>
|
||||
<body style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;">
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
@@ -27,6 +28,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<html>
|
||||
<body style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;">
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
@@ -27,6 +28,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<html>
|
||||
<body style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;">
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
@@ -25,6 +26,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<body style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;">
|
||||
<?php
|
||||
|
||||
?>
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
<div style="color: #444444;font-weight: normal;">
|
||||
@@ -25,6 +25,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
?>
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
<div style="color: #444444;font-weight: normal;">
|
||||
<div style="text-align: center;font-weight:600;font-size:26px;padding: 10px 0;border-bottom: solid 3px #eeeeee;">{site_name}</div>
|
||||
|
||||
<div style="clear:both"></div>
|
||||
</div>
|
||||
|
||||
<div style="padding: 0 30px 30px 30px;border-bottom: 3px solid #eeeeee;">
|
||||
|
||||
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">{display_name} has just deleted their {site_name} account.</span></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="color: #999;padding: 20px 30px">
|
||||
|
||||
<div style="">Thank you!</div>
|
||||
<div style="">The <a href="{site_url}" style="color: #3ba1da;text-decoration: none;">{site_name}</a> Team</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
?>
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
<div style="color: #444444;font-weight: normal;">
|
||||
<div style="text-align: center;font-weight:600;font-size:26px;padding: 10px 0;border-bottom: solid 3px #eeeeee;">{site_name}</div>
|
||||
|
||||
<div style="clear:both"></div>
|
||||
</div>
|
||||
|
||||
<div style="padding: 0 30px 30px 30px;border-bottom: 3px solid #eeeeee;">
|
||||
|
||||
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">{display_name} has just created an account on {site_name}.</span></div>
|
||||
|
||||
<div style="padding: 10px 0 50px 0;text-align: center;">To view their profile click here: {user_profile_link}</div>
|
||||
|
||||
<div style="padding: 0 0 15px 0;">
|
||||
|
||||
<div style="background: #eee;color: #444;padding: 12px 15px; border-radius: 3px;font-weight: bold;font-size: 16px;">Here is the submitted registration form:<br /><br />
|
||||
{submitted_registration}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="color: #999;padding: 20px 30px">
|
||||
|
||||
<div style="">Thank you!</div>
|
||||
<div style="">The <a href="{site_url}" style="color: #3ba1da;text-decoration: none;">{site_name}</a> Team</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
?>
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
<div style="color: #444444;font-weight: normal;">
|
||||
<div style="text-align: center;font-weight:600;font-size:26px;padding: 10px 0;border-bottom: solid 3px #eeeeee;">{site_name}</div>
|
||||
|
||||
<div style="clear:both"></div>
|
||||
</div>
|
||||
|
||||
<div style="padding: 0 30px 30px 30px;border-bottom: 3px solid #eeeeee;">
|
||||
|
||||
<div style="padding: 30px 0;font-size: 24px;text-align: center;line-height: 40px;">{display_name} has just applied for membership to {site_name} and is waiting to be reviewed.</span></div>
|
||||
|
||||
<div style="padding: 10px 0 50px 0;text-align: center;">To review this member please click the following link: {user_profile_link}</div>
|
||||
|
||||
<div style="padding: 0 0 15px 0;">
|
||||
|
||||
<div style="background: #eee;color: #444;padding: 12px 15px; border-radius: 3px;font-weight: bold;font-size: 16px;">Here is the submitted registration form:<br /><br />
|
||||
{submitted_registration}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="color: #999;padding: 20px 30px">
|
||||
|
||||
<div style="">Thank you!</div>
|
||||
<div style="">The <a href="{site_url}" style="color: #3ba1da;text-decoration: none;">{site_name}</a> Team</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<body style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;">
|
||||
<?php
|
||||
|
||||
?>
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
<div style="color: #444444;font-weight: normal;">
|
||||
@@ -25,6 +25,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<html>
|
||||
<body style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;">
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
@@ -25,6 +26,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<html>
|
||||
<body style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;">
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
@@ -27,6 +28,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<html>
|
||||
<body style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;">
|
||||
<?php
|
||||
|
||||
?>
|
||||
|
||||
<div style="max-width: 560px;padding: 20px;background: #ffffff;border-radius: 5px;margin:40px auto;font-family: Open Sans,Helvetica,Arial;font-size: 15px;color: #666;">
|
||||
|
||||
@@ -28,6 +29,3 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user