Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
* Added event triggers for WordPress core and plugin updates
* Fixed PHP warnings preparing nested arrays for user meta
  • Loading branch information
jack-arturo committed Jan 30, 2025
1 parent 7b1ec16 commit 7891ee8
Show file tree
Hide file tree
Showing 27 changed files with 506 additions and 140 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ wp-config.php
#/wp-content/themes
echodash.code-workspace
.DS_Store
composer.lock
vendor/*
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![EchoDash Banner](assets/banner-1544x500.jpg)](https://echodash.com)

# EchoDash for WordPress

Track user events and interactions across your WordPress site with EchoDash analytics. Built for developers and site owners who need detailed insights into user behavior across multiple WordPress plugins.
Expand All @@ -14,7 +16,7 @@ Track user events and interactions across your WordPress site with EchoDash anal
## Requirements

- WordPress 6.0+
- PHP 7.0+
- PHP 7.4+

## Installation

Expand Down Expand Up @@ -190,10 +192,10 @@ add_filter( 'echodash_your-integration_triggers', function( $triggers ) {

## Support

- Documentation: https://echodash.com/docs/
- Documentation: https://echodash.com/docs/echodash-plugin/
- Support: https://echodash.com/support/
- Issues: Create a GitHub issue
- Issues: [Create a GitHub issue](../../issues/new)

## License

GPL v2 or later
GPL v3 or later
Binary file added assets/banner-1544x500.jpg
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/banner-772x250.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/echodash-admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
jQuery(function ($) {
var EchoDash = {
init: function () {

this.optionPageRepeater();
this.multiKeyRepeater();

Expand Down
Binary file added assets/icon-128x128.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 added assets/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/icon.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/screenshot-1.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 added assets/screenshot-2.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 added assets/screenshot-3.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 added assets/screenshot-4.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 added assets/screenshot-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 25 additions & 10 deletions bin/phpstan-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
* @package EchoDash
*/

// WordPress core constants
if ( ! defined( 'ABSPATH' ) ) {
/**
* Absolute path to WordPress.
*
* @phpstan-type string $abspath
* @var string $abspath
*/
define( 'ABSPATH', '/path/to/wordpress/' );
define( 'ABSPATH', __DIR__ . '/../../' );
}

if ( ! defined( 'WP_PLUGIN_DIR' ) ) {
define( 'WP_PLUGIN_DIR', ABSPATH . 'wp-content/plugins' );
}

// EchoDash constants
if ( ! defined( 'ECHODASH_DIR_PATH' ) ) {
/**
* Directory path where EchoDash is located.
*
* @phpstan-type string $dir_path
* @var string $dir_path
*/
define( 'ECHODASH_DIR_PATH', 'path/to/echodash' );
define( 'ECHODASH_DIR_PATH', __DIR__ . '/' );
}

if ( ! defined( 'ECHODASH_PLUGIN_PATH' ) ) {
Expand All @@ -32,7 +32,7 @@
* @phpstan-type string $plugin_path
* @var string $plugin_path
*/
define( 'ECHODASH_PLUGIN_PATH', 'path/to/echodash' );
define( 'ECHODASH_PLUGIN_PATH', __DIR__ );
}

if ( ! defined( 'ECHODASH_DIR_URL' ) ) {
Expand All @@ -42,5 +42,20 @@
* @phpstan-type string $dir_url
* @var string $dir_url
*/
define( 'ECHODASH_DIR_URL', 'https://site.com/path/to/echodash' );
define( 'ECHODASH_DIR_URL', 'https://example.com/wp-content/plugins/echodash/' );
}

// WordPress Core stubs
if ( ! defined( 'COOKIEPATH' ) ) {
/**
* Cookie path.
*/
define( 'COOKIEPATH', 'path' );
}

if ( ! defined( 'COOKIEDOMAIN' ) ) {
/**
* Cookie domain.
*/
define( 'COOKIEDOMAIN', 'domain' );
}
36 changes: 30 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,38 @@
"name": "echodash/echodash",
"description": "Track user events and interactions from popular WordPress plugins in EchoDash analytics",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Jack Arturo",
"email": "[email protected]"
}
],
"scripts": {
"test": "./vendor/bin/phpunit -c phpunit.xml",
"phpstan": "./vendor/bin/phpstan analyse --memory-limit=2G",
"phpcs": "./vendor/bin/phpcs --standard=phpcs.xml"
},
"require": {
"php": ">=7.0",
"php": ">=7.4",
"composer/installers": "^2.0"
},
"config": {
"allow-plugins": {
"require-dev": {
"phpunit/phpunit": "^9.6",
"yoast/phpunit-polyfills": "^1.0",
"szepeviktor/phpstan-wordpress": "^2.0",
"phpstan/extension-installer": "^1.4",
"squizlabs/php_codesniffer": "^3.11",
"wp-coding-standards/wpcs": "^3.1",
"digitalrevolution/php-codesniffer-baseline": "^1.1",
"php-stubs/woocommerce-stubs": "^9.5"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true,
"digitalrevolution/php-codesniffer-baseline": true,
"composer/installers": true
}
}
}
}
}
52 changes: 25 additions & 27 deletions echodash.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* EchoDash - Event Tracking and Activity Log plugin for WordPress
* EchoDash - Event Tracking and Activity Log
*
* @package EchoDash
* @author EchoDash
Expand All @@ -12,7 +12,7 @@
* Plugin Name: EchoDash
* Plugin URI: https://echodash.com/
* Description: Track events from WordPress plugins as real-time activities in the EchoDash platform.
* Version: 1.0.2
* Version: 1.1.0
* Author: EchoDash
* Author URI: https://echodash.com/
* Text Domain: echodash
Expand Down Expand Up @@ -48,7 +48,7 @@
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

define( 'ECHODASH_VERSION', '1.0.2' );
define( 'ECHODASH_VERSION', '1.1.0' );

/**
* Class EchoDash
Expand All @@ -70,7 +70,7 @@ final class EchoDash {
/**
* Allows interfacing with the main class.
*
* @var EchoDash_Queue
* @var EchoDash_Public
* @since 1.0.0
*/
public $public;
Expand Down Expand Up @@ -107,7 +107,7 @@ final class EchoDash {
*/
public static function instance() {

if ( ! isset( self::$instance ) && ! ( self::$instance instanceof EchoDash ) ) {
if ( ! isset( self::$instance ) ) {

self::$instance = new EchoDash();

Expand Down Expand Up @@ -250,6 +250,7 @@ private function integrations_includes() {
// Extend integrations for integrations that does not have files in WPF integrations folder.

$integrations = array(
'wordpress' => 'WP',
'user' => 'WP_User',
'presto-player' => 'PrestoPlayer\Core',
'abandoned-cart' => 'WP_Fusion_Abandoned_Cart',
Expand Down Expand Up @@ -280,6 +281,22 @@ private function integrations_includes() {
do_action( 'echodash_integrations_loaded' );
}

/**
* Show error message if install check failed.
*
* @since 1.0.0
*/
public function admin_notices() {
$return = self::$instance->check_install();

if ( is_wp_error( $return ) && 'error' === $return->get_error_code() ) {
printf(
'<div class="notice notice-error"><p>%s</p></div>',
wp_kses_post( $return->get_error_message() )
);
}
}

/**
* Check install.
*
Expand All @@ -290,35 +307,16 @@ private function integrations_includes() {
* @return mixed True on success, WP_Error on error
*/
public function check_install() {

if ( version_compare( PHP_VERSION, '7.0.0', '<' ) ) {
return new WP_Error( 'error', 'The EchoDash plugin requires PHP 7.0 or higher.' );
return new WP_Error( 'error', esc_html__( 'The EchoDash plugin requires PHP 7.0 or higher.', 'echodash' ) );
}

// Make sure WordPress is at least 6.0.
if ( version_compare( get_bloginfo( 'version' ), '6.0', '<' ) ) {
return new WP_Error( 'error', 'The EchoDash plugin requires WordPress 6.0 or higher.' );
return new WP_Error( 'error', esc_html__( 'The EchoDash plugin requires WordPress 6.0 or higher.', 'echodash' ) );
}
}

/**
* Show error message if install check failed.
*
* @since 1.0.0
*
* @return mixed error message.
*/
public function admin_notices() {

$return = self::$instance->check_install();

if ( is_wp_error( $return ) && 'error' === $return->get_error_code() ) {

echo '<div class="notice notice-error">';
echo '<p>' . wp_kses_post( $return->get_error_message() ) . '</p>';
echo '</div>';

}
return true;
}
}

Expand Down
4 changes: 4 additions & 0 deletions includes/admin/admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ function ecd_render_event_tracking_fields( $args = array() ) {
);
}

if ( ! isset( $args['setting']['name'] ) ) {
$args['setting']['name'] = '';
}

// Get the field ID.
if ( false === $args['field_id'] ) {
$field_id = sanitize_html_class( $args['meta_name'] );
Expand Down
7 changes: 3 additions & 4 deletions includes/admin/class-echodash-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function __construct() {
* @return void
*/
public function send_event_test() {

check_ajax_referer( 'ecd_ajax_nonce', '_ajax_nonce' );

if ( ! isset( $_POST['data'] ) ) {
Expand Down Expand Up @@ -143,9 +144,7 @@ public function save_echodash_callback() {
return;
}

$nonce = wp_unslash( sanitize_key( $_GET['wpnonce'] ) );

if ( ! wp_verify_nonce( $nonce, 'echodash_connect' ) ) {
if ( ! wp_verify_nonce( wp_unslash( sanitize_key( $_GET['wpnonce'] ) ), 'echodash_connect' ) ) {
return;
}

Expand Down Expand Up @@ -217,7 +216,7 @@ public function add_settings_submenu() {
* @return void
*/
public function submenu_callback() {
include_once ECHODASH_DIR_PATH . '/includes/admin/option-page.php';
include_once ECHODASH_DIR_PATH . 'includes/admin/option-page.php';
}

/**
Expand Down
2 changes: 2 additions & 0 deletions includes/integrations/class-echodash-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ public function track_event( $trigger, $objects = array(), $args = array() ) {
foreach ( $args as $object_type => $values ) {
if ( isset( $event_data[ $object_type ] ) ) {
$event_data[ $object_type ] = array_merge( $event_data[ $object_type ], $values );
} else {
$event_data[ $object_type ] = $values;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public function add_meta_boxes() {}
*
* @since 1.3.0
*
* @param string $old_status The old status.
* @param string $new_status The new status.
* @param string $old_status The old status.
* @param string $new_status The new status.
* @param EDD_Subscription $subscription The subscription.
*/
public function subscription_change( $old_status, $new_status, $subscription ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ public function get_license_vars( $license_id = false ) {
if ( isset( $_REQUEST['url'] ) ) {

// If we're activating / deactivating a URL, grab it.// If we're activating / deactivating a URL, grab it.
$vars['license']['site_url'] = urldecode( esc_url_raw( wp_unslash( $_REQUEST['url'] ) ) );
$vars['license']['site_url'] = sanitize_url( wp_unslash( $_REQUEST['url'] ) );

} elseif ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== strpos( $_SERVER['HTTP_USER_AGENT'], 'WordPress' ) ) {
} elseif ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'WordPress' ) ) {

// Installing an update. The user agent will be like "WordPress/5.4.2; https://example.com".
$parts = explode( ';', $_SERVER['HTTP_USER_AGENT'] );
$vars['license']['site_url'] = esc_url_raw( trim( $parts[1] ) );
$parts = explode( ';', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) );
$vars['license']['site_url'] = sanitize_url( trim( $parts[1] ) );
}

$download = new EDD_SL_Download( $license->download_id );
Expand Down
Loading

0 comments on commit 7891ee8

Please sign in to comment.