Skip to content

Commit

Permalink
Merge pull request #1 from kerkness/next
Browse files Browse the repository at this point in the history
next release
  • Loading branch information
kerkness authored Aug 19, 2021
2 parents a189480 + 649bea2 commit 2fdec54
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 86 deletions.
55 changes: 30 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"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": "[email protected]",
"homepage": "https://kerkness.ca"
}
],
"type": "wordpress-plugin",
"require": {
"php": ">=7.1.0",
"composer/installers": "v1.0.6",
"kerkness/kore-wp": "^v1.0.13"
},
"autoload": {
"psr-4": {
"WCSlack\\": "src"
}
},
"config": {
"vendor-dir": "lib"
}
}
39 changes: 38 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,6 +51,13 @@ 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
...

= 1.0.1 =
* Banner and Readme Updates

Expand Down
41 changes: 9 additions & 32 deletions src/Admin/WCSlackOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@

namespace WCSlack\Admin;

use Kerkness\KoreWP\Template;

/**
* WCSlack Admin Options
* Create admin page and handle option updates
*/
class WCSlackOptions
{

public $actions = [];

/**
* Initalize the plugin
*/
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);

}
Expand All @@ -29,7 +34,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'] );
}

/**
Expand Down Expand Up @@ -120,34 +125,6 @@ public function wc_slack_admin_settings_menu()
*/
public function wc_slack_options_page()
{
?>
<div class="wrap">
<h1><?php echo __('WCSlack Settings', 'wc-slack') ?></h1>

<form method="post" action="options.php">
<?php settings_fields('wc_slack_settings'); ?>
<?php do_settings_sections('wc_slack_settings'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php echo __('Slack Hook', 'wc-slack') ?></th>
<td>
https://hooks.slack.com/services
<input type="text" name="wc_slack_post_hook" value="<?php echo esc_attr(get_option('wc_slack_post_hook')); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php echo __('Default Channel', 'wc-slack') ?></th>
<td>
<input type="text" name="wc_slack_default_channel" value="<?php echo esc_attr(get_option('wc_slack_default_channel')); ?>" /><br/>
* Note you have to configure your slack webhook to have permissions for multiple channels.
</td>
</tr>

</table>

<?php submit_button(); ?>

</form>
</div>
<?php
Template::render('admin-options', [], __FILE__);
}
}
1 change: 1 addition & 0 deletions templates/404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Template Not Found]
27 changes: 27 additions & 0 deletions templates/admin-options.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="wrap">
<h1><?php echo __('WCSlack Settings', 'wc-slack') ?></h1>

<form method="post" action="options.php">
<?php settings_fields('wc_slack_settings'); ?>
<?php do_settings_sections('wc_slack_settings'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php echo __('Slack Hook', 'wc-slack') ?></th>
<td>
https://hooks.slack.com/services<br/>
<input type="text" name="wc_slack_post_hook" value="<?php echo esc_attr(get_option('wc_slack_post_hook')); ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php echo __('Default Channel', 'wc-slack') ?></th>
<td>
<input type="text" name="wc_slack_default_channel" value="<?php echo esc_attr(get_option('wc_slack_default_channel')); ?>" /><br/>
* Note you have to configure your slack webhook to have permissions for multiple channels.
</td>
</tr>

</table>

<?php submit_button(); ?>

</form>
</div>
36 changes: 9 additions & 27 deletions wc-slack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.3
* Requires at least: 5.4
* Tested up to: 5.8
* Requires PHP: 7.2
Expand All @@ -32,47 +32,29 @@
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';


/**
* 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
* @return string
*/
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__ );
}
}

/**
* 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);
}
}

0 comments on commit 2fdec54

Please sign in to comment.