Skip to content

Commit

Permalink
Updated all files with the new project name.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-osman committed Oct 5, 2015
1 parent 8cd74ba commit ad4b996
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 54 deletions.
20 changes: 10 additions & 10 deletions go-cannon.php → hectane.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php

/*
Plugin Name: go-cannon
Plugin URI: https://github.com/nathan-osman/wordpress-go-cannon
Description: Deliver all WordPress emails via go-cannon.
Version: 0.1.0
Plugin Name: Hectane
Plugin URI: https://github.com/hectane/hectane
Description: Deliver all WordPress emails via Hectane.
Version: 0.1.1
Author: Nathan Osman
Author URI: https://quickmediasolutions.com
License: MIT
License URI: https://opensource.org/licenses/MIT
*/

require_once plugin_dir_path(__FILE__) . 'go-cannon_api.php';
require_once plugin_dir_path(__FILE__) . 'go-cannon_settings.php';
require_once plugin_dir_path(__FILE__) . 'hectane_api.php';
require_once plugin_dir_path(__FILE__) . 'hectane_settings.php';

// Create the options instance only if the admin is open
// Create the settings instance only if the admin is open
if(is_admin()) {
new GoCannonOptions();
new HectaneSettings();
}

// Only override the wp_mail() function if it doesn't exist
Expand All @@ -25,7 +25,7 @@
* Override the default implementation of wp_mail().
*
* This function is responsible for marshalling the parameters into the JSON
* data that is sent to go-cannon.
* data that is sent to Hectane.
*/
function wp_mail($to, $subject, $message, $headers='', $attachments=array()) {
if(!is_array($to)) {
Expand All @@ -37,7 +37,7 @@ function wp_mail($to, $subject, $message, $headers='', $attachments=array()) {
'subject' => $subject,
'text' => $message,
);
return GoCannonAPI::instance()->send($email);
return HectaneAPI::instance()->send($email);
}
}

Expand Down
24 changes: 12 additions & 12 deletions go-cannon_api.php → hectane_api.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

require_once plugin_dir_path(__FILE__) . 'go-cannon_settings.php';
require_once plugin_dir_path(__FILE__) . 'hectane_settings.php';

/**
* Facilitate communication with the go-cannon API.
* Facilitate communication with the Hectane API.
*/
class GoCannonAPI {
class HectaneAPI {

/**
* Global instance of the API.
Expand All @@ -17,7 +17,7 @@ class GoCannonAPI {
*/
public static function instance() {
if(self::$instance === null) {
self::$instance = new GoCannonAPI();
self::$instance = new HectaneAPI();
}
return self::$instance;
}
Expand All @@ -33,16 +33,16 @@ public static function instance() {
private function build($method) {
$url = sprintf(
'http%s://%s:%s/v1%s',
GoCannonOptions::get('secure') ? 's' : '',
GoCannonOptions::get('host'),
GoCannonOptions::get('port'),
HectaneSettings::get('secure') ? 's' : '',
HectaneSettings::get('host'),
HectaneSettings::get('port'),
$method
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$u = GoCannonOptions::get('username');
$p = GoCannonOptions::get('password');
$u = HectaneSettings::get('username');
$p = HectaneSettings::get('password');
if($u !== '' && $p !== '') {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$u:$p");
Expand All @@ -66,12 +66,12 @@ public function __construct() {
*/
public function show_error() {
echo '<div class="error">';
echo '<p>The cURL PHP extension is required to use go-cannon.</p>';
echo '<p>The cURL PHP extension is required to use Hectane.</p>';
echo '</div>';
}

/**
* Attempt to send the specified email with go-cannon.
* Attempt to send the specified email with Hectane.
*
* The $email parameter is expected to be an array with the same parameters
* that /v1/send expects. A boolean is returned indicating success or
Expand All @@ -91,7 +91,7 @@ public function send($email) {
}

/**
* Retrieve the current version of go-cannon.
* Retrieve the current version of Hectane.
*
* The version is returned as a string or the value "false" if an error
* occurs while making the API call.
Expand Down
52 changes: 26 additions & 26 deletions go-cannon_settings.php → hectane_settings.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

/**
* Manage options for the plugin including the page that allows the connection
* Manage settings for the plugin including the page that allows the connection
* settings to be configured.
*/
class GoCannonOptions {
class HectaneSettings {

/**
* Default values for all options.
Expand All @@ -21,7 +21,7 @@ class GoCannonOptions {
* Obtain the current value for the specified option.
*/
public static function get($name) {
$o = get_option('go-cannon_settings');
$o = get_option('hectane_settings');
return isset($o[$name]) ? $o[$name] : self::$defaults[$name];
}

Expand All @@ -38,70 +38,70 @@ public function __construct() {
*/
public function register_settings() {
add_settings_section(
'go-cannon_connection_settings',
'hectane_connection_settings',
'Connection Settings',
array($this, 'connection_settings_callback'),
'go-cannon'
'hectane'
);
add_settings_field(
'host',
'Host',
array($this, 'text_field_callback'),
'go-cannon',
'go-cannon_connection_settings',
'hectane',
'hectane_connection_settings',
array('host')
);
add_settings_field(
'port',
'Port',
array($this, 'text_field_callback'),
'go-cannon',
'go-cannon_connection_settings',
'hectane',
'hectane_connection_settings',
array('port')
);
add_settings_field(
'tls',
'Use TLS',
array($this, 'checkbox_field_callback'),
'go-cannon',
'go-cannon_connection_settings',
'hectane',
'hectane_connection_settings',
array('tls')
);
add_settings_field(
'username',
'Username',
array($this, 'text_field_callback'),
'go-cannon',
'go-cannon_connection_settings',
'hectane',
'hectane_connection_settings',
array('username')
);
add_settings_field(
'password',
'Password',
array($this, 'text_field_callback'),
'go-cannon',
'go-cannon_connection_settings',
'hectane',
'hectane_connection_settings',
array('password')
);
register_setting(
'go-cannon_settings',
'go-cannon_settings'
'hectane_settings',
'hectane_settings'
);
}

/**
* Render the label for the connection section.
*/
public function connection_settings_callback() {
echo '<p>These settings are used to connect to the go-cannon client.</p>';
echo '<p>These settings are used to connect to the Hectane client.</p>';
}

/**
* Display the specified input field.
*/
public function text_field_callback($args) {
printf(
'<input type="text" id="%s" name="go-cannon_settings[%s]" value="%s">',
'<input type="text" id="%s" name="hectane_settings[%s]" value="%s">',
esc_attr($args[0]),
esc_attr($args[0]),
esc_attr(self::get($args[0]))
Expand All @@ -113,7 +113,7 @@ public function text_field_callback($args) {
*/
public function checkbox_field_callback($args) {
printf(
'<input type="checkbox" id="%s" name="go-cannon_settings[%s]" %s>',
'<input type="checkbox" id="%s" name="hectane_settings[%s]" %s>',
esc_attr($args[0]),
esc_attr($args[0]),
self::get($args[0]) ? 'checked="checked"' : ''
Expand All @@ -125,10 +125,10 @@ public function checkbox_field_callback($args) {
*/
public function add_options_page() {
add_options_page(
'go-cannon Options',
'go-cannon',
'Hectane Options',
'hectane',
'manage_options',
'go-cannon',
'hectane',
array($this, 'display_options_page')
);
}
Expand All @@ -138,10 +138,10 @@ public function add_options_page() {
*/
public function display_options_page() {
echo '<div class="wrap">';
echo '<h2>go-cannon Options</h2>';
echo '<h2>Hectane Options</h2>';
echo '<form method="post" action="options.php">';
settings_fields('go-cannon_settings');
do_settings_sections('go-cannon');
settings_fields('hectane_settings');
do_settings_sections('hectane');
submit_button();
echo '</form>';
echo '</div>';
Expand Down
15 changes: 9 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
=== go-cannon ===
=== Hectane ===
Contributors: george_edison
Tags: mail, email
Requires at least: 3.0.1
Tested up to: 4.3.1
Stable tag: trunk
Stable tag: 0.1.1
License: MIT
License URI: https://opensource.org/licenses/MIT

Deliver all WordPress emails via go-cannon.
Deliver all WordPress emails via Hectane.

== Description ==

This plugin provides an extremely easy way to route WordPress emails through [go-cannon](https://github.com/nathan-osman/go-cannon). After installing and configuring the plugin, all calls to `wp_mail()` will be intercepted and sent to go-cannon which will take care of delivery.
This plugin provides an extremely easy way to route WordPress emails through [Hectane](https://github.com/hectane/hectane). After installing and configuring the plugin, all calls to `wp_mail()` will be intercepted and sent to Hectane which will take care of delivery.

== Installation ==

1. Upload the directory `go-cannon` to the `wp-content/plugins/` directory.
1. Upload the directory `hectane` to the `wp-content/plugins/` directory.
1. Activate the plugin through the 'Plugins' menu in WordPress.
1. Configure the plugin through the 'go-cannon' item in the Settings' menu.
1. Configure the plugin through the 'Hectane' item in the Settings' menu.

== Changelog ==

= 0.1.1 =
* Plugin renamed to "Hectane" due to upstream change of name

= 0.1.0 =
* Initial release of plugin

0 comments on commit ad4b996

Please sign in to comment.