| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * FooGallery Admin Gallery MetaBoxes class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | if ( ! class_exists( 'FooGallery_Admin_Gallery_MetaBoxes' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 	class FooGallery_Admin_Gallery_MetaBoxes { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 		private $_gallery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 		public function __construct() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 			//add our foogallery metaboxes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 			add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes_to_gallery' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 			//save extra post data for a gallery | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 			add_action( 'save_post', array( $this, 'save_gallery' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 			//save custom field on a page or post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 			add_Action( 'save_post', array( $this, 'attach_gallery_to_post' ), 10, 2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 			//whitelist metaboxes for our gallery postype | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 			add_filter( 'foogallery_metabox_sanity', array( $this, 'whitelist_metaboxes' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 			//add scripts used by metaboxes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 			add_action( 'admin_enqueue_scripts', array( $this, 'include_required_scripts' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 			// Ajax calls for creating a page for the gallery | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 			add_action( 'wp_ajax_foogallery_create_gallery_page', array( $this, 'ajax_create_gallery_page' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 			// Ajax call for clearing thumb cache for the gallery | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 			add_action( 'wp_ajax_foogallery_clear_gallery_thumb_cache', array( $this, 'ajax_clear_gallery_thumb_cache' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 		public function whitelist_metaboxes() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 			return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 				FOOGALLERY_CPT_GALLERY => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 					'whitelist'  => apply_filters( 'foogallery_metabox_sanity_foogallery', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 						array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 							'submitdiv', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 							'slugdiv', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 							'postimagediv', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 							'foogallery_items', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 							'foogallery_settings', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 							'foogallery_help', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 							'foogallery_pages', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 							'foogallery_customcss', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 							'foogallery_sorting', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 							'foogallery_thumb_cache', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 							'foogallery_retina' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 						) ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 					'contexts'   => array( 'normal', 'advanced', 'side', ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 					'priorities' => array( 'high', 'core', 'default', 'low', ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 				) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		public function add_meta_boxes_to_gallery() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 			global $post; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 			add_meta_box( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 				'foogallery_items', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 				__( 'Gallery Items', 'foogallery' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 				array( $this, 'render_gallery_media_metabox' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 				FOOGALLERY_CPT_GALLERY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 				'normal', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 				'high' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 			add_meta_box( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 				'foogallery_settings', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 				__( 'Gallery Settings', 'foogallery' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 				array( $this, 'render_gallery_settings_metabox' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 				FOOGALLERY_CPT_GALLERY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 				'normal', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 				'high' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 			add_meta_box( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 				'foogallery_help', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 				__( 'Gallery Shortcode', 'foogallery' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 				array( $this, 'render_gallery_shortcode_metabox' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 				FOOGALLERY_CPT_GALLERY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 				'side', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 				'default' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 			if ( 'publish' == $post->post_status ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 				add_meta_box( 'foogallery_pages', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 					__( 'Gallery Usage', 'foogallery' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 					array( $this, 'render_gallery_usage_metabox' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 					FOOGALLERY_CPT_GALLERY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 					'side', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 					'default' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			add_meta_box( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 				'foogallery_customcss', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 				__( 'Custom CSS', 'foogallery' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 				array( $this, 'render_customcss_metabox' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 				FOOGALLERY_CPT_GALLERY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 				'normal', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 				'low' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 			add_meta_box( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 				'foogallery_retina', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 				__( 'Retina Support', 'foogallery' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 				array( $this, 'render_retina_metabox' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 				FOOGALLERY_CPT_GALLERY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 				'side', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 				'default' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 			add_meta_box( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 				'foogallery_sorting', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 				__( 'Gallery Sorting', 'foogallery' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 				array( $this, 'render_sorting_metabox' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 				FOOGALLERY_CPT_GALLERY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 				'side', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 				'default' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 			add_meta_box( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 				'foogallery_thumb_cache', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 				__( 'Thumbnail Cache', 'foogallery' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 				array( $this, 'render_thumb_cache_metabox' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 				FOOGALLERY_CPT_GALLERY, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 				'side', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 				'default' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 		public function get_gallery( $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 			if ( ! isset($this->_gallery) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 				$this->_gallery = FooGallery::get( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 				//attempt to load default gallery settings from another gallery, as per FooGallery settings page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 				$this->_gallery->load_default_settings_if_new(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 			return $this->_gallery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 		} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 146 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  | 		public function save_gallery( $post_id ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  | 			// check autosave | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  | 			if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  | 				return $post_id; | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  | 			// verify nonce | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  | 			if ( array_key_exists( FOOGALLERY_CPT_GALLERY . '_nonce', $_POST ) && | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  | 				wp_verify_nonce( $_POST[FOOGALLERY_CPT_GALLERY . '_nonce'], plugin_basename( FOOGALLERY_FILE ) ) | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  | 			) { | 
            
                                                                        
                            
            
                                    
            
            
                | 157 |  |  | 				//if we get here, we are dealing with the Gallery custom post type | 
            
                                                                        
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  | 				$attachments = apply_filters( 'foogallery_save_gallery_attachments', explode( ',', $_POST[FOOGALLERY_META_ATTACHMENTS] ) ); | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  | 				update_post_meta( $post_id, FOOGALLERY_META_ATTACHMENTS, $attachments ); | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  | 				$settings = isset($_POST[FOOGALLERY_META_SETTINGS]) ? | 
            
                                                                        
                            
            
                                    
            
            
                | 163 |  |  | 					$_POST[FOOGALLERY_META_SETTINGS] : array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 165 |  |  | 				$settings = apply_filters( 'foogallery_save_gallery_settings', $settings ); | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  | 				update_post_meta( $post_id, FOOGALLERY_META_TEMPLATE, $_POST[FOOGALLERY_META_TEMPLATE] ); | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  | 				update_post_meta( $post_id, FOOGALLERY_META_SETTINGS, $settings ); | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  | 				update_post_meta( $post_id, FOOGALLERY_META_SORT, $_POST[FOOGALLERY_META_SORT] ); | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  | 				$custom_css = isset($_POST[FOOGALLERY_META_CUSTOM_CSS]) ? | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  | 					$_POST[FOOGALLERY_META_CUSTOM_CSS] : ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  | 				if ( empty( $custom_css ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  | 					delete_post_meta( $post_id, FOOGALLERY_META_CUSTOM_CSS ); | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  | 				} else { | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  | 					update_post_meta( $post_id, FOOGALLERY_META_CUSTOM_CSS, $custom_css ); | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  | 				update_post_meta( $post_id, FOOGALLERY_META_RETINA, $_POST[FOOGALLERY_META_RETINA] ); | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  | 				do_action( 'foogallery_after_save_gallery', $post_id, $_POST ); | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 		public function attach_gallery_to_post( $post_id, $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 			// check autosave | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 			if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 				return $post_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 			//only do this check for a page or post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 			if ( 'post' == $post->post_type || | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 				'page' == $post->post_type ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |                 do_action( 'foogallery_start_attach_gallery_to_post', $post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 				//Clear any foogallery usages that the post might have | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 				delete_post_meta( $post_id, FOOGALLERY_META_POST_USAGE ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 				//get all foogallery shortcodes that are on the page/post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 				$gallery_shortcodes = foogallery_extract_gallery_shortcodes( $post->post_content ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |                 if ( is_array( $gallery_shortcodes ) && count( $gallery_shortcodes ) > 0 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |                     foreach ( $gallery_shortcodes as $id => $shortcode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |                         //if the content contains the foogallery shortcode then add a custom field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |                         add_post_meta( $post_id, FOOGALLERY_META_POST_USAGE, $id, false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |                         do_action( 'foogallery_attach_gallery_to_post', $post_id, $id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 		public function render_gallery_media_metabox( $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 			$gallery = $this->get_gallery( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 			wp_enqueue_media(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 			<input type="hidden" name="<?php echo FOOGALLERY_CPT_GALLERY; ?>_nonce" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 				   id="<?php echo FOOGALLERY_CPT_GALLERY; ?>_nonce" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 				   value="<?php echo wp_create_nonce( plugin_basename( FOOGALLERY_FILE ) ); ?>"/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 			<input type="hidden" name='foogallery_attachments' id="foogallery_attachments" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 				   value="<?php echo $gallery->attachment_id_csv(); ?>"/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 			<div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 				<ul class="foogallery-attachments-list"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 				if ( $gallery->has_attachments() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 					foreach ( $gallery->attachments() as $attachment ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 						$this->render_gallery_item( $attachment ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 				} ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 					<li class="add-attachment"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 						<a href="#" data-uploader-title="<?php _e( 'Add Media To Gallery', 'foogallery' ); ?>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 						   data-uploader-button-text="<?php _e( 'Add Media', 'foogallery' ); ?>" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 						   data-post-id="<?php echo $post->ID; ?>" class="upload_image_button" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 						   title="<?php _e( 'Add Media To Gallery', 'foogallery' ); ?>"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  | 							<div class="dashicons dashicons-format-gallery"></div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 							<span><?php _e( 'Add Media', 'foogallery' ); ?></span> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 						</a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 					</li> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 				</ul> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 				<div style="clear: both;"></div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 			</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 			<textarea style="display: none" id="foogallery-attachment-template"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 				<?php $this->render_gallery_item(); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 			</textarea> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 		public function render_gallery_item( $attachment_post = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 			if ( $attachment_post != false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 				$attachment_id = $attachment_post->ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 				$attachment = wp_get_attachment_image_src( $attachment_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 				$attachment_id = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 				$attachment = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 			$data_attribute = empty($attachment_id) ? '' : "data-attachment-id=\"{$attachment_id}\""; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 			$img_tag        = empty($attachment) ? '<img width="150" height="150" />' : "<img width=\"150\" height=\"150\" src=\"{$attachment[0]}\" />"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 			<li class="attachment details" <?php echo $data_attribute; ?>> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 				<div class="attachment-preview type-image"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 					<div class="thumbnail"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 						<div class="centered"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 							<?php echo $img_tag; ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 						</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 					</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 					<a class="info" href="#" title="<?php _e( 'Edit Info', 'foogallery' ); ?>"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 						<span class="dashicons dashicons-info"></span> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 					</a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 					<a class="remove" href="#" title="<?php _e( 'Remove from gallery', 'foogallery' ); ?>"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 						<span class="dashicons dashicons-dismiss"></span> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 					</a> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 				</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 				<!--				<input type="text" value="" class="describe" data-setting="caption" placeholder="Caption this image…" />--> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 			</li> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 		public function render_gallery_settings_metabox( $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 			//gallery settings including: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 			//gallery images link to image or attachment page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 			//default template to use | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 			$gallery             = $this->get_gallery( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 			$available_templates = foogallery_gallery_templates(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 			//check if we have no templates | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 			if ( 0 === count( $available_templates ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 				//force the default template to activate if there are no other gallery templates | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 				foogallery_activate_default_templates_extension(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 				$available_templates = foogallery_gallery_templates(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 			$gallery_template = foogallery_default_gallery_template(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 			if ( ! empty($gallery->gallery_template) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 				$gallery_template = $gallery->gallery_template; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 			$hide_help = 'on' == foogallery_get_setting( 'hide_gallery_template_help' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 			<table class="foogallery-metabox-settings"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 				<tbody> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 				<tr class="gallery_template_field gallery_template_field_selector"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 					<th> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 						<label for="FooGallerySettings_GalleryTemplate"><?php _e( 'Gallery Template', 'foogallery' ); ?></label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 					</th> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 					<td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 						<select id="FooGallerySettings_GalleryTemplate" name="<?php echo FOOGALLERY_META_TEMPLATE; ?>"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 							<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 							foreach ( $available_templates as $template ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 								$selected = ($gallery_template === $template['slug']) ? 'selected' : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 								$preview_css = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 								if ( isset( $template['preview_css'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 									if ( is_array( $template['preview_css'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 										//dealing with an array of css files to include | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 										$preview_css = implode( ',', $template['preview_css'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 									} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 										$preview_css = $template['preview_css']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 									} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 								$preview_css = empty( $preview_css ) ? '' : ' data-preview-css="' . $preview_css . '" '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 								echo "<option {$selected}{$preview_css} value=\"{$template['slug']}\">{$template['name']}</option>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 							?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 						</select> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 						<br /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 						<small><?php _e( 'The gallery template that will be used when the gallery is output to the frontend.', 'foogallery' ); ?></small> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 					</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 				</tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 				<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 				foreach ( $available_templates as $template ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 					$field_visibility = ($gallery_template !== $template['slug']) ? 'style="display:none"' : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 					//allow for extensions to override fields for every gallery template. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 					// Also passes the $template along so you can inspect and conditionally alter fields based on the template properties | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 					$fields = apply_filters( 'foogallery_override_gallery_template_fields', $template['fields'], $template ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 					$section = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 					foreach ( $fields as $field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 						//allow for the field to be altered by extensions. Also used by the build-in fields, e.g. lightbox | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 						$field = apply_filters( 'foogallery_alter_gallery_template_field', $field, $gallery ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 						$class = "gallery_template_field gallery_template_field-{$template['slug']} gallery_template_field-{$template['slug']}-{$field['id']}"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 						if ( isset($field['section']) && $field['section'] !== $section ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 							$section = $field['section']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 							?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 							<tr class="<?php echo $class; ?>" <?php echo $field_visibility; ?>> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 								<td colspan="2"><h4><?php echo $section; ?></h4></td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 							</tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 						<?php } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 						if (isset($field['type']) && 'help' == $field['type'] && $hide_help) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 							continue; //skip help if the 'hide help' setting is turned on | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 						?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 						<tr class="<?php echo $class; ?>" <?php echo $field_visibility; ?>> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 							<?php if ( isset($field['type']) && 'help' == $field['type'] ) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 							<td colspan="2"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 								<div class="foogallery-help"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 									<?php echo $field['desc']; ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 								</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 							</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 							<?php } else { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 							<th> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 								<label | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 									for="FooGallerySettings_<?php echo $template['slug'] . '_' . $field['id']; ?>"><?php echo $field['title']; ?></label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 							</th> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 							<td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 								<?php do_action( 'foogallery_render_gallery_template_field', $field, $gallery, $template ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 							</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 							<?php } ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 						</tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 					<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 				</tbody> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 			</table> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 		public function render_gallery_shortcode_metabox( $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 			$gallery = $this->get_gallery( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 			$shortcode = $gallery->shortcode(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 			<p class="foogallery-shortcode"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 				<input type="text" id="foogallery-copy-shortcode" size="<?php echo strlen( $shortcode ); ?>" value="<?php echo htmlspecialchars( $shortcode ); ?>" readonly="readonly" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 			</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 			<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 				<?php _e( 'Paste the above shortcode into a post or page to show the gallery.', 'foogallery' ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 			</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 			<script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 				jQuery(function($) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 					var shortcodeInput = document.querySelector('#foogallery-copy-shortcode'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 					shortcodeInput.addEventListener('click', function () { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 						try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 							// select the contents | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 							shortcodeInput.select(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 							//copy the selection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 							document.execCommand('copy'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 							//show the copied message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 							$('.foogallery-shortcode-message').remove(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 							$(shortcodeInput).after('<p class="foogallery-shortcode-message"><?php _e( 'Shortcode copied to clipboard :)','foogallery' ); ?></p>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 						} catch(err) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 							console.log('Oops, unable to copy!'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 					}, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 				}); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 			</script> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 		public function render_gallery_usage_metabox( $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 			$gallery = $this->get_gallery( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 			$posts = $gallery->find_usages(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 			if ( $posts && count( $posts ) > 0 ) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 				<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 					<?php _e( 'This gallery is used on the following posts or pages:', 'foogallery' ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 				</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 				<ul class="ul-disc"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 				<?php foreach ( $posts as $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 					$url = get_permalink( $post->ID ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 					echo '<li>' . $post->post_title . ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 					edit_post_link( __( 'Edit', 'foogallery' ), '<span class="edit">', ' | </span>', $post->ID ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 					echo '<span class="view"><a href="' . esc_url( $url ) . '" target="_blank">' . __( 'View', 'foogallery' ) . '</a></li>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 				} ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 				</ul> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 			<?php } else { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 				<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 					<?php _e( 'This gallery is not used on any pages or pages yet. Quickly create a page:', 'foogallery' ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 				</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 				<div class="foogallery_metabox_actions"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 					<button class="button button-primary button-large" id="foogallery_create_page"><?php _e( 'Create Gallery Page', 'foogallery' ); ?></button> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 					<span id="foogallery_create_page_spinner" class="spinner"></span> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 					<?php wp_nonce_field( 'foogallery_create_gallery_page', 'foogallery_create_gallery_page_nonce', false ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 				</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 				<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 					<?php _e( 'A draft page will be created which includes the gallery shortcode in the content. The title of the page will be the same title as the gallery.', 'foogallery' ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  | 				</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 			<?php } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 		public function render_sorting_metabox( $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 			$gallery = $this->get_gallery( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 			$sorting_options = foogallery_sorting_options(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 			if ( empty( $gallery->sorting ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 				$gallery->sorting = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 			<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 				<?php _e('Change the way images are sorted within your gallery. By default, they are sorted in the order you see them.', 'foogallery'); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 			</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 			foreach ( $sorting_options as $sorting_key => $sorting_label ) { ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 				<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 				<input type="radio" value="<?php echo $sorting_key; ?>" <?php checked( $sorting_key === $gallery->sorting ); ?> id="FooGallerySettings_GallerySort_<?php echo $sorting_key; ?>" name="<?php echo FOOGALLERY_META_SORT; ?>" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 				<label for="FooGallerySettings_GallerySort_<?php echo $sorting_key; ?>"><?php echo $sorting_label; ?></label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 				</p><?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 		public function render_retina_metabox( $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 			$gallery = $this->get_gallery( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 			$retina_options = foogallery_retina_options(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 			if ( empty( $gallery->retina ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 				$gallery->retina = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 			<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 				<?php _e('Add retina support to this gallery by choosing the different pixel densities you want to enable.', 'foogallery'); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 			</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  | 			foreach ( $retina_options as $retina_key => $retina_label ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 				$checked = array_key_exists( $retina_key, $gallery->retina ) ? ('true' === $gallery->retina[$retina_key]) : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 				?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 				<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 				<input type="checkbox" value="true" <?php checked( $checked ); ?> id="FooGallerySettings_GallerySort_<?php echo $retina_key; ?>" name="<?php echo FOOGALLERY_META_RETINA; ?>[<?php echo $retina_key; ?>]" /> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 				<label for="FooGallerySettings_GalleryRetina_<?php echo $retina_key; ?>"><?php echo $retina_label; ?></label> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 				</p><?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 			} ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 			<p class="foogallery-help"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 				<?php _e('PLEASE NOTE : thumbnails will be generated for each of the pixel densities chosen, which will increase your website\'s storage space!', 'foogallery'); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 			</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 		public function render_thumb_cache_metabox( $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 			<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 				<?php _e( 'Clear all the previously cached thumbnails that have been generated for this gallery.', 'foogallery' ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 			</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 			<div class="foogallery_metabox_actions"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 				<button class="button button-primary button-large" id="foogallery_clear_thumb_cache"><?php _e( 'Clear Thumbnail Cache', 'foogallery' ); ?></button> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 				<span id="foogallery_clear_thumb_cache_spinner" class="spinner"></span> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 				<?php wp_nonce_field( 'foogallery_clear_gallery_thumb_cache', 'foogallery_clear_gallery_thumb_cache_nonce', false ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 			</div> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 			<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 		public function include_required_scripts() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  | 			$screen_id = foo_current_screen_id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 			//only include scripts if we on the foogallery add/edit page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 			if ( FOOGALLERY_CPT_GALLERY === $screen_id || | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 			     'edit-' . FOOGALLERY_CPT_GALLERY === $screen_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 				//spectrum needed for the colorpicker field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 				$url = FOOGALLERY_URL . 'lib/spectrum/spectrum.js'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  | 				wp_enqueue_script( 'foogallery-spectrum', $url, array('jquery'), FOOGALLERY_VERSION ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 				$url = FOOGALLERY_URL . 'lib/spectrum/spectrum.css'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 				wp_enqueue_style( 'foogallery-spectrum', $url, array(), FOOGALLERY_VERSION ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 				//include any admin js required for the templates | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 				foreach ( foogallery_gallery_templates() as $template ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 					$admin_js = foo_safe_get( $template, 'admin_js' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 					if ( is_array( $admin_js ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 						//dealing with an array of js files to include | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 						foreach( $admin_js as $admin_js_key => $admin_js_src ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 							wp_enqueue_script( 'foogallery-gallery-admin-' . $template['slug'] . '-' . $admin_js_key, $admin_js_src, array('jquery', 'media-upload', 'jquery-ui-sortable'), FOOGALLERY_VERSION ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 						//dealing with a single js file to include | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 						wp_enqueue_script( 'foogallery-gallery-admin-' . $template['slug'], $admin_js, array('jquery', 'media-upload', 'jquery-ui-sortable'), FOOGALLERY_VERSION ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 		public function render_customcss_metabox( $post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 			$gallery = $this->get_gallery( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 			$custom_css = $gallery->custom_css; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 			$example = '<code>#foogallery-gallery-' . $post->ID . ' { }</code>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 			?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 			<p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 				<?php printf( __( 'Add any custom CSS to target this specific gallery. For example %s', 'foogallery' ), $example ); ?> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 			</p> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 			<table id="table_styling" class="form-table"> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 				<tbody> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 				<tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 					<td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 						<textarea class="foogallery_metabox_custom_css" name="<?php echo FOOGALLERY_META_CUSTOM_CSS; ?>" type="text"><?php echo $custom_css; ?></textarea> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 					</td> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 				</tr> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 				</tbody> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 			</table> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 		<?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 		public function ajax_create_gallery_page() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 			if ( check_admin_referer( 'foogallery_create_gallery_page', 'foogallery_create_gallery_page_nonce' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 				$foogallery_id = $_POST['foogallery_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 				$foogallery = FooGallery::get_by_id( $foogallery_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 				$post = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 					'post_content' => $foogallery->shortcode(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 					'post_title'   => $foogallery->name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 					'post_status'  => 'draft', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 					'post_type'    => 'page', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 				wp_insert_post( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 			die(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 		public function ajax_clear_gallery_thumb_cache() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 			if ( check_admin_referer( 'foogallery_clear_gallery_thumb_cache', 'foogallery_clear_gallery_thumb_cache_nonce' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 				$foogallery_id = $_POST['foogallery_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 				$foogallery = FooGallery::get_by_id( $foogallery_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 				ob_start(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 				//loop through all images, get the full sized file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 				foreach ( $foogallery->attachments() as $attachment ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 					$meta_data = wp_get_attachment_metadata( $attachment->ID ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 					$file = $meta_data['file']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 					wpthumb_delete_cache_for_file( $file ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 				ob_end_clean(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 				echo __( 'The thumbnail cache has been cleared!', 'foogallery' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 			die(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 603 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 604 |  |  |  |