| 1 |  |  | <?php | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Set of common functions to separate main plugin from Gravity Forms API and other cross-plugin methods | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @package   GravityView | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @license   GPL2+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @author    Katz Web Services, Inc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @link      http://gravityview.co | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @copyright Copyright 2014, Katz Web Services, Inc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @since 1.5.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | /** If this file is called directly, abort. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | if ( ! defined( 'ABSPATH' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	die; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | class GVCommon { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	 * Returns the form object for a given Form ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	 * @param mixed $form_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	 * @return array|false Array: Form object returned from Gravity Forms; False: no form ID specified or Gravity Forms isn't active. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 2 |  | 	public static function get_form( $form_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 2 |  | 		if ( empty( $form_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 		// Only get_form_meta is cached. ::facepalm:: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 2 |  | 		if ( class_exists( 'RGFormsModel' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 2 |  | 			return GFFormsModel::get_form_meta( $form_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		if ( class_exists( 'GFAPI' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 			return GFAPI::get_form( $form_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	 * Alias of GravityView_Roles_Capabilities::has_cap() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	 * @since 1.15 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	 * @see GravityView_Roles_Capabilities::has_cap() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	 * @param string|array $caps Single capability or array of capabilities | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	 * @param int $object_id (optional) Parameter can be used to check for capabilities against a specific object, such as a post or user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	 * @param int|null $user_id (optional) Check the capabilities for a user who is not necessarily the currently logged-in user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	 * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 2 |  | 	public static function has_cap( $caps = '', $object_id = null, $user_id = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 | 2 |  | 		return GravityView_Roles_Capabilities::has_cap( $caps, $object_id, $user_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	 * Return a Gravity Forms field array, whether using GF 1.9 or not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	 * @since 1.7 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	 * @param array|GF_Fields $field Gravity Forms field or array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	 * @return array Array version of $field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 	public static function get_field_array( $field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 		if ( class_exists( 'GF_Fields' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 			$field_object = GF_Fields::create( $field ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 			// Convert the field object in 1.9 to an array for backward compatibility | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 			$field_array = get_object_vars( $field_object ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 			$field_array = $field; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 		return $field_array; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	 * Get all existing Views | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	 * @since  1.5.4 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	 * @since  TODO Added $args array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	 * @param array $args Pass custom array of args, formatted as if for `get_posts()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 	 * @return array Array of Views as `WP_Post`. Empty array if none found. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	public static function get_all_views( $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		$default_params = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			'post_type' => 'gravityview', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 			'posts_per_page' => -1, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 			'post_status' => 'publish', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 		$params = wp_parse_args( $args, $default_params ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 		 * @filter `gravityview/get_all_views/params` Modify the parameters sent to get all views. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 		 * @param[in,out]  array $params Array of parameters to pass to `get_posts()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 		$views_params = apply_filters( 'gravityview/get_all_views/params', $params ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 		$views = get_posts( $views_params ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 		return $views; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 	 * Get the form array for an entry based only on the entry ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 	 * @param  int|string $entry_slug Entry slug | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 	 * @return array|false Array: Form object returned from Gravity Forms; False: form doesn't exist, or $entry didn't exist or $entry didn't specify form ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 	public static function get_form_from_entry_id( $entry_slug ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 		$entry = self::get_entry( $entry_slug, true, false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		$form = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 		if( $entry ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 			$form = GFAPI::get_form( $entry['form_id'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 		return $form; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	 * Check whether a form has product fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	 * @since 1.16 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	 * @since 1.20 Refactored the field types to get_product_field_types() method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 	 * @param array $form Gravity Forms form array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 	 * @return bool|GF_Field[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 2 |  | 	public static function has_product_field( $form = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 | 2 |  | 		$product_fields = self::get_product_field_types(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 2 |  | 		$fields = GFAPI::get_fields_by_type( $form, $product_fields ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 | 2 |  | 		return empty( $fields ) ? false : $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 	 * Return array of product field types | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 	 * Modify the value using the `gform_product_field_types` filter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 	 * @since 1.20 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 | 3 |  | 	public static function get_product_field_types() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 | 3 |  | 		$product_fields = apply_filters( 'gform_product_field_types', array( 'option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price', 'hiddenproduct', 'singleproduct', 'singleshipping' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 | 3 |  | 		return $product_fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 	 * Check if an entry has transaction data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	 * Checks the following keys to see if they are set: 'payment_status', 'payment_date', 'transaction_id', 'payment_amount', 'payment_method' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	 * @since 1.20 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 	 * @param array $entry Gravity Forms entry array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 	 * @return bool True: Entry has metadata suggesting it has communicated with a payment gateway; False: it does not have that data. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 3 |  | 	public static function entry_has_transaction_data( $entry = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 | 3 |  | 		if ( ! is_array( $entry ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 | 1 |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 | 3 |  | 		$has_transaction_data = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 | 3 |  | 		$payment_meta = array( 'payment_status', 'payment_date', 'transaction_id', 'payment_amount', 'payment_method' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 | 3 |  | 		foreach ( $payment_meta as $meta ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 | 3 |  | 			$has_transaction_data = rgar( $entry, $meta, false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 3 |  | 			if( ! empty( $has_transaction_data ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 3 |  | 				break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 | 3 |  | 		return (bool) $has_transaction_data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 	 * Get the entry ID from the entry slug, which may or may not be the entry ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 	 * @since  1.5.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 	 * @param  string $slug The entry slug, as returned by GravityView_API::get_entry_slug() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 	 * @return int|null       The entry ID, if exists; `NULL` if not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 	public static function get_entry_id_from_slug( $slug ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 		global $wpdb; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 		$search_criteria = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 			'field_filters' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 				array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  | 					'key' => 'gravityview_unique_id', // Search the meta values | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 					'value' => $slug, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 					'operator' => 'is', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 					'type' => 'meta', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 				), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 		// Limit to one for speed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 		$paging = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 			'page_size' => 1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 		 * @filter `gravityview/common/get_entry_id_from_slug/form_id` The form ID used to get the custom entry ID. Change this to avoid collisions with data from other forms with the same values and the same field ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 		 * @since 1.17.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 		 * @param int $form_id ID of the form to search. Default: `0` (searches all forms) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 		$form_id = apply_filters( 'gravityview/common/get_entry_id_from_slug/form_id', 0 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 		$results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 		$result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 		return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 	 * Alias of GFAPI::get_forms() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 	 * @see GFAPI::get_forms() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 	 * @since 1.19 Allow "any" $active status option | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 	 * @param bool|string $active Status of forms. Use `any` to get array of forms with any status. Default: `true` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 	 * @param bool $trash Include forms in trash? Default: `false` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 	 * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 | 1 |  | 	public static function get_forms(  $active = true, $trash = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 | 1 |  | 		$forms = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 | 1 |  | 		if ( class_exists( 'GFAPI' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 | 1 |  | 			if( 'any' === $active ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 				$active_forms = GFAPI::get_forms( true, $trash ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 				$inactive_forms = GFAPI::get_forms( false, $trash ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 				$forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 | 1 |  | 				$forms = GFAPI::get_forms( $active, $trash ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 | 1 |  | 		return $forms; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 	 * Return array of fields' id and label, for a given Form ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 	 * @param string|array $form_id (default: '') or $form object | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 	 * @param bool $add_default_properties | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 	 * @param bool $include_parent_field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 	public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 		if ( ! is_array( $form ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 			$form = self::get_form( $form ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 		$fields = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 		$has_product_fields = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 		$has_post_fields = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 		if ( $form ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 			foreach ( $form['fields'] as $field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 				if ( $include_parent_field || empty( $field['inputs'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 					$fields["{$field['id']}"] = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 						'label' => rgar( $field, 'label' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 						'parent' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 						'type' => rgar( $field, 'type' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 						'adminLabel' => rgar( $field, 'adminLabel' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 						'adminOnly' => rgar( $field, 'adminOnly' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 				if ( $add_default_properties && ! empty( $field['inputs'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 					foreach ( $field['inputs'] as $input ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 						if( ! empty( $input['isHidden'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 							continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 						/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |                          * @hack | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |                          * In case of email/email confirmation, the input for email has the same id as the parent field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |                          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 						if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |                             continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 						$fields["{$input['id']}"] = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 							'label' => rgar( $input, 'label' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 							'customLabel' => rgar( $input, 'customLabel' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 							'parent' => $field, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 							'type' => rgar( $field, 'type' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 							'adminLabel' => rgar( $field, 'adminLabel' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 							'adminOnly' => rgar( $field, 'adminOnly' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 						); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 				if( GFCommon::is_product_field( $field['type'] ) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 					$has_product_fields = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 				if ( GFCommon::is_post_field( $field ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 					$has_post_fields = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 		 * @since 1.7 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 		if ( $has_post_fields ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 			$fields['post_id'] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 				'label' => __( 'Post ID', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 				'type' => 'post_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 		if ( $has_product_fields ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 			$payment_fields = GravityView_Fields::get_all( 'pricing' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 			foreach ( $payment_fields as $payment_field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 				// Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 				if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 					continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 				$fields["{$payment_field->name}"] = array( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 					'label' => $payment_field->label, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 					'desc' => $payment_field->description, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 					'type' => $payment_field->name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 		 * @filter `gravityview/common/get_form_fields` Modify the form fields shown in the Add Field field picker. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 		 * @since 1.17 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 		 * @param array $fields Associative array of fields, with keys as field type, values an array with the following keys: (string) `label` (required), (string) `type` (required), `desc`, (string) `customLabel`, (GF_Field) `parent`, (string) `adminLabel`, (bool)`adminOnly` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 		 * @param array $form GF Form array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 		 * @param bool $include_parent_field Whether to include the parent field when getting a field with inputs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 		$fields = apply_filters( 'gravityview/common/get_form_fields', $fields, $form, $include_parent_field ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 		return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 	 * get extra fields from entry meta | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 	 * @param  string $form_id (default: '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 	public static function get_entry_meta( $form_id, $only_default_column = true ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 		$extra_fields = GFFormsModel::get_entry_meta( $form_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 		$fields = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 		foreach ( $extra_fields as $key => $field ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 			if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 				$fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 		return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 	 * Wrapper for the Gravity Forms GFFormsModel::search_lead_ids() method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 	 * @see  GFEntryList::leads_page() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 	 * @param  int $form_id ID of the Gravity Forms form | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 	 * @since  1.1.6 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 	 * @return array|void          Array of entry IDs. Void if Gravity Forms isn't active. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  | 	public static function get_entry_ids( $form_id, $search_criteria = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 		if ( ! class_exists( 'GFFormsModel' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 			return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 		return GFFormsModel::search_lead_ids( $form_id, $search_criteria ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 	 * Calculates the Search Criteria used on the self::get_entries / self::get_entry methods | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 	 * @since 1.7.4 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 	 * @param array $passed_criteria array Input Criteria (search_criteria, sorting, paging) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 	 * @param array $form_ids array Gravity Forms form IDs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 | 2 |  | 	public static function calculate_get_entries_criteria( $passed_criteria = array(), $form_ids = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  | 		$search_criteria_defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 | 2 |  | 			'search_criteria' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 			'sorting' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 			'paging' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 | 2 |  | 			'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 | 2 |  | 		$criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 | 2 |  | 		if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 | 1 |  | 			foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 | 1 |  | 				if ( ! is_array( $filter ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 | 1 |  | 					continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 				// By default, we want searches to be wildcard for each field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 | 1 |  | 				$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  | 				 * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 				 * @param string $operator Existing search operator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 				 * @param array $filter array with `key`, `value`, `operator`, `type` keys | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 | 1 |  | 				$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 			// don't send just the [mode] without any field filter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 | 1 |  | 			if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 | 1 |  | 				unset( $criteria['search_criteria']['field_filters']['mode'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |  | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  | 		 * Prepare date formats to be in Gravity Forms DB format; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 		 * $passed_criteria may include date formats incompatible with Gravity Forms. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 | 2 |  | 		foreach ( array('start_date', 'end_date' ) as $key ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 | 2 |  | 			if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  | 				// Use date_create instead of new DateTime so it returns false if invalid date format. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 | 1 |  | 				$date = date_create( $criteria['search_criteria'][ $key ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 | 1 |  | 				if ( $date ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 					// Gravity Forms wants dates in the `Y-m-d H:i:s` format. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 | 1 |  | 					$criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 				} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 | 1 |  | 					do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  | 					// If it's an invalid date, unset it. Gravity Forms freaks out otherwise. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 | 2 |  | 					unset( $criteria['search_criteria'][ $key ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 | 2 |  | 		if ( ! GravityView_frontend::getInstance()->getSingleEntry() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 			/** GravityView_View_Data::getInstance() has a side-effect :( and not one, so we can't let it run under some circumstances. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 | 2 |  | 			if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 | 2 |  | 				$multiple_original = gravityview()->views->count() > 1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 | 2 |  | 				GravityView_View_Data::getInstance(); /** Yes, those side-effects have to kick in. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 				/** This weird state only happens in tests, when we play around and reset the $instance... */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 				/** Deprecated, do not use has_multiple_views() anymore. Thanks. */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  | 				$multiple_original = class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 		// Calculate the context view id and send it to the advanced filter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 | 2 |  | 		if ( GravityView_frontend::getInstance()->getSingleEntry() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 | 1 |  | 			$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 | 2 |  | 		} elseif ( $multiple_original ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 | 1 |  | 			$criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 | 2 |  | 		} elseif ( 'delete' === GFForms::get( 'action' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 | 1 |  | 			$criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 | 2 |  | 		} elseif( !isset( $criteria['context_view_id'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |             // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 | 2 |  | 			$criteria['context_view_id'] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 		 * @filter `gravityview_search_criteria` Apply final criteria filter (Used by the Advanced Filter extension) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 		 * @param array $criteria Search criteria used by GravityView | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 		 * @param array $form_ids Forms to search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 		 * @param int $view_id ID of the view being used to search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 | 2 |  | 		$criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 | 2 |  | 		return (array)$criteria; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 	 * Retrieve entries given search, sort, paging criteria | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 	 * @see  GFAPI::get_entries() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 	 * @see GFFormsModel::get_field_filters_where() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 	 * @param int|array $form_ids The ID of the form or an array IDs of the Forms. Zero for all forms. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 	 * @param mixed $passed_criteria (default: null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 	 * @param mixed &$total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate the total count. (default: null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 	 * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 	public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  | 		// Filter the criteria before query (includes Adv Filter) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 		$criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  | 		do_action( 'gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 		// Return value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 		$return = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 		/** Reduce # of database calls */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 		add_filter( 'gform_is_encrypted_field', '__return_false' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 		if ( ! empty( $criteria['cache'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 			$Cache = new GravityView_Cache( $form_ids, $criteria ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 			if ( $entries = $Cache->get() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 				// Still update the total count when using cached results | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 				if ( ! is_null( $total ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 					$total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 				$return = $entries; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 		if ( is_null( $return ) && class_exists( 'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 			 * @filter `gravityview_pre_get_entries` Define entries to be used before GFAPI::get_entries() is called | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 			 * @since 1.14 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 			 * @param  null $return If you want to override GFAPI::get_entries() and define entries yourself, tap in here. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 			 * @param  array $criteria The final search criteria used to generate the request to `GFAPI::get_entries()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 			 * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 			 * @param  int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 			$entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 			// No entries returned from gravityview_before_get_entries | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 			if( is_null( $entries ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 				$entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 				if ( is_wp_error( $entries ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 					do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 					return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 			if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 				// Cache results | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 				$Cache->set( $entries, 'entries' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 			$return = $entries; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  | 		/** Remove filter added above */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 		remove_filter( 'gform_is_encrypted_field', '__return_false' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 		 * @filter `gravityview_entries` Modify the array of entries returned to GravityView after it has been fetched from the cache or from `GFAPI::get_entries()`. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 		 * @param  array|null $entries Array of entries as returned by the cache or by `GFAPI::get_entries()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 		 * @param  array $criteria The final search criteria used to generate the request to `GFAPI::get_entries()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 		 * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 		 * @param  int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  | 		$return = apply_filters( 'gravityview_entries', $return, $criteria, $passed_criteria, $total ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  | 		return $return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  | 	 * Get the entry ID from a string that may be the Entry ID or the Entry Slug | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 	 * @since TODO | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 	 * @param string $entry_id_or_slug The ID or slug of an entry. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 	 * @param bool $force_allow_ids Whether to force allowing getting the ID of an entry, even if custom slugs are enabled | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 	 * @return false|int|null Returns the ID of the entry found, if custom slugs is enabled. Returns original value if custom slugs is disabled. Returns false if not allowed to convert slug to ID. Returns NULL if entry not found for the passed slug. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 | 1 |  | 	public static function get_entry_id( $entry_id_or_slug = '', $force_allow_ids = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 | 1 |  | 		$entry_id = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 		 * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 		 * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 | 1 |  | 		$custom_slug = apply_filters( 'gravityview_custom_entry_slug', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  | 		 * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  | 		 * - If disabled (default), only allow access to an entry using the custom slug value.  (example: `/entry/custom-slug/` NOT `/entry/123/`) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 		 * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 		 * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 | 1 |  | 		$custom_slug_id_access = $force_allow_ids || apply_filters( 'gravityview_custom_entry_slug_allow_id', false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  | 		 * If we're using custom entry slugs, we do a meta value search | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  | 		 * instead of doing a straightup ID search. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 | 1 |  | 		if ( $custom_slug ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  | 			// Search for IDs matching $entry_id_or_slug | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  | 			$entry_id = self::get_entry_id_from_slug( $entry_id_or_slug ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  | 		// If custom slug is off, search using the entry ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  | 		// ID allow ID access is on, also use entry ID as a backup | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 | 1 |  | 		if ( false === $custom_slug || true === $custom_slug_id_access ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  | 			// Search for IDs matching $entry_slug | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 | 1 |  | 			$entry_id = $entry_id_or_slug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 | 1 |  | 		return $entry_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  | 	 * Return a single entry object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  | 	 * Since 1.4, supports custom entry slugs. The way that GravityView fetches an entry based on the custom slug is by searching `gravityview_unique_id` meta. The `$entry_slug` is fetched by getting the current query var set by `is_single_entry()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  | 	 * @param string|int $entry_slug Either entry ID or entry slug string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  | 	 * @param boolean $force_allow_ids Force the get_entry() method to allow passed entry IDs, even if the `gravityview_custom_entry_slug_allow_id` filter returns false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  | 	 * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  | 	 * @return array|boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 | 1 |  | 	public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 | 1 |  | 		if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 | 1 |  | 			$entry_id = self::get_entry_id( $entry_slug, $force_allow_ids ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 | 1 |  | 			if ( empty( $entry_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  | 			// fetch the entry | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 | 1 |  | 			$entry = GFAPI::get_entry( $entry_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  | 			 * @filter `gravityview/common/get_entry/check_entry_display` Override whether to check entry display rules against filters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  | 			 * @since 1.16.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  | 			 * @param bool $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  | 			 * @param array $entry Gravity Forms entry array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 | 1 |  | 			$check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 | 1 |  | 			if( $check_entry_display ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  | 				// Is the entry allowed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 | 1 |  | 				$entry = self::check_entry_display( $entry ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 | 1 |  | 			if( is_wp_error( $entry ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  | 				do_action( 'gravityview_log_error', __METHOD__ . ': ' . $entry->get_error_message() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 | 1 |  | 			return $entry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  | 	 * Wrapper for the GFFormsModel::matches_operation() method that adds additional comparisons, including: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  | 	 * 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  | 	 * and 'not_contains' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  | 	 * @since 1.13 You can define context, which displays/hides based on what's being displayed (single, multiple, edit) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  | 	 * @see http://docs.gravityview.co/article/252-gvlogic-shortcode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  | 	 * @uses GFFormsModel::matches_operation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  | 	 * @since 1.7.5 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  | 	 * @param string $val1 Left side of comparison | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  | 	 * @param string $val2 Right side of comparison | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  | 	 * @param string $operation Type of comparison | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  | 	 * @return bool True: matches, false: not matches | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  | 	public static function matches_operation( $val1, $val2, $operation ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  | 		$value = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  | 		if( 'context' === $val1 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  | 			$matching_contexts = array( $val2 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  | 			// We allow for non-standard contexts. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  | 			switch( $val2 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  | 				// Check for either single or edit | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  | 				case 'singular': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  | 					$matching_contexts = array( 'single', 'edit' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  | 				// Use multiple as alias for directory for consistency | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  | 				case 'multiple': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  | 					$matching_contexts = array( 'directory' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  | 			$val1 = in_array( gravityview_get_context(), $matching_contexts ) ? $val2 : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  | 		switch ( $operation ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  | 			case 'equals': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  | 				$value = GFFormsModel::matches_operation( $val1, $val2, 'is' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  | 				break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  | 			case 'greater_than_or_is': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  | 			case 'greater_than_or_equals': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  | 				$is    = GFFormsModel::matches_operation( $val1, $val2, 'is' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  | 				$gt    = GFFormsModel::matches_operation( $val1, $val2, 'greater_than' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  | 				$value = ( $is || $gt ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  | 				break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  | 			case 'less_than_or_is': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  | 			case 'less_than_or_equals': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  | 				$is    = GFFormsModel::matches_operation( $val1, $val2, 'is' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  | 				$gt    = GFFormsModel::matches_operation( $val1, $val2, 'less_than' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  | 				$value = ( $is || $gt ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  | 				break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  | 			case 'not_contains': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  | 				$contains = GFFormsModel::matches_operation( $val1, $val2, 'contains' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  | 				$value    = ! $contains; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  | 				break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  | 			default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  | 				$value = GFFormsModel::matches_operation( $val1, $val2, $operation ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  | 		return $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  | 	 * Checks if a certain entry is valid according to the View search filters (specially the Adv Filters) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  | 	 * @uses GVCommon::calculate_get_entries_criteria(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  | 	 * @see GFFormsModel::is_value_match() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  | 	 * @since 1.7.4 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  | 	 * @param array $entry Gravity Forms Entry object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  | 	 * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 | 2 |  | 	public static function check_entry_display( $entry ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 | 2 |  | 		if ( ! $entry || is_wp_error( $entry ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 | 1 |  | 			return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 | 2 |  | 		if ( empty( $entry['form_id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 | 1 |  | 			return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 | 2 |  | 		$criteria = self::calculate_get_entries_criteria(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 | 2 |  | 		if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 | 2 |  | 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 | 2 |  | 			return $entry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  | 		// Make sure the current View is connected to the same form as the Entry | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 | 1 |  | 		if( ! empty( $criteria['context_view_id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 | 1 |  | 			$context_view_id = intval( $criteria['context_view_id'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 | 1 |  | 			$context_form_id = gravityview_get_form_id( $context_view_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 | 1 |  | 			if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 | 1 |  | 				return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 | 1 |  | 		$search_criteria = $criteria['search_criteria']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  | 		// check entry status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 | 1 |  | 		if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 | 1 |  | 			return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  | 		// check entry date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  | 		// @todo: Does it make sense to apply the Date create filters to the single entry? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  | 		// field_filters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 | 1 |  | 		if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 | 1 |  | 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 | 1 |  | 			return $entry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 | 1 |  | 		$filters = $search_criteria['field_filters']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 | 1 |  | 		$mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 | 1 |  | 		$form = self::get_form( $entry['form_id'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 | 1 |  | 		foreach ( $filters as $filter ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 | 1 |  | 			if ( ! isset( $filter['key'] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 | 1 |  | 				do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Filter key not set', $filter ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 | 1 |  | 				continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 | 1 |  | 			$k = $filter['key']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 | 1 |  | 			$field = self::get_field( $form, $k ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 | 1 |  | 			if ( is_null( $field ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 | 1 |  | 				$field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  | 				$field_value  = GFFormsModel::get_lead_field_value( $entry, $field ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  | 				 // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  | 				$field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? rgar( $field_value, $k ) : $field_value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 | 1 |  | 			$operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 | 1 |  | 			$is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  | 			// Any match is all we need to know | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 | 1 |  | 			if ( $is_value_match && 'any' === $mode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 | 1 |  | 				return $entry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  | 			// Any failed match is a total fail | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 | 1 |  | 			if ( ! $is_value_match && 'all' === $mode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 | 1 |  | 				return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  | 		// at this point, if in ALL mode, then entry is approved - all conditions were met. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  | 		// Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 | 1 |  | 		if ( 'all' === $mode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 | 1 |  | 			do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved: all conditions were met' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 | 1 |  | 			return $entry; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  | 			return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  | 	 * Allow formatting date and time based on GravityView standards | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  | 	 * @since 1.16 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  | 	 * @see GVCommon_Test::test_format_date for examples | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  | 	 * @param string $date_string The date as stored by Gravity Forms (`Y-m-d h:i:s` GMT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  | 	 * @param string|array $args Array or string of settings for output parsed by `wp_parse_args()`; Can use `raw=1` or `array('raw' => true)` \n | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  | 	 * - `raw` Un-formatted date string in original `Y-m-d h:i:s` format | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  | 	 * - `timestamp` Integer timestamp returned by GFCommon::get_local_timestamp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  | 	 * - `diff` "%s ago" format, unless other `format` is defined | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  | 	 * - `human` Set $is_human parameter to true for `GFCommon::format_date()`. Shows `diff` within 24 hours or date after. Format based on blog setting, unless `format` is defined. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  | 	 * - `time` Include time in the `GFCommon::format_date()` output | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  | 	 * - `format` Define your own date format, or `diff` format | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  | 	 * @return int|null|string Formatted date based on the original date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 | 1 |  | 	public static function format_date( $date_string = '', $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  | 		$default_atts = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 | 1 |  | 			'raw' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  | 			'timestamp' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  | 			'diff' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  | 			'human' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  | 			'format' => '', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  | 			'time' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 | 1 |  | 		$atts = wp_parse_args( $args, $default_atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  | 		 * Gravity Forms code to adjust date to locally-configured Time Zone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  | 		 * @see GFCommon::format_date() for original code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 | 1 |  | 		$date_gmt_time   = mysql2date( 'G', $date_string ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 | 1 |  | 		$date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 | 1 |  | 		$format  = rgar( $atts, 'format' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 | 1 |  | 		$is_human  = ! empty( $atts['human'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 | 1 |  | 		$is_diff  = ! empty( $atts['diff'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 | 1 |  | 		$is_raw = ! empty( $atts['raw'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 | 1 |  | 		$is_timestamp = ! empty( $atts['timestamp'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 | 1 |  | 		$include_time = ! empty( $atts['time'] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  | 		// If we're using time diff, we want to have a different default format | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 | 1 |  | 		if( empty( $format ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  | 			/* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 | 1 |  | 			$format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  | 		// If raw was specified, don't modify the stored value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 | 1 |  | 		if ( $is_raw ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 | 1 |  | 			$formatted_date = $date_string; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 | 1 |  | 		} elseif( $is_timestamp ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 | 1 |  | 			$formatted_date = $date_local_timestamp; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 | 1 |  | 		} elseif ( $is_diff ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 | 1 |  | 			$formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 | 1 |  | 			$formatted_date = GFCommon::format_date( $date_string, $is_human, $format, $include_time ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 | 1 |  | 		unset( $format, $is_diff, $is_human, $is_timestamp, $is_raw, $date_gmt_time, $date_local_timestamp, $default_atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 | 1 |  | 		return $formatted_date; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  | 	 * Retrieve the label of a given field id (for a specific form) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  | 	 * @since 1.17 Added $field_value parameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  | 	 * @param array $form Gravity Forms form array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  | 	 * @param string $field_id ID of the field. If an input, full input ID (like `1.3`) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  | 	 * @param string|array $field_value Raw value of the field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  | 	public static function get_field_label( $form = array(), $field_id = '', $field_value = '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  | 		if ( empty( $form ) || empty( $field_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  | 			return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  | 		$field = self::get_field( $form, $field_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  | 		$label = rgar( $field, 'label' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  | 		if( floor( $field_id ) !== floatval( $field_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  | 			$label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  | 		return $label; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  | 	 * Returns the field details array of a specific form given the field id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  | 	 * Alias of GFFormsModel::get_field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  | 	 * @since 1.19 Allow passing form ID as well as form array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  | 	 * @uses GFFormsModel::get_field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  | 	 * @see GFFormsModel::get_field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  | 	 * @param array|int $form Form array or ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  | 	 * @param string|int $field_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  | 	 * @return GF_Field|null Gravity Forms field object, or NULL: Gravity Forms GFFormsModel does not exist or field at $field_id doesn't exist. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  | 	public static function get_field( $form, $field_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  | 		if ( is_numeric( $form ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 993 |  |  | 			$form = GFAPI::get_form( $form ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 994 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  | 		if ( class_exists( 'GFFormsModel' ) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  | 			return GFFormsModel::get_field( $form, $field_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 999 |  |  | 			return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1004 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  | 	 * Check whether the post is GravityView | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  | 	 * - Check post type. Is it `gravityview`? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  | 	 * - Check shortcode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  | 	 * @param  WP_Post      $post WordPress post object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  | 	 * @return boolean           True: yep, GravityView; No: not! | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 | 2 |  | 	public static function has_gravityview_shortcode( $post = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 | 2 |  | 		if ( ! is_a( $post, 'WP_Post' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 | 1 |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 | 2 |  | 		if ( 'gravityview' === get_post_type( $post ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 | 2 |  | 			return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 | 2 |  | 		return self::has_shortcode_r( $post->post_content, 'gravityview' ) ? true : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  | 	 * Placeholder until the recursive has_shortcode() patch is merged | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  | 	 * @see https://core.trac.wordpress.org/ticket/26343#comment:10 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  | 	 * @param string $content Content to check whether there's a shortcode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  | 	 * @param string $tag Current shortcode tag | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 | 2 |  | 	public static function has_shortcode_r( $content, $tag = 'gravityview' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 | 2 |  | 		if ( false === strpos( $content, '[' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 | 1 |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 | 2 |  | 		if ( shortcode_exists( $tag ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 | 2 |  | 			$shortcodes = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 | 2 |  | 			preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 | 2 |  | 			if ( empty( $matches ) ){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 | 1 |  | 				return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 | 2 |  | 			foreach ( $matches as $shortcode ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 | 2 |  | 				if ( $tag === $shortcode[2] ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 |  |  | 					// Changed this to $shortcode instead of true so we get the parsed atts. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 | 2 |  | 					$shortcodes[] = $shortcode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 | 1 |  | 				} else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 | 1 |  | 					foreach( $results as $result ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 | 2 |  | 						$shortcodes[] = $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 | 2 |  | 			return $shortcodes; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1064 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1067 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  | 	 * Get the views for a particular form | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1070 |  |  | 	 * @since 1.15.2 Add $args array and limit posts_per_page to 500 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  | 	 * @uses get_posts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  | 	 * @param  int $form_id Gravity Forms form ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  | 	 * @param  array $args Pass args sent to get_posts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  | 	 * @return array          Array with view details, as returned by get_posts() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1079 | 1 |  | 	public static function get_connected_views( $form_id, $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1080 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1081 |  |  | 		$defaults = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1082 | 1 |  | 			'post_type' => 'gravityview', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1083 | 1 |  | 			'posts_per_page' => 100, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1084 | 1 |  | 			'meta_key' => '_gravityview_form_id', | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1085 | 1 |  | 			'meta_value' => (int)$form_id, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1086 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1087 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1088 | 1 |  | 		$args = wp_parse_args( $args, $defaults ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1089 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1090 | 1 |  | 		$views = get_posts( $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1091 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1092 | 1 |  | 		return $views; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1093 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1094 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1095 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1096 |  |  | 	 * Get the Gravity Forms form ID connected to a View | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1097 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1098 |  |  | 	 * @param int $view_id The ID of the View to get the connected form of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1099 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1100 |  |  | 	 * @return false|string ID of the connected Form, if exists. Empty string if not. False if not the View ID isn't valid. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1101 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1102 | 1 |  | 	public static function get_meta_form_id( $view_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1103 | 1 |  | 		return get_post_meta( $view_id, '_gravityview_form_id', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1104 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1106 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1107 |  |  | 	 * Get the template ID (`list`, `table`, `datatables`, `map`) for a View | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1108 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1109 |  |  | 	 * @see GravityView_Template::template_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1110 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1111 |  |  | 	 * @param int $view_id The ID of the View to get the layout of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1112 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1113 |  |  | 	 * @return string GravityView_Template::template_id value. Empty string if not. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1114 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1115 | 1 |  | 	public static function get_meta_template_id( $view_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1116 | 1 |  | 		return get_post_meta( $view_id, '_gravityview_directory_template', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1117 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1120 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1121 |  |  | 	 * Get all the settings for a View | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1122 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1123 |  |  | 	 * @uses  \GV\View_Settings::defaults() Parses the settings with the plugin defaults as backups. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1124 |  |  | 	 * @param  int $post_id View ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1125 |  |  | 	 * @return array          Associative array of settings with plugin defaults used if not set by the View | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1126 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1127 | 2 |  | 	public static function get_template_settings( $post_id ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1129 | 2 |  | 		$settings = get_post_meta( $post_id, '_gravityview_template_settings', true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1131 | 2 |  | 		if ( class_exists( 'GravityView_View_Data' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1133 | 2 |  | 			$defaults = defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? \GV\View_Settings::defaults() : GravityView_View_Data::get_default_args(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1135 | 2 |  | 			return wp_parse_args( (array)$settings, $defaults ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1137 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1139 |  |  | 		// Backup, in case GravityView_View_Data isn't loaded yet. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1140 |  |  | 		return $settings; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1141 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1143 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1144 |  |  | 	 * Get the setting for a View | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1145 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1146 |  |  | 	 * If the setting isn't set by the View, it returns the plugin default. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1147 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1148 |  |  | 	 * @param  int $post_id View ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1149 |  |  | 	 * @param  string $key     Key for the setting | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1150 |  |  | 	 * @return mixed|null          Setting value, or NULL if not set. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1151 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1152 |  |  | 	public static function get_template_setting( $post_id, $key ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1154 |  |  | 		$settings = self::get_template_settings( $post_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1156 |  |  | 		if ( isset( $settings[ $key ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1157 |  |  | 			return $settings[ $key ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1158 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1160 |  |  | 		return null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1161 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1162 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1163 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1164 |  |  | 	 * Get the field configuration for the View | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1165 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1166 |  |  | 	 * array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1167 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1168 |  |  | 	 * 	[other zones] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1169 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1170 |  |  | 	 * 	'directory_list-title' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1171 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1172 |  |  | 	 *   	[other fields] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1173 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1174 |  |  | 	 *  	'5372653f25d44' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1175 |  |  | 	 *  		'id' => string '9' (length=1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1176 |  |  | 	 *  		'label' => string 'Screenshots' (length=11) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  | 	 *			'show_label' => string '1' (length=1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  | 	 *			'custom_label' => string '' (length=0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  | 	 *			'custom_class' => string 'gv-gallery' (length=10) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  | 	 * 			'only_loggedin' => string '0' (length=1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  | 	 *			'only_loggedin_cap' => string 'read' (length=4) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  | 	 *  	) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1184 |  |  | 	 * 		[other fields] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  | 	 *  ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1187 |  |  | 	 * 	[other zones] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1188 |  |  | 	 * ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1189 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1190 |  |  | 	 * @since 1.17.4 Added $apply_filter parameter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1191 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1192 |  |  | 	 * @param  int $post_id View ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1193 |  |  | 	 * @param  bool $apply_filter Whether to apply the `gravityview/configuration/fields` filter [Default: true] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1194 |  |  | 	 * @return array          Multi-array of fields with first level being the field zones. See code comment. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1195 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 1196 | 1 |  | 	public static function get_directory_fields( $post_id, $apply_filter = true ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 1197 | 1 |  | 		$fields = get_post_meta( $post_id, '_gravityview_directory_fields', true ); | 
            
                                                                        
                            
            
                                    
            
            
                | 1198 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1199 | 1 |  | 		if( $apply_filter ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 1200 |  |  | 			/** | 
            
                                                                        
                            
            
                                    
            
            
                | 1201 |  |  | 			 * @filter `gravityview/configuration/fields` Filter the View fields' configuration array | 
            
                                                                        
                            
            
                                    
            
            
                | 1202 |  |  | 			 * @since 1.6.5 | 
            
                                                                        
                            
            
                                    
            
            
                | 1203 |  |  | 			 * | 
            
                                                                        
                            
            
                                    
            
            
                | 1204 |  |  | 			 * @param $fields array Multi-array of fields with first level being the field zones | 
            
                                                                        
                            
            
                                    
            
            
                | 1205 |  |  | 			 * @param $post_id int Post ID | 
            
                                                                        
                            
            
                                    
            
            
                | 1206 |  |  | 			 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 1207 | 1 |  | 			$fields = apply_filters( 'gravityview/configuration/fields', $fields, $post_id ); | 
            
                                                                        
                            
            
                                    
            
            
                | 1208 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 1209 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 1210 | 1 |  | 		return $fields; | 
            
                                                                        
                            
            
                                    
            
            
                | 1211 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1214 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1215 |  |  | 	 * Render dropdown (select) with the list of sortable fields from a form ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1216 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1217 |  |  | 	 * @access public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1218 |  |  | 	 * @param  int $formid Form ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1219 |  |  | 	 * @return string         html | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1220 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1221 |  |  | 	public static function get_sortable_fields( $formid, $current = '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1222 |  |  | 		$output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1224 |  |  | 		if ( empty( $formid ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1225 |  |  | 			return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1226 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1228 |  |  | 		$fields = self::get_sortable_fields_array( $formid ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1230 |  |  | 		if ( ! empty( $fields ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1232 |  |  | 			$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1233 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1234 |  |  | 			foreach ( $fields as $id => $field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1235 |  |  | 				if ( in_array( $field['type'], $blacklist_field_types ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1236 |  |  | 					continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1237 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1238 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1239 |  |  | 				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1240 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1241 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1243 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1244 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1246 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1247 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1248 |  |  | 	 * @param int $formid Gravity Forms form ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1249 |  |  | 	 * @param array $blacklist Field types to exclude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1250 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1251 |  |  | 	 * @since 1.8 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1252 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1253 |  |  | 	 * @todo Get all fields, check if sortable dynamically | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1254 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1255 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1256 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1257 |  |  | 	public static function get_sortable_fields_array( $formid, $blacklist = array( 'list', 'textarea' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1259 |  |  | 		// Get fields with sub-inputs and no parent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1260 |  |  | 		$fields = self::get_form_fields( $formid, true, false ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1261 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1262 |  |  | 		$date_created = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1263 |  |  | 			'date_created' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1264 |  |  | 				'type' => 'date_created', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1265 |  |  | 				'label' => __( 'Date Created', 'gravityview' ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1266 |  |  | 			), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1267 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1268 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1269 |  |  |         $fields = $date_created + $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1270 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1271 |  |  | 		$blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1273 |  |  | 		// TODO: Convert to using array_filter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1274 |  |  | 		foreach( $fields as $id => $field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1275 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1276 |  |  | 			if( in_array( $field['type'], $blacklist_field_types ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1277 |  |  | 				unset( $fields[ $id ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1278 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1279 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1281 |  |  |         /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1282 |  |  |          * @filter `gravityview/common/sortable_fields` Filter the sortable fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1283 |  |  |          * @since 1.12 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1284 |  |  |          * @param array $fields Sub-set of GF form fields that are sortable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1285 |  |  |          * @param int $formid The Gravity Forms form ID that the fields are from | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1286 |  |  |          */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1287 |  |  |         $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1288 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1289 |  |  | 		return $fields; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1290 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1292 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1293 |  |  | 	 * Returns the GF Form field type for a certain field(id) of a form | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1294 |  |  | 	 * @param  object $form     Gravity Forms form | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1295 |  |  | 	 * @param  mixed $field_id Field ID or Field array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1296 |  |  | 	 * @return string field type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1297 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1298 |  |  | 	public static function get_field_type( $form = null, $field_id = '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1299 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1300 |  |  | 		if ( ! empty( $field_id ) && ! is_array( $field_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1301 |  |  | 			$field = self::get_field( $form, $field_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1302 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1303 |  |  | 			$field = $field_id; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1304 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1305 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1306 |  |  | 		return class_exists( 'RGFormsModel' ) ? RGFormsModel::get_input_type( $field ) : ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1307 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1308 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1309 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1310 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1311 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1312 |  |  | 	 * Checks if the field type is a 'numeric' field type (e.g. to be used when sorting) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1313 |  |  | 	 * @param  int|array  $form  form ID or form array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1314 |  |  | 	 * @param  int|array  $field field key or field array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1315 |  |  | 	 * @return boolean | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1316 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1317 |  |  | 	public static function is_field_numeric(  $form = null, $field = '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1319 |  |  | 		if ( ! is_array( $form ) && ! is_array( $field ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1320 |  |  | 			$form = self::get_form( $form ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1321 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1323 |  |  | 		// If entry meta, it's a string. Otherwise, numeric | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1324 |  |  | 		if( ! is_numeric( $field ) && is_string( $field ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1325 |  |  | 			$type = $field; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1326 |  |  | 		} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1327 |  |  | 			$type = self::get_field_type( $form, $field ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1328 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1330 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1331 |  |  | 		 * @filter `gravityview/common/numeric_types` What types of fields are numeric? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1332 |  |  | 		 * @since 1.5.2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1333 |  |  | 		 * @param array $numeric_types Fields that are numeric. Default: `[ number, time ]` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1334 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1335 |  |  | 		$numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1337 |  |  | 		// Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1338 |  |  | 		if( $gv_field = GravityView_Fields::get( $type ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1339 |  |  | 			if( true === $gv_field->is_numeric ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1340 |  |  | 				$numeric_types[] = $gv_field->is_numeric; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1341 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1342 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1343 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1344 |  |  | 		$return = in_array( $type, $numeric_types ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1345 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1346 |  |  | 		return $return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1347 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1348 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1349 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1350 |  |  | 	 * Encrypt content using Javascript so that it's hidden when JS is disabled. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1351 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1352 |  |  | 	 * This is mostly used to hide email addresses from scraper bots. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1353 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1354 |  |  | 	 * @param string $content Content to encrypt | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1355 |  |  | 	 * @param string $message Message shown if Javascript is disabled | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1356 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1357 |  |  | 	 * @see  https://github.com/jnicol/standalone-phpenkoder StandalonePHPEnkoder on Github | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1358 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1359 |  |  | 	 * @since 1.7 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1360 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1361 |  |  | 	 * @return string Content, encrypted | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1362 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1363 |  |  | 	public static function js_encrypt( $content, $message = '' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1364 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1365 |  |  | 		$output = $content; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1366 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1367 |  |  | 		if ( ! class_exists( 'StandalonePHPEnkoder' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1368 |  |  | 			include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1369 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1370 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1371 |  |  | 		if ( class_exists( 'StandalonePHPEnkoder' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1372 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1373 |  |  | 			$enkoder = new StandalonePHPEnkoder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1374 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1375 |  |  | 			$message = empty( $message ) ? __( 'Email hidden; Javascript is required.', 'gravityview' ) : $message; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1377 |  |  | 			/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1378 |  |  | 			 * @filter `gravityview/phpenkoder/msg` Modify the message shown when Javascript is disabled and an encrypted email field is displayed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1379 |  |  | 			 * @since 1.7 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1380 |  |  | 			 * @param string $message Existing message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1381 |  |  | 			 * @param string $content Content to encrypt | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1382 |  |  | 			 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1383 |  |  | 			$enkoder->enkode_msg = apply_filters( 'gravityview/phpenkoder/msg', $message, $content ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1384 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1385 |  |  | 			$output = $enkoder->enkode( $content ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1386 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1387 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1388 |  |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1389 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1391 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1392 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1393 |  |  | 	 * Do the same than parse_str without max_input_vars limitation: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1394 |  |  | 	 * Parses $string as if it were the query string passed via a URL and sets variables in the current scope. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1395 |  |  | 	 * @param $string array string to parse (not altered like in the original parse_str(), use the second parameter!) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1396 |  |  | 	 * @param $result array  If the second parameter is present, variables are stored in this variable as array elements | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1397 |  |  | 	 * @return bool true or false if $string is an empty string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1398 |  |  | 	 * @since  1.5.3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1399 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1400 |  |  | 	 * @author rubo77 at https://gist.github.com/rubo77/6821632 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1401 |  |  | 	 **/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1402 |  |  | 	public static function gv_parse_str( $string, &$result ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1403 |  |  | 		if ( empty( $string ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1404 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1405 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1406 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1407 |  |  | 		$result = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1409 |  |  | 		// find the pairs "name=value" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1410 |  |  | 		$pairs = explode( '&', $string ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1411 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1412 |  |  | 		foreach ( $pairs as $pair ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1413 |  |  | 			// use the original parse_str() on each element | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1414 |  |  | 			parse_str( $pair, $params ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1415 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1416 |  |  | 			$k = key( $params ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1417 |  |  | 			if ( ! isset( $result[ $k ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1418 |  |  | 				$result += $params; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1419 |  |  | 			} elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1420 |  |  | 				$result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1421 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1422 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1423 |  |  | 		return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1424 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1426 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1427 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1428 |  |  | 	 * Generate an HTML anchor tag with a list of supported attributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1429 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1430 |  |  | 	 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a Supported attributes defined here | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1431 |  |  | 	 * @uses esc_url_raw() to sanitize $href | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1432 |  |  | 	 * @uses esc_attr() to sanitize $atts | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1433 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1434 |  |  | 	 * @since 1.6 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1435 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1436 |  |  | 	 * @param string $href URL of the link. Sanitized using `esc_url_raw()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1437 |  |  | 	 * @param string $anchor_text The text or HTML inside the anchor. This is not sanitized in the function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1438 |  |  | 	 * @param array|string $atts Attributes to be added to the anchor tag. Parsed by `wp_parse_args()`, sanitized using `esc_attr()` | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1439 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1440 |  |  | 	 * @return string HTML output of anchor link. If empty $href, returns NULL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1441 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1442 | 3 |  | 	public static function get_link_html( $href = '', $anchor_text = '', $atts = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1443 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1444 |  |  | 		// Supported attributes for anchor tags. HREF left out intentionally. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1445 |  |  | 		$allowed_atts = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1446 | 3 |  | 			'href' => null, // Will override the $href argument if set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1447 |  |  | 			'title' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1448 |  |  | 			'rel' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1449 |  |  | 			'id' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1450 |  |  | 			'class' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1451 |  |  | 			'target' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1452 |  |  | 			'style' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1454 |  |  | 			// Used by GravityView | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1455 |  |  | 			'data-viewid' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1456 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1457 |  |  | 			// Not standard | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1458 |  |  | 			'hreflang' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1459 |  |  | 			'type' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1460 |  |  | 			'tabindex' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1461 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1462 |  |  | 			// Deprecated HTML4 but still used | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1463 |  |  | 			'name' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1464 |  |  | 			'onclick' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1465 |  |  | 			'onchange' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1466 |  |  | 			'onkeyup' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1467 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1468 |  |  | 			// HTML5 only | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1469 |  |  | 			'download' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1470 |  |  | 			'media' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1471 |  |  | 			'ping' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1472 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1473 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1474 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1475 |  |  | 		 * @filter `gravityview/get_link/allowed_atts` Modify the attributes that are allowed to be used in generating links | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1476 |  |  | 		 * @param array $allowed_atts Array of attributes allowed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1477 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1478 | 3 |  | 		$allowed_atts = apply_filters( 'gravityview/get_link/allowed_atts', $allowed_atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1479 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1480 |  |  | 		// Make sure the attributes are formatted as array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1481 | 3 |  | 		$passed_atts = wp_parse_args( $atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1483 |  |  | 		// Make sure the allowed attributes are only the ones in the $allowed_atts list | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1484 | 3 |  | 		$final_atts = shortcode_atts( $allowed_atts, $passed_atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1485 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1486 |  |  | 		// Remove attributes with empty values | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1487 | 3 |  | 		$final_atts = array_filter( $final_atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1488 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1489 |  |  | 		// If the href wasn't passed as an attribute, use the value passed to the function | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1490 | 3 |  | 		if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1491 | 3 |  | 			$final_atts['href'] = $href; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1492 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1493 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1494 | 3 |  | 		$final_atts['href'] = esc_url_raw( $href ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1495 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1496 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1497 |  |  | 		 * Fix potential security issue with target=_blank | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1498 |  |  | 		 * @see https://dev.to/ben/the-targetblank-vulnerability-by-example | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1499 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1500 | 3 |  | 		if( '_blank' === rgar( $final_atts, 'target' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1501 |  |  | 			$final_atts['rel'] = trim( rgar( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1502 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1503 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1504 |  |  | 		// Sort the attributes alphabetically, to help testing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1505 | 3 |  | 		ksort( $final_atts ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1506 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1507 |  |  | 		// For each attribute, generate the code | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1508 | 3 |  | 		$output = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1509 | 3 |  | 		foreach ( $final_atts as $attr => $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1510 | 3 |  | 			$output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1511 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1512 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1513 | 3 |  | 		if( '' !== $output ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1514 | 3 |  | 			$output = '<a' . $output . '>' . $anchor_text . '</a>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1515 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1516 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1517 | 3 |  | 		return $output; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1518 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1519 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1520 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1521 |  |  | 	 * array_merge_recursive does indeed merge arrays, but it converts values with duplicate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1522 |  |  | 	 * keys to arrays rather than overwriting the value in the first array with the duplicate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1523 |  |  | 	 * value in the second array, as array_merge does. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1524 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1525 |  |  | 	 * @see http://php.net/manual/en/function.array-merge-recursive.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1526 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1527 |  |  | 	 * @since  1.5.3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1528 |  |  | 	 * @param array $array1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1529 |  |  | 	 * @param array $array2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1530 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1531 |  |  | 	 * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1532 |  |  | 	 * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1533 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1534 |  |  | 	public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1535 |  |  | 		$merged = $array1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1536 |  |  | 		foreach ( $array2 as $key => $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1537 |  |  | 			if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1538 |  |  | 				$merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1539 |  |  | 			} else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1540 |  |  | 				$merged[] = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1541 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1542 |  |  | 				$merged[ $key ] = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1543 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1544 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1545 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1546 |  |  | 		return $merged; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1547 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1548 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1549 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1550 |  |  | 	 * Get WordPress users with reasonable limits set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1551 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1552 |  |  | 	 * @param string $context Where are we using this information (e.g. change_entry_creator, search_widget ..) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1553 |  |  | 	 * @param array $args Arguments to modify the user query. See get_users() {@since 1.14} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1554 |  |  | 	 * @return array Array of WP_User objects. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1555 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1556 |  |  | 	public static function get_users( $context = 'change_entry_creator', $args = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1557 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1558 |  |  | 		$default_args = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1559 |  |  | 			'number' => 2000, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1560 |  |  | 			'orderby' => 'display_name', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1561 |  |  | 			'order' => 'ASC', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1562 |  |  | 			'fields' => array( 'ID', 'display_name', 'user_login', 'user_nicename' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1563 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1564 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1565 |  |  | 		// Merge in the passed arg | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1566 |  |  | 		$get_users_settings = wp_parse_args( $args, $default_args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1567 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1568 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1569 |  |  | 		 * @filter `gravityview/get_users/{$context}` There are issues with too many users using [get_users()](http://codex.wordpress.org/Function_Reference/get_users) where it breaks the select. We try to keep it at a reasonable number. \n | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1570 |  |  | 		 * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1571 |  |  | 		 * @param array $settings Settings array, with `number` key defining the # of users to display | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1572 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1573 |  |  | 		$get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1574 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1575 |  |  | 		return get_users( $get_users_settings ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1576 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1577 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1579 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1580 |  |  |      * Display updated/error notice | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1581 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1582 |  |  |      * @since 1.19.2 Added $cap and $object_id parameters | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1583 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1584 |  |  |      * @param string $notice text/HTML of notice | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1585 |  |  |      * @param string $class CSS class for notice (`updated` or `error`) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1586 |  |  |      * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1587 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1588 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1589 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1590 |  |  |     public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1591 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1592 |  |  |     	// If $cap is defined, only show notice if user has capability | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1593 |  |  |     	if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1594 |  |  |     		return ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1595 |  |  | 	    } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1596 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1597 |  |  |         return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1598 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1599 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1600 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1601 |  |  | 	 * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1602 |  |  | 	 * @since 1.16.5 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1603 |  |  | 	 * @param string $string Input string to decode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1604 |  |  | 	 * @return string $string Output string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1605 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1606 |  |  | 	public static function decode_shortcodes( $string ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1607 |  |  | 		$replace = array( '[', ']', '"' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1608 |  |  | 		$find = array( '[', ']', '"' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1609 |  |  | 		$string = str_replace( $find, $replace, $string ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1610 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1611 |  |  | 		return $string; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1612 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1613 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1614 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1615 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1616 |  |  | 	 * Send email using GFCommon::send_email() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1617 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1618 |  |  | 	 * @since 1.17 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1619 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1620 |  |  | 	 * @see GFCommon::send_email This just makes the method public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1621 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1622 |  |  | 	 * @param string $from               Sender address (required) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1623 |  |  | 	 * @param string $to                 Recipient address (required) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1624 |  |  | 	 * @param string $bcc                BCC recipients (required) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1625 |  |  | 	 * @param string $reply_to           Reply-to address (required) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1626 |  |  | 	 * @param string $subject            Subject line (required) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1627 |  |  | 	 * @param string $message            Message body (required) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1628 |  |  | 	 * @param string $from_name          Displayed name of the sender | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1629 |  |  | 	 * @param string $message_format     If "html", sent text as `text/html`. Otherwise, `text/plain`. Default: "html". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1630 |  |  | 	 * @param string|array $attachments  Optional. Files to attach. {@see wp_mail()} for usage. Default: "". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1631 |  |  | 	 * @param array|false $entry         Gravity Forms entry array, related to the email. Default: false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1632 |  |  | 	 * @param array|false $notification  Gravity Forms notification that triggered the email. {@see GFCommon::send_notification}. Default:false. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1633 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1634 |  |  | 	public static function send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '', $entry = false, $notification = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1635 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1636 |  |  | 		$SendEmail = new ReflectionMethod( 'GFCommon', 'send_email' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1637 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1638 |  |  | 		// It was private; let's make it public | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1639 |  |  | 		$SendEmail->setAccessible( true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1640 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1641 |  |  | 		// Required: $from, $to, $bcc, $replyTo, $subject, $message | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1642 |  |  | 		// Optional: $from_name, $message_format, $attachments, $lead, $notification | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1643 |  |  | 		$SendEmail->invoke( new GFCommon, $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, $attachments, $entry, $notification ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1644 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1645 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1646 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1647 |  |  | } //end class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1648 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1649 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1650 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1651 |  |  |  * Generate an HTML anchor tag with a list of supported attributes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1652 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1653 |  |  |  * @see GVCommon::get_link_html() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1654 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1655 |  |  |  * @since 1.6 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1656 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1657 |  |  |  * @param string $href URL of the link. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1658 |  |  |  * @param string $anchor_text The text or HTML inside the anchor. This is not sanitized in the function. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1659 |  |  |  * @param array|string $atts Attributes to be added to the anchor tag | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1660 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1661 |  |  |  * @return string HTML output of anchor link. If empty $href, returns NULL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1662 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1663 |  |  | function gravityview_get_link( $href = '', $anchor_text = '', $atts = array() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1664 | 2 |  | 	return GVCommon::get_link_html( $href, $anchor_text, $atts ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1665 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 1666 |  |  |  | 
            
                        
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.