Forked from deltafactory/fix-nextgen-lightbox-path.php
Last active
August 29, 2015 14:01
-
-
Save johnleblanc/28294471dbc5c74a8fb8 to your computer and use it in GitHub Desktop.
Revisions
-
johnleblanc revised this gist
May 20, 2014 . 1 changed file with 16 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,10 +12,12 @@ */ /*** Change this to the URL of your Wordpress installation, without the trailing slash. ***/ define( 'YOUR_SITE_ROOT', 'http://www.example.com' ); define( 'YOUR_OLD_SITE_ROOT', 'http://staging.example.com' ); /*** When the results have been confirmed, change this to true to modify data. ***/ define( 'MAKE_CHANGES_TO_SITE', FALSE ); define( 'FIX_CSS_AND_JS', FALSE ); /*** No need to edit below here. ***/ @@ -47,6 +49,18 @@ function fix_ngg_lightbox() { $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'; $css = (string) $data->css_stylesheets; $js = (string) $data->scripts; $find = (string) YOUR_OLD_SITE_ROOT; $replace = (string) YOUR_SITE_ROOT; if ( FIX_CSS_AND_JS ) { // Search/Replace CSS and JS References $data->css_stylesheets = str_replace($find, $replace, $css); $data->scripts = str_replace($find, $replace, $js); } $post_content = $post_content_filtered = base64_encode( json_encode( $data ) ); echo "\n\n"; @@ -64,4 +78,3 @@ function fix_ngg_lightbox() { print_r( $data ); } -
deltafactory created this gist
Oct 2, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ <?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 ); }