From a5a4cae03fddc0d9e6a46002ba80a1ee26687310 Mon Sep 17 00:00:00 2001 From: kerkness Date: Mon, 16 Aug 2021 22:27:00 +0000 Subject: [PATCH 1/7] change basename function --- src/Admin/WCSlackOptions.php | 6 +++--- wc-slack.php | 25 ++----------------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/Admin/WCSlackOptions.php b/src/Admin/WCSlackOptions.php index 5b2fe40..5d11cd5 100644 --- a/src/Admin/WCSlackOptions.php +++ b/src/Admin/WCSlackOptions.php @@ -15,11 +15,11 @@ public static function init() { $instance = new WCSlackOptions(); - register_activation_hook( _get_wc_slack_basename(), [$instance, 'wc_slack_activation_hook'] ); + register_activation_hook( wc_slack_plugin_basename(), [$instance, 'wc_slack_activation_hook'] ); add_action('init', [$instance, 'wc_slack_register_settings']); add_action('admin_menu', [$instance, 'wc_slack_admin_settings_menu']); - add_filter('plugin_action_links_' . _get_wc_slack_basename(), [$instance, 'wc_slack_settings_link'], 10, 1); + add_filter('plugin_action_links_' . wc_slack_plugin_basename(), [$instance, 'wc_slack_settings_link'], 10, 1); add_filter('plugin_row_meta', [$instance, 'plugin_row_meta'], 10, 2); } @@ -29,7 +29,7 @@ public static function init() */ public function wc_slack_activation_hook() { - register_uninstall_hook(_get_wc_slack_basename(), [$this, 'wc_slack_deactivation_hook'] ); + register_uninstall_hook(wc_slack_plugin_basename(), [$this, 'wc_slack_deactivation_hook'] ); } /** diff --git a/wc-slack.php b/wc-slack.php index a8fa6e1..4b000a6 100644 --- a/wc-slack.php +++ b/wc-slack.php @@ -35,32 +35,11 @@ use WCSlack\WCSlack; -/** - * Gets this plugin's absolute directory path. - * - */ -function _get_wc_slack_plugin_directory() { - return __DIR__; -} - -/** - * Gets this plugin's URL. - */ -function _get_wc_slack_plugin_url() { - static $plugin_url; - - if ( empty( $plugin_url ) ) { - $plugin_url = plugins_url( null, __FILE__ ); - } - - return $plugin_url; -} - /** * Get plugin base name */ -if(!function_exists('_get_wc_slack_basename')) { - function _get_wc_slack_basename() { +if(!function_exists('wc_slack_plugin_basename')) { + function wc_slack_plugin_basename() { return plugin_basename( __FILE__ ); } } From d405206ba2e8c0aa7faefa304ab1b81bad0548da Mon Sep 17 00:00:00 2001 From: kerkness Date: Tue, 17 Aug 2021 03:20:56 +0000 Subject: [PATCH 2/7] basename --- readme.txt | 4 ++++ wc-slack.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 7214d4b..ea30d6c 100644 --- a/readme.txt +++ b/readme.txt @@ -51,6 +51,10 @@ That depends on your Slack account. The plugin accepts only one Incoming Webhook == Changelog == += 1.0.2 = +* re-factor prefix and removal of test methods +... + = 1.0.1 = * Banner and Readme Updates diff --git a/wc-slack.php b/wc-slack.php index 4b000a6..01764cf 100644 --- a/wc-slack.php +++ b/wc-slack.php @@ -11,7 +11,7 @@ * Plugin Name: Integrator for Slack * Plugin URI: https://kerkness.ca/wc-slack * Description: Integrator for Slack sends messages from Wordpress and Woocommerce actions or custom events. - * Version: 1.0.1 + * Version: 1.0.2 * Requires at least: 5.4 * Tested up to: 5.8 * Requires PHP: 7.2 From 16b0c9f7d21fa9add3196053f0b69246779a092f Mon Sep 17 00:00:00 2001 From: kerkness Date: Wed, 18 Aug 2021 17:02:55 +0000 Subject: [PATCH 3/7] using kore-wp --- composer.json | 55 ++++++++++++++++++++---------------- composer.lock | 39 ++++++++++++++++++++++++- src/Admin/WCSlackOptions.php | 43 +++++++++------------------- templates/404.php | 1 + templates/admin-options.php | 27 ++++++++++++++++++ wc-slack.php | 2 +- 6 files changed, 111 insertions(+), 56 deletions(-) create mode 100644 templates/404.php create mode 100644 templates/admin-options.php diff --git a/composer.json b/composer.json index 79f53a7..a18db6b 100644 --- a/composer.json +++ b/composer.json @@ -1,28 +1,33 @@ { - "name": "kerkness/wc-slack", - "description": "Integrates WooCommerce and Slack.", - "keywords": ["wordpress", "plugin", "woocommerce", "slack"], - "homepage": "https://kerkness.ca", - "license": "GNU", - "authors": [ - { - "name": "kerkness", - "email": "ryan@kerkness.ca", - "homepage": "https://kerkness.ca" - } - ], - "type": "wordpress-plugin", - "require": { - "php": ">=7.1.0", - "composer/installers": "v1.0.6" - }, - "autoload" : { - "psr-4" : { - "WCSlack\\" : "src" - } - }, - "config": { - "vendor-dir": "lib" + "name": "kerkness/wc-slack", + "description": "Integrates WooCommerce and Slack.", + "keywords": [ + "wordpress", + "plugin", + "woocommerce", + "slack" + ], + "homepage": "https://kerkness.ca", + "license": "GPL-2.0-or-later", + "authors": [ + { + "name": "kerkness", + "email": "ryan@kerkness.ca", + "homepage": "https://kerkness.ca" } + ], + "type": "wordpress-plugin", + "require": { + "php": ">=7.1.0", + "composer/installers": "v1.0.6", + "kerkness/kore-wp": "^1.0" + }, + "autoload": { + "psr-4": { + "WCSlack\\": "src" + } + }, + "config": { + "vendor-dir": "lib" } - \ No newline at end of file +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index 52af47e..f453744 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a2d5072d5fae9d53cb3c510aa4678e98", + "content-hash": "334b17dcc3cb0a362102e4389751ab61", "packages": [ { "name": "composer/installers", @@ -82,6 +82,43 @@ "source": "https://github.com/composer/installers/tree/master" }, "time": "2013-08-20T04:37:09+00:00" + }, + { + "name": "kerkness/kore-wp", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/kerkness/kore-wp.git", + "reference": "dfefd70f7560d27559945bce72569ef05b6f7491" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kerkness/kore-wp/zipball/dfefd70f7560d27559945bce72569ef05b6f7491", + "reference": "dfefd70f7560d27559945bce72569ef05b6f7491", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Kerkness\\KoreWP\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "kerkness", + "email": "ryan@kerkness.ca" + } + ], + "description": "Common classes for building wordpress plugins", + "support": { + "issues": "https://github.com/kerkness/kore-wp/issues", + "source": "https://github.com/kerkness/kore-wp/tree/v1.0.4" + }, + "time": "2021-08-18T16:49:10+00:00" } ], "packages-dev": [], diff --git a/src/Admin/WCSlackOptions.php b/src/Admin/WCSlackOptions.php index 5d11cd5..7b81768 100644 --- a/src/Admin/WCSlackOptions.php +++ b/src/Admin/WCSlackOptions.php @@ -2,12 +2,18 @@ namespace WCSlack\Admin; +use Kerkness\KoreWP\KoreWP; +use Kerkness\KoreWP\Template; + /** * WCSlack Admin Options * Create admin page and handle option updates */ class WCSlackOptions { + + public $actions = []; + /** * Initalize the plugin */ @@ -120,34 +126,13 @@ public function wc_slack_admin_settings_menu() */ public function wc_slack_options_page() { -?> -
-

- -
- - - - - - - - - - - - -
- https://hooks.slack.com/services -
-
- * Note you have to configure your slack webhook to have permissions for multiple channels. -
- - - -
-
- +

+ +
+ + + + + + + + + + + + +
+ https://hooks.slack.com/services
+
+
+ * Note you have to configure your slack webhook to have permissions for multiple channels. +
+ + + +
+ diff --git a/wc-slack.php b/wc-slack.php index 01764cf..7549f36 100644 --- a/wc-slack.php +++ b/wc-slack.php @@ -34,9 +34,9 @@ use WCSlack\WCSlack; - /** * Get plugin base name + * @return string */ if(!function_exists('wc_slack_plugin_basename')) { function wc_slack_plugin_basename() { From 8ee1ace1f8fb1be82003bb852c16d8b7095dcc9a Mon Sep 17 00:00:00 2001 From: kerkness Date: Wed, 18 Aug 2021 21:52:44 +0000 Subject: [PATCH 4/7] kore --- composer.lock | 12 ++++++------ wc-slack.php | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index f453744..5a46ccb 100644 --- a/composer.lock +++ b/composer.lock @@ -85,16 +85,16 @@ }, { "name": "kerkness/kore-wp", - "version": "v1.0.4", + "version": "v1.0.12", "source": { "type": "git", "url": "https://github.com/kerkness/kore-wp.git", - "reference": "dfefd70f7560d27559945bce72569ef05b6f7491" + "reference": "349bf4286c14d2928a752cf4d2f88d435be7d5d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kerkness/kore-wp/zipball/dfefd70f7560d27559945bce72569ef05b6f7491", - "reference": "dfefd70f7560d27559945bce72569ef05b6f7491", + "url": "https://api.github.com/repos/kerkness/kore-wp/zipball/349bf4286c14d2928a752cf4d2f88d435be7d5d0", + "reference": "349bf4286c14d2928a752cf4d2f88d435be7d5d0", "shasum": "" }, "type": "library", @@ -116,9 +116,9 @@ "description": "Common classes for building wordpress plugins", "support": { "issues": "https://github.com/kerkness/kore-wp/issues", - "source": "https://github.com/kerkness/kore-wp/tree/v1.0.4" + "source": "https://github.com/kerkness/kore-wp/tree/v1.0.12" }, - "time": "2021-08-18T16:49:10+00:00" + "time": "2021-08-18T21:49:22+00:00" } ], "packages-dev": [], diff --git a/wc-slack.php b/wc-slack.php index 7549f36..0a93f08 100644 --- a/wc-slack.php +++ b/wc-slack.php @@ -34,6 +34,12 @@ use WCSlack\WCSlack; +// use Kerkness\KoreWP\KoreWP; + +// echo KoreWP::plugin_dir(); + +// // die(); + /** * Get plugin base name * @return string From 27c23b915a7114c0c203e6c51c3244851f940b23 Mon Sep 17 00:00:00 2001 From: kerkness Date: Wed, 18 Aug 2021 21:54:59 +0000 Subject: [PATCH 5/7] __FILE__ --- src/Admin/WCSlackOptions.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Admin/WCSlackOptions.php b/src/Admin/WCSlackOptions.php index 7b81768..50bc52d 100644 --- a/src/Admin/WCSlackOptions.php +++ b/src/Admin/WCSlackOptions.php @@ -2,7 +2,6 @@ namespace WCSlack\Admin; -use Kerkness\KoreWP\KoreWP; use Kerkness\KoreWP\Template; /** @@ -126,13 +125,6 @@ public function wc_slack_admin_settings_menu() */ public function wc_slack_options_page() { - // $plugin_name = reset(explode('/', str_replace(WP_PLUGIN_DIR . '/', '', __DIR__))); - - // echo $plugin_name; - - // echo plugins_url( $plugin_name . '/images/wordpress.png' ); - - echo Template::render('admin-options'); - + echo Template::render('admin-options', [], __FILE__); } } From 00071d2ff7de80646de8ae8773361c9bec0dafc2 Mon Sep 17 00:00:00 2001 From: kerkness Date: Thu, 19 Aug 2021 13:18:57 +0000 Subject: [PATCH 6/7] kore tested --- composer.json | 2 +- composer.lock | 14 +++++++------- src/Admin/WCSlackOptions.php | 2 +- wc-slack.php | 13 +++++-------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index a18db6b..5e3a645 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require": { "php": ">=7.1.0", "composer/installers": "v1.0.6", - "kerkness/kore-wp": "^1.0" + "kerkness/kore-wp": "^v1.0.13" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 5a46ccb..1f9fa1a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "334b17dcc3cb0a362102e4389751ab61", + "content-hash": "0917f7100df230a4c2ab3da2eadd621e", "packages": [ { "name": "composer/installers", @@ -85,16 +85,16 @@ }, { "name": "kerkness/kore-wp", - "version": "v1.0.12", + "version": "v1.0.13", "source": { "type": "git", "url": "https://github.com/kerkness/kore-wp.git", - "reference": "349bf4286c14d2928a752cf4d2f88d435be7d5d0" + "reference": "fd6881fbc5aedb67ef8bcc79a83d9a062859e5c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kerkness/kore-wp/zipball/349bf4286c14d2928a752cf4d2f88d435be7d5d0", - "reference": "349bf4286c14d2928a752cf4d2f88d435be7d5d0", + "url": "https://api.github.com/repos/kerkness/kore-wp/zipball/fd6881fbc5aedb67ef8bcc79a83d9a062859e5c6", + "reference": "fd6881fbc5aedb67ef8bcc79a83d9a062859e5c6", "shasum": "" }, "type": "library", @@ -116,9 +116,9 @@ "description": "Common classes for building wordpress plugins", "support": { "issues": "https://github.com/kerkness/kore-wp/issues", - "source": "https://github.com/kerkness/kore-wp/tree/v1.0.12" + "source": "https://github.com/kerkness/kore-wp/tree/v1.0.13" }, - "time": "2021-08-18T21:49:22+00:00" + "time": "2021-08-19T13:06:23+00:00" } ], "packages-dev": [], diff --git a/src/Admin/WCSlackOptions.php b/src/Admin/WCSlackOptions.php index 50bc52d..2302782 100644 --- a/src/Admin/WCSlackOptions.php +++ b/src/Admin/WCSlackOptions.php @@ -125,6 +125,6 @@ public function wc_slack_admin_settings_menu() */ public function wc_slack_options_page() { - echo Template::render('admin-options', [], __FILE__); + Template::render('admin-options', [], __FILE__); } } diff --git a/wc-slack.php b/wc-slack.php index 0a93f08..a018901 100644 --- a/wc-slack.php +++ b/wc-slack.php @@ -32,13 +32,10 @@ require_once( __DIR__ . '/lib/autoload.php'); } -use WCSlack\WCSlack; +// PHP 8 Support +// Plugin uses some php 8 methods. Include this file for reverse compatibility with php 7 +require_once __DIR__ . '/lib/kerkness/kore-wp/php_8/functions.php'; -// use Kerkness\KoreWP\KoreWP; - -// echo KoreWP::plugin_dir(); - -// // die(); /** * Get plugin base name @@ -53,11 +50,11 @@ function wc_slack_plugin_basename() { /** * Initalize the plugin */ -WCSlack::init(); +\WCSlack\WCSlack::init(); // Post to slack if (!function_exists('wc_slack_message')) { function wc_slack_message($message, $attachements = null, $channel = '' ) { - WCSlack::message($message, $attachements, $channel); + \WCSlack\WCSlack::message($message, $attachements, $channel); } } \ No newline at end of file From 649bea2f4469c037ec91df3b33b58ada42685c90 Mon Sep 17 00:00:00 2001 From: kerkness Date: Thu, 19 Aug 2021 13:22:55 +0000 Subject: [PATCH 7/7] versioned --- readme.txt | 5 ++++- wc-slack.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index ea30d6c..cdbe90f 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Contributors: kerkness Tags: hubspot, crm, woocommerce, customers Requires at least: 5.4 Tested up to: 5.8 -Stable tag: 1.0.1 +Stable tag: 1.0.3 Requires PHP: 7.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -51,6 +51,9 @@ That depends on your Slack account. The plugin accepts only one Incoming Webhook == Changelog == += 1.0.3 = +* switched to using kerkness/kore-wp library for common functions + = 1.0.2 = * re-factor prefix and removal of test methods ... diff --git a/wc-slack.php b/wc-slack.php index a018901..3935aa6 100644 --- a/wc-slack.php +++ b/wc-slack.php @@ -11,7 +11,7 @@ * Plugin Name: Integrator for Slack * Plugin URI: https://kerkness.ca/wc-slack * Description: Integrator for Slack sends messages from Wordpress and Woocommerce actions or custom events. - * Version: 1.0.2 + * Version: 1.0.3 * Requires at least: 5.4 * Tested up to: 5.8 * Requires PHP: 7.2