/** * Widget * * @ Updated 1.2.7 */ function widget($args, $options) { $bot = new PhotoTileForInstagramBot(); extract($args); // Set Important Widget Options $bot->set_private('wid', $args['widget_id']); $bot->set_private('cacheid', $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; }
/** * Alpine PhotoTile for Instagram: Shortcode * * @ Since 1.1.1 * @ Updated 1.2.7 */ function APTFINbyTAP_shortcode_function($atts) { $bot = new PhotoTileForInstagramBot(); // ID is used to retreive from transient. // Ideally, a unique id is assigned to each shortcode $array_string = implode($atts); $id = strlen($array_string); if (!empty($atts['id'])) { $id = $id . "_" . $atts['id']; } if (isset($atts['testmode']) && isset($atts['id'])) { // Load shortcode in test mode (i.e. echo messages ) $bot->set_private('testmode', $atts['testmode']); $bot->set_private('cacheid', $atts['id']); $id = $id . "_" . $atts['testmode']; } else { $bot->set_private('cacheid', $id); } $bot->echo_point("Start plugin."); $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']]; } } $bot->set_private('wid', 'id-' . $id); $bot->set_private('options', $options); $bot->do_alpine_method('update_global_options'); $bot->echo_point("Enqueue styles and scripts"); $bot->do_alpine_method('enqueue_style_and_script'); // Do the photo search $bot->echo_point("Retrieve Photos"); $bot->do_alpine_method('photo_retrieval'); $bot->echo_point("Check Results"); $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')) { $bot->echo_point("Prepare HTML Output"); if ('vertical' == $options['style_option']) { $bot->echo_point("Setup Vertial Style"); $bot->do_alpine_method('display_vertical'); } elseif ('cascade' == $options['style_option']) { $bot->echo_point("Setup Cascade Style"); $bot->do_alpine_method('display_cascade'); } else { $bot->echo_point("Setup jQuery Style (Window, Wall, Gallery)"); $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 { $bot->echo_point("Print Message"); $return .= 'Sorry:<br>' . $bot->get_active_result('message'); } $return .= '</div>'; $bot->echo_point("Loading complete"); if ($bot->get_private('testmode')) { echo '<br><p><h3>Output</h3></p>'; } return $return; }
function sf_get_instagrams() { if (class_exists('PhotoTileForInstagramBot')) { $bot = new PhotoTileForInstagramBot(); $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 APTFINbyTAP_admin_widget_script($hook) { $bot = new PhotoTileForInstagramBot(); // 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', 'APTFINbyTAP_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'); } }