Permalink settings must be changed from default. For the cart to display properly, your theme must contain Widget Areas.
Version: 1.1
Author: 72Lux
Author URI: http://72lux.com/
*/
// ------------------------------------------------------------------------
// REQUIRE MINIMUM VERSION OF WORDPRESS:
// ------------------------------------------------------------------------
// THIS IS USEFUL IF YOU REQUIRE A MINIMUM VERSION OF WORDPRESS TO RUN YOUR
// PLUGIN. IN THIS PLUGIN THE WP_EDITOR() FUNCTION REQUIRES WORDPRESS 3.3
// OR ABOVE. ANYTHING LESS SHOWS A WARNING AND THE PLUGIN IS DEACTIVATED.
// ------------------------------------------------------------------------
function shple_requires_wordpress_version () {
global $wp_version;
$plugin = plugin_basename( __FILE__ );
$plugin_data = get_plugin_data( __FILE__, false );
if ( version_compare($wp_version, "3.3", "<" ) ) {
if( is_plugin_active($plugin) ) {
deactivate_plugins( $plugin );
wp_die( "'".$plugin_data['Name']."' requires WordPress 3.3 or higher, and has been deactivated! Please upgrade WordPress and try again.
Back to WordPress admin." );
}
}
}
add_action( 'admin_init', 'shple_requires_wordpress_version' );
// ------------------------------------------------------------------------
// PLUGIN PREFIX:
// ------------------------------------------------------------------------
// 'shple_' prefix is derived from Shoppable
// ------------------------------------------------------------------------
// REGISTER HOOKS & CALLBACK FUNCTIONS:
// ------------------------------------------------------------------------
// Set-up Action and Filter Hooks
register_activation_hook( __FILE__, 'shple_add_defaults' );
register_uninstall_hook( __FILE__, 'shple_delete_plugin_options' );
add_action( 'admin_init', 'shple_init' );
add_action( 'admin_menu', 'shple_add_settings_page' );
add_action( 'widgets_init','shple_widget_init' );
add_action('init', 'shple_shortcode_button_init');
add_action('wp_head','shple_inject_shopjs_script', 2);
add_action('wp_head','shple_inject_css', 2);
add_filter( 'plugin_action_links', 'shple_plugin_action_links', 10, 2 );
// --------------------------------------------------------------------------------------
// CALLBACK FUNCTION FOR: register_uninstall_hook(__FILE__, 'shple_delete_plugin_options')
// --------------------------------------------------------------------------------------
// Delete options table entries ONLY when plugin deactivated AND deleted
function shple_delete_plugin_options () {
delete_option( 'shple_options' );
}
// ------------------------------------------------------------------------------
// CALLBACK FUNCTION FOR: register_activation_hook(__FILE__, 'shple_add_defaults')
// ------------------------------------------------------------------------------
// Define default option settings
function shple_add_defaults () {
$tmp = get_option('shple_options');
// added the isset() because of unset array keys on activation
if( isset( $tmp['chk_default_options_db'] ) && ( $tmp['chk_default_options_db']=='1' ) || ( !is_array($tmp) ) ) {
delete_option('shple_options'); // so we don't have to reset all the 'off' checkboxes too! (don't think this is needed but leave for now)
$arr = array(
"token" => "",
"flag_poweredby" => false,
"chk_default_options_db" => ""
);
update_option('shple_options', $arr);
}
}
// ------------------------------------------------------------------------------
// CALLBACK FUNCTION FOR: add_action('admin_init', 'shple_init' )
// ------------------------------------------------------------------------------
function shple_init (){
register_setting( 'shple_plugin_options', 'shple_options', 'shple_validate_options' );
}
// ------------------------------------------------------------------------------
// CALLBACK FUNCTION FOR: add_action('widgets_init' , 'shple_widget_init')
// ------------------------------------------------------------------------------
function shple_widget_init (){
register_widget( 'shoppable_frame_widget' );
}
// ------------------------------------------------------------------------------
// CALLBACK FUNCTION FOR: add_action('admin_menu', 'shple_add_settings_page');
// ------------------------------------------------------------------------------
// Add menu page
function shple_add_settings_page() {
add_options_page( 'Shoppable Frames Configurations Page', 'Shoppable', 'manage_options', 'shoppable', 'shple_render_help_settings' );
}
// ------------------------------------------------------------------------------
// CALLBACK FUNCTION SPECIFIED IN: add_options_page()
// ------------------------------------------------------------------------------
function shple_render_help_settings () {
echo '
Check steps #7 and #8 in our WordPress Integration Docs.
You can place the shopping bag as a widget. Navigate to your Widgets page and place the Shoppable Shopping Bag in any widget area.
In these cases, a publisher will have to manually edit the theme files and include the proper Shopping Bag HTML.
Please refer to the 72Lux Documentation about Adding a Shopping Bag Link
They can be located here when viewing your Shoppable Settings.