Skip to content

Commit

Permalink
Merge pull request #1747 from strangerstudios/dev
Browse files Browse the repository at this point in the history
2.6.1.1 Release
  • Loading branch information
ideadude authored Aug 25, 2021
2 parents 648ecff + 7150662 commit 559d2b7
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 81 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
== Changelog ==
= 2.6.1.1 - 2021-08-25 =
* BUG FIX: Fixed issue with PMPro blocks not showing up in the block editor.
* REFACTOR: Some JS functions and element IDs and names have been prefixed with pmpro_ to avoid conflicts.

= 2.6.1 - 2021-08-24 =
* SECURITY: Added capability checks to further tighten security around email template settings. (@ideadude, @sc0ttkclark)
* SECURITY: Added a pmpro_kses function and using that to sanitize email template bodies and all email bodies before sending. (@ideadude, @sc0ttkclark)
Expand Down
16 changes: 8 additions & 8 deletions adminpages/emailtemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
</select>
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" id="pmproet-spinner" style="display:none;"/>

<p id="email_template_help_text" class="description"></p>
<p id="pmpro_email_template_help_text" class="description"></p>
</td>
</tr>
<tr class="hide-while-loading">
<th scope="row" valign="top"></th>
<td>
<label><input id="email_template_disable" name="email_template_disable" type="checkbox" /><span
<label><input id="pmpro_email_template_disable" name="pmpro_email_template_disable" type="checkbox" /><span
id="disable_label"><?php esc_html_e( 'Disable this email?', 'paid-memberships-pro' ); ?></span></label>


Expand All @@ -63,18 +63,18 @@
</td>
</tr>
<tr class="hide-while-loading">
<th scope="row" valign="top"><label for="email_template_subject"><?php esc_html_e( 'Subject', 'paid-memberships-pro' ); ?></label></th>
<th scope="row" valign="top"><label for="pmpro_email_template_subject"><?php esc_html_e( 'Subject', 'paid-memberships-pro' ); ?></label></th>

<td>
<input id="email_template_subject" name="email_template_subject" type="text" size="100"/>
<input id="pmpro_email_template_subject" name="pmpro_email_template_subject" type="text" size="100"/>
</td>
</tr>
<tr class="hide-while-loading">
<th scope="row" valign="top"><label for="email_template_body"><?php esc_html_e( 'Body', 'paid-memberships-pro' ); ?></label></th>
<th scope="row" valign="top"><label for="pmpro_email_template_body"><?php esc_html_e( 'Body', 'paid-memberships-pro' ); ?></label></th>

<td>
<div id="template_editor_container">
<textarea rows="10" cols="80" name="email_template_body" id="email_template_body"></textarea>
<textarea rows="10" cols="80" name="pmpro_email_template_body" id="pmpro_email_template_body"></textarea>
</div>
</td>
</tr>
Expand All @@ -97,10 +97,10 @@
<th scope="row" valign="top"></th>
<td>
<p class="submit">
<input id="submit_template_data" name="save_template" type="button" class="button-primary"
<input id="pmpro_submit_template_data" name="pmpro_save_template" type="button" class="button-primary"
value="<?php esc_attr_e( 'Save Template', 'paid-memberships-pro' ); ?>"/>

<input id="reset_template_data" name="reset_template" type="button" class="button"
<input id="pmpro_reset_template_data" name="pmpro_reset_template" type="button" class="button"
value="<?php esc_attr_e( 'Reset Template', 'paid-memberships-pro' ); ?>"/>

</p>
Expand Down
10 changes: 9 additions & 1 deletion blocks/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ function pmpro_block_editor_scripts() {
wp_enqueue_script(
'pmpro-blocks-editor-js',
plugins_url( 'js/blocks.build.js', PMPRO_BASE_FILE ),
array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api', 'wp-block-editor', 'pmpro_admin'),
[
'wp-i18n',
'wp-element',
'wp-blocks',
'wp-components',
'wp-api',
'wp-block-editor',
'pmpro_admin',
],
PMPRO_VERSION
);

Expand Down
93 changes: 54 additions & 39 deletions includes/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,48 +94,63 @@ function pmpro_enqueue_scripts() {
* Enqueue admin JavaScript and CSS
*/
function pmpro_admin_enqueue_scripts() {
// Admin JS
wp_register_script( 'pmpro_admin', plugins_url( 'js/pmpro-admin.js', __DIR__ ), [
'jquery',
'jquery-ui-sortable',
], PMPRO_VERSION );

$all_levels = pmpro_getAllLevels( true, true );
$all_level_values_and_labels = [];

foreach ( $all_levels as $level ) {
$all_level_values_and_labels[] = [
'value' => $level->id,
'label' => $level->name,
];
}

wp_localize_script( 'pmpro_admin', 'pmpro', [
'all_levels' => $all_levels,
'all_level_values_and_labels' => $all_level_values_and_labels,
] );

// Admin CSS
$admin_css_rtl = false;

if ( file_exists( get_stylesheet_directory() . '/paid-memberships-pro/css/admin.css' ) ) {
$admin_css = get_stylesheet_directory_uri() . '/paid-memberships-pro/css/admin.css';

if ( is_rtl() && file_exists( get_stylesheet_directory() . '/paid-memberships-pro/css/admin-rtl.css' ) ) {
$admin_css_rtl = get_stylesheet_directory_uri() . '/paid-memberships-pro/css/admin-rtl.css';
}
} elseif ( file_exists( get_template_directory() . '/paid-memberships-pro/admin.css' ) ) {
$admin_css = get_template_directory_uri() . '/paid-memberships-pro/admin.css';

if ( is_rtl() && file_exists( get_template_directory() . '/paid-memberships-pro/css/admin-rtl.css' ) ) {
$admin_css_rtl = get_template_directory_uri() . '/paid-memberships-pro/css/admin-rtl.css';
}
} else {
$admin_css = plugins_url( 'css/admin.css', __DIR__ );

if ( is_rtl() ) {
$admin_css_rtl = plugins_url( 'css/admin-rtl.css', __DIR__ );
}
}

wp_register_style( 'pmpro_admin', $admin_css, [], PMPRO_VERSION, 'screen' );
wp_register_style( 'pmpro_admin_rtl', $admin_css_rtl, [], PMPRO_VERSION, 'screen' );

// Only enqueue PMPro admin scripts on our own pages.
if ( ! isset( $_GET['page'] ) || 0 !== strpos( $_GET['page'], 'pmpro' ) ) {
return;
}

// Admin JS
wp_register_script( 'pmpro_admin',
plugins_url( 'js/pmpro-admin.js', dirname(__FILE__) ),
array( 'jquery', 'jquery-ui-sortable' ),
PMPRO_VERSION );
$all_levels = pmpro_getAllLevels( true, true );
$all_level_values_and_labels = array();
foreach( $all_levels as $level ) {
$all_level_values_and_labels[] = array( 'value' => $level->id, 'label' => $level->name );
}
wp_localize_script( 'pmpro_admin', 'pmpro', array(
'all_levels' => $all_levels,
'all_level_values_and_labels' => $all_level_values_and_labels
));
wp_enqueue_script( 'pmpro_admin' );

// Admin CSS
$admin_css_rtl = false;
if(file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/admin.css")) {
$admin_css = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/admin.css";
if( is_rtl() && file_exists(get_stylesheet_directory() . "/paid-memberships-pro/css/admin-rtl.css") ) {
$admin_css_rtl = get_stylesheet_directory_uri() . "/paid-memberships-pro/css/admin-rtl.css";
}
} elseif(file_exists(get_template_directory() . "/paid-memberships-pro/admin.css")) {
$admin_css = get_template_directory_uri() . "/paid-memberships-pro/admin.css";
if( is_rtl() && file_exists(get_template_directory() . "/paid-memberships-pro/css/admin-rtl.css") ) {
$admin_css_rtl = get_template_directory_uri() . "/paid-memberships-pro/css/admin-rtl.css";
}
} else {
$admin_css = plugins_url('css/admin.css',dirname(__FILE__) );
if( is_rtl() ) {
$admin_css_rtl = plugins_url('css/admin-rtl.css',dirname(__FILE__) );
}
}
wp_enqueue_style('pmpro_admin', $admin_css, array(), PMPRO_VERSION, "screen");
if( $admin_css_rtl ) {
wp_enqueue_style('pmpro_admin_rtl', $admin_css_rtl, array(), PMPRO_VERSION, "screen");
}
wp_enqueue_script( 'pmpro_admin' );
wp_enqueue_style( 'pmpro_admin' );

if ( $admin_css_rtl ) {
wp_enqueue_style( 'pmpro_admin_rtl' );
}
}
add_action( 'admin_enqueue_scripts', 'pmpro_admin_enqueue_scripts' );
add_action( 'admin_enqueue_scripts', 'pmpro_admin_enqueue_scripts' );
62 changes: 31 additions & 31 deletions js/pmpro-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ jQuery(document).ready(function($) {

/* Variables */
var template, disabled, $subject, $editor, $testemail;
$subject = $("#email_template_subject").closest("tr");
$subject = $("#pmpro_email_template_subject").closest("tr");
$editor = $("#wp-email_template_body-wrap");
$testemail = $("#test_email_address").closest("tr");

Expand All @@ -226,31 +226,31 @@ jQuery(document).ready(function($) {

//get template data
if (template)
getTemplate(template);
pmpro_get_template(template);
else {
$(".hide-while-loading").hide();
$(".controls").hide();
}
});

$("#submit_template_data").click(function() {
saveTemplate()
$("#pmpro_submit_template_data").click(function() {
pmpro_save_template()
});

$("#reset_template_data").click(function() {
resetTemplate();
$("#pmpro_reset_template_data").click(function() {
pmpro_reset_template();
});

$("#email_template_disable").click(function(e) {
disableTemplate();
$("#pmpro_email_template_disable").click(function(e) {
pmpro_disable_template();
});

$("#send_test_email").click(function(e) {
saveTemplate().done(setTimeout(function(){sendTestEmail();}, '1000'));
pmpro_save_template().done(setTimeout(function(){pmpro_send_test_email();}, '1000'));
});

/* Functions */
function getTemplate(template) {
function pmpro_get_template(template) {

//hide stuff and show ajax spinner
$(".hide-while-loading").hide();
Expand Down Expand Up @@ -295,26 +295,26 @@ jQuery(document).ready(function($) {
}

// populate help text, subject, and body
$('#email_template_help_text').text(template_data['help_text']);
$('#email_template_subject').val(template_data['subject']);
$('#email_template_body').val(template_data['body']);
$('#pmpro_email_template_help_text').text(template_data['help_text']);
$('#pmpro_email_template_subject').val(template_data['subject']);
$('#pmpro_email_template_body').val(template_data['body']);

// disable form
disabled = template_data['disabled'];
toggleFormDisabled(disabled);
pmpro_toggle_form_disabled(disabled);
});
}

function saveTemplate() {
function pmpro_save_template() {

$("#submit_template_data").attr("disabled", true);
$(".status").hide();
// console.log(template);

$data = {
template: template,
subject: $("#email_template_subject").val(),
body: $("#email_template_body").val(),
subject: $("#pmpro_email_template_subject").val(),
body: $("#pmpro_email_template_body").val(),
action: 'pmpro_email_templates_save_template_data',
security: $('input[name=security]').val()
};
Expand All @@ -334,7 +334,7 @@ jQuery(document).ready(function($) {
return $.Deferred().resolve();
}

function resetTemplate() {
function pmpro_reset_template() {

var r = confirm('Are you sure? Your current template settings will be deleted permanently.');

Expand All @@ -347,20 +347,20 @@ jQuery(document).ready(function($) {
};
$.post(ajaxurl, $data, function(response) {
var template_data = $.parseJSON(response);
$('#email_template_subject').val(template_data['subject']);
$('#email_template_body').val(template_data['body']);
$('#pmpro_email_template_subject').val(template_data['subject']);
$('#pmpro_email_template_body').val(template_data['body']);
});

return true;
}

function disableTemplate() {
function pmpro_disable_template() {

//update wp_options
data = {
template: template,
action: 'pmpro_email_templates_disable_template',
disabled: $("#email_template_disable").is(":checked"),
disabled: $("#pmpro_email_template_disable").is(":checked"),
security: $('input[name=security]').val()
};

Expand Down Expand Up @@ -388,11 +388,11 @@ jQuery(document).ready(function($) {

disabled = response['status'];

toggleFormDisabled(disabled);
pmpro_toggle_form_disabled(disabled);
});
}

function sendTestEmail() {
function pmpro_send_test_email() {

//hide stuff and show ajax spinner
$(".hide-while-loading").hide();
Expand Down Expand Up @@ -423,17 +423,17 @@ jQuery(document).ready(function($) {
})
}

function toggleFormDisabled(disabled) {
function pmpro_toggle_form_disabled(disabled) {
if(disabled == 'true') {
$("#email_template_disable").prop('checked', true);
$("#email_template_body").attr('readonly', 'readonly').attr('disabled', 'disabled');
$("#email_template_subject").attr('readonly', 'readonly').attr('disabled', 'disabled');
$("#pmpro_email_template_disable").prop('checked', true);
$("#pmpro_email_template_body").attr('readonly', 'readonly').attr('disabled', 'disabled');
$("#pmpro_email_template_subject").attr('readonly', 'readonly').attr('disabled', 'disabled');
$(".controls").hide();
}
else {
$("#email_template_disable").prop('checked', false);
$("#email_template_body").removeAttr('readonly','readonly').removeAttr('disabled', 'disabled');
$("#email_template_subject").removeAttr('readonly','readonly').removeAttr('disabled', 'disabled');
$("#pmpro_email_template_disable").prop('checked', false);
$("#pmpro_email_template_body").removeAttr('readonly','readonly').removeAttr('disabled', 'disabled');
$("#pmpro_email_template_subject").removeAttr('readonly','readonly').removeAttr('disabled', 'disabled');
$(".controls").show();
}

Expand Down
4 changes: 2 additions & 2 deletions paid-memberships-pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Paid Memberships Pro
* Plugin URI: https://www.paidmembershipspro.com
* Description: The most complete member management and membership subscriptions plugin for WordPress.
* Version: 2.6.1
* Version: 2.6.1.1
* Author: Stranger Studios
* Author URI: https://www.strangerstudios.com
* Text Domain: paid-memberships-pro
Expand All @@ -16,7 +16,7 @@
*/

// version constant
define( 'PMPRO_VERSION', '2.6.1' );
define( 'PMPRO_VERSION', '2.6.1.1' );
define( 'PMPRO_USER_AGENT', 'Paid Memberships Pro v' . PMPRO_VERSION . '; ' . site_url() );
define( 'PMPRO_MIN_PHP_VERSION', '5.6' );

Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ Not sure? You can find out by doing a bit a research.
9. Membership Account page, display all sections or show specific sections using shortcode attributes.

== Changelog ==
= 2.6.1.1 - 2021-08-25 =
* BUG FIX: Fixed issue with PMPro blocks not showing up in the block editor.
* REFACTOR: Some JS functions and element IDs and names have been prefixed with pmpro_ to avoid conflicts.

= 2.6.1 - 2021-08-24 =
* SECURITY: Added capability checks to further tighten security around email template settings. (@ideadude, @sc0ttkclark)
* SECURITY: Added a pmpro_kses function and using that to sanitize email template bodies and all email bodies before sending. (@ideadude, @sc0ttkclark)
Expand Down

0 comments on commit 559d2b7

Please sign in to comment.