2012-04-30 19:50:35 +00:00
< ? php
/**
* ShareYourCart Integration
2012-11-27 16:22:47 +00:00
*
2012-04-30 19:50:35 +00:00
* Enables ShareYourCart integration .
*
* @ class WC_ShareYourCart
2012-11-16 11:55:15 +00:00
* @ package WooCommerce
* @ category Integrations
* @ author WooThemes
2012-04-30 19:50:35 +00:00
*/
2012-11-27 16:22:47 +00:00
2012-04-30 19:50:35 +00:00
class WC_ShareYourCart extends WC_Integration {
2012-11-27 16:22:47 +00:00
var $ShareYourCartWooCommerce ;
public function __construct () {
2012-04-30 19:50:35 +00:00
$this -> id = 'shareyourcart' ;
$this -> method_title = __ ( 'ShareYourCart' , 'woocommerce' );
2012-11-22 12:08:09 +00:00
$this -> method_description = __ ( 'Increase your social media exposure by 10 percent! ShareYourCart helps you get more customers by motivating satisfied customers to talk with their friends about your products. For help with ShareYourCart view the <a href="http://www.woothemes.com/woocommerce-docs/user-guide/shareyourcart/" target="__blank">documentation</a>.' , 'woocommerce' );
2012-11-27 16:22:47 +00:00
2012-04-30 19:50:35 +00:00
// Load the settings.
2012-11-16 11:55:15 +00:00
$this -> settings = ( array ) get_option ( $this -> plugin_id . $this -> id . '_settings' ); //do not rely on the base implementation of init_settings
2012-11-27 16:22:47 +00:00
2012-12-06 15:51:20 +00:00
if ( isset ( $this -> settings [ 'enabled' ] ) && $this -> settings [ 'enabled' ] == 'yes' ) {
//the classes need to be initialized
$this -> init_share_your_cart ();
}
2012-11-27 16:22:47 +00:00
2012-11-16 11:55:15 +00:00
//hook to the admin settings page
2012-04-30 19:50:35 +00:00
add_action ( 'woocommerce_update_options_integration_shareyourcart' , array ( & $this , 'process_forms' ) );
2012-11-27 16:22:47 +00:00
}
2012-04-30 19:50:35 +00:00
/**
* styles function .
2012-11-27 16:22:47 +00:00
*
2012-04-30 19:50:35 +00:00
* @ access public
* @ return void
*/
public function styles () {
wp_enqueue_style ( 'shareyourcart' , plugins_url ( 'css/style.css' , __FILE__ ) );
}
2012-11-27 16:22:47 +00:00
2012-05-01 09:19:56 +00:00
/**
* init_share_your_cart function .
2012-11-27 16:22:47 +00:00
*
2012-05-01 09:19:56 +00:00
* @ access public
* @ return void
*/
function init_share_your_cart () {
2012-11-27 16:22:47 +00:00
2012-05-10 12:51:35 +00:00
if ( empty ( $this -> shareYourCartWooCommerce ) ) {
2012-05-01 09:19:56 +00:00
// Share your cart api class
2012-11-27 16:22:47 +00:00
include_once ( 'class-shareyourcart-woocommerce-extended.php' );
2012-05-01 09:19:56 +00:00
// Init the class
2012-11-16 11:55:15 +00:00
$this -> shareYourCartWooCommerce = new ShareYourCartWooCommerceEx ( $this -> settings );
2012-11-27 16:22:47 +00:00
2012-11-16 11:55:15 +00:00
//by the time we get here, the plugins_loaded hook has allready been called
//so call the method manually
$this -> shareYourCartWooCommerce -> pluginsLoadedHook ();
2012-05-01 09:19:56 +00:00
}
2012-11-27 16:22:47 +00:00
2012-05-01 09:19:56 +00:00
}
2012-11-27 16:22:47 +00:00
2012-04-30 19:50:35 +00:00
/**
2012-11-27 16:22:47 +00:00
* process_forms function .
*
2012-04-30 19:50:35 +00:00
* @ access public
*/
function process_forms () {
2012-11-27 16:22:47 +00:00
2012-11-16 11:55:15 +00:00
//after this function completes, WooCommerce will refresh the page, so we need to save the data here
2012-12-06 15:51:20 +00:00
$this -> init_share_your_cart ();
2012-11-27 16:22:47 +00:00
2012-11-16 11:55:15 +00:00
//stripslashes from button_html
if ( isset ( $_POST [ 'button_html' ]))
$_POST [ 'button_html' ] = stripslashes ( $_POST [ 'button_html' ]);
2012-11-27 16:22:47 +00:00
2012-11-16 11:55:15 +00:00
//TODO: investigate why the files are not being uploaded
2012-11-27 16:22:47 +00:00
2012-11-16 11:55:15 +00:00
$this -> shareYourCartWooCommerce -> getAdminPage ( $this ); //get the admin page ( so that the data is processed, but do not show it )
2012-11-27 16:22:47 +00:00
$this -> shareYourCartWooCommerce -> getButtonCustomizationPage (); //get the customization page ( so that the data is processed, but do not show it )
2012-04-30 19:50:35 +00:00
}
2012-11-27 16:22:47 +00:00
2012-04-30 19:50:35 +00:00
/**
* Admin Options
*
* Setup the gateway settings screen .
* Override this in your gateway .
*
* @ since 1.0 . 0
*/
function admin_options () {
2012-11-27 16:22:47 +00:00
2012-12-06 15:51:20 +00:00
$this -> init_share_your_cart ();
2012-11-16 11:55:15 +00:00
if ( $this -> shareYourCartWooCommerce -> isActive () ) {
2012-11-27 16:22:47 +00:00
2012-11-16 11:55:15 +00:00
// call this manually ( to determine if there needs to be a table update, or not )
2012-04-30 19:50:35 +00:00
$this -> shareYourCartWooCommerce -> install ();
}
2012-11-27 16:22:47 +00:00
2012-11-16 11:55:15 +00:00
$this -> shareYourCartWooCommerce -> showAdminHeader ();
$this -> shareYourCartWooCommerce -> showAdminPage ( $this , true , false ); //send this obj to the view, but do not show the footer
$this -> shareYourCartWooCommerce -> showButtonCustomizationPage ( null , false , false ); //do not show neither the header, nor the footer of this page
2012-11-27 16:22:47 +00:00
}
2012-04-30 19:50:35 +00:00
}
/**
* Add the integration to WooCommerce
2012-11-16 11:55:15 +00:00
**/
2012-04-30 19:50:35 +00:00
function add_shareyourcart_integration ( $integrations ) {
if ( ! class_exists ( 'ShareYourCartAPI' ) ) // Only allow this integration if we're not already using shareyourcart via another plugin
2012-11-27 16:22:47 +00:00
$integrations [] = 'WC_ShareYourCart' ;
2012-04-30 19:50:35 +00:00
return $integrations ;
}
add_filter ( 'woocommerce_integrations' , 'add_shareyourcart_integration' );