setCacheDir( APTFTbyTAP_CACHE ); $cache->clearAll(); } } // Register Widget function APTFTbyTAP_widget_register() {register_widget( 'Alpine_PhotoTile_for_Tumblr' );} add_action('widgets_init','APTFTbyTAP_widget_register'); class Alpine_PhotoTile_for_Tumblr extends WP_Widget { function Alpine_PhotoTile_for_Tumblr() { $widget_ops = array('classname' => 'APTFTbyTAP_widget', 'description' => __('Add images from Tumblr to your sidebar')); $control_ops = array('width' => 550, 'height' => 350); $this->WP_Widget(APTFTbyTAP_DOMAIN, __('Alpine PhotoTile for Tumblr'), $widget_ops, $control_ops); } function widget( $args, $options ) { wp_enqueue_script('APTFTbyTAP_tiles'); wp_enqueue_style('APTFTbyTAP_widget_css'); extract($args); // Set Important Widget Options $id = $args["widget_id"]; $defaults = APTFTbyTAP_option_defaults(); $source_results = APTFTbyTAP_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": APTFTbyTAP_display_vertical($id, $options, $source_results); break; case "windows": APTFTbyTAP_display_hidden($id, $options, $source_results); break; case "bookshelf": APTFTbyTAP_display_hidden($id, $options, $source_results); break; case "rift": APTFTbyTAP_display_hidden($id, $options, $source_results); break; case "floor": APTFTbyTAP_display_hidden($id, $options, $source_results); break; case "wall": APTFTbyTAP_display_hidden($id, $options, $source_results); break; case "cascade": APTFTbyTAP_display_cascade($id, $options, $source_results); break; case "gallery": APTFTbyTAP_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 = APTFTbyTAP_option_defaults(); if ( function_exists( 'theAlpinePressMenuOptionsValidateV1' ) && APTFTbyTAP_CACHE ) { 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 APTFTbyTAP_admin_head_script($hook){ // 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('APTFTbyTAP_widget_menu'); wp_register_script('APTFTbyTAP_widget_menu',APTFTbyTAP_URL.'/js/aptftbytap_widget_menu.js','',APTFTbyTAP_VER); wp_deregister_style('APTFTbyTAP_admin_css'); wp_register_style('APTFTbyTAP_admin_css',APTFTbyTAP_URL.'/css/aptftbytap_admin_style.css','',APTFTbyTAP_VER); if( 'widgets.php' != $hook ) return; wp_enqueue_script( 'jquery'); wp_enqueue_script('APTFTbyTAP_widget_menu'); wp_enqueue_style('APTFTbyTAP_admin_css'); add_action('admin_print_footer_scripts', 'APTFTbyTAP_menu_toggles'); // Only admin can trigger two week cache cleaning if ( class_exists( 'theAlpinePressSimpleCacheV1' ) && APTFTbyTAP_CACHE ) { $cache = new theAlpinePressSimpleCacheV1(); $cache->setCacheDir( APTFTbyTAP_CACHE ); $cache->clean(); } } add_action('admin_enqueue_scripts', 'APTFTbyTAP_admin_head_script'); // admin_init so that it is ready when page loads function APTFTbyTAP_menu_toggles(){ ?>