| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** If this file is called directly, abort. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | if ( ! defined( 'ABSPATH' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | 	die; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | class GravityView_View_Data { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 	static $instance = NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 	protected $views = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	 * @param null $passed_post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 | 2 |  | 	private function __construct( $passed_post = NULL ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 | 2 |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 			/** Reset the new frontend request views, since we now have duplicate state. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 | 2 |  | 			gravityview()->request = new \GV\Dummy_Request(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 2 |  | 		if( !empty( $passed_post ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 2 |  | 			$id_or_id_array = $this->maybe_get_view_id( $passed_post ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 2 |  | 			if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 2 |  | 				foreach( is_array( $id_or_id_array ) ? $id_or_id_array : array( $id_or_id_array ) as $view_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 2 |  | 					if ( \GV\View::exists( $view_id ) && ! gravityview()->views->contains( $view_id ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 2 |  | 						gravityview()->views->add( \GV\View::by_id( $view_id ) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 			} else if ( ! empty( $id_or_id_array ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 				$this->add_view( $id_or_id_array ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 2 |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	 * @see \GV\View_Collection::count via `gravityview()->request->views->count()` or `gravityview()->views->count()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	 * @return boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 1 |  | 	public function has_multiple_views() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 1 |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 1 |  | 			return gravityview()->views->count() > 1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		//multiple views | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		return count( $this->get_views() ) > 1 ? true : false; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	 * Figure out what the View ID is for a variable, if any. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	 * Can be: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	 *      - WP_Post (Either a `gravityview` post type or not) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	 *      - Multi-dimensional array of WP_Post objects | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	 *      - Array with `view_id` or `id` key(s) set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	 *      - String of content that may include GravityView shortcode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 *      - Number representing the Post ID or View ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	 * @param mixed $passed_post See method description | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	 * @see \GV\View_Collection::from_post and \GV\Shortcode::parse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	 * @return int|null|array ID of the View. If there are multiple views in the content, array of IDs parsed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 3 |  | 	public function maybe_get_view_id( $passed_post ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 3 |  | 		$ids = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 3 |  | 		if( ! empty( $passed_post ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 3 |  | 			if( is_numeric( $passed_post ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 | 1 |  | 				$passed_post = get_post( $passed_post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 			// Convert WP_Posts into WP_Posts[] array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 3 |  | 			if( $passed_post instanceof WP_Post ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 | 3 |  | 				$passed_post = array( $passed_post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 3 |  | 			if( is_array( $passed_post ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 3 |  | 				foreach ( $passed_post as &$post) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 | 3 |  | 					if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post instanceof WP_Post ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 | 3 |  | 						$views = \GV\View_Collection::from_post( $post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 | 3 |  | 						foreach ( $views->all() as $view ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 3 |  | 							$ids []= $view->ID; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 							/** And as a side-effect... add each view to the global scope. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 | 3 |  | 							if ( ! gravityview()->views->contains( $view->ID ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 3 |  | 								gravityview()->views->add( $view ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 						/** Deprecated, see \GV\View_Collection::from_post */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 						if( ( get_post_type( $post ) === 'gravityview' ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 							$ids[] = $post->ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 						} else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 							// Parse the Post Content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 							$id = $this->parse_post_content( $post->post_content ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 							if( $id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 								$ids = array_merge( $ids, (array) $id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 							// Parse the Post Meta | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 							$id = $this->parse_post_meta( $post->ID ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 							if( $id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 | 3 |  | 								$ids = array_merge( $ids, (array) $id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 1 |  | 				if ( is_string( $passed_post ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 1 |  | 					if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 1 |  | 						$shortcodes = \GV\Shortcode::parse( $passed_post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 1 |  | 						foreach ( $shortcodes as $shortcode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 1 |  | 							if ( $shortcode->name == 'gravityview' && !empty( $shortcode->atts['id'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 | 1 |  | 								$ids []= $shortcode->atts['id']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 								/** And as a side-effect... add each view to the global scope. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 | 1 |  | 								if ( ! gravityview()->views->contains( $shortcode->atts['id'] ) && \GV\View::exists( $shortcode->atts['id'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 | 1 |  | 									gravityview()->views->add( $shortcode->atts['id'] ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 								} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 					} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 						/** Deprecated, use \GV\Shortcode::parse. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 						$id = $this->parse_post_content( $passed_post ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 						if( $id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 | 1 |  | 							$ids = array_merge( $ids, (array) $id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 					$id = $this->get_id_from_atts( $passed_post ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 					$ids[] = intval( $id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 | 3 |  | 		if( empty($ids) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 			return NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 		// If it's just one ID, return that. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 		// Otherwise, return array of IDs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 | 3 |  | 		return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 	 * @return GravityView_View_Data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 | 2 |  | 	public static function getInstance( $passed_post = NULL ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 | 2 |  | 		if( empty( self::$instance ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 | 2 |  | 			self::$instance = new GravityView_View_Data( $passed_post ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 | 2 |  | 		return self::$instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 	 * @see \GV\View_Collection::all() via `gravityview()->views` or `gravityview()->request->views`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 | 1 |  | 	function get_views() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 1 |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 | 1 |  | 			if ( ! gravityview()->views->count() ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 				return array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 1 |  | 			return array_combine( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 				array_map( function ( $view ) { return $view->ID; }, gravityview()->views->all() ), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 				array_map( function ( $view ) { return $view->as_data(); }, gravityview()->views->all() ) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 		return $this->views; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 	 * @see \GV\View_Collection::get() via `gravityview()->views` or `gravityview()->request->views`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 | 1 |  | 	function get_view( $view_id, $atts = NULL ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 | 1 |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 1 |  | 			if ( ! $view = gravityview()->views->get( $view_id ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 1 |  | 				if ( ! \GV\View::exists( $view_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 | 1 |  | 					return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 				/** Emulate this weird side-effect below... */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 | 1 |  | 				$view = \GV\View::by_id( $view_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 | 1 |  | 				if ( $atts ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 					$view->settings->update( $atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 | 1 |  | 				gravityview()->views->add( $view ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 | 1 |  | 			return $view->as_data(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 		if( ! is_numeric( $view_id) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 			do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 		// Backup: the view hasn't been fetched yet. Doing it now. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 		if ( ! isset( $this->views[ $view_id ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 			return $this->add_view( $view_id, $atts ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 		if ( empty( $this->views[ $view_id ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 		return $this->views[ $view_id ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 	 * Determines if a post, identified by the specified ID, exist | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 	 * within the WordPress database. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 	 * @see http://tommcfarlin.com/wordpress-post-exists-by-id/ Fastest check available | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 	 * @param    int    $view_id    The ID of the post to check | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 	 * @see \GV\View::exists() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 	 * @return   bool   True if the post exists; otherwise, false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 	 * @since    1.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 | 1 |  | 	function view_exists( $view_id ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 | 1 |  | 		return ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && \GV\View::exists( $view_id ) ) || is_string( get_post_status( $view_id ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 	 * Add a view to the views array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 	 * @param int|array $view_id View ID or array of View IDs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 	 * @param array|string $atts Combine other attributes (eg. from shortcode) with the view settings (optional) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 	 * @see \GV\View_Collection::append with the request \GV\View_Collection available via `gravityview()->request->views` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 	 *  or the `gravityview()->views` shortcut. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 	 * @return array|false All views if $view_id is array, a view data array if $view_id is an int, false on errors. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 | 1 |  | 	function add_view( $view_id, $atts = NULL ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 		/** Deprecated. Do not edit. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 | 1 |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 | 1 |  | 			return \GV\Mocks\GravityView_View_Data_add_view( $view_id, $atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 		// Handle array of IDs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 		if( is_array( $view_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 			foreach( $view_id as $id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 				$this->add_view( $id, $atts ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 			return $this->get_views(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 		// The view has been set already; returning stored view. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 		if ( !empty( $this->views[ $view_id ] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 			return $this->views[ $view_id ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 		if( ! $this->view_exists( $view_id ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 		$form_id = gravityview_get_form_id( $view_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 		if( empty( $form_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 		// Get the settings for the View ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 		$view_settings = gravityview_get_template_settings( $view_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 		// Merge the view settings with the defaults | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 		$view_defaults = wp_parse_args( $view_settings, defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? \GV\View_Settings::defaults() : self::get_default_args() ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 		do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 		if( ! empty( $atts ) && is_array( $atts ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging  with the $view_defaults', $atts ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 			// Get the settings from the shortcode and merge them with defaults. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 			$atts = shortcode_atts( $view_defaults, $atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 			do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging  with the $view_defaults', $atts ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 			// If there are no passed $atts, the defaults will be used. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 			$atts = $view_defaults; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 		unset( $atts['id'], $view_defaults, $view_settings ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 		$data = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 			'id' => $view_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 			'view_id' => $view_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 			'form_id' => $form_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 			'template_id' => gravityview_get_template_id( $view_id ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 			'atts' => $atts, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 			'fields' => $this->get_fields( $view_id ), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 			'widgets' => gravityview_get_directory_widgets( $view_id ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 			'form' => gravityview_get_form( $form_id ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 		do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 		$this->views[ $view_id ] = $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 		return $this->views[ $view_id ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 	 * Get the visible fields for a View | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 	 * @uses  gravityview_get_directory_fields() Fetch the configured fields for a View | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 	 * @uses  GravityView_View_Data::filter_fields() Only show visible fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 	 * @param  int $view_id View ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 	 * @see \GV\View::$fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 	 * @return array|null Array of fields as passed by `gravityview_get_directory_fields()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 | 1 |  | 	function get_fields( $view_id ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 | 1 |  | 		$dir_fields = gravityview_get_directory_fields( $view_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 | 1 |  | 		do_action( 'gravityview_log_debug', '[render_view] Fields: ', $dir_fields ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 | 1 |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 | 1 |  | 			if ( \GV\View::exists( $view_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 | 1 |  | 				$view = \GV\View::by_id( $view_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 | 1 |  | 				return $view->fields->by_visible()->as_configuration(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 		// remove fields according to visitor visibility permissions (if logged-in) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 		$dir_fields = $this->filter_fields( $dir_fields ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 		do_action( 'gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 		return $dir_fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 	 * Filter area fields based on specified conditions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 	 * @param array $dir_fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 	private function filter_fields( $dir_fields ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 			throw new Exception( __METHOD__ . ' should not be called anymore. Why was it?' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 		if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 			return $dir_fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 		foreach( $dir_fields as $area => $fields ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 			foreach( (array)$fields as $uniqid => $properties ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 				if( $this->hide_field_check_conditions( $properties ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 					unset( $dir_fields[ $area ][ $uniqid ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 		return $dir_fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 	 * Check whether a certain field should not be presented based on its own properties. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 	 * @param array $properties | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 	 * @return boolean True: (field should be hidden) or False: (field should be presented) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 	private function hide_field_check_conditions( $properties ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 			throw new Exception( __METHOD__ . ' should not be called anymore. Why was it?' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 		// logged-in visibility | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 		if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 			return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 	 * Retrieves view ID from an array. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 	 * @param array $atts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 	 * @deprecated Dead code, was probably superceded by GravityView_View_Data::parse_post_content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 	 * @return int|null A view ID cast to int, or null. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 | 1 |  | 	function get_id_from_atts( $atts ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 | 1 |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 | 1 |  | 			$settings = new \GV\View_Settings(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 | 1 |  | 			$settings->update( \GV\View_Settings::defaults() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 | 1 |  | 			$settings->update( shortcode_parse_atts( $atts ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 | 1 |  | 			$view_id = $settings->get( 'view_id' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 | 1 |  | 			$view_id = empty( $view_id ) ? $settings->get( 'id' ) : $view_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 | 1 |  | 			return empty( $view_id ) ? null : $view_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 		 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 		$atts = is_array( $atts ) ? $atts : shortcode_parse_atts( $atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 		// Get the settings from the shortcode and merge them with defaults. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 		$atts = wp_parse_args( $atts, defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? \GV\View_Settings::defaults() : self::get_default_args() ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  | 		$view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 		if( empty( $view_id ) && !empty( $atts['id'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 			$view_id = (int)$atts['id']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 		if( empty( $view_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 			do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 		return $view_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 	 * Parse content to determine if there is a GV shortcode to allow for enqueing necessary files in the head. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  | 	 * @uses gravityview_has_shortcode_r() Check whether shortcode exists (recursively) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 	 * @uses shortcode_parse_atts() Parse each GV shortcode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 	 * @uses  gravityview_get_template_settings() Get the settings for the View ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 	 * @param  string $content $post->post_content content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 	 * @see \GV\View_Collection::from_content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 	 * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, NULL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 | 1 |  | 	public function parse_post_content( $content ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 | 1 |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 | 1 |  | 			$ids = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 | 1 |  | 			foreach ( \GV\Shortcode::parse( $content ) as $shortcode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 | 1 |  | 				if ( $shortcode->name == 'gravityview' && is_numeric( $shortcode->atts['id'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 | 1 |  | 					if ( \GV\View::exists( $shortcode->atts['id'] ) && ! gravityview()->views->contains( $shortcode->atts['id'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 						gravityview()->views->add( \GV\View::by_id( $shortcode->atts['id'] ) ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 					/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 					 * The original function outputs the ID even though it wasn't added by ::add_view() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 					 * Wether this is a bug or not remains a mystery. But we need to emulate this behavior | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 					 * until better times. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 					 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 | 1 |  | 					$ids []= $shortcode->atts['id']; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 | 1 |  | 			if ( empty ( $ids ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 				return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 | 1 |  | 			return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 		 * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 		 * @since 1.6 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 		if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 			new GravityView_Shortcode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 		$shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 		if( empty( $shortcodes ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 			return NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 		do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 		$ids = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 		foreach ($shortcodes as $key => $shortcode) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  | 			$shortcode[3] = htmlspecialchars_decode( $shortcode[3], ENT_QUOTES ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 			$args = shortcode_parse_atts( $shortcode[3] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 			if( empty( $args['id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 				do_action('gravityview_log_error', 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts', $shortcode ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 			do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 			// Store the View to the object for later fetching. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 			$this->add_view( $args['id'], $args ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 			$ids[] = $args['id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 		if( empty($ids) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 			return NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 		// If it's just one ID, return that. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 		// Otherwise, return array of IDs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 		return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 	 * Parse specific custom fields (Post Meta) to determine if there is a GV shortcode to allow for enqueuing necessary files in the head. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 	 * @since 1.15.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 	 * @see \GV\View_Collection::from_post | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 	 * @uses \GravityView_View_Data::parse_post_content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 	 * @param int $post_id WP_Post ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 	 * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, or meta not parsed, NULL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 	private function parse_post_meta( $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 			/** Is private and no longer used in future mode. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 			throw new RuntimeException( __CLASS__ . '::parse_post_meta is no more. Why was it called?' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 		 * @filter `gravityview/data/parse/meta_keys` Define meta keys to parse to check for GravityView shortcode content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 		 * This is useful when using themes that store content that may contain shortcodes in custom post meta | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 		 * @param[in,out] array $meta_keys Array of key values to check. If empty, do not check. Default: empty array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 		 * @param[in] int $post_id ID of the post being checked | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 		$meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 		if( empty( $meta_keys ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 			return NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 		do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 		$meta_content = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 		foreach( $meta_keys as $key ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 			$meta = get_post_meta( $post_id, $key , true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 			if( ! is_string( $meta ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 			$meta_content .= $meta . ' '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 		if( empty( $meta_content ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 			do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 			return NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 		do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 		return $this->parse_post_content( $meta_content ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 	 * Checks if the passed post id has the passed View id embedded. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 	 * Returns | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 	 * @since 1.6.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 	 * @param string $post_id Post ID where the View is embedded | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 	 * @param string $view_id View ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | 	 * @param string $empty_is_valid If either $post_id or $view_id is empty consider valid. Default: false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 	 * @return bool|WP_Error If valid, returns true. If invalid, returns WP_Error containing error message. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 612 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 613 | 1 |  | 	public static function is_valid_embed_id( $post_id = '', $view_id = '', $empty_is_valid = false ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 614 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 615 | 1 |  | 		$message = NULL; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 616 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 617 |  |  | 		// Not invalid if not set! | 
            
                                                                        
                            
            
                                    
            
            
                | 618 | 1 |  | 		if( empty( $post_id ) || empty( $view_id ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 619 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 620 | 1 |  | 			if( $empty_is_valid ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 621 | 1 |  | 				return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 622 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 623 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 624 | 1 |  | 			$message = esc_html__( 'The ID is required.', 'gravityview' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 625 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 626 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 627 | 1 |  | 		if( ! $message ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 628 | 1 |  | 			$status = get_post_status( $post_id ); | 
            
                                                                        
                            
            
                                    
            
            
                | 629 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 630 |  |  | 			// Nothing exists with that post ID. | 
            
                                                                        
                            
            
                                    
            
            
                | 631 | 1 |  | 			if ( ! is_numeric( $post_id ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 632 |  |  | 				$message = esc_html__( 'You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 633 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 634 |  |  | 				// @todo Convert to generic article about Embed IDs | 
            
                                                                        
                            
            
                                    
            
            
                | 635 |  |  | 				$message .= ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 636 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 637 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 638 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 639 | 1 |  | 		if( ! $message ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 640 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 641 |  |  | 			// Nothing exists with that post ID. | 
            
                                                                        
                            
            
                                    
            
            
                | 642 | 1 |  | 			if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 643 |  |  | 				$message = esc_html__( 'There is no post or page with that ID.', 'gravityview' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 644 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 645 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 646 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 647 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 648 | 1 |  | 		if( ! $message ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 649 | 1 |  | 			if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post = get_post( $post_id ) )  { | 
            
                                                                        
                            
            
                                    
            
            
                | 650 | 1 |  | 				$views = GV\View_Collection::from_post( $post ); | 
            
                                                                        
                            
            
                                    
            
            
                | 651 |  |  | 				$view_ids_in_post = array_map( function( $view ) { return $view->ID; }, $views->all() ); | 
            
                                                                        
                            
            
                                    
            
            
                | 652 |  |  | 			} else { | 
            
                                                                        
                            
            
                                    
            
            
                | 653 |  |  | 				/** ::maybe_get_view_id deprecated. */ | 
            
                                                                        
                            
            
                                    
            
            
                | 654 |  |  | 				$view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 655 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 656 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 657 |  |  | 			// The post or page specified does not contain the shortcode. | 
            
                                                                        
                            
            
                                    
            
            
                | 658 | 1 |  | 			if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 659 | 1 |  | 				$message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 660 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 661 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 662 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 663 | 1 |  | 		if( ! $message ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 664 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 665 |  |  | 			// It's a View | 
            
                                                                        
                            
            
                                    
            
            
                | 666 | 1 |  | 			if ( ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && \GV\View::exists( $post_id ) ) | 
            
                                                                        
                            
            
                                    
            
            
                | 667 | 1 |  | 				|| 'gravityview' === get_post_type( $post_id ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 668 |  |  | 				$message = esc_html__( 'The ID is already a View.', 'gravityview' );; | 
            
                                                                        
                            
            
                                    
            
            
                | 669 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 670 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 671 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 672 | 1 |  | 		if( $message ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 673 | 1 |  | 			return new WP_Error( 'invalid_embed_id', $message ); | 
            
                                                                        
                            
            
                                    
            
            
                | 674 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 675 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 676 | 1 |  | 		return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 677 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 	 * Get a specific default setting | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  | 	 * @param  string  $key          The key of the setting array item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  | 	 * @param  boolean $with_details Include details | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 	 * @return mixed|array                If using $with_details, return array. Otherwise, mixed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 | 1 |  | 	public static function get_default_arg( $key, $with_details = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 | 1 |  | 		$args = defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? \GV\View_Settings::defaults( $with_details ) : self::get_default_args( $with_details ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 | 1 |  | 		if( !isset( $args[ $key ] ) ) { return NULL; } | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 | 1 |  | 		return $args[ $key ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  | 	 * Retrieve the default args for shortcode and theme function | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 	 * @param boolean $with_details True: Return array with full default settings information, including description, name, etc. False: Return an array with only key => value pairs. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 	 * @param string $group Only fetch | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  | 	 * @return array $args Associative array of default settings for a View | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  | 	 *      @param[out] string $label Setting label shown in admin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 	 *      @param[out] string $type Gravity Forms field type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  | 	 *      @param[out] string $group The field group the setting is associated with. Default: "default" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 	 *      @param[out] mixed  $value The default value for the setting | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  | 	 *      @param[out] string $tooltip Tooltip displayed for the setting | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  | 	 *      @param[out] boolean $show_in_shortcode Whether to show the setting in the shortcode configuration modal | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  | 	 *      @param[out] array  $options Array of values to use when generating select, multiselect, radio, or checkboxes fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  | 	 *      @param[out] boolean $full_width True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  | 	 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  | 	 * @see \GV\View_Settings::defaults() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 | 5 |  | 	public static function get_default_args( $with_details = false, $group = NULL ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 | 5 |  | 		if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 | 5 |  | 			return \GV\View_Settings::defaults( $with_details, $group ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  | 		 * @filter `gravityview_default_args` Modify the default settings for new Views | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  | 		 * @param[in,out] array $default_args Array of default args. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  | 		 * @deprecated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  | 		 * @see filter `gravityview/view/settings/defaults` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  | 		$default_settings = apply_filters( 'gravityview_default_args', array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  | 			'id' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  | 				'label' => __('View ID', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  | 				'type' => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  | 				'value' => NULL, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  | 				'tooltip' => NULL, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  | 			'page_size' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  | 				'label' 	=> __('Number of entries per page', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  | 				'type' => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  | 				'class'	=> 'small-text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  | 				'value' => 25, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  | 			'offset' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  | 				'label' 	=> __('Offset entries starting from', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  | 				'type' => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  | 				'class'	=> 'small-text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  | 				'value' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  | 			'lightbox' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  | 				'label' => __( 'Enable lightbox for images', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  | 				'type' => 'checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  | 				'value' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  | 				'tooltip' => NULL, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  | 			'show_only_approved' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  | 				'label' => __( 'Show only approved entries', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  | 				'type' => 'checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  | 				'value' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  | 			'admin_show_all_statuses' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  | 				'label' => __( 'Show all entries to administrators', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  | 				'desc'	=> __('Administrators will be able to see entries with any approval status.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  | 				'tooltip' => __('Logged-out visitors and non-administrators will only see approved entries, while administrators will see entries with all statuses. This makes it easier for administrators to moderate entries from a View.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  | 				'requires' => 'show_only_approved', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  | 				'type' => 'checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  | 				'value' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  | 			'hide_until_searched' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  | 				'label' => __( 'Hide View data until search is performed', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  | 				'type' => 'checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  | 				'tooltip' => __( 'When enabled it will only show any View entries after a search is performed.', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  | 				'value' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  | 			'hide_empty' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  | 				'label' 	=> __( 'Hide empty fields', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  | 				'type'	=> 'checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  | 				'value' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  | 			'user_edit' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  | 				'label'	=> __( 'Allow User Edit', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  | 				'desc'	=> __('Allow logged-in users to edit entries they created.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  | 				'value'	=> 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  | 				'tooltip' => __('Display "Edit Entry" fields to non-administrator users if they created the entry. Edit Entry fields will always be displayed to site administrators.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  | 				'type'	=> 'checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  | 			'user_delete' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  | 				'label'	=> __( 'Allow User Delete', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  | 				'desc'	=> __('Allow logged-in users to delete entries they created.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  | 				'value'	=> 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  | 				'tooltip' => __('Display "Delete Entry" fields to non-administrator users if they created the entry. Delete Entry fields will always be displayed to site administrators.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  | 				'type'	=> 'checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  | 			'sort_field' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  | 				'label'	=> __('Sort by field', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  | 				'type' => 'select', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  | 				'value' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  | 				'group'	=> 'sort', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  | 				'options' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  | 					'' => __( 'Default', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  | 					'date_created' => __( 'Date Created', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  | 				), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  | 			'sort_direction' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  | 				'label' 	=> __('Sort direction', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  | 				'type' => 'select', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  | 				'value' => 'ASC', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  | 				'group'	=> 'sort', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  | 				'options' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  | 					'ASC' => __('ASC', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  | 					'DESC' => __('DESC', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  | 					//'RAND' => __('Random', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  | 				), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  | 			'sort_columns' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  | 				'label' 	=> __( 'Enable sorting by column', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  | 				'left_label' => __( 'Column Sorting', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  | 				'type' => 'checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  | 				'value' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  | 				'group'	=> 'sort', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  | 				'tooltip' => NULL, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  | 				'show_in_template' => array( 'default_table' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  | 			'start_date' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  | 				'label' 	=> __('Filter by Start Date', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  | 				'class'	=> 'gv-datepicker', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  | 				'desc'	=> __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  | 				'type' => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  | 				'value' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  | 				'group'	=> 'filter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  | 			'end_date' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  | 				'label' 	=> __('Filter by End Date', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  | 				'class'	=> 'gv-datepicker', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  | 				'desc'	=> __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  | 				'type' => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  | 				'value' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  | 				'group'	=> 'filter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  | 				'show_in_shortcode' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  | 			'class' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  | 				'label' 	=> __('CSS Class', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  | 				'desc'	=> __('CSS class to add to the wrapping HTML container.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  | 				'type' => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  | 				'value' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  | 			'search_value' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  | 				'label' 	=> __('Search Value', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  | 				'desc'	=> __('Define a default search value for the View', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  | 				'type' => 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  | 				'value' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  | 				'group'	=> 'filter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  | 			'search_field' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  | 				'label' 	=> __('Search Field', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  | 				'desc'	=> __('If Search Value is set, you can define a specific field to search in. Otherwise, all fields will be searched.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  | 				'type' => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  | 				'value' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  | 				'group'	=> 'filter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  | 			'single_title' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  | 				'label'	=> __('Single Entry Title', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  | 				'type'	=> 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  | 				'desc'	=> __('When viewing a single entry, change the title of the page to this setting. Otherwise, the title will not change between the Multiple Entries and Single Entry views.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  | 				'value'	=> '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  | 				'full_width' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  | 			'back_link_label' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  | 				'label'	=> __('Back Link Label', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  | 				'desc'	=> __('The text of the link that returns to the multiple entries view.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  | 				'type'	=> 'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  | 				'value'	=> '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  | 				'full_width' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  | 			'embed_only' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  | 				'label'	=> __('Prevent Direct Access', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  | 				'group'	=> 'default', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  | 				'desc'	=> __('Only allow access to this View when embedded using the shortcode.', 'gravityview'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  | 				'type'	=> 'checkbox', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  | 				'value'	=> '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  | 				'full_width' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  | 			'post_id' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  | 				'type' => 'number', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  | 				'value' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  | 				'show_in_shortcode' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  | 		)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  | 		// By default, we only want the key => value pairing, not the whole array. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  | 		if( empty( $with_details ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  | 			$defaults = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  | 			foreach( $default_settings as $key => $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  | 				$defaults[ $key ] = $value['value']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  | 			return $defaults; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  | 		// But sometimes, we want all the details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  | 		else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  | 			foreach ($default_settings as $key => $value) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  | 				// If the $group argument is set for the method, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  | 				// ignore any settings that aren't in that group. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  | 				if( !empty( $group ) && is_string( $group ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  | 					if( empty( $value['group'] ) || $value['group'] !== $group ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  | 						unset( $default_settings[ $key ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  | 			return $default_settings; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 949 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 950 |  |  |  | 
            
                        
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.