-
-
Save deltafactory/6789297 to your computer and use it in GitHub Desktop.
<?php | |
/* | |
INSTRUCTIONS: | |
Use at your own risk. Backup your database before continuing. | |
1. Copy code to a file in the root of your website. | |
2. Change YOUR_SITE_ROOT to a value that makes sense. | |
3. Execute by visiting the page. Verify before/after results. | |
4. Change MAKE_CHANGES_TO_SITE to true and execute it again. | |
*/ | |
/*** Change this to the URL of your Wordpress installation, without the trailing slash. ***/ | |
define( 'YOUR_SITE_ROOT', 'http://yoursiteurl.com' ); | |
/*** When the results have been confirmed, change this to true to modify data. ***/ | |
define( 'MAKE_CHANGES_TO_SITE', false ); | |
/*** No need to edit below here. ***/ | |
require( 'wp-load.php' ); // Load the WordPress environment | |
header( 'Content-type: text/plain' ); // Set text output for easier debugging/readability. | |
fix_ngg_lightbox(); // Run the fix | |
function fix_ngg_lightbox() { | |
global $wpdb; | |
// Find the row in question, if it exists. | |
$post = $wpdb->get_row( | |
"SELECT ID, post_title, post_content | |
FROM $wpdb->posts | |
WHERE post_type='lightbox_library' AND post_title='lightbox'" | |
); | |
if ( !$post ) | |
exit( 'Lightbox library post not found.' ); | |
// Decode blob to proper object. Done twice to avoid shared reference. | |
$data_before = json_decode( base64_decode( $post->post_content ) ); | |
$data = json_decode( base64_decode( $post->post_content ) ); | |
$base_url = untrailingslashit( YOUR_SITE_ROOT ); | |
$data->values->nextgen_lightbox_loading_img_url = $base_url . '/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/lightbox/static/jquery.lightbox/lightbox-ico-loading.gif'; | |
$data->values->nextgen_lightbox_close_btn_url = $base_url . '/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/lightbox/static/jquery.lightbox/lightbox-btn-close.gif'; | |
$data->values->nextgen_lightbox_btn_prev_url = $base_url . '/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/lightbox/static/jquery.lightbox/lightbox-btn-prev.gif'; | |
$data->values->nextgen_lightbox_btn_next_url = $base_url . '/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/lightbox/static/jquery.lightbox/lightbox-btn-next.gif'; | |
$data->values->nextgen_lightbox_blank_img_url = $base_url . '/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/lightbox/static/jquery.lightbox/lightbox-blank.gif'; | |
$post_content = $post_content_filtered = base64_encode( json_encode( $data ) ); | |
echo "\n\n"; | |
if ( MAKE_CHANGES_TO_SITE ) { | |
$wpdb->update( $wpdb->posts, compact( 'post_content', 'post_content_filtered' ), array( 'ID' => $post->ID ) ); | |
echo '*** Done.'; | |
} else { | |
echo '*** No data is being changed. Verify the results and change the constant "MAKE_CHANGES_TO_SITE" to "true" and re-run the script to commit.'; | |
} | |
echo "\n\n"; | |
echo "Before:\n"; | |
print_r( $data_before ); | |
echo "\nAfter:\n"; | |
print_r( $data ); | |
} | |
thanks for this fix.
$base_url .
can be removed (if WP installed NOT into subdir) to be domain independent
Hello!
Your code works! But I found one more issue with NextGen Gallery—and that's when you use "Highslide" for the Lightbox effect. Apparently, it still contains the old URL. To fix this, there's just a little modification made to this code:
Line 33: WHERE post_type='lightbox_library' AND post_title='lightbox'"
Change to: WHERE post_type='lightbox_library' AND post_title='highslide'"
Remove Lines 44 to 48 and replace with:
$data->values->nextgen_highslide_graphics_dir = $base_url . '/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/lightbox/static/highslide/graphics';
Just dropping this here in case somebody encounters the same problem.
Thanks for the continued feedback guys. I'm sure it's helpful for others who discover this. It's too bad that Photocrati hasn't really felt it necessary to fix the problem within the plugin itself.
Hi, I tried this, and I have 4 comments:
$data->css_stylesheets = $base_url . '/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/lightbox/static/jquery.lightbox/jquery.lightbox-0.5.css';
none, shutter, shutter2, thickbox, fancybox, highslide
Anyway, I just went into other options and in the Lightbox Tab I switched to every option (Fancybox, Thickbox, etc.) and clicked teh advanced settings, then it showed a textarea with the old url in it, just removed the http://domain.com part and voilá.