clearAllCache(); } } register_deactivation_hook( __FILE__, 'APTFINbyTAP_remove' ); /** * Register Widget * * @since 1.0.0 * */ function APTFINbyTAP_widget_register() {register_widget( 'Alpine_PhotoTile_for_Instagram' );} add_action('widgets_init','APTFINbyTAP_widget_register'); include_once( WP_PLUGIN_DIR.'/'.basename(dirname(__FILE__)).'/gears/alpinebot-primary.php' ); include_once( WP_PLUGIN_DIR.'/'.basename(dirname(__FILE__)).'/gears/alpinebot-secondary.php' ); include_once( WP_PLUGIN_DIR.'/'.basename(dirname(__FILE__)).'/gears/alpinebot-tertiary.php' ); include_once( WP_PLUGIN_DIR.'/'.basename(dirname(__FILE__)).'/gears/plugin-widget.php' ); include_once( WP_PLUGIN_DIR.'/'.basename(dirname(__FILE__)).'/gears/plugin-shortcode.php' ); /** * Load Admin JS and CSS * * @since 1.0.0 * */ function APTFINbyTAP_admin_widget_script($hook){ $bot = new PhotoTileForInstagramBot(); wp_register_script($bot->wmenujs,$bot->url.'/js/'.$bot->wmenujs.'.js','',$bot->ver); wp_register_style($bot->acss,$bot->url.'/css/'.$bot->acss.'.css','',$bot->ver); wp_register_script($bot->wjs,$bot->url.'/js/'.$bot->wjs.'.js','',$bot->ver); wp_register_style($bot->wcss,$bot->url.'/css/'.$bot->wcss.'.css','',$bot->ver); wp_register_script( 'fancybox', $bot->url.'/js/fancybox/jquery.fancybox-1.3.4.pack.js', '', '1.0', true ); wp_register_style( 'fancybox-stylesheet', $bot->url . '/js/fancybox/jquery.fancybox-1.3.4.css', false, '1.0', 'screen' ); wp_register_script( 'jquery-form', $bot->url.'/js/form/jquery.form.js', '', '1.0', true ); if( 'widgets.php' != $hook ){ return; } wp_enqueue_script( 'jquery'); wp_enqueue_script($bot->wmenujs); wp_enqueue_style($bot->acss); add_action('admin_print_footer_scripts', 'APTFINbyTAP_menu_toggles'); // Only admin can trigger two week cache cleaning by visiting widgets.php $disablecache = $bot->get_option( 'cache_disable' ); if ( !$disablecache ) { $bot->cleanCache(); } } add_action('admin_enqueue_scripts', 'APTFINbyTAP_admin_widget_script'); /** * Load JS to activate menu toggles * * @since 1.0.0 * */ function APTFINbyTAP_menu_toggles(){ $bot = new PhotoTileForInstagramBot(); ?> wjs,$bot->url.'/js/'.$bot->wjs.'.js','',$bot->ver); wp_register_style($bot->wcss,$bot->url.'/css/'.$bot->wcss.'.css','',$bot->ver); wp_register_script( 'fancybox', $bot->url.'/js/fancybox/jquery.fancybox-1.3.4.pack.js', '', '1.0', true ); wp_register_style( 'fancybox-stylesheet', $bot->url . '/js/fancybox/jquery.fancybox-1.3.4.css', false, '1.0', 'screen' ); } add_action('wp_enqueue_scripts', 'APTFINbyTAP_enqueue_display_scripts'); /** * Setup the Theme Admin Settings Page * * @ Since 1.0.1 */ function APTFINbyTAP_admin_options() { $bot = new PhotoTileForInstagramBot(); $page = add_options_page(__($bot->page), __($bot->page), 'manage_options', $bot->settings , 'APTFINbyTAP_admin_options_page'); // Using registered $page handle to hook script load add_action('admin_print_scripts-' . $page, 'APTFINbyTAP_enqueue_admin_scripts'); } // Load the Admin Options page add_action('admin_menu', 'APTFINbyTAP_admin_options'); /** * Enqueue admin scripts (and related stylesheets) * * @ Since 1.0.0 */ function APTFINbyTAP_enqueue_admin_scripts() { $bot = new PhotoTileForInstagramBot(); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'farbtastic' ); wp_enqueue_style( 'farbtastic' ); wp_enqueue_script($bot->wmenujs); wp_enqueue_style($bot->acss); add_action('admin_print_footer_scripts', 'APTFINbyTAP_menu_toggles'); add_action('admin_print_footer_scripts', 'APTFINbyTAP_shortcode_select'); } /** * Settings Page Markup * * @ Since 1.0.2 */ function APTFINbyTAP_admin_options_page() { if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient permissions to access this page.') ); } $bot = new PhotoTileForInstagramBot(); $bot->build_settings_page(); } /** * Display a notice to add Instagram user that can be dismissed * * @ Since 1.2.1 */ function APTFINbyTAP_admin_notice() { global $current_user ; $user_id = $current_user->ID; /* Check that the user hasn't already clicked to ignore the message */ if ( ! get_user_meta($user_id, 'APTFINbyTAP_ignore_notice') ) { $bot = new PhotoTileForInstagramBot(); $users = $bot->get_users(); if( $users['none'] ){ echo '

'; echo 'Add user to Photo Tile for Instagram here'; printf(__(' | Hide Notice'), '?APTFINbyTAP_nag_ignore=0'); echo "

"; } } } add_action('admin_notices', 'APTFINbyTAP_admin_notice'); /** * Notice dismiss function * * @ Since 1.2.1 */ add_action('admin_init', 'APTFINbyTAP_nag_ignore'); function APTFINbyTAP_nag_ignore() { global $current_user; $user_id = $current_user->ID; /* If user clicks to ignore the notice, add that to their user meta */ if ( isset($_GET['APTFINbyTAP_nag_ignore']) && '0' == $_GET['APTFINbyTAP_nag_ignore'] ) { add_user_meta($user_id, 'eAPTFINbyTAP_ignore_notice', 'true', true); } } ?>