Edit Gallery admin link...


Joined: 2007-01-02
Posts: 20
Posted: Sat, 2008-03-01 09:35

I made a stupidly simple plugin for wordpress a little while ago to add a function that I found to be missing from WPG2.

I would like to share it hoping it might help other. It adds a admin link that allows the user to access G2 through the WP admin. An application for this is for if a site is setup with lightbox and you only even see the 'Sidebar Grid Block' side of WPG2 on the front end of the site, just using G2 to upload and manage images like you would use Flickr. Anyway I find it brings integration a bit closer.

Plugin Name: WP-Admin Edit Gallery2 Link
Plugin URI: n/a
Description: Adds a link to the WP-Admin top level to allow editing of Gallery2 without leaving the Admin.
Author: Darren Di Lieto
Version: 0.1
Author URI: http://apefluff.com

add_action('admin_menu', 'ddl_add_pages');

function ddl_add_pages() {

add_menu_page('Edit Gallery', 'Edit Gallery', 8, __FILE__, 'ddl_toplevel_page');

function ddl_toplevel_page() {
echo "<div class=\"wrap\"><h2>Edit Gallery</h2><iframe src =\"";
echo get_option('home');
echo "/gallery2/main.php\" height=\"900px\" width=\"99%\"></iframe></div>";



Joined: 2007-01-02
Posts: 20
Posted: Sat, 2008-03-01 11:13

Copy from <? to ?> paste into notepad or something similar. Save as g2admin-link.php or whatever you want to call it
, just end it with .php

Upload (FTP) to the WordPress's plugin folder, login and activate.

ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Sun, 2008-03-02 00:49

I would suggest you add the following before the IFRAME, this will log you into Gallery2 before executing the IFRAME

$wpg2_option = get_option('wpg2_options');

if (!defined('G2INIT')) {
$ret = g2_login();
if ($ret) {
echo '<h2>' . __('Fatal G2 error', 'wpg2') . '</h2> ' . __("Here's the error from G2: ", 'wpg2') . $ret->getAsHtml();

Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo


Joined: 2007-01-02
Posts: 20
Posted: Sun, 2008-03-02 08:14

Cool! Tested and revised.