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 documentation.', 'woocommerce' ), 'http://www.woothemes.com/woocommerce-docs/user-guide/shareyourcart/' ); // Load the form fields. $this->init_form_fields(); // 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') ); 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'); // Init the class $this->shareYourCartWooCommerce = new ShareYourCartWooCommerce( $this->settings ); } } /** * 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; } } /** * Admin Options * * Setup the gateway settings screen. * Override this in your gateway. * * @since 1.0.0 */ function admin_options() { if ( $this->enabled == 'yes' ) { // Installation $this->shareYourCartWooCommerce->install(); // Check status $this->shareYourCartWooCommerce->admin_settings_page(); } ?> client_id && ! $this->app_key ) { if ( ! empty( $_REQUEST['syc-account'] ) && $_REQUEST['syc-account'] == 'create' ) { ?>

 

method_description; ?>

ShareYourCart'; echo wpautop( $this->method_description ); } ?> generate_settings_html(); ?> client_id && $this->app_key ) : ?>

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' => '', 'type' => 'textarea', 'class' => 'custom_html' ) ); } // End init_form_fields() } /** * 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'; return $integrations; } add_filter('woocommerce_integrations', 'add_shareyourcart_integration' );