Skip to content

Commit

Permalink
Various bug fixes.
Browse files Browse the repository at this point in the history
* Bug Fix: Fixed the _n() function for opt-in lists to display plural or singular text.

* Bug Fix: Fixed issue with the text domain for all plugin text to make it translatable for GlotPress.

Resolves: #8
  • Loading branch information
andrewlimaza committed Sep 6, 2022
1 parent 8c99c12 commit 3ab8358
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
10 changes: 4 additions & 6 deletions includes/opt-in-lists-functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* Dispaly additional opt-in list fields on checkout
*
Expand All @@ -24,7 +23,7 @@ function pmpro_mailpoet_additional_lists_on_checkout() {
<hr />
<h3>
<span class="pmpro_checkout-h3-name">
<?php echo _n( 'Join Our Mailing List', 'Join Our Mailing Lists', $options['opt-in_lists'], 'pmpro-mailpoet' ); ?>
<?php echo _n( 'Join Our Mailing List', 'Join Our Mailing Lists', count( $options['opt-in_lists'] ), 'mailpoet-paid-memberships-pro-add-on' ); ?>
</span>
</h3>
<div class="pmpro_checkout-fields">
Expand Down Expand Up @@ -64,12 +63,12 @@ function pmpro_mailpoet_show_optin_list_profile_fields( $user ) {

// Show opt-in lists setting.
?>
<h3><?php esc_html_e( 'Opt-in MailPoet Lists', 'pmpro-mailpoet' ); ?></h3>
<h3><?php esc_html_e( 'Opt-in MailPoet Lists', 'mailpoet-paid-memberships-pro-add-on' ); ?></h3>

<table class="form-table">
<tr>
<th>
<label><?php esc_html_e( 'Mailing Lists', 'pmpro-mailpoet' ); ?></label>
<label><?php esc_html_e( 'Mailing Lists', 'mailpoet-paid-memberships-pro-add-on' ); ?></label>
</th>
<td>
<?php pmpro_mailpoet_show_optin_checkboxes( $user->ID ); ?>
Expand All @@ -95,9 +94,8 @@ function pmpro_mailpoet_show_optin_list_profile_fields_frontend( $user ) {
// Show opt-in lists setting.
?>
<div class="pmpro_checkout_box-mailpoet-require-opt-in">
<h3><?php echo _n( 'Join Our Mailing List', 'Join Our Mailing Lists', $options['opt-in_lists'], 'pmpro-mailpoet' ); ?></h3>
<h3><?php echo _n( 'Join Our Mailing List', 'Join Our Mailing Lists', count( $options['opt-in_lists'] ), 'mailpoet-paid-memberships-pro-add-on' ); ?></h3>
<div class="pmpro_member_profile_edit-fields">
<?php /*<label><?php esc_html_e( 'Mailing Lists', 'pmpro-mailpoet' ); ?></label> */ ?>
<?php pmpro_mailpoet_show_optin_checkboxes( $user->ID ); ?>
</div> <!-- end pmpro_member_profile_edit-fields -->
</div> <!-- end pmpro_checkout_box_mailpoet-require-opt-in -->
Expand Down
42 changes: 21 additions & 21 deletions includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function pmpro_mailpoet_add_admin_page() {
}

if ( version_compare( PMPRO_VERSION, '2.0' ) >= 0 ) {
add_submenu_page( 'pmpro-dashboard', __( 'MailPoet', 'pmpro-mailpoet' ), __( 'PMPro MailPoet', 'pmpro-mailpoet' ), 'manage_options', 'pmpro-mailpoet', 'pmpro_mailpoet_render_adminpage' );
add_submenu_page( 'pmpro-dashboard', __( 'MailPoet', 'mailpoet-paid-memberships-pro-add-on' ), __( 'PMPro MailPoet', 'mailpoet-paid-memberships-pro-add-on' ), 'manage_options', 'pmpro-mailpoet', 'pmpro_mailpoet_render_adminpage' );
}
}
add_action( 'admin_menu', 'pmpro_mailpoet_add_admin_page', 20 );
Expand All @@ -29,7 +29,7 @@ function pmpro_mailpoet_admin_bar_menu() {
array(
'id' => 'pmpro-mailpoet',
'parent' => 'paid-memberships-pro',
'title' => esc_html__( 'MailPoet', 'pmpro-mailpoet' ),
'title' => esc_html__( 'MailPoet', 'mailpoet-paid-memberships-pro-add-on' ),
'href' => get_admin_url(
null,
'/admin.php?page=pmpro-mailpoet'
Expand All @@ -48,7 +48,7 @@ function pmpro_mailpoet_render_adminpage() {
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br></div>
<h2><?php esc_html_e( 'Paid Memberships Pro - MailPoet Integration Settings', 'pmpro-mailpoet' ); ?></h2>
<h2><?php esc_html_e( 'Paid Memberships Pro - MailPoet Integration Settings', 'mailpoet-paid-memberships-pro-add-on' ); ?></h2>

<?php pmpro_mailpoet_admin_warnings(); ?>
<form action="options.php" method="post">
Expand All @@ -59,7 +59,7 @@ function pmpro_mailpoet_render_adminpage() {

<div class="bottom-buttons">
<input type="hidden" name="pmpro_mailpoet_options[set]" value="1"/>
<input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Settings', 'pmpro-mailpoet' ); ?>">
<input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e( 'Save Settings', 'mailpoet-paid-memberships-pro-add-on' ); ?>">
</div>

</form>
Expand All @@ -76,19 +76,19 @@ function pmpro_mailpoet_admin_init() {
register_setting( 'pmpro_mailpoet_options', 'pmpro_mailpoet_options', 'pmpro_mailpoet_options_validate' );

// General Settings.
add_settings_section( 'pmpro_mailpoet_section_opt_in_lists', esc_html__( 'General Settings', 'pmpro-mailpoet' ), '', 'pmpro_mailpoet_options' );
add_settings_field( 'pmpro_mailpoet_option_nonmember_lists', esc_html__( 'Non-Member Lists', 'pmpro-mailpoet' ), 'pmpro_mailpoet_option_nonmember_lists', 'pmpro_mailpoet_options', 'pmpro_mailpoet_section_opt_in_lists' );
add_settings_field( 'pmpro_mailpoet_option_opt_in_lists', esc_html__( 'Opt-in Lists', 'pmpro-mailpoet' ), 'pmpro_mailpoet_option_opt_in_lists', 'pmpro_mailpoet_options', 'pmpro_mailpoet_section_opt_in_lists' );
add_settings_section( 'pmpro_mailpoet_section_opt_in_lists', esc_html__( 'General Settings', 'mailpoet-paid-memberships-pro-add-on' ), '', 'pmpro_mailpoet_options' );
add_settings_field( 'pmpro_mailpoet_option_nonmember_lists', esc_html__( 'Non-Member Lists', 'mailpoet-paid-memberships-pro-add-on' ), 'pmpro_mailpoet_option_nonmember_lists', 'pmpro_mailpoet_options', 'pmpro_mailpoet_section_opt_in_lists' );
add_settings_field( 'pmpro_mailpoet_option_opt_in_lists', esc_html__( 'Opt-in Lists', 'mailpoet-paid-memberships-pro-add-on' ), 'pmpro_mailpoet_option_opt_in_lists', 'pmpro_mailpoet_options', 'pmpro_mailpoet_section_opt_in_lists' );

//SendWP Email Deliverability.
add_settings_field( 'pmpro_mailpoet_sendwp_cta', 'Email Deliverability', 'pmpro_mailpoet_sendwp_cta', 'pmpro_mailpoet_options', 'pmpro_mailpoet_section_opt_in_lists' );

add_settings_section( 'pmpro_mailpoet_section_membership_lists', esc_html__( 'Membership Lists', 'pmpro-mailpoet' ), 'pmpro_mailpoet_section_membership_lists', 'pmpro_mailpoet_options' );
add_settings_section( 'pmpro_mailpoet_section_membership_lists', esc_html__( 'Membership Lists', 'mailpoet-paid-memberships-pro-add-on' ), 'pmpro_mailpoet_section_membership_lists', 'pmpro_mailpoet_options' );
$levels = pmpro_mailpoet_get_all_levels();
foreach ( $levels as $level ) {
add_settings_field( 'pmpro_mailpoet_option_memberships_lists_' . (int) $level->id, esc_html( $level->name ), 'pmpro_mailpoet_option_memberships_lists', 'pmpro_mailpoet_options', 'pmpro_mailpoet_section_membership_lists', array( $level ) );
}
add_settings_field( 'pmpro_mailpoet_option_unsubscribe_on_level_change', esc_html__( 'Unsubscribe on Level Change?', 'pmpro-mailpoet' ), 'pmpro_mailpoet_option_unsubscribe_on_level_change', 'pmpro_mailpoet_options', 'pmpro_mailpoet_section_membership_lists' );
add_settings_field( 'pmpro_mailpoet_option_unsubscribe_on_level_change', esc_html__( 'Unsubscribe on Level Change?', 'mailpoet-paid-memberships-pro-add-on' ), 'pmpro_mailpoet_option_unsubscribe_on_level_change', 'pmpro_mailpoet_options', 'pmpro_mailpoet_section_membership_lists' );
}
add_action( 'admin_init', 'pmpro_mailpoet_admin_init' );

Expand Down Expand Up @@ -156,7 +156,7 @@ function pmpro_mailpoet_admin_warnings() {
if ( $show_error ) {
?>
<div class="notice notice-error">
<p><strong><?php esc_html_e( 'Membership lists lists cannot also be set as opt-in lists.', 'pmpro-mailpoet' ); ?></strong></p>
<p><strong><?php esc_html_e( 'Membership lists lists cannot also be set as opt-in lists.', 'mailpoet-paid-memberships-pro-add-on' ); ?></strong></p>
</div>
<?php
}
Expand All @@ -169,7 +169,7 @@ function pmpro_mailpoet_admin_warnings() {
*/
function pmpro_mailpoet_section_membership_lists() {
?>
<p><?php esc_html_e( 'Users will automatically be subscribed to selected lists when they receive the corresponding membership level.', 'pmpro-mailpoet' ); ?></p>
<p><?php esc_html_e( 'Users will automatically be subscribed to selected lists when they receive the corresponding membership level.', 'mailpoet-paid-memberships-pro-add-on' ); ?></p>
<?php
}

Expand All @@ -191,7 +191,7 @@ function pmpro_mailpoet_option_memberships_lists( $level ) {
*/
function pmpro_mailpoet_option_nonmember_lists() {
pmpro_mailpoet_settings_build_list_checkboxes_helper( 'nonmember_lists' );
echo '<p class="description">' . esc_html__( 'Users will automatically be subscribed to non-member lists when they register without purchasing a membership level or when their membership level is removed.', 'pmpro-mailpoet' ) . '</p>';
echo '<p class="description">' . esc_html__( 'Users will automatically be subscribed to non-member lists when they register without purchasing a membership level or when their membership level is removed.', 'mailpoet-paid-memberships-pro-add-on' ) . '</p>';
}

/**
Expand All @@ -204,8 +204,8 @@ function pmpro_mailpoet_option_unsubscribe_on_level_change() {

?>
<select name="pmpro_mailpoet_options[unsubscribe_on_level_change]">
<option value="0" <?php selected( $options['unsubscribe_on_level_change'], 0 ); ?>><?php esc_html_e( 'No.', 'pmpro-mailpoet' ); ?></option>
<option value="1" <?php selected( $options['unsubscribe_on_level_change'], 1 ); ?>><?php esc_html_e( 'Yes, unsubscribe from old membership lists on level change.', 'pmpro-mailpoet' ); ?></option>
<option value="0" <?php selected( $options['unsubscribe_on_level_change'], 0 ); ?>><?php esc_html_e( 'No.', 'mailpoet-paid-memberships-pro-add-on' ); ?></option>
<option value="1" <?php selected( $options['unsubscribe_on_level_change'], 1 ); ?>><?php esc_html_e( 'Yes, unsubscribe from old membership lists on level change.', 'mailpoet-paid-memberships-pro-add-on' ); ?></option>
</select>
<?php
}
Expand All @@ -227,24 +227,24 @@ function pmpro_mailpoet_sendwp_cta() {
),
'em' => array(),
);
echo sprintf( wp_kses( __( 'If you are having issues with email delivery from your server, <a href="%s" title="Paid Memberships Pro - Subscription Delays Add On" target="_blank" rel="nofollow noopener">please read our email troubleshooting guide</a>. As an alternative, Paid Memberships Pro offers built-in integration for SendWP. <em>Optional: SendWP is a third-party service for transactional email in WordPress. <a href="%s" title="Documentation on SendWP and Paid Memberships Pro" target="_blank" rel="nofollow noopener">Click here to learn more about SendWP and Paid Memberships Pro</a></em>.', 'pmpro-mailpoet' ), $allowed_email_troubleshooting_html ), 'https://www.paidmembershipspro.com/troubleshooting-email-issues-sending-sent-spam-delivery-delays/?utm_source=plugin&utm_medium=pmpro-emailsettings&utm_campaign=blog&utm_content=email-troubleshooting', 'https://www.paidmembershipspro.com/documentation/member-communications/email-delivery-sendwp/?utm_source=plugin&utm_medium=pmpro-emailsettings&utm_campaign=documentation&utm_content=sendwp' );
echo sprintf( wp_kses( __( 'If you are having issues with email delivery from your server, <a href="%s" title="Paid Memberships Pro - Subscription Delays Add On" target="_blank" rel="nofollow noopener">please read our email troubleshooting guide</a>. As an alternative, Paid Memberships Pro offers built-in integration for SendWP. <em>Optional: SendWP is a third-party service for transactional email in WordPress. <a href="%s" title="Documentation on SendWP and Paid Memberships Pro" target="_blank" rel="nofollow noopener">Click here to learn more about SendWP and Paid Memberships Pro</a></em>.', 'mailpoet-paid-memberships-pro-add-on' ), $allowed_email_troubleshooting_html ), 'https://www.paidmembershipspro.com/troubleshooting-email-issues-sending-sent-spam-delivery-delays/?utm_source=plugin&utm_medium=pmpro-emailsettings&utm_campaign=blog&utm_content=email-troubleshooting', 'https://www.paidmembershipspro.com/documentation/member-communications/email-delivery-sendwp/?utm_source=plugin&utm_medium=pmpro-emailsettings&utm_campaign=documentation&utm_content=sendwp' );
?></p>

<?php
// Check to see if connected or not.
$sendwp_connected = function_exists( 'sendwp_client_connected' ) && sendwp_client_connected() ? true : false;

if ( ! $sendwp_connected ) { ?>
<p><button id="pmpro-sendwp-connect" class="button"><?php esc_html_e( 'Connect to SendWP', 'pmpro-mailpoet' ); ?></button></p>
<p><button id="pmpro-sendwp-connect" class="button"><?php esc_html_e( 'Connect to SendWP', 'mailpoet-paid-memberships-pro-add-on' ); ?></button></p>
<?php } else { ?>
<p><button id="pmpro-sendwp-disconnect" class="button-primary"><?php esc_html_e( 'Disconnect from SendWP', 'pmpro-mailpoet' ); ?></button></p>
<p><button id="pmpro-sendwp-disconnect" class="button-primary"><?php esc_html_e( 'Disconnect from SendWP', 'mailpoet-paid-memberships-pro-add-on' ); ?></button></p>
<?php
// Update SendWP status to see if email forwarding is enabled or not.
$sendwp_email_forwarding = function_exists( 'sendwp_forwarding_enabled' ) && sendwp_forwarding_enabled() ? true : false;

// Messages for connected or not.
$connected = __( 'Your site is connected to SendWP.', 'pmpro-mailpoet' ) . " <a href='https://app.sendwp.com/dashboard/' target='_blank' rel='nofollow noopener'>" . __( 'View Your SendWP Account', 'pmpro-mailpoet' ) . "</a>";
$disconnected = ' ' . sprintf( __( 'Please enable email sending inside %s.', 'pmpro-mailpoet' ), '<a href="' . admin_url('/tools.php?page=sendwp') . '">SendWP Settings</a>' );
$connected = __( 'Your site is connected to SendWP.', 'mailpoet-paid-memberships-pro-add-on' ) . " <a href='https://app.sendwp.com/dashboard/' target='_blank' rel='nofollow noopener'>" . __( 'View Your SendWP Account', 'mailpoet-paid-memberships-pro-add-on' ) . "</a>";
$disconnected = ' ' . sprintf( __( 'Please enable email sending inside %s.', 'mailpoet-paid-memberships-pro-add-on' ), '<a href="' . admin_url('/tools.php?page=sendwp') . '">SendWP Settings</a>' );
?>
<p class="description" id="pmpro-sendwp-description"><?php echo $sendwp_email_forwarding ? $connected : $disconnected; ?></p>
<?php }
Expand All @@ -259,7 +259,7 @@ function pmpro_mailpoet_sendwp_cta() {
*/
function pmpro_mailpoet_option_opt_in_lists() {
pmpro_mailpoet_settings_build_list_checkboxes_helper( 'opt-in_lists' );
echo '<p class="description">' . esc_html__( 'Give users the option to subscribe to additional lists at checkout and on their profile page.', 'pmpro-mailpoet' ) . '</p>';
echo '<p class="description">' . esc_html__( 'Give users the option to subscribe to additional lists at checkout and on their profile page.', 'mailpoet-paid-memberships-pro-add-on' ) . '</p>';

}

Expand Down Expand Up @@ -293,6 +293,6 @@ function pmpro_mailpoet_settings_build_list_checkboxes_helper( $option_name ) {
?>
</div> <!-- end pmpro_checkbox_box -->
<?php } else {
esc_html_e( 'No lists found.', 'pmpro-mailpoet' );
esc_html_e( 'No lists found.', 'mailpoet-paid-memberships-pro-add-on' );
}
}
12 changes: 6 additions & 6 deletions pmpro-mailpoet.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Version: 3.0
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
Text Domain: pmpro-mailpoet
Text Domain: mailpoet-paid-memberships-pro-add-on
*/

define( 'PMPRO_MAILPOET_BASE_FILE', __FILE__ );
Expand All @@ -32,7 +32,7 @@ function pmpro_mailpoet_show_notice() {
if ( ! empty( $_REQUEST['page'] ) && sanitize_text_field( $_REQUEST['page'] ) == 'pmpro-mailpoet' ) {
$mailpoet_v3_org = 'https://wordpress.org/plugins/mailpoet/';
$msgt = sprintf(
__( "In order for <strong>Paid Memberships Pro - MailPoet Integration</strong> to function correctly, you must install or activate the latest version of <a href='%s' target='_blank'>MailPoet v3</a>.", 'pmpro-mailpoet' ),
__( "In order for <strong>Paid Memberships Pro - MailPoet Integration</strong> to function correctly, you must install or activate the latest version of <a href='%s' target='_blank'>MailPoet v3</a>.", 'mailpoet-paid-memberships-pro-add-on' ),
esc_url( $mailpoet_v3_org )
);

Expand All @@ -49,7 +49,7 @@ function pmpro_mailpoet_show_notice() {
* @since 3.0
*/
function pmpro_mailpoet_load_textdomain() {
load_plugin_textdomain( 'pmpro-mailpoet', false, basename( dirname( __FILE__ ) ) . '/languages' );
load_plugin_textdomain( 'mailpoet-paid-memberships-pro-add-on', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
add_action( 'plugins_loaded', 'pmpro_mailpoet_load_textdomain' );

Expand All @@ -64,7 +64,7 @@ function pmpro_mailpoet_load_textdomain() {
function pmpro_mailpoet_add_action_links( $links ) {

$new_links = array(
'<a href="' . get_admin_url( null, 'options-general.php?page=pmpro_mailpoet_options' ) . '">' . __( 'Settings', 'pmpro-mailpoet' ) . '</a>',
'<a href="' . get_admin_url( null, 'options-general.php?page=pmpro_mailpoet_options' ) . '">' . __( 'Settings', 'mailpoet-paid-memberships-pro-add-on' ) . '</a>',
);
return array_merge( $new_links, $links );
}
Expand All @@ -82,8 +82,8 @@ function pmpro_mailpoet_add_action_links( $links ) {
function pmpro_mailpoet_plugin_row_meta( $links, $file ) {
if ( strpos( $file, 'pmpro-mailpoet.php' ) !== false ) {
$new_links = array(
'<a href="' . esc_url( 'https://www.paidmembershipspro.com/add-ons/pmpro-mailpoet-integration/' ) . '" title="' . esc_attr( __( 'View Documentation', 'pmpro-mailpoet' ) ) . '">' . __( 'Docs', 'pmpro-mailpoet' ) . '</a>',
'<a href="' . esc_url( 'https://www.paidmembershipspro.com/support/' ) . '" title="' . esc_attr( __( 'Visit Customer Support Forum', 'pmpro-mailpoet' ) ) . '">' . __( 'Support', 'pmpro-mailpoet' ) . '</a>',
'<a href="' . esc_url( 'https://www.paidmembershipspro.com/add-ons/pmpro-mailpoet-integration/' ) . '" title="' . esc_attr( __( 'View Documentation', 'mailpoet-paid-memberships-pro-add-on' ) ) . '">' . __( 'Docs', 'mailpoet-paid-memberships-pro-add-on' ) . '</a>',
'<a href="' . esc_url( 'https://www.paidmembershipspro.com/support/' ) . '" title="' . esc_attr( __( 'Visit Customer Support Forum', 'mailpoet-paid-memberships-pro-add-on' ) ) . '">' . __( 'Support', 'mailpoet-paid-memberships-pro-add-on' ) . '</a>',
);
$links = array_merge( $links, $new_links );
}
Expand Down

0 comments on commit 3ab8358

Please sign in to comment.