Skip to content

Commit

Permalink
Merge pull request #179 from WebDevStudios/release220
Browse files Browse the repository at this point in the history
Release 2.2.0
  • Loading branch information
tw2113 authored Oct 25, 2023
2 parents a4a648e + 209b725 commit c4bf8cc
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 25 deletions.
33 changes: 12 additions & 21 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
=== Constant Contact + WooCommerce ===
Contributors: constantcontact, webdevstudios, znowebdev, jmichaelward, ggwicz, ravedev, newyorkerlaura
Tags: Constant Contact, WooCommerce, eCommerce, email marketing, marketing automation, email, form, forms, marketing, mobile, opt-in, plugin, signup, subscribe, subscription, widget
Tags: Constant Contact, WooCommerce, ecommerce, email marketing, marketing automation, marketing, opt in, abandoned cart
Requires at least: 5.2.2
Tested up to: 6.2.2
Stable tag: 2.1.2
Tested up to: 6.3.2
Stable tag: 2.2.0
Requires PHP: 7.2
License: GPLv3

Expand All @@ -22,28 +22,16 @@ https://www.youtube.com/watch?v=ZH9G4yhAngk
**With Constant Contact you can:**

* Easily connect WooCommerce to your Constant Contact account and sync contacts automatically.

* Drag and drop a product(s) from your WooCommerce catalog and insert them into your email in seconds.

* Target the right customer/prospect with the right message with predefined segments based on your customers’ purchasing behavior:


* All WooCommerce contacts who opt in to receive email e-marketing

* Recent Customers: Purchased within 30 days

* First-time Customers: Purchased once

* Repeat Customers: Made more than one purchase

* Lapsed Customers: Have not made a purchase in more than 120 days

* Prospects: Have not made a purchase yet

* All WooCommerce contacts who opt in to receive email marketing
* Recent Customers: Purchased within 30 days
* First-time Customers: Purchased once
* Repeat Customers: Made more than one purchase
* Lapsed Customers: Have not made a purchase in more than 120 days
* Prospects: Have not made a purchase yet
* Bring customers back to your online store with automated, targeted emails.

* Find new customers with our social marketing and advertising tools to expand your reach.

* Automatically send a customized branded abandoned cart email to customers who left items in their cart and track resulting revenue.

== Screenshots ==
Expand Down Expand Up @@ -83,6 +71,9 @@ You've connected your WooCommerce store to Constant Contact, promoted your WooCo

== Changelog ==

= 2.2.0 =
* Added - Initial support for integration with WordPress Site Health Panel, including connection status, key status, and abandoned cart status.

= 2.1.2 =
* Fixed - `enableStoreDetails` javascript console error.
* Fixed - PHP8 compatibility errors.
Expand Down
6 changes: 6 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,11 @@
"phpcs.xml.dist",
"tags"
]
},
"config": {
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
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-woocommerce",
"version": "2.1.1",
"version": "2.2.0",
"description": "",
"main": "index.js",
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
* Plugin Name: Constant Contact + WooCommerce
* Description: Add products to your emails and sync your contacts.
* Plugin URI: https://github.com/WebDevStudios/constant-contact-woocommerce
* Version: 2.1.2
* Version: 2.2.0
* Author: Constant Contact
* Author URI: https://www.constantcontact.com/
* Text Domain: constant-contact-woocommerce
* WC requires at least: 3.6.0
* WC tested up to: 6.8.2
* WC tested up to: 8.1.1
* Requires PHP: 7.2
* License: GPL-3.0+
* License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
Expand Down
8 changes: 7 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Exception;

use WebDevStudios\CCForWoo\Utility\HealthPanel;
use WebDevStudios\CCForWoo\Utility\PluginCompatibilityCheck;
use WebDevStudios\OopsWP\Structure\ServiceRegistrar;
use WebDevStudios\CCForWoo\View\ViewRegistrar;
Expand Down Expand Up @@ -47,7 +48,7 @@ final class Plugin extends ServiceRegistrar {
* @since 1.0.0
* @var string
*/
const PLUGIN_VERSION = '2.0.3';
const PLUGIN_VERSION = '2.2.0';

/**
* Whether the plugin is currently active.
Expand Down Expand Up @@ -211,6 +212,7 @@ public function register_hooks() {
add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ], 99 );
add_action( 'init', [ $this, 'load_plugin_textdomain' ] );
add_action( 'init', [ $this, 'load_health_panel' ] );

register_activation_hook( $this->plugin_file, [ $this, 'do_activation_process' ] );
register_deactivation_hook( $this->plugin_file, [ $this, 'do_deactivation_process' ] );
Expand Down Expand Up @@ -377,5 +379,9 @@ public function admin_enqueue_scripts() {
public function load_plugin_textdomain() {
load_plugin_textdomain( 'constant-contact-woocommerce' );
}

public function load_health_panel() {
new HealthPanel();
}
}

128 changes: 128 additions & 0 deletions src/Utility/HealthPanel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?php
/**
* Constant Contact + WooCommerce Health Panel
*
* Adds debugging information to the Site Health panel.
*
* @since 2.2.0
* @package cc-woo
*/

namespace WebDevStudios\CCForWoo\Utility;

use WebDevStudios\CCForWoo\Meta\ConnectionStatus;
use WebDevStudios\CCForWoo\Plugin;
use WebDevStudios\CCForWoo\AbandonedCheckouts\CheckoutsTable;

/**
* Class HealthPanel
*
* @package WebDevStudios\CCForWoo\Utility
* @since 2.2.0
*/
class HealthPanel {

public function __construct() {
add_filter( 'debug_information', [ $this, 'health_information' ], 1 );
}

/**
* Callback to add in our own cusotm site health information.
*
* @since 2.2.0
*
* @throws Exception
*
* @param array $debug_info Array of debug info panels.
* @return array
*/
public function health_information( $debug_info ) {

$connection = new ConnectionStatus();
$debug_info['constant-contact-woocommerce'] = [
'label' => esc_html__( 'Constant Contact + WooCommerce', 'constant-contact-woocommerce' ),
'description' => esc_html__( 'Debugging and troubleshooting information for support purposes', 'constant-contact-woocommerce' ),
'fields' => [
[
'label' => esc_html__( 'Plugin version', 'constant-contact-woocommerce' ),
'value' => Plugin::PLUGIN_VERSION,
],
[
'label' => esc_html__( 'Connection status', 'constant-contact-woocommerce' ),
'value' => ( $connection->is_connected() )
? esc_html__( 'Connected', 'constant-contact-woocommerce' )
: esc_html__( 'Disconnected', 'constant-contact-woocommerce' )
],
[
'label' => esc_html__( 'Abandoned checkouts total pending items', 'constant-contact-woocommerce' ),
'value' => $this->abandoned_checkouts_count(),
],
[
'label' => esc_html__( 'Abandoned checkouts expiration cron status', 'constant-contact-woocommerce' ),
'value' => ( wp_next_scheduled( 'cc_woo_check_expired_checkouts' ) )
? esc_html__( 'Scheduled', 'constant-contact-woocommerce' )
: esc_html__( 'Not scheduled', 'constant-contact-woocommerce' ),
],
[
'label' => esc_html__( 'Current user has a CC key', 'constant-contact-woocommerce' ),
'value' => ( $this->user_has_cc_key() )
? esc_html__( 'True', 'constant-contact-woocommerce' )
: esc_html__( 'False', 'constant-contact-woocommerce' ),
],
]
];

return $debug_info;
}

/**
* Check if the current user has a Constant Contact API key.
*
* @since 2.2.0
*
* @return bool
*/
private function user_has_cc_key(): bool {
$user_id = get_current_user_id();

if ( ! $user_id ) {
return false;
}

$query = <<<SQL
SELECT
key_id
FROM
{$GLOBALS['wpdb']->prefix}woocommerce_api_keys
WHERE
user_id = %d
AND
(
description LIKE '%Constant Contact%'
OR
description LIKE '%ConstantContact%'
)
SQL;

return ! empty( $GLOBALS['wpdb']->get_col( $GLOBALS['wpdb']->prepare( $query, $user_id ) ) );
}

/**
* Returns a count of total abandoned checkouts.
*
* @since 2.2.0
*
* @return string
*/
private function abandoned_checkouts_count() : string {
$table = CheckoutsTable::get_table_name();
$query = <<<SQL
SELECT
count(*)
FROM
{$table}
SQL;
$count = (string) $GLOBALS['wpdb']->get_var( $query );
return ( ! empty( $count ) ) ? $count : '0';
}
}

0 comments on commit c4bf8cc

Please sign in to comment.