Updated the ShareYourCart Integration such that it uses the latest SDK but still has the layout style of WooCommerce.
Analytics has been disabled
This commit is contained in:
parent
51bf586fd7
commit
b7acbc2d2a
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
require_once("class.shareyourcart-wp-woocommerce.php");
|
||||
|
||||
class ShareYourCartWooCommerceEx extends ShareYourCartWooCommerce {
|
||||
|
||||
public $settings;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param null
|
||||
*/
|
||||
function __construct( $settings ) {
|
||||
|
||||
$this->settings = $settings;
|
||||
$this->SDK_ANALYTICS = false; //disable analytics for the woocommerce integration
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function isCartActive() {
|
||||
return true; //since this class has loaded, the WooCommerce plugin is active
|
||||
}
|
||||
|
||||
public function getSecretKey() {
|
||||
return '2cfd496d-7812-44ba-91ce-e43c59f6c680';
|
||||
}
|
||||
|
||||
public function showAdminMenu() {
|
||||
//since we have allready integrated this in our own settings page,
|
||||
//leave this function empty
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Set the field value
|
||||
*
|
||||
*/
|
||||
protected function setConfigValue($field, $value) {
|
||||
|
||||
$this->settings[$field] = $value;
|
||||
|
||||
//make sure to update the enabled field as well, based on the account_status
|
||||
switch($field){
|
||||
case 'account_status':
|
||||
$this->settings['enabled'] = ( $value == 'active' ? 'yes' : 'no' );
|
||||
break;
|
||||
case "plugin_current_version":
|
||||
//this setting needs to be set globaly as well, in order to be recognized by other ShareYourCart integrations,
|
||||
//and to not interfear with one-another
|
||||
parent::setConfigValue($field, $value);
|
||||
break;
|
||||
}
|
||||
|
||||
//save the config in the DB
|
||||
update_option( 'woocommerce_shareyourcart_settings', $this->settings );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the field value
|
||||
*
|
||||
*/
|
||||
protected function getConfigValue( $field ) {
|
||||
|
||||
$value = ( isset( $this->settings[$field] ) ) ? $this->settings[$field] : '';
|
||||
|
||||
//search for the global value of this field
|
||||
//as it might have been changed by an external ShareYourCart integration
|
||||
if($field == "plugin_current_version"){
|
||||
$val = parent::getConfigValue($field);
|
||||
|
||||
if(!empty($val)) $value = $val;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
|
@ -1,386 +0,0 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
require_once "sdk/class.shareyourcart-base.php";
|
||||
|
||||
class ShareYourCartWooCommerce extends ShareYourCartBase {
|
||||
|
||||
public $settings;
|
||||
public $_plugin_name = "shareyourcart_woo_commerce";
|
||||
public $_post_user_id = 1;
|
||||
protected static $_VERSION = 1;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param null
|
||||
*/
|
||||
function __construct( $settings ) {
|
||||
|
||||
$this->settings = $settings;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
//if there is installed another plugin with a never version
|
||||
//do not load this one further
|
||||
if (!$this->canLoad()) return;
|
||||
|
||||
// Shortcodes
|
||||
add_shortcode( 'shareyourcart', array(&$this, 'getButton') );
|
||||
add_shortcode( 'shareyourcart_button', array(&$this, 'getButton') );
|
||||
|
||||
// Actions
|
||||
add_action( 'init', array(&$this, 'init') );
|
||||
add_action( 'wp', array(&$this, 'hook_buttons') );
|
||||
add_action( 'wp_head', array(&$this, 'wp_head') );
|
||||
}
|
||||
|
||||
function admin_settings_page() {
|
||||
$this->checkSDKStatus(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* processInit function.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function init() {
|
||||
if (isset($_REQUEST['action'])) {
|
||||
switch ($_REQUEST['action']) {
|
||||
case $this->_plugin_name:
|
||||
$this->buttonCallback();
|
||||
break;
|
||||
|
||||
case $this->_plugin_name . '_coupon':
|
||||
$this->couponCallback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* hook_buttons function.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function hook_buttons() {
|
||||
if ( $this->isSingleProduct() )
|
||||
add_filter('woocommerce_product_description_heading', array(&$this, '_getProductButton'));
|
||||
|
||||
add_action('woocommerce_cart_coupon', array(&$this, '_getCartButton'));
|
||||
}
|
||||
|
||||
public function wp_head() {
|
||||
echo '<meta property="syc:client_id" content="' . $this->getClientId() . '" />';
|
||||
}
|
||||
|
||||
public function _getProductButton( $title ) {
|
||||
$title .= $this->getProductButton();
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function _getCartButton() {
|
||||
echo '<div id="shareyourcart_button">' . $this->getCartButton() . '</div>';
|
||||
}
|
||||
|
||||
public function getSecretKey() {
|
||||
return '2cfd496d-7812-44ba-91ce-e43c59f6c680';
|
||||
}
|
||||
|
||||
public function isSingleProduct() {
|
||||
return is_singular('product');
|
||||
}
|
||||
|
||||
public function saveCoupon( $token, $coupon_code, $coupon_value, $coupon_type ) {
|
||||
|
||||
// Create coupon
|
||||
$post_id = $this->_saveCouponPost($coupon_code);
|
||||
|
||||
// Set coupon meta
|
||||
switch ($coupon_type) {
|
||||
case 'amount':
|
||||
$discount_type = 'fixed_product';
|
||||
$free_shipping = 'no';
|
||||
break;
|
||||
case 'percent':
|
||||
$discount_type = 'percent_product';
|
||||
$free_shipping = 'no';
|
||||
break;
|
||||
case 'free_shipping':
|
||||
$discount_type = 'fixed_product';
|
||||
$coupon_value = 0;
|
||||
$free_shipping = 'yes';
|
||||
break;
|
||||
default :
|
||||
$discount_type = 'fixed_cart';
|
||||
$free_shipping = 'no';
|
||||
}
|
||||
|
||||
update_post_meta( $post_id, 'customer_email', array() );
|
||||
update_post_meta( $post_id, 'minimum_amount', '' );
|
||||
update_post_meta( $post_id, 'exclude_product_categories', array() );
|
||||
update_post_meta( $post_id, 'product_categories', array() );
|
||||
update_post_meta( $post_id, 'free_shipping', $free_shipping );
|
||||
update_post_meta( $post_id, 'apply_before_tax', 'yes' );
|
||||
update_post_meta( $post_id, 'expiry_date', '' );
|
||||
update_post_meta( $post_id, 'usage_limit', 1 );
|
||||
update_post_meta( $post_id, 'exclude_product_ids', '' );
|
||||
update_post_meta( $post_id, 'product_ids', '' );
|
||||
update_post_meta( $post_id, 'individual_use', 'yes' );
|
||||
update_post_meta( $post_id, 'coupon_amount', $coupon_value );
|
||||
update_post_meta( $post_id, 'discount_type', $discount_type );
|
||||
|
||||
// parent
|
||||
parent::saveCoupon( $token, $coupon_code, $coupon_value, $coupon_type );
|
||||
}
|
||||
|
||||
public function applyCoupon( $coupon_code ) {}
|
||||
|
||||
private function _saveCouponPost($coupon_code) {
|
||||
$new_post = array(
|
||||
'post_title' => $coupon_code,
|
||||
'post_name' => sanitize_title( $coupon_code ),
|
||||
'post_content' => '',
|
||||
'post_status' => 'publish',
|
||||
'comment_status'=> 'closed',
|
||||
'ping_status' => 'closed',
|
||||
'post_author' => $this->_post_user_id,
|
||||
'post_type' => 'shop_coupon'
|
||||
);
|
||||
|
||||
$post_id = wp_insert_post($new_post);
|
||||
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
public function getButtonCallbackURL() {
|
||||
global $wp_query;
|
||||
|
||||
$callback_url = add_query_arg( 'action', $this->_plugin_name, trailingslashit( home_url() ) );
|
||||
|
||||
if ($this->isSingleProduct()) {
|
||||
$callback_url .= '&p='. $wp_query->post->ID;
|
||||
}
|
||||
|
||||
return $callback_url;
|
||||
}
|
||||
|
||||
public function buttonCallback() {
|
||||
global $woocommerce;
|
||||
|
||||
//specify the parameters
|
||||
$params = array(
|
||||
'callback_url' => get_bloginfo('wpurl').'/?action='.$this->_plugin_name.'_coupon'.(isset($_REQUEST['p']) ? '&p='.$_REQUEST['p'] : '' ),
|
||||
'success_url' => get_option('shopping_cart_url'),
|
||||
'cancel_url' => get_option('shopping_cart_url'),
|
||||
);
|
||||
|
||||
//there is no product set, thus send the products from the shopping cart
|
||||
if (!isset($_REQUEST['p'])) {
|
||||
if ( sizeof( $woocommerce->cart->get_cart() ) == 0 )
|
||||
exit("Cart is empty");
|
||||
|
||||
foreach ($woocommerce->cart->get_cart() as $cart_details) {
|
||||
$params['cart'][] = $this->_getProductDetails($cart_details['product_id']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$params['cart'][] = $this->_getProductDetails($_GET['p']);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->startSession($params);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
//display the error to the user
|
||||
echo $e->getMessage();
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
private function _getProductDetails($product_id) {
|
||||
$product = new WC_Product($product_id);
|
||||
|
||||
ob_start();
|
||||
|
||||
echo $product->get_image();
|
||||
|
||||
$image = ob_get_clean();
|
||||
|
||||
return array(
|
||||
"item_name" => $product->get_title(),
|
||||
"item_description" => $product->post->post_content,
|
||||
"item_url" => $product->post->guid,
|
||||
"item_price" => $product->price,
|
||||
"item_picture_url" => $image,
|
||||
);
|
||||
}
|
||||
|
||||
public function loadSessionData() {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the plugin version.
|
||||
* @return an integer
|
||||
*
|
||||
*/
|
||||
protected function getPluginVersion() {
|
||||
|
||||
return self::$_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the project's URL
|
||||
*
|
||||
*/
|
||||
protected function getDomain() {
|
||||
|
||||
return get_bloginfo('url');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the admin's email
|
||||
*
|
||||
*/
|
||||
protected function getAdminEmail() {
|
||||
|
||||
return get_settings('admin_email');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Set the field value
|
||||
*
|
||||
*/
|
||||
public function setConfigValue($field, $value) {
|
||||
$this->settings[$field] = $value;
|
||||
update_option( 'woocommerce_shareyourcart_settings', $this->settings );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the field value
|
||||
*
|
||||
*/
|
||||
protected function getConfigValue( $field ) {
|
||||
|
||||
switch ( $field ) {
|
||||
case "clientId" :
|
||||
return $this->settings['client_id'];
|
||||
case "hide_on_checkout" :
|
||||
return ( $this->settings['show_on_cart'] == 'yes' ) ? false : true;
|
||||
case "hide_on_product" :
|
||||
return ( $this->settings['show_on_product'] == 'yes' ) ? false : true;
|
||||
case "appKey" :
|
||||
return $this->settings['app_key'];
|
||||
case "account_status" :
|
||||
return 'active';
|
||||
case "button_type" :
|
||||
|
||||
if ( $this->settings['button_style'] == 'image_button' ) return 2;
|
||||
if ( $this->settings['button_style'] == 'custom_html' ) return 3;
|
||||
|
||||
return 1; // Standard
|
||||
|
||||
break;
|
||||
default :
|
||||
return ( isset( $this->settings[$field] ) ) ? $this->settings[$field] : '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Execute the SQL statement
|
||||
*
|
||||
*/
|
||||
protected function executeNonQuery($sql) {
|
||||
|
||||
if (substr($sql, 0, 12) == "CREATE TABLE") {
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
||||
|
||||
//if this is a create table command, use the special function which compares tables
|
||||
dbDelta($sql);
|
||||
|
||||
} else {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
//use the normal query
|
||||
$wpdb->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the row returned from the SQL
|
||||
*
|
||||
* @return an associative array containing the data of the row OR NULL
|
||||
* if there is none
|
||||
*/
|
||||
protected function getRow($sql) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
//get the row as an associative array
|
||||
return $wpdb->get_row($sql, ARRAY_A);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the table name based on the key
|
||||
*
|
||||
*/
|
||||
protected function getTableName($key) {
|
||||
global $wpdb;
|
||||
|
||||
return $wpdb->base_prefix . $key;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Insert the row into the specified table
|
||||
*
|
||||
*/
|
||||
protected function insertRow($tableName, $data) {
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->insert($tableName, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Create url for the specified file. The file must be specified in relative path
|
||||
* to the base of the plugin
|
||||
*/
|
||||
protected function createUrl($file) {
|
||||
//get the real file path
|
||||
$file = realpath($file);
|
||||
|
||||
//calculate the relative path from this file
|
||||
$file = SyC::relativepath(dirname(__FILE__), $file);
|
||||
|
||||
//append the relative path to the current file's URL
|
||||
return WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__), "", plugin_basename(__FILE__)).$file;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Called when a new coupon is generated
|
||||
*
|
||||
*/
|
||||
public function couponCallback() {
|
||||
|
||||
parent::couponCallback();
|
||||
|
||||
//since this is actually an API, exit
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,177 +1,85 @@
|
|||
<?php
|
||||
/**
|
||||
* ShareYourCart Integration
|
||||
*
|
||||
*
|
||||
* Enables ShareYourCart integration.
|
||||
*
|
||||
* @class WC_ShareYourCart
|
||||
* @extends WC_Integration
|
||||
* @version 1.6.4
|
||||
* @package WooCommerce/Classes/Integrations
|
||||
* @author WooThemes
|
||||
* @package WooCommerce
|
||||
* @category Integrations
|
||||
* @author WooThemes
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
class WC_ShareYourCart extends WC_Integration {
|
||||
|
||||
var $ShareYourCartWooCommerce;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
var $ShareYourCartWooCommerce;
|
||||
|
||||
public function __construct() {
|
||||
$this->id = 'shareyourcart';
|
||||
$this->method_title = __( 'ShareYourCart', 'woocommerce' );
|
||||
$this->method_description = sprintf( __( '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="%s">documentation</a>.', 'woocommerce' ), 'http://www.woothemes.com/woocommerce-docs/user-guide/shareyourcart/' );
|
||||
|
||||
// Load the form fields.
|
||||
$this->init_form_fields();
|
||||
|
||||
$this->method_description = sprintf( __( '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="%s" target="__blank">documentation</a>.', 'woocommerce' ), 'http://www.woothemes.com/woocommerce-docs/user-guide/shareyourcart/' );
|
||||
|
||||
// Load the settings.
|
||||
$this->init_settings();
|
||||
|
||||
// Define user set variables
|
||||
$this->enabled = $this->settings['enabled'];
|
||||
$this->client_id = $this->settings['client_id'];
|
||||
$this->app_key = $this->settings['app_key'];
|
||||
$this->email = $this->settings['email'];
|
||||
|
||||
// Actions
|
||||
add_action( 'woocommerce_update_options_integration_shareyourcart', array( &$this, 'process_admin_options') );
|
||||
$this->settings = ( array ) get_option( $this->plugin_id . $this->id . '_settings' ); //do not rely on the base implementation of init_settings
|
||||
|
||||
//the classes need to be initialized
|
||||
$this->init_share_your_cart();
|
||||
|
||||
//hook to the admin settings page
|
||||
add_action( 'woocommerce_update_options_integration_shareyourcart', array( &$this, 'process_forms') );
|
||||
|
||||
// Actions if enabled
|
||||
if ( $this->enabled == 'yes' ) {
|
||||
add_action( 'wp_enqueue_scripts', array(&$this, 'styles') );
|
||||
|
||||
$this->init_share_your_cart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* styles function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function styles() {
|
||||
wp_enqueue_style( 'shareyourcart', plugins_url( 'css/style.css', __FILE__ ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* init_share_your_cart function.
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function init_share_your_cart() {
|
||||
|
||||
|
||||
if ( empty( $this->shareYourCartWooCommerce ) ) {
|
||||
// Share your cart api class
|
||||
include_once('class-shareyourcart-woocommerce.php');
|
||||
|
||||
include_once('class-shareyourcart-woocommerce-extended.php');
|
||||
|
||||
// Init the class
|
||||
$this->shareYourCartWooCommerce = new ShareYourCartWooCommerce( $this->settings );
|
||||
$this->shareYourCartWooCommerce = new ShareYourCartWooCommerceEx( $this->settings );
|
||||
|
||||
//by the time we get here, the plugins_loaded hook has allready been called
|
||||
//so call the method manually
|
||||
$this->shareYourCartWooCommerce->pluginsLoadedHook();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* process_forms function.
|
||||
*
|
||||
* process_forms function.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function process_forms() {
|
||||
|
||||
if ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'create' ) {
|
||||
|
||||
$this->init_share_your_cart();
|
||||
|
||||
$error = $message = '';
|
||||
|
||||
$redirect = remove_query_arg( 'saved' );
|
||||
$redirect = remove_query_arg( 'wc_error', $redirect );
|
||||
$redirect = remove_query_arg( 'wc_message', $redirect );
|
||||
|
||||
if ( ! empty( $_POST['domain'] ) && ! empty( $_POST['email'] ) && ! empty( $_POST['syc-terms-agreement'] ) ) {
|
||||
if ( ! ( ( $register = $this->shareYourCartWooCommerce->register( $this->shareYourCartWooCommerce->getSecretKey(), $_POST['domain'], $_POST['email'], $message ) ) === false) ) {
|
||||
|
||||
$this->shareYourCartWooCommerce->setConfigValue('app_key', $register['app_key']);
|
||||
$this->shareYourCartWooCommerce->setConfigValue('client_id', $register['client_id']);
|
||||
|
||||
$redirect = remove_query_arg( 'syc-account', $redirect );
|
||||
} else {
|
||||
|
||||
$error = $message;
|
||||
|
||||
if ( json_decode($error) ) {
|
||||
$error = json_decode($error);
|
||||
$error = $error->message;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$error = __( 'Please complete all fields.', 'woocommerce' );
|
||||
|
||||
}
|
||||
|
||||
if ( $error ) $redirect = add_query_arg( 'wc_error', urlencode( esc_attr( $error ) ), $redirect );
|
||||
if ( $message ) $redirect = add_query_arg( 'wc_message', urlencode( esc_attr( $message ) ), $redirect );
|
||||
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
|
||||
} elseif ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'recover' ) {
|
||||
|
||||
$this->init_share_your_cart();
|
||||
|
||||
$error = $message = '';
|
||||
|
||||
$redirect = remove_query_arg( 'saved' );
|
||||
$redirect = remove_query_arg( 'wc_error', $redirect );
|
||||
$redirect = remove_query_arg( 'wc_message', $redirect );
|
||||
|
||||
if ( ! empty( $_POST['domain'] ) && ! empty( $_POST['email'] ) ) {
|
||||
|
||||
if ( ! $this->shareYourCartWooCommerce->recover( $this->shareYourCartWooCommerce->getSecretKey(), $_POST['domain'], $_POST['email'], $message ) ) {
|
||||
|
||||
$error = $message;
|
||||
|
||||
if ( json_decode($error) ) {
|
||||
$error = json_decode($error);
|
||||
$error = $error->message;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
|
||||
} else {
|
||||
$redirect = remove_query_arg( 'syc-account', $redirect );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$error = __( 'Please complete all fields.', 'woocommerce' );
|
||||
|
||||
}
|
||||
|
||||
if ( $error ) $redirect = add_query_arg( 'wc_error', urlencode( esc_attr( $error ) ), $redirect );
|
||||
if ( $message ) $redirect = add_query_arg( 'wc_message', urlencode( esc_attr( $message ) ), $redirect );
|
||||
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//after this function completes, WooCommerce will refresh the page, so we need to save the data here
|
||||
|
||||
//stripslashes from button_html
|
||||
if(isset($_POST['button_html']))
|
||||
$_POST['button_html'] = stripslashes($_POST['button_html']);
|
||||
|
||||
//TODO: investigate why the files are not being uploaded
|
||||
|
||||
$this->shareYourCartWooCommerce->getAdminPage($this); //get the admin page ( so that the data is processed, but do not show it )
|
||||
$this->shareYourCartWooCommerce->getButtonCustomizationPage(); //get the customization page ( so that the data is processed, but do not show it )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Admin Options
|
||||
*
|
||||
|
@ -181,226 +89,25 @@ class WC_ShareYourCart extends WC_Integration {
|
|||
* @since 1.0.0
|
||||
*/
|
||||
function admin_options() {
|
||||
|
||||
if ( $this->enabled == 'yes' ) {
|
||||
// Installation
|
||||
|
||||
if ( $this->shareYourCartWooCommerce->isActive() ) {
|
||||
|
||||
// call this manually ( to determine if there needs to be a table update, or not )
|
||||
$this->shareYourCartWooCommerce->install();
|
||||
|
||||
// Check status
|
||||
$this->shareYourCartWooCommerce->admin_settings_page();
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ( ! $this->client_id && ! $this->app_key ) {
|
||||
|
||||
if ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'create' ) {
|
||||
|
||||
?>
|
||||
<div class="updated">
|
||||
<h3><?php _e( 'Create a ShareYourCart account', 'woocommerce' ) ?></h3>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th><?php _e( 'Domain', 'woocommerce' ); ?></th>
|
||||
<td><input type="text" name="domain" id="domain" class="regular-text" value="<?php echo (isset($_POST['domain']) ? $_POST['domain'] : site_url()); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php _e( 'Email', 'woocommerce' ); ?></th>
|
||||
<td><input type="text" name="email" id="email" class="regular-text" value="<?php echo (isset($_POST['email']) ? $_POST['email'] : get_option('admin_email')); ?>"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<td><input class="buttonCheckbox" name="syc-terms-agreement" id="syc-terms-agreement" type="checkbox" /> <label for="syc-terms-agreement"><?php printf(__( 'I agree to the <a href="%s">ShareYourCart terms and conditions</a>', 'woocommerce' ), 'http://shareyourcart.com/terms'); ?></label></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="submit"><input type="submit" class="button button-primary" value="<?php _e( 'Create Account', 'woocommerce' ) ?>" /></p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
} elseif ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'recover' ) {
|
||||
|
||||
?>
|
||||
<div class="updated">
|
||||
<h3><?php _e( 'Recover your ShareYourCart account', 'woocommerce' ) ?></h3>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th><?php _e( 'Domain', 'woocommerce' ); ?></th>
|
||||
<td><input type="text" name="domain" id="domain" class="regular-text" value="<?php echo (isset($_POST['domain']) ? $_POST['domain'] : site_url()); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php _e( 'Email', 'woocommerce' ); ?></th>
|
||||
<td><input type="text" name="email" id="email" class="regular-text" value="<?php echo (isset($_POST['email']) ? $_POST['email'] : get_option('admin_email')); ?>"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="submit"><input type="submit" class="button button-primary" value="<?php _e( 'Email me my details', 'woocommerce' ) ?>" /></p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
} else {
|
||||
|
||||
?>
|
||||
<div id="wc_get_started">
|
||||
<span class="main"><?php _e( 'Setup your ShareYourCart account', 'woocommerce' ); ?></span>
|
||||
<span><?php echo $this->method_description; ?></span>
|
||||
<p><a href="<?php echo add_query_arg( 'syc-account', 'create', admin_url( 'admin.php?page=woocommerce_settings&tab=integration§ion=shareyourcart' ) ); ?>" class="button button-primary api-link"><?php _e( 'Create an account', 'woocommerce' ); ?></a> <a href="<?php echo add_query_arg( 'syc-account', 'recover', admin_url( 'admin.php?page=woocommerce_settings&tab=integration§ion=shareyourcart' ) ); ?>" class="button api-link"><?php _e( 'Can\'t access your account?', 'woocommerce' ); ?></a></p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
} else {
|
||||
echo '<h3><a href="http://shareyourcart.com/"><img src="' . plugins_url( 'sdk/img/shareyourcart-logo.png', __FILE__ ) . '" alt="ShareYourCart" /></a></h3>';
|
||||
echo wpautop( $this->method_description );
|
||||
}
|
||||
?>
|
||||
|
||||
<table class="form-table">
|
||||
<?php $this->generate_settings_html(); ?>
|
||||
<?php if ( $this->client_id && $this->app_key ) : ?>
|
||||
<tr>
|
||||
<th><?php _e( 'Configure ShareYourCart', 'woocommerce' ); ?></th>
|
||||
<td>
|
||||
<p><?php _e( 'You can choose how much of a discount to give (in fixed amount, percentage, or free shipping) and to which social media channels it should it be applied. You can also define what the advertisement should say, so that it fully benefits your sales.', 'woocommerce' ); ?></p>
|
||||
<p><a href="http://www.shareyourcart.com/configure/?app_key=<?php echo $this->app_key; ?>&client_id=<?php echo $this->client_id; ?>&email=<?php echo $this->email; ?>" class="button" target="_blank"><?php _e( 'Configure', 'woocommerce' ); ?></a></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery('#woocommerce_shareyourcart_button_style').change(function(){
|
||||
|
||||
var value = jQuery(this).val();
|
||||
|
||||
if ( value == 'standard_button' ) {
|
||||
jQuery('.standard_button').closest('tr').show();
|
||||
jQuery('.image_button').closest('tr').hide();
|
||||
jQuery('.custom_html').closest('tr').hide();
|
||||
}
|
||||
if ( value == 'image_button' ) {
|
||||
jQuery('.standard_button').closest('tr').hide();
|
||||
jQuery('.image_button').closest('tr').show();
|
||||
jQuery('.custom_html').closest('tr').hide();
|
||||
}
|
||||
if ( value == 'custom_html' ) {
|
||||
jQuery('.standard_button').closest('tr').hide();
|
||||
jQuery('.image_button').closest('tr').hide();
|
||||
jQuery('.custom_html').closest('tr').show();
|
||||
}
|
||||
|
||||
}).change();
|
||||
|
||||
</script>
|
||||
|
||||
<!-- Section -->
|
||||
<div><input type="hidden" name="section" value="<?php echo $this->id; ?>" /></div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise Settings Form Fields
|
||||
*/
|
||||
function init_form_fields() {
|
||||
|
||||
$this->form_fields = array(
|
||||
'enabled' => array(
|
||||
'title' => __( 'Enable/Disable', 'woocommerce' ),
|
||||
'label' => __( 'Enable ShareYourCart integration', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'default' => 'no',
|
||||
),
|
||||
'client_id' => array(
|
||||
'title' => __( 'Client ID', 'woocommerce' ),
|
||||
'description' => __( 'Get your client ID by creating a ShareYourCart account.', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'css' => 'width: 300px'
|
||||
),
|
||||
'app_key' => array(
|
||||
'title' => __( 'App Key', 'woocommerce' ),
|
||||
'description' => __( 'Get your app key by creating a ShareYourCart account.', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'default' => '',
|
||||
'css' => 'width: 300px'
|
||||
),
|
||||
'email' => array(
|
||||
'title' => __( 'Email address', 'woocommerce' ),
|
||||
'description' => __( 'The email address you used to sign up for ShareYourCart.', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'default' => get_option('admin_email'),
|
||||
'css' => 'width: 300px'
|
||||
),
|
||||
'show_on_product' => array(
|
||||
'title' => __( 'Show button by default on:', 'woocommerce' ),
|
||||
'label' => __( 'Product page', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'default' => 'yes',
|
||||
),
|
||||
'show_on_cart' => array(
|
||||
'label' => __( 'Cart page', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'default' => 'yes',
|
||||
),
|
||||
'button_style' => array(
|
||||
'title' => __( 'Button style', 'woocommerce' ),
|
||||
'description' => __( 'Select a style for your share buttons', 'woocommerce' ),
|
||||
'default' => 'standard_button',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'standard_button' => __( 'Standard Button', 'woocommerce' ),
|
||||
'custom_html' => __( 'Custom HTML', 'woocommerce' )
|
||||
)
|
||||
),
|
||||
'button_skin' => array(
|
||||
'title' => __( 'Button skin', 'woocommerce' ),
|
||||
'description' => __( 'Select a skin for your share buttons', 'woocommerce' ),
|
||||
'default' => 'orange',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'orange' => __( 'Orange', 'woocommerce' ),
|
||||
'blue' => __( 'Blue', 'woocommerce' ),
|
||||
'light' => __( 'Light', 'woocommerce' ),
|
||||
'dark' => __( 'Dark', 'woocommerce' )
|
||||
),
|
||||
'class' => 'standard_button'
|
||||
),
|
||||
'button_position' => array(
|
||||
'title' => __( 'Button position', 'woocommerce' ),
|
||||
'description' => __( 'Where should the button be positioned?', 'woocommerce' ),
|
||||
'default' => 'normal',
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'normal' => __( 'Normal', 'woocommerce' ),
|
||||
'floating' => __( 'Floating', 'woocommerce' )
|
||||
),
|
||||
'class' => 'standard_button'
|
||||
),
|
||||
'button_html' => array(
|
||||
'title' => __( 'HTML for the button', 'woocommerce' ),
|
||||
'description' => __( 'Enter the HTML code for your custom button.', 'woocommerce' ),
|
||||
'default' => '<button>Get a <div class="shareyourcart-discount"></div> discount</button>',
|
||||
'type' => 'textarea',
|
||||
'class' => 'custom_html'
|
||||
)
|
||||
);
|
||||
|
||||
} // End init_form_fields()
|
||||
|
||||
|
||||
$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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the integration to WooCommerce
|
||||
*
|
||||
* @package WooCommerce/Classes/Integrations
|
||||
* @access public
|
||||
* @param mixed $integrations
|
||||
* @return void
|
||||
*/
|
||||
**/
|
||||
function add_shareyourcart_integration( $integrations ) {
|
||||
if ( ! class_exists('ShareYourCartAPI') ) // Only allow this integration if we're not already using shareyourcart via another plugin
|
||||
$integrations[] = 'WC_ShareYourCart';
|
||||
$integrations[] = 'WC_ShareYourCart';
|
||||
return $integrations;
|
||||
}
|
||||
add_filter('woocommerce_integrations', 'add_shareyourcart_integration' );
|
||||
|
|
|
@ -0,0 +1,245 @@
|
|||
<?php
|
||||
|
||||
require_once("class.shareyourcart-wp.php");
|
||||
|
||||
if(!class_exists('ShareYourCartWooCommerce',false)){
|
||||
|
||||
class ShareYourCartWooCommerce extends ShareYourCartWordpressPlugin{
|
||||
|
||||
public $_plugin_name = "shareyourcart_woo_commerce";
|
||||
public $_post_user_id = 1;
|
||||
|
||||
public function processInit(){
|
||||
if(isset($_REQUEST['action'])){
|
||||
switch($_REQUEST['action']){
|
||||
case $this->_plugin_name:
|
||||
$this->buttonCallback();
|
||||
break;
|
||||
|
||||
case $this->_plugin_name.'_coupon':
|
||||
$this->couponCallback();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isCartActive() {
|
||||
return in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Extend the base class implementation
|
||||
*
|
||||
*/
|
||||
public function pluginsLoadedHook() {
|
||||
parent::pluginsLoadedHook();
|
||||
|
||||
if(!$this->isCartActive()) return;
|
||||
|
||||
add_action('init', array(&$this, 'processInit'));
|
||||
|
||||
add_action('woocommerce_before_single_product', array(&$this,'showProductButton'));
|
||||
add_action('woocommerce_cart_contents', array(&$this,'showCartButton'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the jQuery sibling selector for the product button
|
||||
*
|
||||
*/
|
||||
protected function getProductButtonPosition(){
|
||||
$selector = parent::getProductButtonPosition();
|
||||
return (!empty($selector) ? $selector : ".summary .price .amount");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the jQuery sibling selector for the cart button
|
||||
*
|
||||
*/
|
||||
protected function getCartButtonPosition(){
|
||||
$selector = parent::getCartButtonPosition();
|
||||
return (!empty($selector) ? $selector : ".cart-subtotal .amount");
|
||||
}
|
||||
|
||||
public function getSecretKey() {
|
||||
return 'd3ce6c18-7e45-495d-aa4c-8f63edee03a5';
|
||||
}
|
||||
|
||||
public function isSingleProduct() {
|
||||
return is_singular('product');
|
||||
}
|
||||
|
||||
protected function saveCoupon($token, $coupon_code, $coupon_value, $coupon_type, $product_unique_ids = array()) {
|
||||
|
||||
// Create coupon
|
||||
$post_id = $this->_saveCouponPost($coupon_code);
|
||||
|
||||
// Set coupon meta
|
||||
switch ($coupon_type) {
|
||||
case 'amount':
|
||||
$discount_type = 'fixed_product';
|
||||
$free_shipping = 'no';
|
||||
break;
|
||||
case 'percent':
|
||||
$discount_type = 'percent_product';
|
||||
$free_shipping = 'no';
|
||||
break;
|
||||
case 'free_shipping':
|
||||
$discount_type = 'fixed_product';
|
||||
$coupon_value = 0;
|
||||
$free_shipping = 'yes';
|
||||
break;
|
||||
default :
|
||||
$discount_type = 'fixed_cart';
|
||||
$free_shipping = 'no';
|
||||
}
|
||||
|
||||
update_post_meta( $post_id, 'customer_email', array() );
|
||||
update_post_meta( $post_id, 'minimum_amount', '' );
|
||||
update_post_meta( $post_id, 'exclude_product_categories', array() );
|
||||
update_post_meta( $post_id, 'product_categories', array() );
|
||||
update_post_meta( $post_id, 'free_shipping', $free_shipping );
|
||||
update_post_meta( $post_id, 'apply_before_tax', 'yes' );
|
||||
update_post_meta( $post_id, 'expiry_date', '' );
|
||||
update_post_meta( $post_id, 'usage_limit', 1 );
|
||||
update_post_meta( $post_id, 'exclude_product_ids', '' );
|
||||
update_post_meta( $post_id, 'product_ids', '' );
|
||||
update_post_meta( $post_id, 'individual_use', 'yes' );
|
||||
update_post_meta( $post_id, 'coupon_amount', $coupon_value );
|
||||
update_post_meta( $post_id, 'discount_type', $discount_type );
|
||||
|
||||
// parent
|
||||
parent::saveCoupon( $token, $coupon_code, $coupon_value, $coupon_type );
|
||||
}
|
||||
|
||||
public function applyCoupon($coupon_code) {
|
||||
//$this->_loadWooCommerce();
|
||||
|
||||
//global $woocommerce;
|
||||
//$woocommerce->cart->add_discount($coupon_code);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private function _saveCouponPost($coupon_code){
|
||||
$new_post = array(
|
||||
'post_title' => $coupon_code,
|
||||
'post_name' => ereg_replace("[^A-Za-z0-9]", "", $coupon_code),
|
||||
'post_content' => '',
|
||||
'post_status' => 'publish',
|
||||
'comment_status'=> 'closed',
|
||||
'ping_status' => 'closed',
|
||||
'post_author' => $this->_post_user_id,
|
||||
'post_type' => 'shop_coupon'
|
||||
);
|
||||
|
||||
$post_id = wp_insert_post($new_post);
|
||||
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
public function getButtonCallbackURL() {
|
||||
global $wp_query;
|
||||
|
||||
$callback_url = add_query_arg( 'action', $this->_plugin_name, trailingslashit( home_url() ) );
|
||||
|
||||
if ($this->isSingleProduct()) {
|
||||
$callback_url .= '&p='. $wp_query->post->ID;
|
||||
}
|
||||
|
||||
return $callback_url;
|
||||
}
|
||||
|
||||
public function buttonCallback(){
|
||||
if(!$this->isCartActive()) return;
|
||||
|
||||
$this->_loadWooCommerce();
|
||||
|
||||
//specify the parameters
|
||||
$params = array(
|
||||
'callback_url' => get_bloginfo('wpurl').'/?action='.$this->_plugin_name.'_coupon'.(isset($_REQUEST['p']) ? '&p='.$_REQUEST['p'] : '' ),
|
||||
'success_url' => get_option('shopping_cart_url'),
|
||||
'cancel_url' => get_option('shopping_cart_url'),
|
||||
);
|
||||
|
||||
//there is no product set, thus send the products from the shopping cart
|
||||
if(!isset($_REQUEST['p']))
|
||||
{
|
||||
if(empty($_SESSION['cart']))
|
||||
exit("Cart is empty");
|
||||
|
||||
foreach($_SESSION['cart'] as $cart_details){
|
||||
$params['cart'][] = $this->_getProductDetails($cart_details['product_id']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$params['cart'][] = $this->_getProductDetails($_REQUEST['p']);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->startSession($params);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
//display the error to the user
|
||||
echo $e->getMessage();
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
private function _getProductDetails($product_id){
|
||||
$product = new WC_Product($product_id);
|
||||
|
||||
//WooCommerce actually echoes the image
|
||||
ob_start();
|
||||
echo $product->get_image(); //older WooCommerce versions might allready echo, but newer versions don't, so force it anyway
|
||||
$image = ob_get_clean();
|
||||
|
||||
//check is image actually a HTML img entity
|
||||
if(($doc = @DomDocument::loadHTML($image)) !== FALSE)
|
||||
{
|
||||
$imageTags = $doc->getElementsByTagName('img');
|
||||
if($imageTags->length >0 )
|
||||
$src = $imageTags->item(0)->getAttribute('src');
|
||||
|
||||
//replace image only if src has been set
|
||||
if (!empty($src))
|
||||
$image = $src;
|
||||
}
|
||||
|
||||
return array(
|
||||
"item_name" => $product->get_title(),
|
||||
"item_description" => $product->post->post_excerpt,
|
||||
"item_url" => get_permalink($product_id),
|
||||
"item_price" => $product->price,
|
||||
"item_picture_url" => $image,
|
||||
);
|
||||
}
|
||||
|
||||
public function loadSessionData() {
|
||||
return;
|
||||
}
|
||||
|
||||
private function _loadWooCommerce(){
|
||||
// Sometimes the WooCommerce Class is not loaded...
|
||||
|
||||
if(!class_exists('Woocommerce', false)){
|
||||
require_once(ABSPATH . 'wp-content/plugins/woocommerce/woocommerce.php');
|
||||
}
|
||||
|
||||
// Important Classes Not included
|
||||
if(!function_exists('has_post_thumbnail')){
|
||||
require_once(ABSPATH . 'wp-includes/post-thumbnail-template.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO: see why this is not used
|
||||
add_action(ShareYourCartWordpressPlugin::getPluginFile(), array('ShareYourCartWooCommerce','uninstallHook'));
|
||||
|
||||
} //END IF
|
|
@ -0,0 +1,382 @@
|
|||
<?php
|
||||
/**
|
||||
* CLASS: Share Your Cart Wordpress Plugin
|
||||
* AUTHOR: Barandi Solutions
|
||||
* COUNTRY: Romania
|
||||
* EMAIL: catalin.paun@barandisolutions.ro
|
||||
* VERSION : 1.0
|
||||
* DESCRIPTION: This class is used as a base class for every wordpress shopping cart plugin we create.
|
||||
* * Copyright (C) 2011 Barandi Solutions
|
||||
*/
|
||||
|
||||
require_once("sdk/class.shareyourcart-base.php");
|
||||
|
||||
if(!class_exists('ShareYourCartWordpressPlugin',false)){
|
||||
|
||||
abstract class ShareYourCartWordpressPlugin extends ShareYourCartBase {
|
||||
|
||||
protected static $_INSTANCES = array();
|
||||
protected static $_VERSION = 4;
|
||||
protected $_PLUGIN_PATH;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param null
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
parent::__construct();
|
||||
|
||||
//if there is installed another plugin with a never version
|
||||
//do not load this one further
|
||||
if(!$this->canLoad()) return;
|
||||
|
||||
//make sure we add this instance
|
||||
self::$_INSTANCES []= $this;
|
||||
$this->_PLUGIN_PATH = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
|
||||
|
||||
//setup the hooks
|
||||
register_activation_hook(self::getPluginFile(), array(&$this,'activateHook'));
|
||||
register_deactivation_hook(self::getPluginFile(), array(&$this,'deactivateHook'));
|
||||
|
||||
//perform the rest of the loading AFTER all plugins have been loaded
|
||||
add_action('plugins_loaded', array(&$this,'pluginsLoadedHook'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract isCartActive
|
||||
* @param null
|
||||
* @return boolean
|
||||
*/
|
||||
protected abstract function isCartActive();
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the plugin version.
|
||||
* @return an integer
|
||||
*
|
||||
*/
|
||||
protected function getPluginVersion(){
|
||||
|
||||
return self::$_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the project's URL
|
||||
*
|
||||
*/
|
||||
protected function getDomain(){
|
||||
|
||||
return get_bloginfo('url');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the admin's email
|
||||
*
|
||||
*/
|
||||
protected function getAdminEmail(){
|
||||
|
||||
return get_settings('admin_email');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Set the field value
|
||||
*
|
||||
*/
|
||||
protected function setConfigValue($field,$value){
|
||||
update_option('_shareyourcart_'.$field,$value);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the field value
|
||||
*
|
||||
*/
|
||||
protected function getConfigValue($field){
|
||||
return get_option('_shareyourcart_'.$field);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the path to the main file of the plugin
|
||||
*
|
||||
*/
|
||||
public static function getPluginFile(){
|
||||
global $plugin;
|
||||
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the upload directory
|
||||
*
|
||||
*/
|
||||
public function getUploadDir(){
|
||||
$dir = wp_upload_dir();
|
||||
|
||||
return (!empty($dir['path']) ? $dir['path'] : parent::getUploadDir());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Execute the SQL statement
|
||||
*
|
||||
*/
|
||||
protected function executeNonQuery($sql){
|
||||
|
||||
if(substr($sql,0,12) == "CREATE TABLE"){
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
||||
|
||||
//if this is a create table command, use the special function which compares tables
|
||||
dbDelta($sql);
|
||||
|
||||
} else {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
//use the normal query
|
||||
$wpdb->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the row returned from the SQL
|
||||
*
|
||||
* @return an associative array containing the data of the row OR NULL
|
||||
* if there is none
|
||||
*/
|
||||
protected function getRow($sql){
|
||||
|
||||
global $wpdb;
|
||||
|
||||
//get the row as an associative array
|
||||
return $wpdb->get_row($sql,ARRAY_A);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the table name based on the key
|
||||
*
|
||||
*/
|
||||
protected function getTableName($key){
|
||||
global $wpdb;
|
||||
|
||||
return $wpdb->base_prefix.$key;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Insert the row into the specified table
|
||||
*
|
||||
*/
|
||||
protected function insertRow($tableName,$data){
|
||||
global $wpdb;
|
||||
|
||||
$wpdb->insert($tableName,$data);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Create url for the specified file. The file must be specified in relative path
|
||||
* to the base of the plugin
|
||||
*/
|
||||
protected function createUrl($file){
|
||||
//get the real file path
|
||||
$file = realpath($file);
|
||||
|
||||
//calculate the relative path from this file
|
||||
$file = SyC::relativepath(dirname(__FILE__),$file);
|
||||
|
||||
//append the relative path to the current file's URL
|
||||
return WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).$file;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Part of the initialization process, this is used to check if the cart is
|
||||
* really active
|
||||
*
|
||||
*/
|
||||
public function pluginsLoadedHook() {
|
||||
|
||||
//if the cart is not loaded, do not load this plugin further
|
||||
if(!$this->isCartActive()) return;
|
||||
|
||||
add_action('wp_head', array(&$this,'showPageHeader'));
|
||||
add_action('admin_menu', array(&$this,'showAdminMenu'));
|
||||
|
||||
//add the shortcodes ONLY if they where not added before, by another plugin
|
||||
global $shortcode_tags;
|
||||
if(!array_key_exists('shareyourcart',$shortcode_tags)){
|
||||
add_shortcode('shareyourcart', array(&$this,'getButton'));
|
||||
add_shortcode('shareyourcart_button', array(&$this,'getButton'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This is the activate hook called by WordPress. It is used for both install and activate
|
||||
*
|
||||
*/
|
||||
public function activateHook() {
|
||||
|
||||
if(!$this->isCartActive()) return;
|
||||
|
||||
$message = '';
|
||||
|
||||
//the db version is old, so install it again
|
||||
if(version_compare($this->getConfigValue('db_version'),self::$_DB_VERSION)!=0){
|
||||
|
||||
$this->install($message);
|
||||
} else { //if the version are equal, simply activate the plugin
|
||||
|
||||
$this->activate($message);
|
||||
}
|
||||
|
||||
//TODO: perhaps we can show the message somehow to the user. For now, just log it
|
||||
error_log($message);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This is the deactivate hook called by WordPress.
|
||||
*
|
||||
*/
|
||||
public function deactivateHook() {
|
||||
|
||||
if(!$this->isCartActive()) return;
|
||||
|
||||
$message = '';
|
||||
|
||||
$this->deactivate($message);
|
||||
|
||||
//TODO: perhaps we can show the message somehow to the user. For now, just log it
|
||||
error_log($message);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* When installing the new wordpress plugin, make sure to move the old data
|
||||
*
|
||||
*/
|
||||
public function install(&$message = null) {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$old_table_name = $this->getTableName('shareyourcart_settings');
|
||||
if($wpdb->get_var("show tables like '$old_table_name'") == $old_table_name) {
|
||||
|
||||
//get the old app_key and client_id
|
||||
$settings = $wpdb->get_row("SELECT app_key, client_id FROM ".$wpdb->base_prefix."shareyourcart_settings LIMIT 1");
|
||||
if($settings) {
|
||||
|
||||
$this->setConfigValue('appKey', $settings->app_key);
|
||||
$this->setConfigValue('clientId', $settings->client_id);
|
||||
}
|
||||
|
||||
//remove the old table
|
||||
$wpdb->query("DROP TABLE $old_table_name");
|
||||
}
|
||||
|
||||
parent::install($message);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This is the deactivate hook called by WordPress.
|
||||
*
|
||||
*/
|
||||
public static function uninstallHook() {
|
||||
|
||||
//this hook is required by WordPress to be static
|
||||
//so call uninstall on the first instance
|
||||
if(!empty(self::$_INSTANCES)){
|
||||
|
||||
self::$_INSTANCES[0]->uninstall();
|
||||
} else {
|
||||
|
||||
//log the error
|
||||
error_log("There is no instance created when calling uninstall hook");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* show the admin menu
|
||||
* @param null
|
||||
* @return boolean
|
||||
*/
|
||||
public function showAdminMenu() {
|
||||
|
||||
//this is a single call function
|
||||
if(!$this->isFirstCall(__FUNCTION__)) return;
|
||||
|
||||
//first, check the SDK status
|
||||
$this->checkSDKStatus();
|
||||
|
||||
//see if we need to show the update notification
|
||||
$notification = null;
|
||||
if($this->hasNewerVersion())
|
||||
$notification = "<span class='update-plugins count-$warning_count'><span class='update-count'>" . number_format_i18n(1) . "</span></span>";
|
||||
|
||||
$page = add_menu_page(
|
||||
__('Share your cart settings'),
|
||||
__('ShareYourCart').$notification,
|
||||
1,
|
||||
basename(__FILE__),
|
||||
array(&$this, 'showAdminPage'),
|
||||
$this->_PLUGIN_PATH .'sdk/img/shareyourcart.png'
|
||||
);
|
||||
add_action( 'admin_head-'.$page, array(&$this, 'showAdminHeader'));
|
||||
|
||||
if($this->isActive())
|
||||
{
|
||||
//show the rest of the menu ONLY if the plugin is active
|
||||
$page = add_submenu_page(
|
||||
basename(__FILE__),
|
||||
__('Button'),
|
||||
__('Customize Button'),
|
||||
1,
|
||||
basename(__FILE__).'-button',
|
||||
array(&$this, 'showButtonCustomizationPage'));
|
||||
add_action( 'admin_head-'. $page, array(&$this, 'showAdminHeader'));
|
||||
|
||||
$page = add_submenu_page(
|
||||
basename(__FILE__),
|
||||
__('Documentation'),
|
||||
__('Documentation'),
|
||||
1,
|
||||
basename(__FILE__).'-documentation',
|
||||
array(&$this, 'showDocumentationPage'));
|
||||
add_action( 'admin_head-'. $page, array(&$this, 'showAdminHeader'));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Called when a new coupon is generated
|
||||
*
|
||||
*/
|
||||
public function couponCallback(){
|
||||
|
||||
//since there are a lot of plugins for wordpress, first make sure this plugin
|
||||
//is active
|
||||
if(!$this->isCartActive()) {
|
||||
|
||||
throw new Exception(SyC::t('sdk','Shopping Cart is not active'));
|
||||
}
|
||||
|
||||
parent::couponCallback();
|
||||
|
||||
//since this is actually an API, exit
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
} //END IF
|
||||
?>
|
|
@ -0,0 +1,73 @@
|
|||
/*use our own save buttons, in order to determine what actions the user made*/
|
||||
p.submit .button-primary{
|
||||
display:none
|
||||
}
|
||||
|
||||
/* disable extra padding */
|
||||
.wrap {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.form-table th {
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.form-table td{
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
margin-bottom: 9px;
|
||||
padding: 8px 10px;
|
||||
}
|
||||
|
||||
.form-table a{
|
||||
color: #21759B;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.api-link {
|
||||
color: #464646;
|
||||
font-weight: normal;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.api-status {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.api-link:hover{
|
||||
color: #d54e21;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.syc-configuration {
|
||||
width: 60%;
|
||||
}
|
||||
.configure-button-container {
|
||||
width: auto;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.buttonTextarea {
|
||||
width: auto;
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.buttonOption {
|
||||
height: 170px;
|
||||
background-position: right -54px;
|
||||
}
|
||||
|
||||
body .buttonCheckbox {
|
||||
margin: 0 9px 0 0;
|
||||
}
|
||||
|
||||
.buttonOptions {
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
#visual-options>fieldset {
|
||||
margin: 0 0 20px;
|
||||
}
|
|
@ -9,8 +9,6 @@
|
|||
* * Copyright (C) 2011 Barandi Solutions
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if(!class_exists('ShareYourCartAPI',false)){
|
||||
|
||||
class ShareYourCartAPI {
|
||||
|
@ -25,6 +23,7 @@ class ShareYourCartAPI {
|
|||
protected $SHAREYOURCART_API_CREATE;
|
||||
protected $SHAREYOURCART_API_VALIDATE;
|
||||
protected $SHAREYOURCART_API_STATUS;
|
||||
protected $SHAREYOURCART_API_TRANSLATION;
|
||||
protected $SHAREYOURCART_CONFIGURE;
|
||||
protected $SHAREYOURCART_BUTTON_JS;
|
||||
protected $SHAREYOURCART_BUTTON_URL;
|
||||
|
@ -42,7 +41,7 @@ class ShareYourCartAPI {
|
|||
if(method_exists ($this,'getSecretKey')){
|
||||
$secretKey = $this->getSecretKey();
|
||||
if(empty($secretKey)){
|
||||
throw new Exception("You must specify a valid secret key");
|
||||
throw new Exception(SyC::t('sdk',"You must specify a valid secret key"));
|
||||
}
|
||||
|
||||
//check if the secret key is a sandbox one
|
||||
|
@ -61,6 +60,7 @@ class ShareYourCartAPI {
|
|||
$this->SHAREYOURCART_API_CREATE = $this->SHAREYOURCART_API.'/session/create';
|
||||
$this->SHAREYOURCART_API_VALIDATE = $this->SHAREYOURCART_API.'/session/validate';
|
||||
$this->SHAREYOURCART_API_STATUS = $this->SHAREYOURCART_API.'/sdk';
|
||||
$this->SHAREYOURCART_API_TRANSLATION = $this->SHAREYOURCART_API.'/sdk/translation';
|
||||
$this->SHAREYOURCART_CONFIGURE = $this->SHAREYOURCART_API.'/configure';
|
||||
$this->SHAREYOURCART_BUTTON_JS = $this->SHAREYOURCART_API.'/js/'.($is_live ? 'button.js' : 'button_sandbox.js');
|
||||
$this->SHAREYOURCART_BUTTON_URL = $this->SHAREYOURCART_API.'/button';
|
||||
|
@ -354,6 +354,41 @@ class ShareYourCartAPI {
|
|||
// Decode the result
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns an array of messages for the SDK, in the specified language
|
||||
*
|
||||
*/
|
||||
public function getSDKTranslation($lang, &$message = null)
|
||||
{
|
||||
$params = array('lang' => $lang);
|
||||
|
||||
//make the API call
|
||||
$session = curl_init($this->SHAREYOURCART_API_TRANSLATION);
|
||||
|
||||
// Tell curl to use HTTP POST
|
||||
curl_setopt($session, CURLOPT_POST, true);
|
||||
// Tell curl that this is the body of the POST
|
||||
curl_setopt($session, CURLOPT_POSTFIELDS, http_build_query($params,'','&'));
|
||||
// Tell curl not to return headers, but do return the response
|
||||
curl_setopt($session, CURLOPT_HEADER, false);
|
||||
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($session);
|
||||
$httpCode = curl_getinfo($session, CURLINFO_HTTP_CODE);
|
||||
curl_close($session);
|
||||
|
||||
// Notify the caller
|
||||
if($httpCode != 200) {
|
||||
if(isset($message)) $message = $response;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decode the result
|
||||
return json_decode($response, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -366,6 +401,7 @@ class SyC
|
|||
{
|
||||
static $_messages;
|
||||
static $_language = 'en';
|
||||
static $loadLanguage = array('SyC','loadFileLanguage'); //variable that holds the name of the function used to load a particular language
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -379,6 +415,38 @@ class SyC
|
|||
self::$_messages = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the language that is currently loaded
|
||||
*
|
||||
*/
|
||||
public static function getLanguage(){
|
||||
return self::$_language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the checksum of the currently loaded translation
|
||||
*/
|
||||
public static function getLanguageChecksum($category = 'sdk')
|
||||
{
|
||||
//load the translation from file if not done so
|
||||
if(!isset(self::$_messages)){
|
||||
|
||||
//load the language
|
||||
self::$_messages = call_user_func(self::$loadLanguage,self::$_language,$category);
|
||||
}
|
||||
|
||||
return md5(json_encode(self::$_messages));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload the language
|
||||
*/
|
||||
public static function reloadLanguage()
|
||||
{
|
||||
self::$_messages = null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate the specified message
|
||||
*
|
||||
|
@ -388,16 +456,8 @@ class SyC
|
|||
//load the translation from file if not done so
|
||||
if(!isset(self::$_messages)){
|
||||
|
||||
//The language is the folder name, and the category is the name of the file
|
||||
$messageFile = dirname(__FILE__).DIRECTORY_SEPARATOR.'messages'.DIRECTORY_SEPARATOR.self::$_language.DIRECTORY_SEPARATOR.$category.'.php';
|
||||
|
||||
if(is_file($messageFile))
|
||||
{
|
||||
self::$_messages=include($messageFile);
|
||||
}
|
||||
|
||||
//make sure we have an array for this variable
|
||||
if(!is_array(self::$_messages)) self::$_messages=array();
|
||||
//load the language
|
||||
self::$_messages = call_user_func(self::$loadLanguage,self::$_language,$category);
|
||||
}
|
||||
|
||||
//check if the text has a valid translation
|
||||
|
@ -409,8 +469,46 @@ class SyC
|
|||
return $params!==array() ? strtr($message,$params) : $message;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* change the language loader method
|
||||
*
|
||||
*/
|
||||
public static function setLanguageLoader($loader)
|
||||
{
|
||||
//make sure the loader is ok
|
||||
if(!is_callable($loader))
|
||||
throw new Exception(SyC::t('sdk',"The language loader is not a valid callback"));
|
||||
|
||||
self::$loadLanguage = $loader;
|
||||
|
||||
//reset the old messages, so that they are reloaded with the new loader
|
||||
self::$_messages = null;
|
||||
}
|
||||
|
||||
function relativepath($from, $to, $ps = '/' ,$ds = DIRECTORY_SEPARATOR)
|
||||
/**
|
||||
*
|
||||
* Function to load a language from the hard-drive.
|
||||
*
|
||||
*/
|
||||
public static function loadFileLanguage($lang, $category)
|
||||
{
|
||||
//The language is the folder name, and the category is the name of the file
|
||||
$messageFile = dirname(__FILE__).DIRECTORY_SEPARATOR.'messages'.DIRECTORY_SEPARATOR.$lang.DIRECTORY_SEPARATOR.$category.'.php';
|
||||
|
||||
$messages = null;
|
||||
if(is_file($messageFile))
|
||||
{
|
||||
$messages=include($messageFile);
|
||||
}
|
||||
|
||||
//make sure we have an array for this variable
|
||||
if(!is_array($messages)) $messages=array();
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public static function relativepath($from, $to, $ps = '/' ,$ds = DIRECTORY_SEPARATOR)
|
||||
{
|
||||
$arFrom = explode($ds, rtrim($from, $ds));
|
||||
$arTo = explode($ds, rtrim($to, $ds));
|
||||
|
@ -428,7 +526,7 @@ class SyC
|
|||
* @param string $src
|
||||
* @return string
|
||||
*/
|
||||
function rel2Abs($rel, $base) {
|
||||
public static function rel2Abs($rel, $base) {
|
||||
|
||||
/* return if already absolute URL */
|
||||
if (parse_url($rel, PHP_URL_SCHEME) != '')
|
||||
|
@ -467,7 +565,7 @@ class SyC
|
|||
* @param string $src
|
||||
* @return string
|
||||
*/
|
||||
function htmlIndent($src) {
|
||||
public static function htmlIndent($src) {
|
||||
|
||||
//replace all leading spaces with
|
||||
//Attention: this will render wrong html if you split a tag on more lines!
|
||||
|
@ -475,6 +573,22 @@ class SyC
|
|||
), $src);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns TRUE if haystack starts with needle
|
||||
*/
|
||||
public static function startsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
return (substr($haystack, 0, $length) === $needle);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns TRUE if haystack ends with needle
|
||||
*/
|
||||
public static function endsWith($haystack, $needle)
|
||||
{
|
||||
return (substr($haystack, strlen($haystack) - strlen($needle)) === $needle);
|
||||
}
|
||||
}
|
||||
|
||||
} //END IF
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
* DESCRIPTION: This class is used as a base class for every PHP plugin we create.
|
||||
* * Copyright (C) 2012 Barandi Solutions
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
require_once(dirname(__FILE__) ."/class.shareyourcart-api.php");
|
||||
|
||||
if(!class_exists('ShareYourCartBase',false)){
|
||||
|
@ -20,8 +17,9 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
|
||||
//this array is used to hold function calls between different instances of this class
|
||||
private static $_SINGLE_FUNCTIONS_CALLS = array();
|
||||
private static $_SDK_VERSION = '1.6'; //the first one is the SDK main version, while the second one is it's revision
|
||||
private static $_SDK_VERSION = '1.9'; //the first one is the SDK main version, while the second one is it's revision
|
||||
protected static $_DB_VERSION = '1.1';
|
||||
protected $SDK_ANALYTICS = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -37,10 +35,15 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
|
||||
//now, add the api version to the button_js, in order to force users to download the latest
|
||||
//JS file
|
||||
$this->SHAREYOURCART_BUTTON_JS .= '?v='. $this->getConfigValue('api_version');
|
||||
if(!$this->isDebugMode()){
|
||||
$this->SHAREYOURCART_BUTTON_JS .= '?v='. $this->getConfigValue('api_version');
|
||||
} else { //for debug mode, use a different JS ( one that is not minified, and can be cached thus debugged
|
||||
$this->SHAREYOURCART_BUTTON_JS = $this->SHAREYOURCART_API.'/js/button.dev.js';
|
||||
}
|
||||
$this->SHAREYOURCART_BUTTON_URL .= '?client_id='. $this->getClientId();
|
||||
|
||||
//set the language
|
||||
//set the language & it's loader
|
||||
SyC::setLanguageLoader(array(&$this,'loadLanguage'));
|
||||
SyC::setLanguage($this->getConfigValue('lang'));
|
||||
}
|
||||
|
||||
|
@ -77,7 +80,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
protected abstract function setConfigValue($field, $value);
|
||||
|
||||
/**
|
||||
* Abstract setConfigValue
|
||||
* Abstract getConfigValue
|
||||
* @param string option
|
||||
* @param string value
|
||||
* @return string
|
||||
|
@ -104,6 +107,15 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
*/
|
||||
protected abstract function isSingleProduct();
|
||||
|
||||
/**
|
||||
*
|
||||
* Return FALSE if the curent single product is out of stock, or not
|
||||
*
|
||||
*/
|
||||
public function isOutOfStock(){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the URL to be called when the button is pressed
|
||||
|
@ -148,6 +160,24 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
*/
|
||||
protected abstract function applyCoupon($coupon_code);
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the jQuery sibling selector for the product button
|
||||
*
|
||||
*/
|
||||
protected function getProductButtonPosition(){
|
||||
return $this->getConfigValue('product_button_position');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the jQuery sibling selector for the cart button
|
||||
*
|
||||
*/
|
||||
protected function getCartButtonPosition(){
|
||||
return $this->getConfigValue('cart_button_position');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the plugin version.
|
||||
|
@ -170,6 +200,18 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
return self::$_SDK_VERSION.'.'.$minor_version;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns TRUE if the account is in debug mode
|
||||
*
|
||||
*/
|
||||
public function isDebugMode()
|
||||
{
|
||||
$val =$this->getConfigValue('debug');
|
||||
|
||||
return !empty($val);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return TRUE if there is a newer version of the plugin
|
||||
|
@ -236,6 +278,12 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
|
||||
$activated = $this->activate($message);
|
||||
}
|
||||
|
||||
//set some default value, like the button skin
|
||||
$skin = $this->getConfigValue('button_skin');
|
||||
if(empty($skin)){
|
||||
$this->setConfigValue("button_skin", "light");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -295,12 +343,12 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
public function deactivate(&$message = null) {
|
||||
|
||||
//send the notification to the API
|
||||
$this->setAccountStatus($this->getSecretKey(), $this->getClientID(), $this->getAppKey(), false, $message);
|
||||
$success = $this->setAccountStatus($this->getSecretKey(), $this->getClientID(), $this->getAppKey(), false, $message);
|
||||
|
||||
//no matter what the API says, disable this plugin
|
||||
$this->setConfigValue("account_status", "inactive");
|
||||
|
||||
return true;
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,6 +397,11 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
//create a new session
|
||||
$data = parent::startSession($params);
|
||||
|
||||
//reset the Location, as the following code might give an error
|
||||
//and the developer needs to be aware of it
|
||||
$headers = headers_list();
|
||||
header('Location:');
|
||||
|
||||
//save session details
|
||||
$this->insertRow($this->getTableName('shareyourcart_tokens'), $data);
|
||||
|
||||
|
@ -356,6 +409,13 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
if($this->getSessionId($data['token']) === null)
|
||||
throw new Exception(SyC::t('sdk','Token cannot be saved. Check your "{table_name}" table permissions.', array('{table_name}' => $this->getTableName('shareyourcart_tokens'))));
|
||||
|
||||
|
||||
//since everything is ok, resume the Location header
|
||||
foreach($headers as $header)
|
||||
{
|
||||
header($header);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -390,9 +450,9 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
* @param null
|
||||
* @return boolean
|
||||
*/
|
||||
public function showButton() {
|
||||
public function showButton($position = null) {
|
||||
|
||||
echo $this->getButton();
|
||||
echo $this->getButton($position);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -400,12 +460,12 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
* get the button code
|
||||
*
|
||||
*/
|
||||
public function getButton() {
|
||||
public function getButton($position = null) {
|
||||
|
||||
//make sure the API is active
|
||||
if(!$this->isActive()) return;
|
||||
|
||||
return $this->renderButton($this->getButtonCallbackURL());
|
||||
return $this->renderButton($this->getButtonCallbackURL(), $position);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -413,38 +473,44 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
* @param null
|
||||
* @return boolean
|
||||
*/
|
||||
protected function renderButton($callback_url) {
|
||||
ob_start();
|
||||
|
||||
$current_button_type = $this->getConfigValue("button_type");
|
||||
$button_html = $this->getConfigValue("button_html");
|
||||
protected function renderButton($callback_url,$position = null) {
|
||||
|
||||
$button_img = $this->getConfigValue("btn-img");
|
||||
$button_img_width = $this->getConfigValue("btn-img-width");
|
||||
$button_img_height = $this->getConfigValue("btn-img-height");
|
||||
$data = array(
|
||||
'current_button_type' => $this->getConfigValue("button_type"),
|
||||
'button_html' => $this->getConfigValue("button_html"),
|
||||
|
||||
$button_img_hover = $this->getConfigValue("btn-img-h");
|
||||
$button_img_hover_width = $this->getConfigValue("btn-img-h-width");
|
||||
$button_img_hover_height = $this->getConfigValue("btn-img-h-height");
|
||||
'button_img' => $this->getUrl($this->getConfigValue("btn-img")),
|
||||
'button_img_width' => $this->getConfigValue("btn-img-width"),
|
||||
'button_img_height' => $this->getConfigValue("btn-img-height"),
|
||||
|
||||
'button_img_hover' => $this->getUrl($this->getConfigValue("btn-img-h")),
|
||||
'button_img_hover_width' => $this->getConfigValue("btn-img-h-width"),
|
||||
'button_img_hover_height' => $this->getConfigValue("btn-img-h-height"),
|
||||
|
||||
switch ($current_button_type)
|
||||
'is_product_page' => $this->isSingleProduct(),
|
||||
|
||||
'position_'.(SyC::startsWith($position,"/*before*/") ? 'before' : 'after') => $position,
|
||||
);
|
||||
|
||||
$output = null;
|
||||
switch ($data['current_button_type'])
|
||||
{
|
||||
case '1':
|
||||
include(dirname(__FILE__) . '/views/button.php');
|
||||
$output = $this->renderView('button',$data);
|
||||
break;
|
||||
case '2':
|
||||
include(dirname(__FILE__) . '/views/button-img.php');
|
||||
$output = $this->renderView('button-img',$data);
|
||||
break;
|
||||
case '3':
|
||||
include(dirname(__FILE__) . '/views/button-custom.php');
|
||||
$output = $this->renderView('button-custom',$data);
|
||||
break;
|
||||
default:
|
||||
include(dirname(__FILE__) . '/views/button.php');
|
||||
$output = $this->renderView('button',$data);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ob_get_clean();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -464,9 +530,9 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
*/
|
||||
public function getProductButton() {
|
||||
|
||||
if($this->isSingleProduct() && !$this->getConfigValue('hide_on_product')){
|
||||
if($this->isSingleProduct() && !$this->getConfigValue('hide_on_product') && !$this->isOutOfStock()){
|
||||
|
||||
return $this->getButton();
|
||||
return $this->getButton($this->getProductButtonPosition());
|
||||
}
|
||||
|
||||
//else return nothing
|
||||
|
@ -492,7 +558,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
|
||||
if(!$this->getConfigValue('hide_on_checkout')){
|
||||
|
||||
return $this->getButton();
|
||||
return $this->getButton($this->getCartButtonPosition(),false);
|
||||
}
|
||||
|
||||
//return nothing
|
||||
|
@ -520,11 +586,9 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
if (!$this->isFirstCall(__FUNCTION__))
|
||||
return;
|
||||
|
||||
$data = $this->getCurrentProductDetails();
|
||||
|
||||
ob_start();
|
||||
include(dirname(__FILE__) . '/views/page-header.php');
|
||||
return ob_get_clean();
|
||||
return $this->renderView('page-header',array(
|
||||
'data' => $this->getCurrentProductDetails(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -549,11 +613,9 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
return;
|
||||
|
||||
//check the SDK status
|
||||
$this->checkSDKStatus(true); //for a check, as the admin might have changed the language in the configure page, so we need to sync with it
|
||||
$this->checkSDKStatus(true); //force a check, as the admin might have changed the language in the configure page, so we need to sync with it
|
||||
|
||||
ob_start();
|
||||
include(dirname(__FILE__) . '/views/admin-header.php');
|
||||
return ob_get_clean();
|
||||
return $this->renderView('admin-header');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -577,7 +639,8 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
if (!$this->isFirstCall(__FUNCTION__))
|
||||
return;
|
||||
|
||||
$status_message = '';
|
||||
$status_message = ''; //this is to be used for good messages
|
||||
$error_message = ''; //this is to be used for bad messages
|
||||
$refresh = false;
|
||||
|
||||
//check if this is a post for this particular page
|
||||
|
@ -596,7 +659,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
} else {
|
||||
|
||||
//the account did not activate, so show the error
|
||||
$status_message = $message;
|
||||
$error_message = $message;
|
||||
}
|
||||
|
||||
//since we might have changed the status, REFRESH
|
||||
|
@ -606,7 +669,14 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
else if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
|
||||
!empty($_POST['disable-API'])){
|
||||
|
||||
$this->deactivate($status_message);
|
||||
$message = '';
|
||||
if($this->deactivate($message) == true) {
|
||||
|
||||
$status_message = $message;
|
||||
} else {
|
||||
|
||||
$error_message = $message;
|
||||
}
|
||||
|
||||
//since we might have changed the status, REFRESH
|
||||
$refresh = true;
|
||||
|
@ -615,7 +685,14 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
else if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
|
||||
!empty($_POST['enable-API'])){
|
||||
|
||||
$this->activate($status_message);
|
||||
$message = '';
|
||||
if($this->activate($message) == true) {
|
||||
|
||||
$status_message = $message;
|
||||
} else {
|
||||
|
||||
$error_message = $message;
|
||||
}
|
||||
|
||||
//since we might have changed the status, REFRESH
|
||||
$refresh = true;
|
||||
|
@ -632,16 +709,12 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
$show_form = !$this->recover($this->getSecretKey(), @$_REQUEST['domain'], @$_REQUEST['email'], $status_message);
|
||||
}
|
||||
|
||||
//if we need to show the form
|
||||
//if we need to show the form, the recovery failed
|
||||
if($show_form)
|
||||
{
|
||||
//if there is a message, put the form on a new line
|
||||
if(!empty($status_message))
|
||||
$status_message .= "<br /><br />";
|
||||
|
||||
ob_start();
|
||||
include(dirname(__FILE__) . '/views/account-recover-partial.php');
|
||||
$status_message .= ob_get_clean();
|
||||
$error_message = $status_message;
|
||||
$status_message = $this->renderView('account-recover-partial');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -674,6 +747,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
}
|
||||
else
|
||||
{
|
||||
//put it in the status message, as it will be moved to error_message in the following IF
|
||||
$status_message = SyC::t('sdk',"Error. You must agree with the terms and conditions bellow");
|
||||
}
|
||||
}
|
||||
|
@ -681,47 +755,51 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
//if we need to show the form
|
||||
if($show_form)
|
||||
{
|
||||
//if there is a message, put the form on a new line
|
||||
if(!empty($status_message))
|
||||
$status_message .= "<br /><br />";
|
||||
|
||||
ob_start();
|
||||
include(dirname(__FILE__) . '/views/account-create-partial.php');
|
||||
$status_message .= ob_get_clean();
|
||||
//move any message to errors
|
||||
$error_message = $status_message;
|
||||
$status_message = $this->renderView('account-create-partial');
|
||||
}
|
||||
}
|
||||
|
||||
//make sure there is a session variable setup
|
||||
session_start();
|
||||
@session_start();
|
||||
|
||||
//since switching the API status has a great impact on how the UI looks, refresh the page
|
||||
//just to make sure the UI is using the latest value
|
||||
if($refresh)
|
||||
{
|
||||
//first, save the status message
|
||||
//make sure to save the messages
|
||||
$_SESSION['_syc_status_message'] = $status_message;
|
||||
|
||||
//recreate the url ( but before that make sure there is no syc-account parameter in it )
|
||||
unset($_GET['syc-account']);
|
||||
$url = '?'.http_build_query($_GET,'','&');
|
||||
|
||||
@header("HTTP/1.1 302 Found");
|
||||
@header("Location: $url");
|
||||
echo "<meta http-equiv=\"refresh\" content=\"0; url=$url\">"; //it can happen that the headers have allready been sent, so use the html version as well
|
||||
exit;
|
||||
$_SESSION['_syc_error_message'] = $error_message;
|
||||
}
|
||||
else
|
||||
{
|
||||
//load the variables, if any
|
||||
|
||||
//if there is a status message
|
||||
if(!empty($_SESSION['_syc_status_message']))
|
||||
{
|
||||
$status_message = $_SESSION['_syc_status_message'];
|
||||
unset($_SESSION['_syc_status_message']);
|
||||
}
|
||||
|
||||
//if there is an error message
|
||||
if(!empty($_SESSION['_syc_error_message']))
|
||||
{
|
||||
$error_message = $_SESSION['_syc_error_message'];
|
||||
unset($_SESSION['_syc_error_message']);
|
||||
}
|
||||
}
|
||||
|
||||
//if there is a status message
|
||||
if(!empty($_SESSION['_syc_status_message']))
|
||||
{
|
||||
$status_message = $_SESSION['_syc_status_message'];
|
||||
unset($_SESSION['_syc_status_message']);
|
||||
}
|
||||
|
||||
// Display the view
|
||||
ob_start();
|
||||
include(dirname(__FILE__) . '/views/admin-page.php');
|
||||
return ob_get_clean();
|
||||
return $this->renderView('admin-page',array(
|
||||
'html' => $html,
|
||||
'show_header' => $show_header,
|
||||
'show_footer' => $show_footer,
|
||||
'status_message' => $status_message,
|
||||
'error_message' => $error_message,
|
||||
'refresh' => $refresh,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -764,11 +842,16 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
|
||||
//set the show'
|
||||
$this->setConfigValue("hide_on_checkout", empty($_POST['show_on_checkout']));
|
||||
|
||||
//set button position
|
||||
$this->setConfigValue("product_button_position",$_POST['product_button_position']);
|
||||
$this->setConfigValue("cart_button_position",$_POST['cart_button_position']);
|
||||
|
||||
if($_FILES["button-img"]["name"]!='') {
|
||||
|
||||
$target_path = dirname(__FILE__). "/img/";
|
||||
|
||||
$target_path = $this->getUploadDir();
|
||||
if(!SyC::endsWith($target_path,'/')) $target_path .= '/'; //make sure that the path has a / in it's end
|
||||
|
||||
$target_path = $target_path . 'button-img.png';
|
||||
|
||||
if(file_exists($target_path)) unlink($target_path);
|
||||
|
@ -778,14 +861,20 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
if (move_uploaded_file($_FILES['button-img']['tmp_name'], $target_path))
|
||||
{
|
||||
//set the button img
|
||||
$this->setConfigValue("btn-img", $this->createUrl($target_path));
|
||||
$this->setConfigValue("btn-img", $this->getUrl($target_path));
|
||||
$this->setConfigValue("btn-img-width", $width);
|
||||
$this->setConfigValue("btn-img-height", $height);
|
||||
}
|
||||
else
|
||||
{
|
||||
//upload failed, so notify the user
|
||||
throw new Exception(SyC::t('sdk','Cannot upload image to directory {directory}. Check the permissions',array('{directory}',$this->getUploadDir())));
|
||||
}
|
||||
}
|
||||
|
||||
if($_FILES["button-img-hover"]["name"]!='') {
|
||||
$target_path = dirname(__FILE__). "/img/";
|
||||
$target_path = $this->getUploadDir();
|
||||
if(!SyC::endsWith($target_path,'/')) $target_path .= '/'; //make sure that the path has a / in it's end
|
||||
|
||||
$target_path = $target_path . 'btn-img-hover.png';
|
||||
|
||||
|
@ -796,32 +885,50 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
if(move_uploaded_file($_FILES['button-img-hover']['tmp_name'], $target_path))
|
||||
{
|
||||
//set the show'
|
||||
$this->setConfigValue("btn-img-h", $this->createUrl($target_path));
|
||||
$this->setConfigValue("btn-img-h", $this->getUrl($target_path));
|
||||
$this->setConfigValue("btn-img-h-width", $width);
|
||||
$this->setConfigValue("btn-img-h-height", $height);
|
||||
}
|
||||
else
|
||||
{
|
||||
//upload failed, so notify the user
|
||||
throw new Exception(SyC::t('sdk','Cannot upload image to directory {directory}. Check the permissions',array('{directory}',$this->getUploadDir())));
|
||||
}
|
||||
}
|
||||
|
||||
$status_message = SyC::t('sdk','Button settings successfully updated.');
|
||||
}
|
||||
|
||||
$current_button_type = $this->getConfigValue("button_type");
|
||||
$current_skin = $this->getConfigValue("button_skin");
|
||||
$current_position = $this->getConfigValue("button_position");
|
||||
$show_on_checkout = !$this->getConfigValue("hide_on_checkout");
|
||||
$show_on_product = !$this->getConfigValue("hide_on_product");
|
||||
$show_on_single_row = !$this->getConfigValue("dont_set_height");
|
||||
|
||||
$button_html = $this->getConfigValue("button_html");
|
||||
$button_img = $this->getConfigValue("btn-img");
|
||||
$button_img_hover = $this->getConfigValue("btn-img-h");
|
||||
|
||||
//render the view
|
||||
ob_start();
|
||||
include(dirname(__FILE__) . '/views/button-settings-page.php');
|
||||
return ob_get_clean();
|
||||
return $this->renderView('button-settings-page', array(
|
||||
'current_button_type' => $this->getConfigValue("button_type"),
|
||||
'current_skin' => $this->getConfigValue("button_skin"),
|
||||
'current_position' => $this->getConfigValue("button_position"),
|
||||
'show_on_checkout' => !$this->getConfigValue("hide_on_checkout"),
|
||||
'show_on_product' => !$this->getConfigValue("hide_on_product"),
|
||||
'show_on_single_row' => !$this->getConfigValue("dont_set_height"),
|
||||
|
||||
'button_html' => $this->getConfigValue("button_html"),
|
||||
'button_img' => $this->getUrl($this->getConfigValue("btn-img")),
|
||||
'button_img_hover' => $this->getUrl($this->getConfigValue("btn-img-h")),
|
||||
|
||||
'html' => $html,
|
||||
'show_header' => $show_header,
|
||||
'show_footer' => $show_footer,
|
||||
'status_message' => @$status_message,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Override this function and provide a writable folder to upload
|
||||
* the files to
|
||||
*
|
||||
*/
|
||||
public function getUploadDir(){
|
||||
return dirname(_FILE_). "/img/";
|
||||
}
|
||||
|
||||
/**
|
||||
* showDocumentation
|
||||
* @param null
|
||||
|
@ -842,13 +949,15 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
//this is a single call function
|
||||
if (!$this->isFirstCall(__FUNCTION__))
|
||||
return;
|
||||
|
||||
$action_url = $this->getButtonCallbackURL();
|
||||
|
||||
//render the view
|
||||
ob_start();
|
||||
include(dirname(__FILE__) . '/views/documentation.php');
|
||||
return ob_get_clean();
|
||||
return $this->renderView('documentation',array(
|
||||
'action_url' => $this->getButtonCallbackURL(),
|
||||
|
||||
'html' => $html,
|
||||
'show_header' => $show_header,
|
||||
'show_footer' => $show_footer,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -865,9 +974,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
*/
|
||||
public function getUpdateNotification(){
|
||||
//render the view
|
||||
ob_start();
|
||||
include(dirname(__FILE__) . '/views/update-notification-partial.php');
|
||||
return ob_get_clean();
|
||||
return $this->renderView('update-notification-partial');
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -888,7 +995,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
$this->assertCouponIsValid($_POST['token'], $_POST['coupon_code'], $_POST['coupon_value'], $_POST['coupon_type']);
|
||||
|
||||
//save the coupon
|
||||
$this->saveCoupon($_POST['token'], $_POST['coupon_code'], $_POST['coupon_value'], $_POST['coupon_type']);
|
||||
$this->saveCoupon($_POST['token'], $_POST['coupon_code'], $_POST['coupon_value'], $_POST['coupon_type'], (isset($_POST['product_unique_ids']) && is_array($_POST['product_unique_ids']) ? $_POST['product_unique_ids'] : array()));
|
||||
|
||||
//check if the coupon is intended to be applied to the current cart
|
||||
if (empty($_POST['save_only'])) {
|
||||
|
@ -898,6 +1005,10 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
|
||||
header("HTTP/1.0 403");
|
||||
echo $e->getMessage();
|
||||
|
||||
if($this->isDebugMode()){
|
||||
echo $e->getTraceAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -906,7 +1017,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
* @param null
|
||||
* @return boolean
|
||||
*/
|
||||
protected function saveCoupon($token, $coupon_code, $coupon_value, $coupon_type) {
|
||||
protected function saveCoupon($token, $coupon_code, $coupon_value, $coupon_type, $product_unique_ids = array()) {
|
||||
|
||||
//add the coupon id in shareyourcart coupons table
|
||||
$data = array(
|
||||
|
@ -957,7 +1068,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
|
||||
//we can't relly on the fact that the table has been properly created, so check it!
|
||||
if(!$this->existsTable($tableName))
|
||||
throw new Exception(SyC::t('sdk','Cannot create table "{table_name}". Check your database permissions.', array('{table_name}' => $tableName)));
|
||||
throw new Exception(SyC::t('sdk','Cannot create table "{table_name}". Check your database permissions or manually run the following SQL command and try again:<br /><strong>{sql}</strong>', array('{table_name}' => $tableName,'{sql}' => nl2br($sql))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -980,12 +1091,88 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
*/
|
||||
protected function dropTable($tableName) {
|
||||
|
||||
$this->executeNonQuery("DROP TABLE $tableName");
|
||||
$sql = "DROP TABLE $tableName";
|
||||
$this->executeNonQuery($sql);
|
||||
|
||||
//we can't relly on the fact that the table has been properly droped, so check it!
|
||||
if(!$this->existsTable($tableName))
|
||||
throw new Exception(SyC::t('sdk','Cannot drop table "{table_name}". Check your database permissions.', array('{table_name}' => $tableName)));
|
||||
if($this->existsTable($tableName))
|
||||
throw new Exception(SyC::t('sdk','Cannot drop table "{table_name}". Check your database permissions or manually run the following SQL command and try again:<br /><strong>{sql}</strong>', array('{table_name}' => $tableName, '{sql}' => nl2br($sql))));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Render the specified views. we use special variable names here to avoid conflict when extracting data
|
||||
*
|
||||
*/
|
||||
protected function renderView($_viewName_, $_data_=NULL, $_return_=true){
|
||||
|
||||
//get information about the Top Parent class
|
||||
$_reflection_ = new ReflectionClass(get_class($this));
|
||||
$_viewFile_ = dirname($_reflection_->getFileName())."/views/$_viewName_.php";
|
||||
|
||||
//check if there is a file in the specified location
|
||||
if(!file_exists($_viewFile_)){
|
||||
|
||||
//the view has not been overrided, so use the SDK one
|
||||
$_viewFile_ = dirname(__FILE__) . "/views/$_viewName_.php";
|
||||
}
|
||||
|
||||
//extract the data
|
||||
if(is_array($_data_))
|
||||
extract($_data_,EXTR_PREFIX_SAME,'data');
|
||||
else
|
||||
$data=$_data_;
|
||||
|
||||
//render the view
|
||||
if($_return_)
|
||||
{
|
||||
ob_start();
|
||||
ob_implicit_flush(false);
|
||||
require($_viewFile_);
|
||||
return ob_get_clean();
|
||||
}
|
||||
else
|
||||
require($_viewFile_);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This function is used to make sure that the created url returns a proper scheme
|
||||
*
|
||||
*/
|
||||
protected function getUrl($file){
|
||||
|
||||
//if there is no file, return an empty string
|
||||
if(empty($file)) return $file;
|
||||
|
||||
//test if the files is a url, as one migt send it that way
|
||||
$parts = parse_url($file);
|
||||
$is_url = is_array($parts) && isset($parts['scheme']);
|
||||
|
||||
//if this is not a url, create one for it
|
||||
if(!$is_url)
|
||||
{
|
||||
//as we can't control what if the developers
|
||||
//will take care of the HTTP / HTTPS matching,
|
||||
$url = $this->createUrl($file);
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = $file;
|
||||
}
|
||||
|
||||
//do it here. the problem is loading an insecure object over a secure page, so check for this situation
|
||||
|
||||
if( (isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'],'on')) && //the page is a secure one
|
||||
SyC::startsWith($url,'http://') //the created url is an insecure one, adjust it
|
||||
)
|
||||
{
|
||||
$url = "https://".substr($url, 7);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -993,7 +1180,7 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
* @param $force. TRUE to check, no matter how soon the previous check was. This can have a great impact on the experience of the admin
|
||||
*
|
||||
*/
|
||||
protected function checkSDKStatus($force = false) {
|
||||
public function checkSDKStatus($force = false) {
|
||||
|
||||
//call the API at most only once every 5 minutes, not sooner
|
||||
if(!$force && (time()-$this->getConfigValue('api_last_check')) < 5*60)
|
||||
|
@ -1006,15 +1193,30 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
$message = '';
|
||||
if(is_array($result = $this->getSDKStatus($this->getSecretKey(), $this->getClientId(), $this->getAppKey(), $message)))
|
||||
{
|
||||
|
||||
//save the data
|
||||
$this->setConfigValue('api_version', @$result['api_version']);
|
||||
$this->setConfigValue('latest_version', @$result['plugin_latest_version']);
|
||||
$this->setConfigValue('download_url', @$result['plugin_download_url']);
|
||||
$this->setConfigValue('debug', @$result['debug']);
|
||||
|
||||
//set the current language the SDK should be displayed in
|
||||
if(isset($result['lang'])){
|
||||
$this->setConfigValue('lang', $result['lang']);
|
||||
SyC::setLanguage($result['lang']);
|
||||
|
||||
//check if there is a new translation available for this language
|
||||
if(!empty($result['lang_checksum']) && $result['lang_checksum'] != SyC::getLanguageChecksum()){
|
||||
|
||||
//download the translation
|
||||
$messages = $this->getSDKTranslation(SyC::getLanguage());
|
||||
|
||||
//save the translation
|
||||
$this->setConfigValue('messages', $messages);
|
||||
|
||||
//reset the loaded messages so that the new ones are being used
|
||||
SyC::reloadLanguage();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//simply log the error, for now!
|
||||
|
@ -1022,6 +1224,27 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Language loader ( from the DB )
|
||||
*
|
||||
*/
|
||||
public function loadLanguage($lang, $category)
|
||||
{
|
||||
//see if we have the language saved in the db
|
||||
$messages = $this->getConfigValue('messages');
|
||||
|
||||
if(empty($messages)) //no language is saved, so revert to the file one
|
||||
{
|
||||
$messages = SyC::loadFileLanguage($lang,$category);
|
||||
}
|
||||
|
||||
//make sure we have an array for this variable
|
||||
if(!is_array($messages)) $messages=array();
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Call to see if the function was called once, or not
|
||||
|
@ -1044,6 +1267,10 @@ abstract class ShareYourCartBase extends ShareYourCartAPI {
|
|||
public function UncaughtExceptionHandler(Exception $e) {
|
||||
//@header("HTTP/1.0 403");
|
||||
echo $e->getMessage();
|
||||
|
||||
if($this->isDebugMode()){
|
||||
echo $e->getTraceAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,13 +7,22 @@
|
|||
}
|
||||
|
||||
.button_iframe-normal iframe {
|
||||
float:right;
|
||||
height: 58px;
|
||||
height: 78px;
|
||||
width: 230px;
|
||||
position:relative;
|
||||
z-index:1000;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.button_iframe-normal[data-syc-skin="light"] iframe, .button_iframe-normal[data-syc-skin="dark"] iframe{
|
||||
height: 25px;
|
||||
width: 125px;
|
||||
}
|
||||
|
||||
.button_iframe-normal.button_height {
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.button_iframe-normal.button_height[data-syc-skin="light"],.button_iframe-normal.button_height[data-syc-skin="dark"] {
|
||||
height: 27px;
|
||||
}
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* This is the configuration for generating message translations
|
||||
* for the app. It is used by the 'yiic message' command.
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
*
|
||||
* @version $Id: $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
return array (
|
||||
'API Status:' => '',
|
||||
'App Key' => '',
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
*
|
||||
* @version $Id: $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
return array (
|
||||
'API Status:' => '',
|
||||
'App Key' => '',
|
||||
|
|
|
@ -18,9 +18,6 @@
|
|||
*
|
||||
* @version $Id: $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
return array (
|
||||
'API Status:' => '',
|
||||
'App Key' => '',
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<script type="text/javascript">
|
||||
if(_gaq) _gaq.push(['_trackPageview', '/admin/create-view']);
|
||||
</script>
|
||||
|
@ -26,7 +23,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input class="buttonCheckbox" name="syc-terms-agreement" id="syc-terms-agreement" <?php if( $_SERVER['REQUEST_METHOD'] !== 'POST' || isset($_POST['syc-terms-agreement'])){ echo 'checked="checked"'; } ?> type="checkbox" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/create-view/toogle-terms-agreement-click']);"><label for="syc-terms-agreement"><?php echo SyC::t('sdk','I agree to create the account on {brand}',array('{brand}' => '<a href="http://www.shareyourcart.com" target="_blank" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/create-view/logo-terms-click\']);">www.shareyourcart.com</a>')); ?></label>
|
||||
<input class="buttonCheckbox" name="syc-terms-agreement" id="syc-terms-agreement" <?php if( $_SERVER['REQUEST_METHOD'] !== 'POST' || isset($_POST['syc-terms-agreement'])){ echo 'checked="checked"'; } ?> type="checkbox" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/create-view/toogle-terms-agreement-click']);"><label for="syc-terms-agreement"><?php echo SyC::t('sdk','I agree with the {brand} terms & conditions',array('{brand}' => '<a href="http://www.shareyourcart.com/terms" target="_blank" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/create-view/logo-terms-click\']);">ShareYourCart</a>')); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<script type="text/javascript">
|
||||
if(_gaq) _gaq.push(['_trackPageview', '/admin/recover-view']);
|
||||
</script>
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $this->getUrl(dirname(__FILE__).'/../css/admin-style.css'); ?>" />
|
||||
|
||||
<?php //check if there is an admin-style outside of the SDK, and include that one as well
|
||||
|
||||
$_reflection_ = new ReflectionClass(get_class($this));
|
||||
$_file_ = dirname($_reflection_->getFileName())."/css/admin-style.css";
|
||||
|
||||
//check if there is a file in the specified location
|
||||
if(file_exists($_file_)):?>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $this->getUrl($_file_); ?>" />
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $this->createUrl(dirname(__FILE__).'/../css/admin-style.css'); ?>" />
|
||||
<script type="text/javascript">
|
||||
|
||||
<?php if($this->SHAREYOURCART_URL == "www.shareyourcart.com"): //only if in production mode anonymously monitor the usage ?>
|
||||
<?php if($this->SHAREYOURCART_URL == "www.shareyourcart.com" && $this->SDK_ANALYTICS): //only if in production mode anonymously monitor the usage ?>
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-2900571-7']);
|
||||
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied');
|
||||
|
||||
$admin_base_url = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
|
||||
|
||||
//in case we need to refresh the page
|
||||
if($refresh)
|
||||
{
|
||||
//recreate the url ( but before that make sure there is no syc-account parameter in it )
|
||||
unset($_GET['syc-account']);
|
||||
$url = $admin_base_url.'?'.http_build_query($_GET,'','&');
|
||||
|
||||
@header("HTTP/1.1 302 Found");
|
||||
@header("Location: $url");
|
||||
echo "<meta http-equiv=\"refresh\" content=\"0; url=$url\">"; //it can happen that the headers have allready been sent, so use the html version as well
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
if(_gaq) _gaq.push(['_trackPageview', '/admin-view']);
|
||||
</script>
|
||||
|
@ -12,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
|
||||
<h2>
|
||||
<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart" class="shareyourcart-logo" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/logo-click']);">
|
||||
<img src="<?php echo $this->createUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
|
||||
<img src="<?php echo $this->getUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
|
||||
</a>
|
||||
<div class="syc-slogan"><?php echo SyC::t('sdk','Increase your social media exposure by 10%!'); ?></div>
|
||||
|
||||
|
@ -23,9 +36,22 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
</h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(!empty($status_message)): ?>
|
||||
<?php if(!empty($status_message) || !empty($error_message)): ?>
|
||||
<div class="updated settings-error"><p><strong>
|
||||
<?php echo $status_message; ?>
|
||||
<?php
|
||||
$message = @$error_message;
|
||||
|
||||
//is there a status message?
|
||||
if(!empty($status_message))
|
||||
{
|
||||
//put the status message on a new line
|
||||
if(!empty($message)) $message .= "<br /><br />";
|
||||
|
||||
$message .= $status_message;
|
||||
}
|
||||
|
||||
echo $message;
|
||||
?>
|
||||
</strong></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
@ -60,7 +86,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><a href="?<?php echo http_build_query(array_merge($_GET,array('syc-account'=>'recover')),'','&')?>" class="api-link" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/recover-click']);"><?php echo SyC::t('sdk',"Can't access your account?"); ?></a> <strong><?php echo SyC::t('sdk','or'); ?></strong> <?php echo SyC::t('sdk','New to ShareYourCart™?'); ?> <a href="?<?php echo http_build_query(array_merge($_GET,array('syc-account'=>'create')),'','&')?>" id="account-recovery" class="api-link" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/create-account-click']);"><?php echo SyC::t('sdk','Create an account'); ?></a></td>
|
||||
<td><a href="<?php echo $admin_base_url.'?'.http_build_query(array_merge($_GET,array('syc-account'=>'recover')),'','&')?>" class="api-link" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/recover-click']);"><?php echo SyC::t('sdk',"Can't access your account?"); ?></a> <strong><?php echo SyC::t('sdk','or'); ?></strong> <?php echo SyC::t('sdk','New to ShareYourCart™?'); ?> <a href="<?php echo $admin_base_url.'?'.http_build_query(array_merge($_GET,array('syc-account'=>'create')),'','&')?>" id="account-recovery" class="api-link" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/create-account-click']);"><?php echo SyC::t('sdk','Create an account'); ?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo $html;?>
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
|
||||
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-layout="custom">
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-layout="custom" <?php if(!empty($position_after)): echo "data-syc-position-after=\"$position_after\""; elseif(!empty($position_before)): echo "data-syc-position-before=\"$position_before\""; endif; ?>>
|
||||
<?php echo $button_html;?>
|
||||
</a>
|
||||
|
||||
<!--
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
|
||||
a.src = '<?php echo $this->SHAREYOURCART_BUTTON_JS; ?>';
|
||||
var b = document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a, b);
|
||||
})();
|
||||
</script>
|
||||
</script> -->
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
<?php
|
||||
if(!class_exists('ShareYourCartBase',false)) die('Access Denied');
|
||||
|
||||
// If only the hover is uploaded
|
||||
if((!$button_img or !$button_img_width or !$button_img_height) and ($button_img_hover and $button_img_hover_width and $button_img_hover_height)) {
|
||||
$button_img = $button_img_hover;
|
||||
|
@ -18,8 +18,8 @@
|
|||
}
|
||||
?>
|
||||
|
||||
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button" <?php echo $callbackDataAttr; ?> data-syc-layout="custom">
|
||||
ShareYourCart Discount
|
||||
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?>" <?php echo $callbackDataAttr; ?> data-syc-layout="custom" <?php if(!empty($position_after)): echo "data-syc-position-after=\"$position_after\""; elseif(!empty($position_before)): echo "data-syc-position-before=\"$position_before\""; endif; ?>>
|
||||
|
||||
</a>
|
||||
|
||||
<style>
|
||||
|
@ -50,11 +50,11 @@
|
|||
}
|
||||
?>
|
||||
</style>
|
||||
|
||||
<!--
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
|
||||
a.src = '<?php echo $this->SHAREYOURCART_BUTTON_JS; ?>';
|
||||
var b = document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a, b);
|
||||
})();
|
||||
</script>
|
||||
</script> -->
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<?php if(!$this->isActive()) return; //if the plugin is not active, do not show this page ?>
|
||||
<script type="text/javascript">
|
||||
if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view']);
|
||||
|
@ -13,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
|
||||
<h2>
|
||||
<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart" class="shareyourcart-logo" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/logo-click']);">
|
||||
<img src="<?php echo $this->createUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
|
||||
<img src="<?php echo $this->getUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
|
||||
</a>
|
||||
<div class="syc-slogan"><?php echo SyC::t('sdk','Increase your social media exposure by 10%!'); ?></div>
|
||||
<br clear="all" />
|
||||
|
@ -130,6 +127,18 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<br />
|
||||
<input class="buttonCheckbox" name="show_on_checkout" <?php echo $show_on_checkout ? 'checked="checked"' : ''; ?> type='checkbox' onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/toggle-show-on-checkout-click']);"><?php echo SyC::t('sdk','Checkout page'); ?></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" valign="top"><?php echo SyC::t('sdk','Position product button after: '); ?></th>
|
||||
<td>
|
||||
<input name="product_button_position" class="regular-text" value="<?php echo $this->getProductButtonPosition(); ?>" /><p><?php echo SyC::t('sdk','<strong>jQuery selector</strong>. Start with <strong>{elem}</strong> to position the button before the actual object',array('{elem}' => "/*before*/")); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" valign="top"><?php echo SyC::t('sdk','Position cart button after: '); ?></th>
|
||||
<td>
|
||||
<input name="cart_button_position" class="regular-text" value="<?php echo $this->getCartButtonPosition(); ?>" /><p><?php echo SyC::t('sdk','<strong>jQuery selector</strong>. Start with <strong>{elem}</strong> to position the button before the actual object',array('{elem}' => "/*before*/")); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
|
||||
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php echo ( $this->getConfigValue('button_position') == 'floating' ? 'button_iframe' : 'button_iframe-normal');?> <?php echo ( !$this->getConfigValue('dont_set_height') ? 'button_height' : ''); ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-skin="<?php echo $this->getConfigValue('button_skin');?>" data-syc-orientation="<?php echo $this->getConfigValue('button_position'); ?>" >
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<a href="<?php echo $this->SHAREYOURCART_BUTTON_URL ?>" class="shareyourcart-button <?php if (isset($is_product_page) && $is_product_page) echo "product_button"; ?> <?php echo ( $this->getConfigValue('button_position') == 'floating' ? 'button_iframe' : 'button_iframe-normal');?> <?php echo ( !$this->getConfigValue('dont_set_height') ? 'button_height' : ''); ?>" <?php echo (isset($callback_url) && !empty($callback_url)) ? "data-syc-callback_url=$callback_url" : ''; ?> data-syc-skin="<?php echo $this->getConfigValue('button_skin');?>" data-syc-orientation="<?php echo $this->getConfigValue('button_position'); ?>" <?php if(!empty($position_after)): echo "data-syc-position-after=\"$position_after\""; elseif(!empty($position_before)): echo "data-syc-position-before=\"$position_before\""; endif; ?> >
|
||||
ShareYourCart Discount
|
||||
</a>
|
||||
|
||||
<!--
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
|
||||
a.src = '<?php echo $this->SHAREYOURCART_BUTTON_JS; ?>';
|
||||
var b = document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a, b);
|
||||
})();
|
||||
</script>
|
||||
</script> -->
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<?php if(!$this->isActive()) return; //if the plugin is not active, do not show this page ?>
|
||||
<script type="text/javascript">
|
||||
if(_gaq) _gaq.push(['_trackPageview', '/admin/documentation']);
|
||||
|
@ -13,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
|
||||
<h2>
|
||||
<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart" class="shareyourcart-logo" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/documentation/logo-click']);">
|
||||
<img src="<?php echo $this->createUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
|
||||
<img src="<?php echo $this->getUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
|
||||
</a>
|
||||
<div class="syc-slogan"><?php echo SyC::t('sdk','Increase your social media exposure by 10%!'); ?></div>
|
||||
<br clear="all" />
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $this->createUrl(dirname(__FILE__).'/../css/style.css'); ?>" />
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $this->getUrl(dirname(__FILE__).'/../css/style.css'); ?>" />
|
||||
<!--[if lt IE 9]>
|
||||
<link rel="stylesheet" href="<?php echo $this->createUrl(dirname(__FILE__).'/../css/ie.css'); ?>" type="text/css"/>
|
||||
<link rel="stylesheet" href="<?php echo $this->getUrl(dirname(__FILE__).'/../css/ie.css'); ?>" type="text/css"/>
|
||||
<![endif]-->
|
||||
|
||||
<?php //check if there is a style outside of the SDK, and include that one as well
|
||||
|
||||
$_reflection_ = new ReflectionClass(get_class($this));
|
||||
$_file_ = dirname($_reflection_->getFileName())."/css/style.css";
|
||||
|
||||
//check if there is a file in the specified location
|
||||
if(file_exists($_file_)):?>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $this->getUrl($_file_); ?>" />
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<meta property="syc:client_id" content="<?php echo $this->getClientId(); ?>" />
|
||||
<meta property="syc:callback_url" content="<?php echo $this->getButtonCallbackURL(); ?>" />
|
||||
|
||||
<?php if($this->isActive() & is_array($data)): ?>
|
||||
|
||||
<meta property="og:title" content="<?php echo htmlspecialchars(@$data['item_name']); ?>" />
|
||||
|
@ -16,4 +28,13 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||
<meta property="og:image" content="<?php echo @$data['item_picture_url'] ?>" />
|
||||
<meta property="syc:price" content="<?php echo @$data['item_price'] ?>" />
|
||||
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var a = document.createElement('script'); a.type = 'text/javascript'; a.async = true;
|
||||
a.src = '<?php echo $this->SHAREYOURCART_BUTTON_JS; ?>';
|
||||
var b = document.getElementsByTagName('script')[0]; b.parentNode.insertBefore(a, b);
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
|
||||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<?php if($this->hasNewerVersion()): //if there is a newer version, show the upgrade message?>
|
||||
<div class="syc-update-nag">
|
||||
<strong><?php echo SyC::t('sdk','{link}ShareYourCart {version}</a> is available! {link}Please update now</a>.', array('{version}' => $this->getConfigValue('latest_version'), '{link}' => '<a href="'.$this->getConfigValue("download_url").'" target="_blank">')); ?></strong>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<script type="text/javascript">
|
||||
if(_gaq) _gaq.push(['_trackPageview', '/admin/create-view']);
|
||||
</script>
|
||||
<?php echo SyC::t('sdk','Create a ShareYourCart account'); ?>
|
||||
<form method="POST">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="domain"><?php echo SyC::t('sdk','Domain:'); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="domain" id="domain" class="regular-text" value="<?php echo (isset($_POST['domain']) ? $_POST['domain'] : $this->getDomain()); ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="email"><?php echo SyC::t('sdk','Email:'); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="email" id="email" class="regular-text" value="<?php echo (isset($_POST['email']) ? $_POST['email'] : $this->getAdminEmail()); ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input class="buttonCheckbox" name="syc-terms-agreement" id="syc-terms-agreement" <?php if( $_SERVER['REQUEST_METHOD'] !== 'POST' || isset($_POST['syc-terms-agreement'])){ echo 'checked="checked"'; } ?> type="checkbox" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/create-view/toogle-terms-agreement-click']);"><label for="syc-terms-agreement"><?php echo SyC::t('sdk','I agree with the {brand} terms & conditions',array('{brand}' => '<a href="http://www.shareyourcart.com/terms" target="_blank" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/create-view/logo-terms-click\']);">ShareYourCart</a>')); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="submit" name="syc-create-account" value="<?php echo SyC::t('sdk','Create account'); ?>" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/create-view/save-click']);"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php echo $html;?>
|
||||
</form>
|
|
@ -0,0 +1,28 @@
|
|||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<script type="text/javascript">
|
||||
if(_gaq) _gaq.push(['_trackPageview', '/admin/recover-view']);
|
||||
</script>
|
||||
<?php echo SyC::t('sdk','Enter the domain and email you used when you created the ShareYourCart account'); ?>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="domain"><?php echo SyC::t('sdk','Domain:'); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="domain" id="domain" class="regular-text" value="<?php echo (isset($_POST['domain']) ? $_POST['domain'] : $this->getDomain()); ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="email"><?php echo SyC::t('sdk','Email:'); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="email" id="email" class="regular-text" value="<?php echo (isset($_POST['email']) ? $_POST['email'] : $this->getAdminEmail()); ?>"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="submit" name="syc-recover-account" value="<?php echo SyC::t('sdk','Recover my account'); ?>" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/recover-view/save-click']);" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
|
@ -0,0 +1,139 @@
|
|||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied');
|
||||
|
||||
$wcIntegration = $html; //the object is sent under the $html parameter
|
||||
|
||||
//since this is a post, and is related to recovering or creating a new account, perform some special operations
|
||||
if ($refresh || ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty( $_REQUEST['syc-account'] ))){
|
||||
|
||||
$redirect = remove_query_arg( 'saved' );
|
||||
$redirect = remove_query_arg( 'wc_error', $redirect );
|
||||
$redirect = remove_query_arg( 'wc_message', $redirect );
|
||||
|
||||
//remove the syc-account argument only if the SDK commanded as such
|
||||
if($refresh) $redirect = remove_query_arg( 'syc-account', $redirect );
|
||||
|
||||
if ( !empty($error_message) ) $redirect = add_query_arg( 'wc_error', urlencode( esc_attr( $error_message ) ), $redirect );
|
||||
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
if(_gaq) _gaq.push(['_trackPageview', '/admin-view']);
|
||||
</script>
|
||||
<div class="wrap">
|
||||
<?php if($show_header):?>
|
||||
|
||||
<?php echo $this->getUpdateNotification(); ?>
|
||||
|
||||
<?php if(true || !$this->getClientId() && !$this->getAppKey()): //show the get started message ?>
|
||||
|
||||
<div id="wc_get_started">
|
||||
<span class="main"><?php _e('Setup your ShareYourCart account', 'woocommerce'); ?></span>
|
||||
<span><?php echo $wcIntegration->method_description; ?></span>
|
||||
<p><a href="<?php echo add_query_arg( 'syc-account', 'create', admin_url( 'admin.php?page=woocommerce&tab=integration§ion=shareyourcart' ) ); ?>" class="button button-primary api-link"><?php _e('Create an account', 'woocommerce'); ?></a> <a href="<?php echo add_query_arg( 'syc-account', 'recover', admin_url( 'admin.php?page=woocommerce&tab=integration§ion=shareyourcart' ) ); ?>" class="button api-link"><?php _e('Can\'t access your account?', 'woocommerce'); ?></a></p>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<h3>
|
||||
<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart" class="shareyourcart-logo" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/logo-click']);">
|
||||
<img src="<?php echo $this->createUrl(dirname(__FILE__).'/../sdk/img/shareyourcart-logo.png'); ?>"/>
|
||||
</a>
|
||||
</h3>
|
||||
<br class="clr" />
|
||||
<?php echo wpautop( $wcIntegration->method_description );?>
|
||||
|
||||
<?php endif;?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(!empty($status_message) || !empty($error_message)): ?>
|
||||
<div class="updated settings-error"><p><strong>
|
||||
<?php
|
||||
$message = @$error_message;
|
||||
|
||||
//is there a status message?
|
||||
if(!empty($status_message))
|
||||
{
|
||||
//put the status message on a new line
|
||||
if(!empty($message)) $message .= "<br /><br />";
|
||||
|
||||
$message .= $status_message;
|
||||
}
|
||||
|
||||
echo $message;
|
||||
?>
|
||||
</strong></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<h3>Account Options</h3>
|
||||
<div id="acount-options">
|
||||
<fieldset>
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th class="titledesc" scope="row">
|
||||
<?php echo SyC::t('sdk','API Status:'); ?>
|
||||
<?php if($this->isActive()) : ?>
|
||||
<span class="green"><?php echo SyC::t('sdk','Enabled'); ?></span>
|
||||
<?php else :?>
|
||||
<span class="red"><?php echo SyC::t('sdk','Disabled'); ?></span>
|
||||
<?php endif;?>
|
||||
</th>
|
||||
<td class="forminp">
|
||||
<?php if($this->isActive()) : ?>
|
||||
<input class="button" type="submit" value="<?php echo SyC::t('sdk','Disable'); ?>" name="disable-API" class="api-button" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/disable-click']);" />
|
||||
<?php else :?>
|
||||
<input class="button" type="submit" value="<?php echo SyC::t('sdk','Enable'); ?>" name="enable-API" class="api-button" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/enable-click']);" />
|
||||
<?php endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="form-table form-table-api" name="shareyourcart_settings">
|
||||
<tr valign="top">
|
||||
<th class="titledesc" scope="row"><?php echo SyC::t('sdk','Client ID'); ?></th>
|
||||
<td class="forminp"><input type="text" name="client_id" id="client_id" class="regular-text" value="<?php echo $this->getClientId(); ?>"/></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th class="titledesc" scope="row"><?php echo SyC::t('sdk','App Key'); ?></th>
|
||||
<td class="forminp"><input type="text" name="app_key" id="app_key" class="regular-text" value="<?php echo $this->getAppKey(); ?>"/></td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td class="titledesc"></td>
|
||||
<td class="forminp">
|
||||
<span class="description">
|
||||
<a href="?<?php echo http_build_query(array_merge($_GET,array('syc-account'=>'recover')),'','&')?>" class="api-link" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/recover-click']);">
|
||||
<?php echo SyC::t('sdk',"Can't access your account?"); ?></a> <strong><?php echo SyC::t('sdk','or'); ?></strong> <?php echo SyC::t('sdk','New to ShareYourCart™?'); ?> <a href="?<?php echo http_build_query(array_merge($_GET,array('syc-account'=>'create')),'','&')?>" id="account-recovery" class="api-link" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/create-account-click']);"><?php echo SyC::t('sdk','Create an account'); ?>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<br class="clr">
|
||||
|
||||
<div class="submit">
|
||||
<input type="submit" name="syc-account-form" class="button-primary" value="<?php echo SyC::t('sdk','Save changes'); ?>" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin-view/save-click']);">
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<?php if($this->isActive()): //show the configure part only if it is active ?>
|
||||
<h3>Configuration</h3>
|
||||
|
||||
<fieldset class="syc-configuration">
|
||||
<p><?php echo SyC::t('sdk','You can choose how much of a discount to give (in fixed amount, percentage, or free shipping) and to which social media channels it should it be applied. You can also define what the advertisement should say, so that it fully benefits your sales.'); ?></p>
|
||||
|
||||
<div class="submit">
|
||||
<a href="<?php echo $this->SHAREYOURCART_CONFIGURE; ?>?app_key=<?php echo $this->getAppKey(); ?>&client_id=<?php echo $this->getClientId(); ?>&email=<?php echo $this->getAdminEmail(); ?>" class="button-primary" target="_blank">
|
||||
<?php _e('Configure', 'woocommerce'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<?php endif; //show only if the cart is active ?>
|
||||
</div>
|
|
@ -0,0 +1,151 @@
|
|||
<?php if(!class_exists('ShareYourCartBase',false)) die('Access Denied'); ?>
|
||||
<?php if(!$this->isActive()) return; //if the plugin is not active, do not show this page ?>
|
||||
<script type="text/javascript">
|
||||
if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view']);
|
||||
</script>
|
||||
|
||||
<div class="wrap">
|
||||
<h3>Button options</h3>
|
||||
<?php if($show_header):?>
|
||||
|
||||
<?php echo $this->getUpdateNotification(); ?>
|
||||
|
||||
<h2>
|
||||
<a href="http://www.shareyourcart.com" target="_blank" title="Shareyourcart" class="shareyourcart-logo" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/logo-click']);">
|
||||
<img src="<?php echo $this->createUrl(dirname(__FILE__).'/../img/shareyourcart-logo.png'); ?>"/>
|
||||
</a>
|
||||
<div class="syc-slogan"><?php echo SyC::t('sdk','Increase your social media exposure by 10%!'); ?></div>
|
||||
<br clear="all" />
|
||||
</h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($status_message)): ?>
|
||||
<div class="updated settings-error"><p><strong>
|
||||
<?php echo $status_message; ?>
|
||||
</strong></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div id="visual-options">
|
||||
<fieldset>
|
||||
<div>
|
||||
<input type="radio" value="1" id="button_type_1" <?php if ($current_button_type == '1'||$current_button_type == '') echo 'checked' ?> name="button_type" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/default-click']);" />
|
||||
<label for="button_type_1"><?php echo SyC::t('sdk','Use Standard Button'); ?></label>
|
||||
</div>
|
||||
<table class="form-table shareyourcart_button_standard" name="shareyourcart_button_standard">
|
||||
<tr >
|
||||
<th class="titledesc" scope="row"><?php echo SyC::t('sdk','Button skin'); ?></th>
|
||||
<td class="forminp">
|
||||
<select name="button_skin" id="button_skin" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/button-skin-click']);">
|
||||
<option name="orange" <?php echo $current_skin == 'orange' ? 'selected="selected"' : ''; ?> value="orange"><?php echo SyC::t('sdk','Orange'); ?></option>
|
||||
<option name="blue" <?php echo $current_skin == 'blue' ? 'selected="selected"' : ''; ?> value="blue"><?php echo SyC::t('sdk','Blue'); ?></option>
|
||||
<option name="light" <?php echo $current_skin == 'light' ? 'selected="selected"' : ''; ?> value="light"><?php echo SyC::t('sdk','Light'); ?></option>
|
||||
<option name="dark" <?php echo $current_skin == 'dark' ? 'selected="selected"' : ''; ?> value="dark"><?php echo SyC::t('sdk','Dark'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr >
|
||||
<th class="titledesc" scope="row"><?php echo SyC::t('sdk','Button position'); ?></th>
|
||||
<td class="forminp">
|
||||
<select name="button_position" id="button_position" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/button-position-click']);">
|
||||
<option name="normal" <?php echo $current_position == 'normal' ? 'selected="selected"' : ''; ?> value="normal"><?php echo SyC::t('sdk','Normal'); ?></option>
|
||||
<option name="floating" <?php echo $current_position == 'floating' ? 'selected="selected"' : ''; ?> value="floating"><?php echo SyC::t('sdk','Floating'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- <tr align="center"> since we switched to <a> on the button, this does not seem to be needed anymore
|
||||
<td>
|
||||
<input class="buttonCheckbox" name="show_on_single_row" <?php echo $show_on_single_row ? 'checked="checked"' : ''; ?> type='checkbox' onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/toggle-show-on-single-row-click']);"><?php echo SyC::t('sdk','Check this if you want the button to be shown on it\'s own row'); ?></input>
|
||||
</td>
|
||||
</tr> -->
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<input type="radio" value="2" id="button_type_2" name="button_type" <?php if ($current_button_type == '2') echo 'checked' ?> onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/image-button-click']);"/>
|
||||
<label for="button_type_2"><?php echo SyC::t('sdk','Use Image Button'); ?></label>
|
||||
<?php if (empty($button_img)){ ?><br /><?php } ?>
|
||||
<table class="form-table shareyourcart_button_image" name="shareyourcart_button_image">
|
||||
<tr>
|
||||
<th scope="row" class="titledesc"><label><?php echo SyC::t('sdk','Image:'); ?></label></th>
|
||||
|
||||
<td class="forminp">
|
||||
<?php if (!empty($button_img)): ?>
|
||||
<img src="<?php echo $button_img ?>" height="40" />
|
||||
<?php endif; ?>
|
||||
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000" />
|
||||
<input type="file" accept="image/gif, image/jpeg, image/jpg, image/png" name="button-img" id="button-img" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/upload-normal-img-click']);" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row" class="titledesc"><label><?php echo SyC::t('sdk','Hover image:'); ?></label></th>
|
||||
|
||||
<td class="forminp">
|
||||
<?php if (!empty($button_img_hover)): ?>
|
||||
<img src="<?php echo $button_img_hover ?>" height="40" />
|
||||
<?php endif; ?>
|
||||
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="100000000000" />
|
||||
<input type="file" accept="image/gif, image/jpeg, image/jpg, image/png" name="button-img-hover" id="button-img-hover" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/upload-hover-img-click']);" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<input type="radio" value="3" id="button_type_3" name="button_type" <?php if ($current_button_type == '3') echo 'checked' ?> onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/custom-button-click']);"/>
|
||||
<label for="button_type_3"><?php echo SyC::t('sdk','Build your own HTML button'); ?></label>
|
||||
<table class="form-table shareyourcart_button_html" name="shareyourcart_button_html">
|
||||
<tr>
|
||||
<th>
|
||||
HTML:
|
||||
</th>
|
||||
<td>
|
||||
<textarea id="syc_button_textarea" class="buttonTextarea" rows="7" cols="56" name="button_html"><?php echo ($button_html!=''?$button_html:'<button>'.SyC::t('sdk','Get a {value} discount',array('{value}' => '<div class="shareyourcart-discount"></div>')).'</button>'); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php echo $html; ?>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<table class="form-table " name="shareyourcart_settings">
|
||||
<tr>
|
||||
<th scope="row" valign="top"><?php echo SyC::t('sdk','Show button by default on: '); ?></th>
|
||||
<td>
|
||||
<input class="buttonCheckbox" name="show_on_product" <?php echo $show_on_product ? 'checked="checked"' : ''; ?> type='checkbox' onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/toggle-show-on-product-click']);"><?php echo SyC::t('sdk','Product page'); ?></input>
|
||||
<br />
|
||||
<input class="buttonCheckbox" name="show_on_checkout" <?php echo $show_on_checkout ? 'checked="checked"' : ''; ?> type='checkbox' onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/toggle-show-on-checkout-click']);"><?php echo SyC::t('sdk','Checkout page'); ?></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" valign="top"><?php echo SyC::t('sdk','Position product button after: '); ?></th>
|
||||
<td>
|
||||
<input name="product_button_position" class="regular-text" value="<?php echo $this->getProductButtonPosition(); ?>" />
|
||||
<span class="description"><?php echo SyC::t('sdk','<strong>jQuery selector</strong>. Start with <strong>{elem}</strong> to position the button before the actual object',array('{elem}' => "/*before*/")); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" valign="top"><?php echo SyC::t('sdk','Position cart button after: '); ?></th>
|
||||
<td>
|
||||
<input name="cart_button_position" class="regular-text" value="<?php echo $this->getCartButtonPosition(); ?>" />
|
||||
<span class="description"><?php echo SyC::t('sdk','<strong>jQuery selector</strong>. Start with <strong>{elem}</strong> to position the button before the actual object',array('{elem}' => "/*before*/")); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
|
||||
<div class="submit">
|
||||
<input type="submit" class="button-primary" name="syc-visual-form" id="syc-visual-form" value="<?php echo SyC::t('sdk','Save changes'); ?>" onclick=" if(_gaq) _gaq.push(['_trackPageview', '/admin/button-settings-view/save-click']);">
|
||||
</div>
|
||||
|
||||
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<?php if($show_footer):?>
|
||||
<h2><?php echo SyC::t('sdk','Contact'); ?></h2>
|
||||
<p><?php echo SyC::t('sdk',"If you've got 30 seconds, we'd {link-1} love to know what ideal outcome you'd like ShareYourCart to help bring to your business</a>, or if you have a private question, you can {link-2} contact us directly</a>", array('{link-1}' => '<a href="http://shareyourcart.uservoice.com" target="_blank" title="forum" class="api-link" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/forum-click\']);">', '{link-2}' => '<a href="http://www.shareyourcart.com/contact" target="_blank" class="api-link" onclick=" if(_gaq) _gaq.push([\'_trackPageview\', \'/admin/documentation/contact-click\']);">')); ?></p>
|
||||
<br />
|
||||
<?php endif; ?>
|
||||
</div>
|
Loading…
Reference in New Issue