/** * Alpine PhotoTile for Tumblr: Shortcode * * @ Since 1.1.1 * @ Updated 1.2.5 */ function APTFTbyTAP_shortcode_function($atts) { $bot = new PhotoTileForTumblrBot(); $optiondetails = $bot->option_defaults(); $options = array(); foreach ($optiondetails as $opt => $details) { $options[$opt] = $details['default']; if (isset($details['short']) && isset($atts[$details['short']])) { $options[$opt] = $atts[$details['short']]; } } $id = rand(100, 1000); $bot->set_private('wid', 'id' . $id); $bot->set_private('options', $options); $bot->do_alpine_method('update_global_options'); $bot->do_alpine_method('enqueue_style_and_script'); // Do the photo search $bot->do_alpine_method('photo_retrieval'); $return = '<div id="' . $bot->get_private('id') . '-by-shortcode-' . $id . '" class="AlpinePhotoTiles_inpost_container">'; $return .= $bot->get_active_result('hidden'); if ($bot->check_active_result('success')) { if ('vertical' == $options['style_option']) { $bot->do_alpine_method('display_vertical'); } elseif ('cascade' == $options['style_option']) { $bot->do_alpine_method('display_cascade'); } else { $bot->do_alpine_method('display_hidden'); } $return .= $bot->get_private('output'); } elseif ($bot->check_active_option('general_hide_message')) { $return .= '<!-- Sorry:<br>' . $bot->get_active_result('message') . '-->'; } else { $return .= 'Sorry:<br>' . $bot->get_active_result('message'); } $return .= '</div>'; return $return; }
/** * Load Admin JS and CSS * * @ Since 1.0.0 * @ Updated 1.2.3 */ function APTFTbyTAP_admin_widget_script($hook) { $bot = new PhotoTileForTumblrBot(); // Bot needed to clean cache wp_register_script($bot->get_private('ajs'), $bot->get_script('admin'), '', $bot->get_private('ver')); wp_register_style($bot->get_private('acss'), $bot->get_style('admin'), '', $bot->get_private('ver')); $bot->do_alpine_method('register_style_and_script'); // Register widget styles and scripts if ('widgets.php' != $hook) { return; } wp_enqueue_script('jquery'); wp_enqueue_script($bot->get_private('ajs')); wp_enqueue_style($bot->get_private('acss')); add_action('admin_print_footer_scripts', 'APTFTbyTAP_menu_toggles'); // Only admin can trigger two week cache cleaning by visiting widgets.php $disablecache = $bot->get_option('cache_disable'); if (empty($disablecache)) { $bot->do_alpine_method('cleanCache'); } }
/** * First function for printing options page * * @ Since 1.1.0 * @ Updated 1.2.4 * */ function admin_setup_options_form($currenttab) { $options = $this->get_all_options(); $settings_section = $this->get_private('id') . '_' . $currenttab . '_tab'; $submitted = isset($_POST["hidden"]) && $_POST["hidden"] == "Y" ? true : false; if ($submitted) { $options = $this->admin_simple_update($currenttab, $_POST, $options); } $buttom = isset($_POST[$this->get_private('settings') . '_' . $currenttab]['submit-' . $currenttab]) ? $_POST[$this->get_private('settings') . '_' . $currenttab]['submit-' . $currenttab] : ''; if ($buttom == 'Delete Current Cache') { $bot = new PhotoTileForTumblrBot(); $bot->clearAllCache(); echo '<div class="announcement">' . __("Cache Cleared") . '</div>'; } elseif ($buttom == 'Save Settings') { $bot = new PhotoTileForTumblrBot(); $bot->clearAllCache(); echo '<div class="announcement">' . __("Settings Saved") . '</div>'; } echo '<form action="" method="post">'; echo '<input type="hidden" name="hidden" value="Y">'; $this->admin_display_opt_form($options, $currenttab); echo '<div class="AlpinePhotoTiles-breakline"></div>'; echo '</form>'; }
/** * Widget * * @ Updated 1.2.5 */ function widget($args, $options) { $bot = new PhotoTileForTumblrBot(); extract($args); // Set Important Widget Options $bot->set_private('wid', $args['widget_id']); $bot->set_private('options', $options); $bot->do_alpine_method('update_global_options'); $bot->do_alpine_method('enqueue_style_and_script'); // Do the photo search $bot->do_alpine_method('photo_retrieval'); echo $before_widget . $before_title . $options['widget_title'] . $after_title; echo $bot->get_active_result('hidden'); if ($bot->check_active_result('success')) { if (isset($options['style_option']) && 'vertical' == $options['style_option']) { $bot->do_alpine_method('display_vertical'); } elseif (isset($options['style_option']) && 'cascade' == $options['style_option']) { $bot->do_alpine_method('display_cascade'); } else { $bot->do_alpine_method('display_hidden'); } echo $bot->get_private('output'); } elseif ($bot->check_active_option('general_hide_message')) { echo '<!-- Sorry:<br>' . $bot->get_active_result('message') . '-->'; } else { echo 'Sorry:<br>' . $bot->get_active_result('message'); } echo $after_widget; }