| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * All Legacy FooVideo Code lives in this class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |   */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | if ( ! class_exists( 'FooGallery_Pro_Video_Legacy' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | 	define( 'FOOGALLERY_FOOVIDEO_MIGRATION_REQUIRED', 'foogallery-foovideo-migration-required' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 	define( 'FOOGALLERY_FOOVIDEO_MIGRATED', 'foogallery-foovideo-migrated' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 	class FooGallery_Pro_Video_Legacy { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 		function __construct() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 			add_filter( 'foogallery_is_attachment_video', array( $this, 'foogallery_is_attachment_video_legacy' ), 10, 2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 			add_filter( 'foogallery_clean_video_url', array( $this, 'foogallery_clean_video_url_legacy_filter' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 			add_filter( 'foogallery_youtubekey', array( $this, 'foogallery_youtubekey_legacy_filter' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 			if ( is_admin() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 				//check if the old FooVideo was/is installed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 				if ( $this->migration_required() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 					add_action( 'admin_notices', array( $this, 'display_foovideo_notice') ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 					add_action( 'admin_menu',  array( $this, 'add_migration_menu' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 					add_filter( 'foogallery_render_gallery_settings_metabox', array( $this, 'migrate_settings' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 					add_action( 'foogallery_after_save_gallery', array( $this, 'migrate_gallery' ), 99, 2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 				//check if the old FooVideo is still activated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 				if ( class_exists( 'Foo_Video' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 					//rename the Video Slider template | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 					add_filter( 'foogallery_gallery_templates', array( $this, 'rename_videoslider_template' ), 99 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 					//remove legacy fields added by FooVideo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 					add_filter( 'foogallery_override_gallery_template_fields', array( $this, 'remove_legacy_template_fields' ), 99 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 					//short-circuit saving the post meta for video count on the gallery | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 					add_filter( 'update_post_metadata', array( $this, 'short_circuit_legacy_video_count' ), 10, 5 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 				add_filter( 'foogallery_foovideo_discount_offer_notice_title', array( $this, 'override_discount_offer_notice_title' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 				add_filter( 'foogallery_foovideo_discount_offer_notice_message', array( $this, 'override_discount_offer_notice_message' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 				add_filter( 'foogallery_foovideo_discount_offer_menu', array( $this, 'override_discount_offer_menu' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 				add_filter( 'foogallery_foovideo_discount_offer_show_upgrade', '__return_false' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 				add_filter( 'foogallery_foovideo_discount_offer_message', array( $this, 'override_discount_offer_message' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 			if ( !is_admin() && class_exists( 'Foo_Video' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 				add_filter( 'foogallery_build_class_attribute', array( $this, 'foogallery_build_class_attribute' ), 20 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 			// Ajax calls for migrating | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 			add_action( 'wp_ajax_foogallery_video_migration', array( $this, 'ajax_foogallery_video_migration' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 			add_action( 'wp_ajax_foogallery_video_migration_reset', array( $this, 'ajax_foogallery_video_migration_reset' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		 * Determines if a migration is needed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 		function migration_required() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 			//first try to get the saved option | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | - 			$migration_required = get_option( FOOGALLERY_FOOVIDEO_MIGRATION_REQUIRED, 0 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 			//we require migration - get out early | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 			if ( "1" === $migration_required ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 			if ( class_exists('Foo_Video') ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 				//the legacy plugin is installed, so set the option for future use | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 				$migration_required = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 				update_option( FOOGALLERY_FOOVIDEO_MIGRATION_REQUIRED, $migration_required ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			//we have no option saved and no legacy plugin, so no migration required | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 			if ( 0 === $migration_required ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 				$migration_required = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 			return $migration_required; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		 * Migrate the gallery settings | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		 * @param $foogallery | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 		 * @return FooGallery | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 		function migrate_settings( $foogallery ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 			$helper = new FooGallery_Pro_Video_Migration_Helper(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 			$foogallery = $helper->migrate_gallery( $foogallery, false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 			return $foogallery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 		 * Short-circuit the post meta updates for the legacy FooVideo while both plugins are activated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 		 * @param $check | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 		 * @param $object_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 		 * @param $meta_key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 		 * @param $meta_value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 		 * @param $prev_value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 		function short_circuit_legacy_video_count( $check, $object_id, $meta_key, $meta_value, $prev_value ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 			if ( '_foovideo_video_count' === $meta_key ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 				$check = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 			return $check; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 		 * Migrate video for the gallery that is saved | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 		 * @param $post_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 		 * @param $post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		function migrate_gallery($post_id, $post) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 			if ( $this->migration_required() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 				$helper = new FooGallery_Pro_Video_Migration_Helper(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 				if ( $helper->check_gallery_needs_migration( $post_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 					//migrate all the video attachments | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 					$gallery = FooGallery::get_by_id( $post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 					foreach ( $gallery->attachments() as $attachment ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 						$helper->migrate_attachment( $attachment->ID ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 					$helper->migrate_video_counts( $post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 		 * Remove the legacy template fields added by FooVideo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 		 * @param $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 		 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 		function remove_legacy_template_fields( $fields ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 			$new_fields = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 			foreach ( $fields as $field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 				if ( $field['id'] !== 'foovideo_video_overlay' && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 					$field['id'] !== 'foovideo_sticky_icon' && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 					$field['id'] !== 'foovideo_video_size' && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 					$field['id'] !== 'foovideo_autoplay' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 					$new_fields[] = $field; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 			return $new_fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 		 * Rename the Video Slider template to include the text 'Deprecated' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 		 * @param $templates | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		 * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 		function rename_videoslider_template( $templates ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 			foreach( $templates as &$template ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 				if ( 'videoslider' === $template['slug'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 					$template['name'] = __( 'Video Slider (Deprecated!)', 'foogallery' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 			return $templates; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 		 * Legacy way of knowing if an attachment is a video | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 		 * @param $is_video | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		 * @param $foogallery_attachment | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 		 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 		function foogallery_is_attachment_video_legacy( $is_video, $foogallery_attachment ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 			$video_info = get_post_meta( $foogallery_attachment->ID, FOOGALLERY_VIDEO_POST_META, true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 			return isset( $video_info ) && isset( $video_info['id'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 		 * Applies the legacy filter for backwards compatibility | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 		 * @param $url | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 		 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 		function foogallery_clean_video_url_legacy_filter( $url ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 			return apply_filters( 'foogallery_foovideo_clean_video_url', $url ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 		public function foogallery_build_class_attribute( $classes ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 			//remove any legacy classes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 			if ( ( $key = array_search( 'video-icon-1', $classes ) ) !== false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 				unset( $classes[$key] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 			if ( ( $key = array_search( 'video-icon-2', $classes ) ) !== false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 				unset( $classes[$key] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 			if ( ( $key = array_search( 'video-icon-3', $classes ) ) !== false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 				unset( $classes[$key] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 			if ( ( $key = array_search( 'video-icon-default', $classes ) ) !== false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 				unset( $classes[$key] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 			return $classes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 		 * Display a message if the FooVideo extension is also installed | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 226 |  |  | 		 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 227 |  |  | 		function display_foovideo_notice() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 228 |  |  | 			if ( 'foogallery' !== foo_current_screen_post_type() ) return; | 
            
                                                                        
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 230 |  |  | 			$url = admin_url( add_query_arg( array( 'page' => 'foogallery-video-migration' ), foogallery_admin_menu_parent_slug() ) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 231 |  |  | 			?> | 
            
                                                                        
                            
            
                                    
            
            
                | 232 |  |  | 			<div class="notice error"> | 
            
                                                                        
                            
            
                                    
            
            
                | 233 |  |  | 				<p> | 
            
                                                                        
                            
            
                                    
            
            
                | 234 |  |  | 					<strong><?php _e('FooGallery Video Migration Required!', 'foogallery'); ?></strong><br/> | 
            
                                                                        
                            
            
                                    
            
            
                | 235 |  |  | 					<?php if ( class_exists( 'Foo_Video' ) ) { ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 236 |  |  | 						<?php _e('You have both FooGallery PRO and the legacy FooVideo extension activated. FooGallery PRO now includes all the video features that FooVideo had, plus more! Which means the FooVideo extension is now redundant.', 'foogallery'); ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 237 |  |  | 						<br/> | 
            
                                                                        
                            
            
                                    
            
            
                | 238 |  |  | 						<?php _e('Your video galleries will continue to work, but we recommend you migrate them across to use the video features in FooGallery PRO as soon as possible.', 'foogallery'); ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 239 |  |  | 					<?php } else { ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 240 |  |  | 						<?php _e('At some point you had the FooVideo extension installed. FooGallery PRO now includes all the video features that FooVideo had, plus more! Which means the FooVideo extension is now redundant.', 'foogallery'); ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 241 |  |  | 						<br/> | 
            
                                                                        
                            
            
                                    
            
            
                | 242 |  |  | 						<?php _e('You will need to migrate your video galleries across to use the new video features in FooGallery PRO as soon as possible.', 'foogallery'); ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 243 |  |  | 					<?php } ?> | 
            
                                                                        
                            
            
                                    
            
            
                | 244 |  |  | 					<br/> | 
            
                                                                        
                            
            
                                    
            
            
                | 245 |  |  | 					<br/> | 
            
                                                                        
                            
            
                                    
            
            
                | 246 |  |  | 					<a href="<?php echo $url; ?>" class="button button-primary button-large"><?php _e('Migrate Video Galleries', 'foogallery'); ?></a> | 
            
                                                                        
                            
            
                                    
            
            
                | 247 |  |  | 					<br/> | 
            
                                                                        
                            
            
                                    
            
            
                | 248 |  |  | 				</p> | 
            
                                                                        
                            
            
                                    
            
            
                | 249 |  |  | 			</div> | 
            
                                                                        
                            
            
                                    
            
            
                | 250 |  |  | 			<?php | 
            
                                                                        
                            
            
                                    
            
            
                | 251 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 		 * Outputs the video migration view | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 		function render_video_migration_view() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 			require_once 'view-video-migration.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 		 * Add a new menu item for running the migration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 		function add_migration_menu() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 			foogallery_add_submenu_page( __( 'Video Migration', 'foogallery' ), 'manage_options', 'foogallery-video-migration', array( $this, 'render_video_migration_view', ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 		 * Handle the Video Migration Step from an AJAX call | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 		function ajax_foogallery_video_migration() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 			if ( check_admin_referer( 'foogallery_video_migration' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 				$helper = new FooGallery_Pro_Video_Migration_Helper(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 				$state = $helper->run_next_migration_step(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 				header( 'Content-type: application/json' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 				echo json_encode( $state ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 			die(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 		 * Handle the Video Migration Reset from an AJAX call | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 		function ajax_foogallery_video_migration_reset() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 			if ( check_admin_referer( 'foogallery_video_migration' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 				$helper = new FooGallery_Pro_Video_Migration_Helper(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 				$state = $helper->reset_state(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 				header( 'Content-type: application/json' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 				echo json_encode( $state ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 			die(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 		 * Override the Discount Offer admin notice title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 		 * @param $title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 		 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 		function override_discount_offer_notice_title( $title ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 			$title = __( 'FooGallery Renewal Offer Available!', 'foogallery' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 			return $title; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 		 * Override the Discount Offer admin notice message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 		 * @param $message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 		 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 		function override_discount_offer_notice_message( $message ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 			$message = __( 'We noticed that you own licenses for FooVideo and FooGallery PRO. FooGallery PRO now has all the awesome features of FooVideo, plus more! And because you already own both, you are eligible for a free renewal on your existing FooGallery PRO license.', 'foogallery' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 			return $message; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 		 * Override the Discount Offer menu | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 		 * @param $menu | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 		 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 		function override_discount_offer_menu( $menu ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 			$menu = __( 'Renewal Offer', 'foogallery' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 			return $menu; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 		 * Override the Discount Offer page message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 		 * @param $message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 		 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 		function override_discount_offer_message( $message ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 			$message = __( 'Thank you for your support - you are awesome! FooGallery PRO now has all the awesome features of FooVideo, plus more! And because you already own both, you are eligible for a free renewal on your existing FooGallery PRO license.', 'foogallery' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 			return $message; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 338 |  |  | 	} | 
            
                                                        
            
                                    
            
            
                | 339 |  |  | } | 
            
                        
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.