Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/cc 440 comment login signup errors #683

Open
wants to merge 6 commits into
base: release270
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed assets/images/add-forms.png
Binary file not shown.
Binary file removed assets/images/builder.png
Binary file not shown.
Binary file removed assets/images/cc-login-connect.png
Binary file not shown.
Binary file removed assets/images/cc-modal-bg.png
Binary file not shown.
Binary file removed assets/images/cc-modal-logo.png
Binary file not shown.
Binary file removed assets/images/coffee-hero.jpg
Binary file not shown.
Binary file removed assets/images/constant-contact-logo.png
Binary file not shown.
Binary file removed assets/images/contacts.png
Binary file not shown.
8 changes: 8 additions & 0 deletions assets/images/createAccount.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/form-display.png
Binary file not shown.
Binary file removed assets/images/icon.jpg
Binary file not shown.
9 changes: 9 additions & 0 deletions assets/images/login.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/logo-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/question-mail-connect.png
Binary file not shown.
Binary file removed assets/images/reporting.png
Binary file not shown.
Binary file removed assets/images/stay-connected.png
Binary file not shown.
2 changes: 1 addition & 1 deletion assets/js/ctct-plugin-admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/ctct-plugin-admin.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/ctct-plugin-admin.min.js.map

Large diffs are not rendered by default.

78 changes: 49 additions & 29 deletions assets/js/ctct-plugin-admin/optins.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
window.CTCT_OptIns = {};

( function( window, $, app ) {
( function( window, app ) {

/**
* @constructor
Expand All @@ -20,12 +20,12 @@ window.CTCT_OptIns = {};
* @since 1.0.0
*/
app.cache = () => {
app.$c = {
optinNoConn: $( '#cmb2-metabox-ctct_1_optin_metabox #_ctct_opt_in_not_connected' ),
list: $( '#cmb2-metabox-ctct_0_list_metabox [name="_ctct_list[]"]' ),
title: $( '#cmb2-metabox-ctct_1_optin_metabox .cmb2-id-email-optin-title' ),
optin: $( '#cmb2-metabox-ctct_1_optin_metabox .cmb2-id--ctct-opt-in' ),
instruct: $( '#cmb2-metabox-ctct_1_optin_metabox .cmb2-id--ctct-opt-in-instructions' )
app.cache = {
optinNoConn: document.querySelectorAll( '#cmb2-metabox-ctct_1_optin_metabox #_ctct_opt_in_not_connected' ),
list: document.querySelectorAll('#cmb2-metabox-ctct_0_list_metabox .attached-posts-wrap .attached li'),
title: document.querySelectorAll( '#cmb2-metabox-ctct_1_optin_metabox .cmb2-id-email-optin-title' ),
optin: document.querySelectorAll( '#cmb2-metabox-ctct_1_optin_metabox .cmb2-id--ctct-opt-in' ),
instruct: document.querySelectorAll( '#cmb2-metabox-ctct_1_optin_metabox .cmb2-id--ctct-opt-in-instructions' )
};
};

Expand All @@ -38,27 +38,32 @@ window.CTCT_OptIns = {};
app.bindEvents = () => {

// Only fire show/hide if we have the normal checkbox.
if ( app.$c.optinNoConn.length ) {
if ( app.cache.optinNoConn.length ) {

// Fire once to get our loaded state set up.
app.toggleNoConnectionFields();

// Bind to fire when needed.
app.$c.optinNoConn.change( () => {
app.toggleNoConnectionFields();
} );
Array.from(app.cache.optinNoConn).forEach((item) => {
item.addEventListener('change', () => {
app.toggleNoConnectionFields();
});
});
}

// Only fire show/hide if we have the normal checkbox.
if ( app.$c.list.length ) {
if ( app.cache.list.length ) {

// Fire once to get our loaded state set up.
app.toggleConnectionFields();

// Bind to fire when needed.
app.$c.list.change( () => {
app.toggleConnectionFields();
} );
Array.from(app.cache.list).forEach((item) => {
item.addEventListener('change', () => {
app.toggleConnectionFields();
});
})

}
};

Expand All @@ -69,11 +74,14 @@ window.CTCT_OptIns = {};
* @since 1.0.0
*/
app.toggleNoConnectionFields = () => {

if ( app.$c.optinNoConn.prop( 'checked' ) ) {
app.$c.instruct.slideDown();
if ( app.cache.optinNoConn.checked ) {
Array.from(app.cache.instruct).forEach((item) => {
item.style.display = 'block';
});
} else {
app.$c.instruct.slideUp();
Array.from(app.cache.instruct).forEach((item) => {
item.style.display = 'none';
});
}
};

Expand All @@ -86,17 +94,29 @@ window.CTCT_OptIns = {};
app.toggleConnectionFields = () => {

// If checked, show them, else hide it.
if ( '' !== app.$c.list.val() ) {
app.$c.title.slideDown();
app.$c.optin.slideDown();
app.$c.instruct.slideDown();
if ( 0 <= app.cache.list.length ) {
Array.from(app.cache.title).forEach((item) => {
item.style.display = 'block';
});
Array.from(app.cache.optin).forEach((item) => {
item.style.display = 'block';
});
Array.from(app.cache.instruct).forEach((item) => {
item.style.display = 'block';
});
//app.cache.instruct.slideDown();
} else {
app.$c.title.slideUp();
app.$c.optin.slideUp();
app.$c.instruct.slideUp();
Array.from(app.cache.title).forEach((item) => {
item.style.display = 'none';
});
Array.from(app.cache.optin).forEach((item) => {
item.style.display = 'none';
});
Array.from(app.cache.instruct).forEach((item) => {
item.style.display = 'none';
});
}
};

$( app.init );

} ( window, jQuery, window.CTCT_OptIns ) );
app.init();
} ( window, window.CTCT_OptIns ) );
4 changes: 2 additions & 2 deletions constant-contact-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Constant Contact Forms for WordPress
* Plugin URI: https://www.constantcontact.com
* Description: Be a better marketer. All it takes is Constant Contact email marketing.
* Version: 2.6.0
* Version: 2.6.1
* Author: Constant Contact
* Author URI: https://www.constantcontact.com/index?pn=miwordpress
* Requires PHP: 7.4
Expand Down Expand Up @@ -76,7 +76,7 @@ class Constant_Contact {
* @since 1.0.0
* @var string
*/
const VERSION = '2.6.0';
const VERSION = '2.6.1';

/**
* URL of plugin directory.
Expand Down
7 changes: 3 additions & 4 deletions includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public function add_social_links( $links ) {
return $links;
}

$twitter_cta = esc_html__( 'Check out the official WordPress plugin from @constantcontact:', 'constant-contact-forms' );
$x_cta = esc_html__( 'Check out the official WordPress plugin from @constantcontact:', 'constant-contact-forms' );

$add_links[] = $this->get_admin_link( esc_html__( 'About', 'constant-contact-forms' ), 'about' );
$add_links[] = $this->get_admin_link( esc_html__( 'License', 'constant-contact-forms' ), 'license' );
Expand All @@ -520,12 +520,11 @@ public function add_social_links( $links ) {
*
* @param string $value Social URL base.
*/
$site_link = apply_filters( 'constant_contact_social_base_url', 'https://constantcontact.com/' );
$site_link = esc_url( apply_filters( 'constant_contact_social_base_url', 'https://constantcontact.com/' ) );

$social_share = esc_html__( 'Spread the word!', 'constant-contact-forms' );
$add_links[] = '<a title="' . $social_share . '" href="https://www.facebook.com/sharer/sharer.php?u=' . rawurlencode( $site_link ) . '" target="_blank" rel="noopener noreferrer" class="dashicons-before dashicons-facebook"></a>';
$add_links[] = '<a title="' . $social_share . '" href="https://twitter.com/home?status=' . $twitter_cta . ' ' . $site_link . '" target="_blank" rel="noopener noreferrer" class="dashicons-before dashicons-twitter"></a>';
$add_links[] = '<a title="' . $social_share . '" href="https://plus.google.com/share?url=' . rawurlencode( $site_link ) . '" target="_blank" rel="noopener noreferrer" class="dashicons-before dashicons-googleplus"></a>';
$add_links[] = '<a title="' . $social_share . '" href="https://x.com/intent/post?text=' . $x_cta . ' ' . $site_link . '" target="_blank" rel="noopener noreferrer"><img src="' . esc_url( constant_contact()->url ) . '/assets/images/logo-black.png" alt="' . esc_attr__( 'X logo', 'constant-contact-forms' ) . '" style="height:16px;width:16px;float:none;"></a>';

/**
* Filters the final custom social links.
Expand Down
10 changes: 2 additions & 8 deletions includes/class-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public function output_not_connected_modal( $post_id = 0 ) {
<?php // Empty alt tag OK; decorative image. ?>
<img
class="ctct-modal-flare"
src="<?php echo esc_url_raw( $this->plugin->url . 'assets/images/question-mail.png' ); ?>"
src="<?php echo esc_url_raw( $this->plugin->url . 'assets/images/createAccount.svg' ); ?>"
alt=""
/>
<h3><?php esc_attr_e( 'Try email marketing.', 'constant-contact-forms' ); ?></h3>
Expand All @@ -331,19 +331,13 @@ class="ctct-modal-flare"
</p>
<a href="<?php echo esc_url_raw( constant_contact()->api->get_signup_link() ); ?>" target="_blank" rel="noopener noreferrer" class="button button-orange" title="<?php esc_attr_e( 'Try Us Free', 'constant-contact-forms' ); ?>"><?php esc_html_e( 'Try Us Free', 'constant-contact-forms' ); ?></a><br/>

<?php // Empty alt tag OK; decorative image. ?>
<img
class="flare"
src="<?php echo esc_url_raw( $this->plugin->url . 'assets/images/cc-modal-logo.png' ); ?>"
alt=""
/>
</div>
<div class="ctct-modal-right">

<?php // Empty alt tag OK; decorative image. ?>
<img
class="ctct-modal-flare"
src="<?php echo esc_url_raw( $this->plugin->url . 'assets/images/cc-login.png' ); ?>"
src="<?php echo esc_url_raw( $this->plugin->url . 'assets/images/login.svg' ); ?>"
alt=""
/>
<h3><?php esc_attr_e( 'Connect my account.', 'constant-contact-forms' ); ?></h3>
Expand Down
11 changes: 8 additions & 3 deletions includes/class-mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,15 @@ public function mail( $destination_email, $content, $submission_details, $was_fo

$content_title = '<p><strong>' . esc_html__( 'Form title: ', 'constant-contact-forms' ) . '</strong>' . get_the_title( $submission_details['form_id'] ) . '<br/>';

$list_ids = get_post_meta( (int) $submission_details['form_id'], '_ctct_list', true );
if ( ! is_array( $list_ids ) ) {
$list_ids = [ $list_ids ];
if ( ! empty( $_POST ) && is_array( $_POST ) ) { //phpcs:ignore
foreach( $_POST as $key => $value ) { //phpcs:ignore
if ( false !== strpos( $key, 'lists' ) ) {
$list_ids = array_map( 'sanitize_text_field', array_values( $value ) );
break;
}
}
}

foreach ( $list_ids as $list_id ) {
$list_info = constant_contact()->api->cc()->get_list( $list_id );
if ( ! empty( $list_info ) && isset( $list_info['name'] ) ) {
Expand Down
36 changes: 26 additions & 10 deletions includes/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,20 @@ protected function register_fields_general() {
]
);

$lists = constant_contact()->builder->get_lists();
$lists = constant_contact()->builder->get_lists();
$woo_lists = [
'WooCommerce - All Customers',
'WooCommerce - First time Customers',
'WooCommerce - Lapsed Customers',
'WooCommerce - Potential Customers',
'WooCommerce - Recent Customers',
'WooCommerce - Repeat Customers',
];
foreach( $lists as $list_id => $list_name ) {
if ( in_array( $list_name, $woo_lists ) ) {
unset( $lists[ $list_id ] );
}
}

if ( $lists && is_array( $lists ) ) {

Expand All @@ -391,8 +404,6 @@ protected function register_fields_general() {
]
);

$lists[0] = esc_html__( 'Select a list', 'constant-contact-forms' );

$cmb->add_field(
[
'name' => esc_html__( 'Add subscribers to', 'constant-contact-forms' ),
Expand Down Expand Up @@ -735,12 +746,14 @@ public function optin_form_field() {
if ( ! constant_contact()->api->is_connected() ) {
return;
}

$saved_label = constant_contact_get_option( '_ctct_optin_label', '' );

$lists = $this->get_optin_list_options();
$label = $saved_label ?: esc_html__( 'Sign up to our newsletter.', 'constant-contact-forms' );

if ( empty( $lists ) ) {
return;
}

$saved_label = constant_contact_get_option( '_ctct_optin_label', '' );
$label = $saved_label ?: esc_html__( 'Sign up to our newsletter.', 'constant-contact-forms' );
?>
<p class="ctct-optin-wrapper" style="padding: 0 0 1em 0;">
<p><?php echo esc_attr( $label ); ?></p>
Expand Down Expand Up @@ -1078,7 +1091,7 @@ private function get_default_spam_error() {
}

/**
* Returns formated list of available lists during opt-in.
* Returns formatted list of available lists during opt-in.
*
* @author Scott Anderson <[email protected]>
* @since 1.12.0
Expand All @@ -1099,8 +1112,11 @@ private function get_optin_list_options() {
];
$list = get_posts( $list_args );

$formatted_lists[ $list_id ] = $list[0]->post_title;
if ( ! empty( $list ) ) {
$formatted_lists[ $list_id ] = $list[0]->post_title;
}
}

return $formatted_lists;
}
}
Expand All @@ -1122,7 +1138,7 @@ function constant_contact_get_option( $key = '', $default = null ) {
return cmb2_get_option( constant_contact()->settings->key, $key, $default );
}

$options = get_option( constant_contact()->settings->key, $key, $default );
$options = get_option( $key, $default );
$value = $default;

if ( 'all' === $key ) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "constant-contact-forms",
"version": "2.6.0",
"version": "2.6.1",
"description": "",
"main": "build/index.js",
"engines": {
Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: constantcontact, webdevstudios, tw2113, znowebdev, ggwicz, ra
Tags: constant contact, constant contact official, marketing, newsletter, contacts
Requires at least: 5.2.0
Tested up to: 6.5.4
Stable tag: 2.6.0
Stable tag: 2.6.1
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Requires PHP: 7.4
Expand Down Expand Up @@ -49,6 +49,12 @@ Development of Constant Contact Forms plugin occurs on [GitHub](https://github.c

== Changelog ==

= 2.6.1 =
* Fixed: Issues around opt-in option display that were introduced with version 2.6.0.
* Fixed: Issues regarding lists display in admin emails after user signup.
* Updated: Removed unused images and changed some.
* Updated: Social sharing icons in plugin list page.

= 2.6.0 =
* Updated: Amended the list selection process for a given form. Should not break existing forms, and now you can make use of drag-n-drop to order the list selection when offering multiple lists.
* Updated: reworked the underpinning of the Constant Contact block to be more in line with modern WordPress coding patterns, including block.json based. Should not break existing forms.
Expand Down
2 changes: 1 addition & 1 deletion src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "constant-contact/single-contact-form",
"version": "2.6.0",
"version": "2.6.1",
"title": "Constant Contact: Single Form",
"category": "widgets",
"icon": "index-card",
Expand Down