_gallery[0])) { $this->_gallery[0] = new StdClass(); } $this->_gallery_id = intval($_GET['id']); if (isset($_GET['debug'])) { $logged_contents = get_site_transient( "vimeography_gallery_" . $this->_gallery_id . "_response" ); echo "
";
      var_dump($logged_contents);
      echo "
"; die(); } $this->load_gallery(); require_once VIMEOGRAPHY_PATH . 'lib/deprecated/cache.php'; $this->_cache = new \Vimeography_Cache($this->_gallery_id); add_action('vimeography_action_refresh_gallery_cache', array( $this, 'vimeography_refresh_gallery_cache' )); add_action('vimeography_action_refresh_gallery_appearance', array( $this, 'vimeography_refresh_gallery_appearance' )); add_action('vimeography_action_set_gallery_theme', array( $this, 'vimeography_set_gallery_theme' )); add_action('vimeography/reload-gallery', array($this, 'load_gallery')); if (isset($_GET['created']) && $_GET['created'] == 1) { $this->messages[] = array( 'type' => 'updated', 'heading' => __('Gallery created.', 'vimeography'), 'message' => __('Well, that was easy.', 'vimeography') ); } } /** * Load gallery on page load - this is also available through * the `vimeography/reload-gallery` action. * * @since 1.3 * @return void */ public function load_gallery() { global $wpdb; $this->_gallery = $wpdb->get_results( ' SELECT * FROM ' . $wpdb->vimeography_gallery_meta . ' AS meta JOIN ' . $wpdb->vimeography_gallery . ' AS gallery ON meta.gallery_id = gallery.id WHERE meta.gallery_id = ' . $this->_gallery_id . ' LIMIT 1; ' ); if (!$this->_gallery) { $this->messages[] = array( 'type' => 'error', 'heading' => __('Uh oh.', 'vimeography'), 'message' => __( "That gallery no longer exists. It's gone. Kaput!", 'vimeography' ) ); } else { if (strtolower($this->_gallery[0]->theme_name) === 'bugsauce') { $this->messages[] = array( 'type' => 'error', 'heading' => __('Heads up!', 'vimeography'), 'message' => __( "The Bugsauce gallery theme has been discontinued in Vimeography 2. We recommend switching over to the free Harvestone gallery theme.", 'vimeography' ) ); } try { $theme = self::_set_active_theme($this->_gallery[0]->theme_name); } catch (Exception $e) { $this->messages[] = array( 'type' => 'error', 'heading' => __('Heads up!', 'vimeography'), 'message' => $e->getMessage() ); } } $this->_gallery[0]->featured_video = $this->_gallery[0]->featured_video === 0 ? '' : $this->_gallery[0]->featured_video; // Backwards compatibility $this->_gallery = apply_filters( 'vimeography/deprecated/reload-pro-gallery-settings', $this, $this->_gallery ); } /** * [_set_active_theme description] * @since 1.3 * @param string $theme_name [description] * @return array Theme meta */ private static function _set_active_theme($theme_name) { $vimeography = Vimeography::get_instance(); $vimeography->addons->set_active_theme($theme_name); return $vimeography->addons->active_theme; } /** * Removes the cache file associated with the loaded gallery. * * @return void */ public function vimeography_refresh_gallery_cache() { if ($this->_cache->exists()) { $this->_cache->delete(); } $this->messages[] = array( 'type' => 'updated', 'heading' => __('So fresh.', 'vimeography'), 'message' => __('Your videos have been refreshed.', 'vimeography') ); } /** * Removes the custom CSS file associated with * the current gallery, if it exists. * * @return void */ public function vimeography_refresh_gallery_appearance() { if ( file_exists( VIMEOGRAPHY_CUSTOMIZATIONS_PATH . 'vimeography-gallery-' . $this->_gallery_id . '-custom.css' ) ) { unlink( VIMEOGRAPHY_CUSTOMIZATIONS_PATH . 'vimeography-gallery-' . $this->_gallery_id . '-custom.css' ); } $this->messages[] = array( 'type' => 'updated', 'heading' => __('Theme settings cleared.', 'vimeography'), 'message' => __('Your gallery appearance has been reset.', 'vimeography') ); } /** * Returns the gallery settings to the gallery editor template * * @since 1.3 * @return array */ public function gallery() { return apply_filters('vimeography/gallery-settings', $this->_gallery); } /** * Switches to the selected gallery theme * * @param array $input posted values * @return void */ public function vimeography_set_gallery_theme($input) { // if this fails, check_admin_referer() will automatically print a "failed" page and die. if ( check_admin_referer( 'vimeography-theme-action', 'vimeography-theme-verification' ) ) { try { $theme = $input['theme_name']; global $wpdb; $result = $wpdb->update( $wpdb->vimeography_gallery_meta, array('theme_name' => $theme), array('gallery_id' => $this->_gallery_id), array('%s'), array('%d') ); if ($result === false) { throw new Exception( __('Your theme could not be updated.', 'vimeography') ); } if ( file_exists( VIMEOGRAPHY_CUSTOMIZATIONS_PATH . 'vimeography-gallery-' . $this->_gallery_id . '-custom.css' ) ) { unlink( VIMEOGRAPHY_CUSTOMIZATIONS_PATH . 'vimeography-gallery-' . $this->_gallery_id . '-custom.css' ); } do_action('vimeography/reload-gallery'); $this->messages[] = array( 'type' => 'updated', 'heading' => __('Theme updated.', 'vimeography'), 'message' => sprintf( __('You are now using the "%s" theme.', 'vimeography'), $theme ) ); } catch (Exception $e) { $this->messages[] = array( 'type' => 'error', 'heading' => __('Ruh roh.', 'vimeography'), 'message' => $e->getMessage() ); } } } }