Skip to content

Commit

Permalink
ShareYourCart + integration tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Apr 30, 2012
1 parent 911ae3d commit 62c1d9d
Show file tree
Hide file tree
Showing 49 changed files with 1,353 additions and 562 deletions.
120 changes: 42 additions & 78 deletions admin/woocommerce-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1101,75 +1101,6 @@

)); // End email settings

$woocommerce_settings['integration'] = apply_filters('woocommerce_intregation_settings', array(

array( 'name' => __( 'ShareThis', 'woocommerce' ), 'type' => 'title', 'desc' => __('ShareThis offers a sharing widget which will allow customers to share links to products with their friends.', 'woocommerce'), 'id' => 'share_this' ),

array(
'name' => __( 'ShareThis Publisher ID', 'woocommerce' ),
'desc' => sprintf( __( 'Enter your %1$sShareThis publisher ID%2$s to show social sharing buttons on product pages.', 'woocommerce' ), '<a href="http://sharethis.com/account/">', '</a>' ),
'id' => 'woocommerce_sharethis',
'type' => 'text',
'std' => '',
'css' => 'min-width:300px;',
),

array( 'type' => 'sectionend', 'id' => 'share_this'),

array( 'name' => __( 'ShareDaddy', 'woocommerce' ), 'type' => 'title', 'desc' => __('ShareDaddy is a sharing plugin bundled with JetPack.', 'woocommerce'), 'id' => 'sharedaddy' ),

array(
'name' => __( 'Output ShareDaddy button?', 'woocommerce' ),
'desc' => __( 'Enable this option to show the ShareDaddy button (if installed) on the product page.', 'woocommerce' ),
'id' => 'woocommerce_sharedaddy',
'type' => 'checkbox',
'std' => 'no',
),

array( 'type' => 'sectionend', 'id' => 'sharedaddy'),

array( 'name' => __( 'ShareYourCart', 'woocommerce' ), 'type' => 'title', 'desc' => __('ShareYourCart helps you get more customers by motivating satisfied customers to talk with their friends about your products.', 'woocommerce'), 'id' => 'shareyourcart' ),

array(
'name' => __( 'ShareYourCart integration', 'woocommerce' ),
'desc' => __( 'Enable this option to enable ShareYourCart', 'woocommerce' ),
'id' => 'woocommerce_shareyourcart',
'type' => 'checkbox',
'std' => 'no',
),

array( 'type' => 'sectionend', 'id' => 'shareyourcart'),

array( 'name' => __( 'Google Analytics', 'woocommerce' ), 'type' => 'title', 'desc' => __('Google Analytics is a free service offered by Google that generates detailed statistics about the visitors to a website.', 'woocommerce'), 'id' => 'google_analytics' ),

array(
'name' => __('Google Analytics ID', 'woocommerce'),
'desc' => __('Log into your google analytics account to find your ID. e.g. <code>UA-XXXXX-X</code>', 'woocommerce'),
'id' => 'woocommerce_ga_id',
'type' => 'text',
'css' => 'min-width:300px;',
),

array(
'name' => __('Tracking code', 'woocommerce'),
'desc' => __('Add tracking code to your site\'s footer. You don\'t need to enable this if using a 3rd party analytics plugin.', 'woocommerce'),
'id' => 'woocommerce_ga_standard_tracking_enabled',
'type' => 'checkbox',
'checkboxgroup' => 'start'
),

array(
'name' => __('Tracking code', 'woocommerce'),
'desc' => __('Add eCommerce tracking code to the thankyou page', 'woocommerce'),
'id' => 'woocommerce_ga_ecommerce_tracking_enabled',
'type' => 'checkbox',
'checkboxgroup' => 'end'
),

array( 'type' => 'sectionend', 'id' => 'google_analytics'),

)); // End integration settings

/**
* Settings page
*
Expand All @@ -1179,11 +1110,12 @@
function woocommerce_settings() {
global $woocommerce, $woocommerce_settings;

$current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : urldecode( $_GET['tab'] );
$current_section = ( empty( $_GET['section'] ) ) ? '' : urldecode( $_GET['section'] );
$current_tab = ( empty( $_GET['tab'] ) ) ? 'general' : urldecode( $_GET['tab'] );
$current_section = ( empty( $_REQUEST['section'] ) ) ? '' : urldecode( $_REQUEST['section'] );

// Save settings
if ( ! empty( $_POST ) ) {

if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-settings' ) )
die( __( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) );

Expand All @@ -1197,7 +1129,6 @@ function woocommerce_settings() {
case "shipping" :
case "tax" :
case "email" :
case "integration" :
woocommerce_update_options( $woocommerce_settings[$current_tab] );
break;
}
Expand Down Expand Up @@ -1225,13 +1156,28 @@ function woocommerce_settings() {
wp_redirect( $redirect );
exit;
}

// Settings saved message

// Get any returned messages
$error = ( empty( $_GET['wc_error'] ) ) ? '' : urldecode( stripslashes( $_GET['wc_error'] ) );
$message = ( empty( $_GET['wc_message'] ) ) ? '' : urldecode( stripslashes( $_GET['wc_message'] ) );

if ( $error || $message ) {

if ( $error ) {
echo '<div id="message" class="error fade"><p><strong>' . wptexturize( $error ) . '</strong></p></div>';
} else {
echo '<div id="message" class="updated fade"><p><strong>' . wptexturize( $message ) . '</strong></p></div>';
}

} elseif ( ! empty( $_GET['saved'] ) ) {

echo '<div id="message" class="updated fade"><p><strong>' . __( 'Your settings have been saved.', 'woocommerce' ) . '</strong></p></div>';

}

// Were the settings saved?
if ( ! empty( $_GET['saved'] ) ) {
echo '<div id="message" class="updated fade"><p><strong>' . __( 'Your settings have been saved.', 'woocommerce' ) . '</strong></p></div>';

flush_rewrite_rules( false );

do_action('woocommerce_settings_saved');
}

Expand Down Expand Up @@ -1317,7 +1263,6 @@ function woocommerce_settings() {
case "inventory" :
case "tax" :
case "email" :
case "integration" :
woocommerce_admin_fields( $woocommerce_settings[$current_tab] );
break;
case "shipping" :
Expand Down Expand Up @@ -1460,6 +1405,25 @@ function woocommerce_settings() {

echo '</div>';

break;
case "integration" :

$integrations = $woocommerce->integrations->get_integrations();

$section = empty( $_GET['section'] ) ? key( $integrations ) : urldecode( $_GET['section'] );

foreach ( $integrations as $integration ) {
$title = ( isset( $integration->method_title ) && $integration->method_title) ? ucwords( $integration->method_title ) : ucwords( $method->id );
$current = ( $integration->id == $section ) ? 'class="current"' : '';

$links[] = '<a href="' . add_query_arg( 'section', $integration->id, admin_url('admin.php?page=woocommerce&tab=integration') ) . '"' . $current . '>' . $title . '</a>';
}

echo '<ul class="subsubsub"><li>' . implode(' | </li><li>', $links) . '</li></ul><br class="clear" />';

if ( isset( $integrations[ $section ] ) )
$integrations[ $section ]->admin_options();

break;
default :
do_action( 'woocommerce_settings_tabs_' . $current_tab );
Expand Down
2 changes: 1 addition & 1 deletion assets/css/admin.css

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions assets/css/admin.less
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
}
}

#wc_get_started { position: relative; margin: 1em 0 2em; padding: 15px 15px 15px 90px; border: 1px solid #d9d9d9; background: #f5f5f5 url(../images/gear.png) no-repeat 15px 15px; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #fff; -moz-box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #fff; -webkit-box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #fff; }
#wc_get_started span { display: block; text-shadow: 1px 1px 0 #fff; font-size: 14px; line-height: 22px; color: #595959; }
#wc_get_started span.main { margin-top: 2px; font-weight: bold; font-size: 16px; }
#wc_get_started .main-button { position: absolute; right: 20px; top: 27px; }
#wc_get_started p { margin: 1em 0 .5em; }

#icon-woocommerce, .woocommerce_icon, .icon32-posts-product, .icon32-posts-shop_order, .icon32-posts-shop_coupon, .icon32-posts-product_variation {
background-image: url(../images/icons/woocommerce-icons.png) !important;
background-position: -11px -6px;
Expand Down
Binary file added assets/images/gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions classes/integrations/class-wc-integration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* WooCommerce Integration class
*
* Extended by individual integrations to offer additional functionality.
*
* @class WC_Integration
* @package WooCommerce
* @category Integrations
* @author WooThemes
*/
class WC_Integration extends WC_Settings_API {

/**
* Admin Options
*
* Setup the gateway settings screen.
* Override this in your gateway.
*
* @since 1.0.0
*/
function admin_options() { ?>

<h3><?php echo isset( $this->method_title ) ? $this->method_title : __( 'Settings', 'woocommerce' ) ; ?></h3>

<?php echo isset( $this->method_description ) ? wpautop( $this->method_description ) : ''; ?>

<table class="form-table">
<?php $this->generate_settings_html(); ?>
</table>

<!-- Section -->
<div><input type="hidden" name="section" value="<?php echo $this->id; ?>" /></div>

<?php
}

}
42 changes: 42 additions & 0 deletions classes/integrations/class-wc-integrations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* WooCommerce Integrations class
*
* Loads Integrations into WooCommerce.
*
* @class WC_Integrations
* @package WooCommerce
* @category Integrations
* @author WooThemes
*/
class WC_Integrations {

var $integrations = array();

/**
* init function.
*
* @access public
*/
function init() {

do_action('woocommerce_integrations_init');

$load_integrations = apply_filters('woocommerce_integrations', array() );

// Load integration classes
foreach ( $load_integrations as $integration ) {

$load_integration = new $integration();

$this->integrations[$load_integration->id] = $load_integration;

}

}

function get_integrations() {
return $this->integrations;
}

}
Loading

0 comments on commit 62c1d9d

Please sign in to comment.