woocommerce/classes/integrations/sharedaddy/class-wc-sharedaddy.php

94 lines
2.2 KiB
PHP
Raw Normal View History

2012-04-30 19:50:35 +00:00
<?php
/**
* ShareDaddy Integration
2012-08-15 18:15:06 +00:00
*
2012-04-30 19:50:35 +00:00
* Enables ShareDaddy integration.
*
2012-08-15 18:15:06 +00:00
* @class WC_ShareDaddy
* @extends WC_Integration
* @version 1.6.4
* @package WooCommerce/Classes/Integrations
* @author WooThemes
2012-04-30 19:50:35 +00:00
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2012-04-30 19:50:35 +00:00
class WC_ShareDaddy extends WC_Integration {
2012-08-15 18:15:06 +00:00
/**
* Init and hook in the integration.
*
* @access public
* @return void
*/
public function __construct() {
2012-04-30 19:50:35 +00:00
$this->id = 'sharedaddy';
$this->method_title = __( 'ShareDaddy', 'woocommerce' );
$this->method_description = __( 'ShareDaddy is a sharing plugin bundled with JetPack.', 'woocommerce' );
// Load the settings.
2013-01-03 10:38:59 +00:00
$this->init_form_fields();
2012-04-30 19:50:35 +00:00
$this->init_settings();
// Actions
add_action( 'woocommerce_update_options_integration_sharedaddy', array( $this, 'process_admin_options' ) );
2012-08-15 18:15:06 +00:00
2012-04-30 19:50:35 +00:00
// Share widget
add_action( 'woocommerce_share', array( $this, 'sharedaddy_code' ) );
2012-08-15 18:15:06 +00:00
}
/**
2012-04-30 19:50:35 +00:00
* Initialise Settings Form Fields
2012-08-15 18:15:06 +00:00
*
* @access public
* @return void
2012-04-30 19:50:35 +00:00
*/
function init_form_fields() {
2012-08-15 18:15:06 +00:00
$this->form_fields = array(
'enabled' => array(
2012-04-30 19:50:35 +00:00
'title' => __( 'Output ShareDaddy button?', 'woocommerce' ),
'description' => __( 'Enable this option to show the ShareDaddy button on the product page.', 'woocommerce' ),
'type' => 'checkbox',
'default' => get_option('woocommerce_sharedaddy') ? get_option('woocommerce_sharedaddy') : 'no'
)
);
2012-08-15 18:15:06 +00:00
}
2012-04-30 19:50:35 +00:00
/**
2012-08-15 18:15:06 +00:00
* Output share code.
*
* @access public
* @return void
2012-04-30 19:50:35 +00:00
*/
function sharedaddy_code() {
global $post;
2012-08-15 18:15:06 +00:00
2012-04-30 19:50:35 +00:00
if ( $this->enabled == 'yes' && function_exists('sharing_display') ) {
2012-08-15 18:15:06 +00:00
2012-04-30 19:50:35 +00:00
?><div class="social"><?php echo sharing_display(); ?></div><?php
2012-08-15 18:15:06 +00:00
2012-04-30 19:50:35 +00:00
}
}
2012-08-15 18:15:06 +00:00
2012-04-30 19:50:35 +00:00
}
2012-08-15 18:15:06 +00:00
2012-04-30 19:50:35 +00:00
/**
2012-08-15 18:15:06 +00:00
* Add the integration to WooCommerce.
*
2012-08-15 18:30:35 +00:00
* @package WooCommerce/Classes/Integrations
2012-08-15 18:15:06 +00:00
* @access public
* @param array $integrations
* @return array
*/
2012-04-30 19:50:35 +00:00
function add_sharedaddy_integration( $integrations ) {
if ( class_exists('jetpack') )
2012-08-15 18:15:06 +00:00
$integrations[] = 'WC_ShareDaddy';
2012-04-30 19:50:35 +00:00
return $integrations;
}
2012-08-15 18:15:06 +00:00
add_filter('woocommerce_integrations', 'add_sharedaddy_integration' );