Title: Error When Editing Page
Last modified: December 4, 2019

---

# Error When Editing Page

 *  Resolved [bensteelesortit](https://wordpress.org/support/users/bensteelesortit/)
 * (@bensteelesortit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-when-editing-page/)
 *     ```
       Error thrown
       Class 'MslsBlogCollection' not found
       ```
   
 * I am getting the above error when trying to edit any of my pages on the site 
   [https://terraplas.com](https://terraplas.com). This has only started happening
   recently, and no updates have been made to the site.
 * Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Dennis Ploetner](https://wordpress.org/support/users/realloc/)
 * (@realloc)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-when-editing-page/#post-12205461)
 * Do you have the latest version installed? Do you have some custom code in the
   functions.php of your theme?
 * MSLS has namespaced classes and the class MslsBlogCollection is reachable as 
   lloc\Msls\MslsBlogCollection … for an example read on here: [http://msls.co/developer-docs/snippets-examples.html#get-the-current-language](http://msls.co/developer-docs/snippets-examples.html#get-the-current-language)
 *  Thread Starter [bensteelesortit](https://wordpress.org/support/users/bensteelesortit/)
 * (@bensteelesortit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-when-editing-page/#post-12205539)
 * Sorry, our developer who wrote this site is no longer available, and I’m not 
   clever enough to work this out myself.
 * We have version 2.3.0 installed, which I believe is the latest version.
 * No custom code in the function.php, but we have this document in the themes/<
   themename>/widget_shared_gallery.php that has very similar code to that in the
   docs you provided.
 *     ```
       <?php
       	/**
       	*	Create Widget
       	*/
       	class Shared_Gallery extends WP_Widget {
       		// Class constructor
       		function __construct() {
       			parent::__construct(
       				'shared-gallery', 
       				'Shared Gallery',
       				array( 
       					'classname' => 'shared-gallery',
       					'description' => 'Displays a gallery from an alternate blog on this network'
       				)
       			);
       		}
   
       		// Output for widget content
       		public function widget($args, $instance) {
   
       			echo $args['before_widget'];
   
       			// if title is not null or empty
       			if ($instance['title'] != null && $instance['title'] != '') 
       			{
       				// display the title
       				echo '<h3 class="widget-title">'.$instance['title'].'</h3>';
       			}
   
       			$blogID = $instance['blogID'];
       			$galleryID = $instance['galleryID'];
   
       			// switch blog
       			switch_to_blog($blogID);
       			// display gallery
       			nggShowGallery($galleryID, 'Terraplas', 9999);
       			// restore blog
       			restore_current_blog();
   
       			// $query = 'SELECT filename, description, alttext FROM wp_'.wpdb::get_blog_prefix($blogID).'ngg_pictures WHERE galleryid = '.$galleryID;
   
       			// global $wpdb;
       			// $images = $wpdb->get_results( $query );
   
       			// $str =  '<div>';
       			// foreach ($images as $image) {
       			// 	$str .=  '<img src="'.$image->filename.'" alt="'.$image->alttext.'"/>';
       			// }
       			// $str .=  '</div>';
   
       			// echo $str;
   
       			echo $args['after_widget'];
       		}
   
       		// Output for admin widget creation
       		public function form($instance) {
   
       	    	wp_enqueue_script( 'shared-gallery', get_stylesheet_directory_uri() . '/scripts/shared-gallery.js' );
   
       			$blog_list = MslsBlogCollection::instance()->get_current_blog();
   
       			$str = '<input type="hidden" id="blogID" name="'. esc_attr( $this->get_field_name( 'blogID' ) ) .'"/>';
       			$str .= '<input type="hidden" id="galleryID" name="'. esc_attr( $this->get_field_name( 'galleryID' ) ) .'"/>';
   
       			$str .= 	'<label>Gallery Title</label><br />';
       			$str .= 	'<input type="text" id="'.esc_attr( $this->get_field_name( 'title' ) ).'" name="'. esc_attr( $this->get_field_name( 'title' ) ) .'" /><br />';
   
       			$str .= 	'<label>Select a Blog</label><br />';
       			$str .= 	'<select id="shared-gallery-blog" onchange="setSharedBlog()">';
       			$str .=			'<option value=""> - Please Select a Blog - </option>';
       			foreach ($blog_list as $blog) {
       				$str .=		'<option value="'.$blog->blog_id.'">'.$blog->blogname.'</option>';
       			}
       			$str .= 	'</select><br /><br />';
   
       			$str .= '<label id="shared-gallery-title" style="display:none;">Select a Gallery</label>';
       			foreach ($blog_list as $blog) {
       				$str .= '<select class="shared-gallery-gallery" id="shared-gallery-galleries-'.$blog->blog_id.'" onchange="setSharedGallery()" style="display:none;">';
       				$str .=		'<option value=""> - Please Select a Gallery - </option>';
   
       				$query = 'SELECT gid, title FROM wp_' . wpdb::get_blog_prefix($blog->blog_id) . 'ngg_gallery';
   
       				global $wpdb;
       				$results = $wpdb->get_results( $query );
   
       				foreach ($results as $gallery) {
       					$str .= '<option value="'.$gallery->gid.'">'.$gallery->title.'</option>';
       				}
       				$str .= '</select>';
       			}
   
       			echo $str;
       		}
   
       		// Update function for widget
       		public function update($new_instance, $old_instance) {
       			$instance = array();
   
       			$instance['title'] = $new_instance['title'];
   
       			if (!empty($new_instance['blog_gallery'])) 
       			{
       				$vars = array_split($new_instance['blog_gallery'], ':');
   
       				$instance['blogID'] = $vals[0];
       				$instance['galleryID'] = $vals[1];
       			} else {
       				$instance['blogID'] = $old_instance['blogID'];
       				$instance['galleryID'] = $old_instance['galleryID'];
       			}
   
       			return $instance;
       		}
       	}
   
       	// Register widget
       	add_action( 'widgets_init', function(){
       		register_widget( 'Shared_Gallery' );
       	});
       ?>
       ```
   
 *  Plugin Author [Dennis Ploetner](https://wordpress.org/support/users/realloc/)
 * (@realloc)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-when-editing-page/#post-12207665)
 * You can probably correct this easily. At the beginning of the file (right after
   the line `<?php`), just insert this line:
 * `use lloc\Msls\MslsBlogCollection;`
    -  This reply was modified 6 years, 6 months ago by [Dennis Ploetner](https://wordpress.org/support/users/realloc/).
 *  Thread Starter [bensteelesortit](https://wordpress.org/support/users/bensteelesortit/)
 * (@bensteelesortit)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/error-when-editing-page/#post-12207944)
 * That’s worked perfectly. Thanks for your help!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Error When Editing Page’ is closed to new replies.

 * ![](https://ps.w.org/multisite-language-switcher/assets/icon-256x256.png?rev=
   2793358)
 * [Multisite Language Switcher](https://wordpress.org/plugins/multisite-language-switcher/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/multisite-language-switcher/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/multisite-language-switcher/)
 * [Active Topics](https://wordpress.org/support/plugin/multisite-language-switcher/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multisite-language-switcher/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multisite-language-switcher/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [bensteelesortit](https://wordpress.org/support/users/bensteelesortit/)
 * Last activity: [6 years, 6 months ago](https://wordpress.org/support/topic/error-when-editing-page/#post-12207944)
 * Status: resolved