public function index_action() { $this->object->enqueue_backend_resources(); $key = C_Photocrati_Transient_Manager::create_key('nextgen_pro_upgrade_page', 'html'); if ($html = C_Photocrati_Transient_Manager::fetch($key, FALSE)) { echo $html; } else { // Get page content $template = 'photocrati-nextgen_pro_upgrade#plus'; if (defined('NGG_PLUS_PLUGIN_BASENAME')) { $template = 'photocrati-nextgen_pro_upgrade#pro'; } $description = 'Extend NextGEN Gallery with 8 new pro gallery displays, a full screen responsive pro lightbox, commenting / social sharing / deep linking for individual images, ecommerce, digital downloads, and pro email support.'; $headline = 'Upgrade to NextGEN Plus or NextGEN Pro'; if (defined('NGG_PLUS_PLUGIN_BASENAME')) { $description = 'NextGEN Pro now offers ecommerce! Extend NextGEN Gallery and NextGEN Plus with a complete solution for selling prints and digital downloads, including unlimited pricelists, PayPal and Stripe integration, and more.'; $headline = 'Upgrade to NextGEN Pro with Ecommerce'; } $params = array('description' => $description, 'headline' => $headline); $html = $this->render_view($template, $params, TRUE); // Cache it C_Photocrati_Transient_Manager::update($key, $html); // Render it echo $html; } }
function index_action() { $this->object->enqueue_backend_resources(); $key = C_Photocrati_Transient_Manager::create_key('nextgen_pro_upgrade_page', 'html'); if ($html = C_Photocrati_Transient_Manager::fetch($key, FALSE)) { echo $html; } else { // Get template and page content $template = 'photocrati-nextgen_pro_upgrade#plus'; if (defined('NGG_PLUS_PLUGIN_BASENAME')) { $template = 'photocrati-nextgen_pro_upgrade#pro'; } $html = $this->render_view($template, array('i18n' => $this->get_i18n_strings()), TRUE); // Cache it C_Photocrati_Transient_Manager::update($key, $html); // Render it echo $html; } }
/** * Looks up using SQL the columns existing in the database */ function update_columns_cache() { $key = C_Photocrati_Transient_Manager::create_key('col_in_' . $this->get_table_name(), 'columns'); global $wpdb; $this->_table_columns = array(); $sql = "SHOW COLUMNS FROM `{$this->get_table_name()}`"; foreach ($wpdb->get_results($sql) as $row) { $this->_table_columns[] = $row->Field; } C_Photocrati_Transient_Manager::update($key, $this->_table_columns); }
public function _get_cache_key() { return C_Photocrati_Transient_Manager::create_key('MVC', 'get_static_url'); }
/** * Looks up using SQL the columns existing in the database */ public function lookup_columns() { // Avoid doing multiple SHOW COLUMNS if we can help it $key = C_Photocrati_Transient_Manager::create_key('col_in_' . $this->get_table_name(), 'columns'); $this->_table_columns = C_Photocrati_Transient_Manager::fetch($key, FALSE); if (!$this->_table_columns) { global $wpdb; $this->_table_columns = array(); $sql = "SHOW COLUMNS FROM `{$this->get_table_name()}`"; foreach ($wpdb->get_results($sql) as $row) { $this->_table_columns[] = $row->Field; } C_Photocrati_Transient_Manager::update($key, $this->_table_columns); } return $this->_table_columns; }
/** * Renders a displayed gallery on the frontend * @param C_Displayed_Gallery|stdClass $displayed_gallery */ public function render($displayed_gallery, $return = FALSE, $mode = null) { $retval = ''; $lookup = TRUE; // Simply throwing our rendered gallery into a feed will most likely not work correctly. // The MediaRSS option in NextGEN is available as an alternative. if (!C_NextGen_Settings::get_instance()->galleries_in_feeds && is_feed()) { return sprintf(__(' [<a href="%s">See image gallery at %s</a>] ', 'nggallery'), esc_url(apply_filters('the_permalink_rss', get_permalink())), $_SERVER['SERVER_NAME']); } if ($mode == null) { $mode = 'normal'; } if (apply_filters('ngg_cache_displayed_galleries', FALSE)) { // Save the displayed gallery as a transient if it hasn't already. Allows for ajax operations // to add or modify the gallery without losing a retrievable ID if (!$displayed_gallery->apply_transient()) { $displayed_gallery->to_transient(); } } else { if (is_null($displayed_gallery->id())) { $displayed_gallery->id(md5(json_encode($displayed_gallery->get_entity()))); } } // Get the display type controller $controller = $this->get_registry()->get_utility('I_Display_Type_Controller', $displayed_gallery->display_type); // Get routing info $router = C_Router::get_instance(); $url = $router->get_url($router->get_request_uri(), TRUE); // Should we lookup in cache? if (is_array($displayed_gallery->container_ids) && in_array('All', $displayed_gallery->container_ids)) { $lookup = FALSE; } elseif ($displayed_gallery->source == 'albums' && $controller->param('gallery') or $controller->param('album')) { $lookup = FALSE; } elseif ($controller->param('show')) { $lookup = FALSE; } elseif ($controller->is_cachable() === FALSE) { $lookup = FALSE; } elseif (!NGG_RENDERING_CACHE_ENABLED) { $lookup = FALSE; } // Enqueue any necessary static resources if (!defined('NGG_SKIP_LOAD_SCRIPTS') || !NGG_SKIP_LOAD_SCRIPTS) { $controller->enqueue_frontend_resources($displayed_gallery); } // Try cache lookup, if we're to do so $key = NULL; $html = FALSE; if ($lookup) { // The display type may need to output some things // even when serving from the cache if ($controller->has_method('cache_action')) { $retval = $controller->cache_action($displayed_gallery); } // Output debug message $retval .= $this->debug_msg('Lookup!'); // Some settings affect display types $settings = C_NextGen_Settings::get_instance(); $key_params = apply_filters('ngg_displayed_gallery_cache_params', array($displayed_gallery->get_entity(), $url, $mode, $settings->activateTags, $settings->appendType, $settings->maxImages, $settings->thumbEffect, $settings->thumbCode, $settings->galSort, $settings->galSortDir)); // Any displayed gallery links on the home page will need to be regenerated if the permalink structure // changes if (is_home() or is_front_page()) { $key_params[] = get_option('permalink_structure'); } // Try getting the rendered HTML from the cache $key = C_Photocrati_Transient_Manager::create_key('displayed_gallery_rendering', $key_params); $html = C_Photocrati_Transient_Manager::fetch($key, FALSE); // Output debug messages if ($html) { $retval .= $this->debug_msg('HIT!'); } else { $retval .= $this->debug_msg('MISS!'); } // TODO: This is hack. We need to figure out a more uniform way of detecting dynamic image urls if (strpos($html, C_Photocrati_Settings_Manager::get_instance()->dynamic_thumbnail_slug . '/') !== FALSE) { $html = FALSE; } } else { $retval .= $this->debug_msg('Not looking up in cache as per rules'); } // If we're displaying a variant, I want to know it if (isset($displayed_gallery->variation) && is_numeric($displayed_gallery->variation) && $displayed_gallery->variation > 0) { $retval .= $this->debug_msg("Using variation #{$displayed_gallery->variation}!"); } // If a cached version doesn't exist, then create the cache if (!$html) { $retval .= $this->debug_msg('Rendering displayed gallery'); $current_mode = $controller->get_render_mode(); $controller->set_render_mode($mode); $html = apply_filters('ngg_displayed_gallery_rendering', $controller->index_action($displayed_gallery, TRUE), $displayed_gallery); if ($key != null) { C_Photocrati_Transient_Manager::update($key, $html, NGG_RENDERING_CACHE_TTL); } } $retval .= $html; if (!$return) { echo $retval; } return $retval; }