setCacheDir( APTFPINbyTAP_CACHE );
$cache->clearAll();
}
}
// Register Widget
function APTFPINbyTAP_widget_register() {register_widget( 'Alpine_PhotoTile_for_Pinterest' );}
add_action('widgets_init','APTFPINbyTAP_widget_register');
class Alpine_PhotoTile_for_Pinterest extends WP_Widget {
function Alpine_PhotoTile_for_Pinterest() {
$widget_ops = array('classname' => 'APTFPINbyTAP_widget', 'description' => __('Add images from Pinterest to your sidebar'));
$control_ops = array('width' => 550, 'height' => 350);
$this->WP_Widget(APTFPINbyTAP_DOMAIN, __('Alpine PhotoTile for Pinterest'), $widget_ops, $control_ops);
}
function widget( $args, $options ) {
extract($args);
// Set Important Widget Options
$id = $args["widget_id"];
$defaults = APTFPINbyTAP_option_defaults();
$source_results = APTFPINbyTAP_photo_retrieval($id, $options, $defaults);
echo $before_widget . $before_title . $options['widget_title'] . $after_title;
echo $source_results['hidden'];
if( $source_results['continue'] ){
switch ($options['style_option']) {
case "vertical":
APTFPINbyTAP_display_vertical($id, $options, $source_results);
break;
case "windows":
APTFPINbyTAP_display_hidden($id, $options, $source_results);
break;
case "bookshelf":
APTFPINbyTAP_display_hidden($id, $options, $source_results);
break;
case "rift":
APTFPINbyTAP_display_hidden($id, $options, $source_results);
break;
case "floor":
APTFPINbyTAP_display_hidden($id, $options, $source_results);
break;
case "wall":
APTFPINbyTAP_display_hidden($id, $options, $source_results);
break;
case "cascade":
APTFPINbyTAP_display_cascade($id, $options, $source_results);
break;
case "gallery":
APTFPINbyTAP_display_hidden($id, $options, $source_results);
break;
}
}
// If user does not have necessary extensions
// or error occured before content complete, report such...
else{
echo 'Sorry:
'.$source_results['message'];
}
echo $after_widget;
}
function update( $newoptions, $oldoptions ) {
$optiondetails = APTFPINbyTAP_option_defaults();
if ( function_exists( 'theAlpinePressMenuOptionsValidateV1' ) ) {
foreach( $newoptions as $id=>$input ){
$options[$id] = theAlpinePressMenuOptionsValidateV1( $input,$oldoptions[$id],$optiondetails[$id] );
}
}else{
$options = $newoptions;
}
return $options;
}
function form( $options ) {
include( 'admin/widget-menu-form.php');
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////// Safely Enqueue Scripts and Register Widget ////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Load Admin JS and CSS
function APTFPINbyTAP_admin_head_script(){
// TODO - CREATE SEPERATE FUNCTIONS TO LOAD ADMIN PAGE AND WIDGET PAGE SCRIPTS
wp_enqueue_script( 'jquery');
// Replication Error caused by not loading new version of JS and CSS
// Fix by always changing version number if changes were made
wp_deregister_script('APTFPINbyTAP_widget_menu');
wp_register_script('APTFPINbyTAP_widget_menu',APTFPINbyTAP_URL.'/js/aptfpinbytap_widget_menu.js','',APTFPINbyTAP_VER);
wp_enqueue_script('APTFPINbyTAP_widget_menu');
wp_deregister_style('APTFPINbyTAP_admin_css');
wp_register_style('APTFPINbyTAP_admin_css',APTFPINbyTAP_URL.'/css/aptfpinbytap_admin_style.css','',APTFPINbyTAP_VER);
wp_enqueue_style('APTFPINbyTAP_admin_css');
add_action('admin_print_footer_scripts', 'APTFPINbyTAP_menu_toggles');
// Only admin can trigger two week cache cleaning
if ( class_exists( 'theAlpinePressSimpleCacheV1' ) && APTFPINbyTAP_CACHE ) {
$cache = new theAlpinePressSimpleCacheV1();
$cache->setCacheDir( APTFPINbyTAP_CACHE );
$cache->clean();
}
}
add_action('admin_enqueue_scripts', 'APTFPINbyTAP_admin_head_script'); // admin_init so that it is ready when page loads
function APTFPINbyTAP_menu_toggles(){
?>