Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BFTrick committed Jul 15, 2014
1 parent 8627829 commit 46c6b87
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 4 deletions.
4 changes: 0 additions & 4 deletions README.md

This file was deleted.

63 changes: 63 additions & 0 deletions includes/class-wc-integration-demo-integration.php
@@ -0,0 +1,63 @@
<?php
/**
* Integration Demo Integration.
*
* @package WC_Integration_Demo_Integration
* @category Integration
* @author WooThemes
*/

if ( ! class_exists( 'WC_Integration_Demo_Integration' ) ) :

class WC_Integration_Demo_Integration extends WC_Integration {

/**
* Init and hook in the integration.
*/
public function __construct() {
global $woocommerce;

$this->id = 'integration-demo';
$this->method_title = __( 'Integration Demo', 'woocommerce-integration-demo' );
$this->method_description = __( 'An integratino demo to show you how easy it is to extend WooCommerce.', 'woocommerce-integration-demo' );

// Load the settings.
$this->init_form_fields();
$this->init_settings();

// Define user set variables.
$this->api_key = $this->get_option( 'api_key' );
$this->debug = $this->get_option( 'debug' );

// Actions.
add_action( 'woocommerce_update_options_integration_' . $this->id, array( $this, 'process_admin_options' ) );

}


/**
* Initialize integration settings form fields.
*
* @return void
*/
public function init_form_fields() {
$this->form_fields = array(
'api_key' => array(
'title' => __( 'API Key', 'woocommerce-integration-demo' ),
'type' => 'text',
'description' => __( 'Enter with your API Key. You can find this in "User Profile" drop-down (top right corner) > API Keys.', 'woocommerce-integration-demo' ),
'desc_tip' => true,
'default' => ''
),
'debug' => array(
'title' => __( 'Debug Log', 'woocommerce-integration-demo' ),
'type' => 'checkbox',
'label' => __( 'Enable logging', 'woocommerce-integration-demo' ),
'default' => 'no',
'description' => __( 'Log events such as API requests', 'woocommerce-integration-demo' ),
)
);
}
}

endif;
19 changes: 19 additions & 0 deletions readme.txt
@@ -0,0 +1,19 @@
=== WooCommerce Integration Demo ===
Contributors: bftrick
Tags: email, woocommerce, integration,
Requires at least: 3.9
Tested up to: 3.9
Stable tag: 1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

An example plugin that shows you how to create a new WooCommerce integration.

== Description ==

An example plugin that shows you how to create a new WooCommerce integration.

== Changelog ==

= 1.0 =
* Launch!
87 changes: 87 additions & 0 deletions woocommerce-integration-demo.php
@@ -0,0 +1,87 @@
<?php
/**
* Plugin Name: WooCommerce Integration Demo
* Plugin URI: https://github.com/BFTrick/woocommerce-integration-demo
* Description: A plugin demonstrating how to add a new WooCommerce integration.
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

if ( ! class_exists( 'WC_Integration_Demo' ) ) :

class WC_Integration_Demo {

/**
* Instance of this class.
*
* @var object
*/
protected static $instance = null;


/**
* Initialize the plugin.
*/
private function __construct() {

// Checks with WooCommerce is installed.
if ( class_exists( 'WC_Integration' ) ) {
// Integration classes.
include_once 'includes/class-wc-integration-demo-integration.php';

// Register the integration.
add_filter( 'woocommerce_integrations', array( $this, 'add_integration' ) );

} else {
// throw an admin notice error
}
}


/**
* Return an instance of this class.
*
* @return object A single instance of this class.
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}

return self::$instance;
}


/**
* Add a new integration to WooCommerce.
*
* @param array $integrations WooCommerce integrations.
*
* @return array
*/
public function add_integration( $integrations ) {
$integrations[] = 'WC_Integration_Demo_Integration';
return $integrations;
}

}

add_action( 'plugins_loaded', array( 'WC_Integration_Demo', 'get_instance' ), 0 );

endif;

0 comments on commit 46c6b87

Please sign in to comment.