Completed
Branch BUG-11025-attendee-fullname (c9e1fb)
by
unknown
85:45 queued 74:33
created
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.014');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.47.rc.014');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 2 patches
Indentation   +665 added lines, -665 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -23,670 +23,670 @@  discard block
 block discarded – undo
23 23
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee
24 24
 {
25 25
 
26
-    /**
27
-     * Sets some dynamic defaults
28
-     *
29
-     * @param array  $fieldValues
30
-     * @param bool   $bydb
31
-     * @param string $timezone
32
-     * @param array  $date_formats
33
-     */
34
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35
-    {
36
-        if (! isset($fieldValues['ATT_full_name'])) {
37
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
38
-            $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
-            $fieldValues['ATT_full_name'] = $fname . $lname;
40
-        }
41
-        if (! isset($fieldValues['ATT_slug'])) {
42
-            //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44
-        }
45
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47
-        }
48
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
49
-    }
50
-
51
-
52
-    /**
53
-     * @param array  $props_n_values          incoming values
54
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
55
-     *                                        used.)
56
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
57
-     *                                        date_format and the second value is the time format
58
-     * @return EE_Attendee
59
-     */
60
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
61
-    {
62
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
63
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
64
-    }
65
-
66
-
67
-    /**
68
-     * @param array  $props_n_values  incoming values from the database
69
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
70
-     *                                the website will be used.
71
-     * @return EE_Attendee
72
-     */
73
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
74
-    {
75
-        return new self($props_n_values, true, $timezone);
76
-    }
77
-
78
-
79
-    /**
80
-     *        Set Attendee First Name
81
-     *
82
-     * @access        public
83
-     * @param string $fname
84
-     */
85
-    public function set_fname($fname = '')
86
-    {
87
-        $this->set('ATT_fname', $fname);
88
-    }
89
-
90
-
91
-    /**
92
-     *        Set Attendee Last Name
93
-     *
94
-     * @access        public
95
-     * @param string $lname
96
-     */
97
-    public function set_lname($lname = '')
98
-    {
99
-        $this->set('ATT_lname', $lname);
100
-    }
101
-
102
-
103
-    /**
104
-     *        Set Attendee Address
105
-     *
106
-     * @access        public
107
-     * @param string $address
108
-     */
109
-    public function set_address($address = '')
110
-    {
111
-        $this->set('ATT_address', $address);
112
-    }
113
-
114
-
115
-    /**
116
-     *        Set Attendee Address2
117
-     *
118
-     * @access        public
119
-     * @param        string $address2
120
-     */
121
-    public function set_address2($address2 = '')
122
-    {
123
-        $this->set('ATT_address2', $address2);
124
-    }
125
-
126
-
127
-    /**
128
-     *        Set Attendee City
129
-     *
130
-     * @access        public
131
-     * @param        string $city
132
-     */
133
-    public function set_city($city = '')
134
-    {
135
-        $this->set('ATT_city', $city);
136
-    }
137
-
138
-
139
-    /**
140
-     *        Set Attendee State ID
141
-     *
142
-     * @access        public
143
-     * @param        int $STA_ID
144
-     */
145
-    public function set_state($STA_ID = 0)
146
-    {
147
-        $this->set('STA_ID', $STA_ID);
148
-    }
149
-
150
-
151
-    /**
152
-     *        Set Attendee Country ISO Code
153
-     *
154
-     * @access        public
155
-     * @param        string $CNT_ISO
156
-     */
157
-    public function set_country($CNT_ISO = '')
158
-    {
159
-        $this->set('CNT_ISO', $CNT_ISO);
160
-    }
161
-
162
-
163
-    /**
164
-     *        Set Attendee Zip/Postal Code
165
-     *
166
-     * @access        public
167
-     * @param        string $zip
168
-     */
169
-    public function set_zip($zip = '')
170
-    {
171
-        $this->set('ATT_zip', $zip);
172
-    }
173
-
174
-
175
-    /**
176
-     *        Set Attendee Email Address
177
-     *
178
-     * @access        public
179
-     * @param        string $email
180
-     */
181
-    public function set_email($email = '')
182
-    {
183
-        $this->set('ATT_email', $email);
184
-    }
185
-
186
-
187
-    /**
188
-     *        Set Attendee Phone
189
-     *
190
-     * @access        public
191
-     * @param        string $phone
192
-     */
193
-    public function set_phone($phone = '')
194
-    {
195
-        $this->set('ATT_phone', $phone);
196
-    }
197
-
198
-
199
-    /**
200
-     *        set deleted
201
-     *
202
-     * @access        public
203
-     * @param        bool $ATT_deleted
204
-     */
205
-    public function set_deleted($ATT_deleted = false)
206
-    {
207
-        $this->set('ATT_deleted', $ATT_deleted);
208
-    }
209
-
210
-
211
-    /**
212
-     * Returns the value for the post_author id saved with the cpt
213
-     *
214
-     * @since 4.5.0
215
-     * @return int
216
-     */
217
-    public function wp_user()
218
-    {
219
-        return $this->get('ATT_author');
220
-    }
221
-
222
-
223
-    /**
224
-     *        get Attendee First Name
225
-     *
226
-     * @access        public
227
-     * @return string
228
-     */
229
-    public function fname()
230
-    {
231
-        return $this->get('ATT_fname');
232
-    }
233
-
234
-
235
-    /**
236
-     * echoes out the attendee's first name
237
-     *
238
-     * @return void
239
-     */
240
-    public function e_full_name()
241
-    {
242
-        echo $this->full_name();
243
-    }
244
-
245
-
246
-    /**
247
-     * Returns the first and last name concatenated together with a space.
248
-     *
249
-     * @param bool $apply_html_entities
250
-     * @return string
251
-     */
252
-    public function full_name($apply_html_entities = false)
253
-    {
254
-        $full_name = array(
255
-            $this->fname(),
256
-            $this->lname()
257
-        );
258
-        $full_name = array_filter($full_name);
259
-        $full_name = implode(' ', $full_name);
260
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
261
-    }
262
-
263
-
264
-    /**
265
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
266
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
267
-     * attendee.
268
-     *
269
-     * @param bool $apply_html_entities
270
-     * @return string
271
-     */
272
-    public function ATT_full_name($apply_html_entities = false)
273
-    {
274
-        return $apply_html_entities
275
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
276
-            : $this->get('ATT_full_name');
277
-    }
278
-
279
-
280
-    /**
281
-     *        get Attendee Last Name
282
-     *
283
-     * @access        public
284
-     * @return string
285
-     */
286
-    public function lname()
287
-    {
288
-        return $this->get('ATT_lname');
289
-    }
290
-
291
-
292
-    /**
293
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
294
-     *
295
-     * @return array numerically indexed, with each part of the address that is known.
296
-     * Eg, if the user only responded to state and country,
297
-     * it would be array(0=>'Alabama',1=>'USA')
298
-     * @return array
299
-     */
300
-    public function full_address_as_array()
301
-    {
302
-        $full_address_array     = array();
303
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
304
-        foreach ($initial_address_fields as $address_field_name) {
305
-            $address_fields_value = $this->get($address_field_name);
306
-            if (! empty($address_fields_value)) {
307
-                $full_address_array[] = $address_fields_value;
308
-            }
309
-        }
310
-        //now handle state and country
311
-        $state_obj = $this->state_obj();
312
-        if (! empty($state_obj)) {
313
-            $full_address_array[] = $state_obj->name();
314
-        }
315
-        $country_obj = $this->country_obj();
316
-        if (! empty($country_obj)) {
317
-            $full_address_array[] = $country_obj->name();
318
-        }
319
-        //lastly get the xip
320
-        $zip_value = $this->zip();
321
-        if (! empty($zip_value)) {
322
-            $full_address_array[] = $zip_value;
323
-        }
324
-        return $full_address_array;
325
-    }
326
-
327
-
328
-    /**
329
-     *        get Attendee Address
330
-     *
331
-     * @return string
332
-     */
333
-    public function address()
334
-    {
335
-        return $this->get('ATT_address');
336
-    }
337
-
338
-
339
-    /**
340
-     *        get Attendee Address2
341
-     *
342
-     * @return string
343
-     */
344
-    public function address2()
345
-    {
346
-        return $this->get('ATT_address2');
347
-    }
348
-
349
-
350
-    /**
351
-     *        get Attendee City
352
-     *
353
-     * @return string
354
-     */
355
-    public function city()
356
-    {
357
-        return $this->get('ATT_city');
358
-    }
359
-
360
-
361
-    /**
362
-     *        get Attendee State ID
363
-     *
364
-     * @return string
365
-     */
366
-    public function state_ID()
367
-    {
368
-        return $this->get('STA_ID');
369
-    }
370
-
371
-
372
-    /**
373
-     * @return string
374
-     */
375
-    public function state_abbrev()
376
-    {
377
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
378
-    }
379
-
380
-
381
-    /**
382
-     * Gets the state set to this attendee
383
-     *
384
-     * @return EE_State
385
-     */
386
-    public function state_obj()
387
-    {
388
-        return $this->get_first_related('State');
389
-    }
390
-
391
-
392
-    /**
393
-     * Returns the state's name, otherwise 'Unknown'
394
-     *
395
-     * @return string
396
-     */
397
-    public function state_name()
398
-    {
399
-        if ($this->state_obj()) {
400
-            return $this->state_obj()->name();
401
-        } else {
402
-            return '';
403
-        }
404
-    }
405
-
406
-
407
-    /**
408
-     * either displays the state abbreviation or the state name, as determined
409
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
410
-     * defaults to abbreviation
411
-     *
412
-     * @return string
413
-     */
414
-    public function state()
415
-    {
416
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
417
-            return $this->state_abbrev();
418
-        } else {
419
-            return $this->state_name();
420
-        }
421
-    }
422
-
423
-
424
-    /**
425
-     *    get Attendee Country ISO Code
426
-     *
427
-     * @return string
428
-     */
429
-    public function country_ID()
430
-    {
431
-        return $this->get('CNT_ISO');
432
-    }
433
-
434
-
435
-    /**
436
-     * Gets country set for this attendee
437
-     *
438
-     * @return EE_Country
439
-     */
440
-    public function country_obj()
441
-    {
442
-        return $this->get_first_related('Country');
443
-    }
444
-
445
-
446
-    /**
447
-     * Returns the country's name if known, otherwise 'Unknown'
448
-     *
449
-     * @return string
450
-     */
451
-    public function country_name()
452
-    {
453
-        if ($this->country_obj()) {
454
-            return $this->country_obj()->name();
455
-        } else {
456
-            return '';
457
-        }
458
-    }
459
-
460
-
461
-    /**
462
-     * either displays the country ISO2 code or the country name, as determined
463
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
464
-     * defaults to abbreviation
465
-     *
466
-     * @return string
467
-     */
468
-    public function country()
469
-    {
470
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
471
-            return $this->country_ID();
472
-        } else {
473
-            return $this->country_name();
474
-        }
475
-    }
476
-
477
-
478
-    /**
479
-     *        get Attendee Zip/Postal Code
480
-     *
481
-     * @return string
482
-     */
483
-    public function zip()
484
-    {
485
-        return $this->get('ATT_zip');
486
-    }
487
-
488
-
489
-    /**
490
-     *        get Attendee Email Address
491
-     *
492
-     * @return string
493
-     */
494
-    public function email()
495
-    {
496
-        return $this->get('ATT_email');
497
-    }
498
-
499
-
500
-    /**
501
-     *        get Attendee Phone #
502
-     *
503
-     * @return string
504
-     */
505
-    public function phone()
506
-    {
507
-        return $this->get('ATT_phone');
508
-    }
509
-
510
-
511
-    /**
512
-     *    get deleted
513
-     *
514
-     * @return        bool
515
-     */
516
-    public function deleted()
517
-    {
518
-        return $this->get('ATT_deleted');
519
-    }
520
-
521
-
522
-    /**
523
-     * Gets registrations of this attendee
524
-     *
525
-     * @param array $query_params
526
-     * @return EE_Registration[]
527
-     */
528
-    public function get_registrations($query_params = array())
529
-    {
530
-        return $this->get_many_related('Registration', $query_params);
531
-    }
532
-
533
-
534
-    /**
535
-     * Gets the most recent registration of this attendee
536
-     *
537
-     * @return EE_Registration
538
-     */
539
-    public function get_most_recent_registration()
540
-    {
541
-        return $this->get_first_related('Registration',
542
-            array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
543
-    }
544
-
545
-
546
-    /**
547
-     * Gets the most recent registration for this attend at this event
548
-     *
549
-     * @param int $event_id
550
-     * @return EE_Registration
551
-     */
552
-    public function get_most_recent_registration_for_event($event_id)
553
-    {
554
-        return $this->get_first_related('Registration',
555
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
556
-    }
557
-
558
-
559
-    /**
560
-     * returns any events attached to this attendee ($_Event property);
561
-     *
562
-     * @return array
563
-     */
564
-    public function events()
565
-    {
566
-        return $this->get_many_related('Event');
567
-    }
568
-
569
-
570
-    /**
571
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
572
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
573
-     * used to save the billing info
574
-     *
575
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
576
-     * @return EE_Form_Section_Proper|null
577
-     */
578
-    public function billing_info_for_payment_method($payment_method)
579
-    {
580
-        $pm_type = $payment_method->type_obj();
581
-        if (! $pm_type instanceof EE_PMT_Base) {
582
-            return null;
583
-        }
584
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
585
-        if (! $billing_info) {
586
-            return null;
587
-        }
588
-        $billing_form = $pm_type->billing_form();
589
-        if ($billing_form instanceof EE_Form_Section_Proper) {
590
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
591
-        }
592
-        return $billing_form;
593
-    }
594
-
595
-
596
-    /**
597
-     * Gets the postmeta key that holds this attendee's billing info for the
598
-     * specified payment method
599
-     *
600
-     * @param EE_Payment_Method $payment_method
601
-     * @return string
602
-     */
603
-    public function get_billing_info_postmeta_name($payment_method)
604
-    {
605
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
606
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
607
-        } else {
608
-            return null;
609
-        }
610
-    }
611
-
612
-
613
-    /**
614
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
615
-     * retrieve it
616
-     *
617
-     * @param EE_Billing_Attendee_Info_Form $billing_form
618
-     * @param EE_Payment_Method             $payment_method
619
-     * @return boolean
620
-     */
621
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
622
-    {
623
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
624
-            EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
625
-            return false;
626
-        }
627
-        $billing_form->clean_sensitive_data();
628
-        return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method),
629
-            $billing_form->input_values(true));
630
-    }
631
-
632
-
633
-    /**
634
-     * Return the link to the admin details for the object.
635
-     *
636
-     * @return string
637
-     */
638
-    public function get_admin_details_link()
639
-    {
640
-        return $this->get_admin_edit_link();
641
-    }
642
-
643
-
644
-    /**
645
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
646
-     *
647
-     * @return string
648
-     */
649
-    public function get_admin_edit_link()
650
-    {
651
-        EE_Registry::instance()->load_helper('URL');
652
-        return EEH_URL::add_query_args_and_nonce(
653
-            array(
654
-                'page'   => 'espresso_registrations',
655
-                'action' => 'edit_attendee',
656
-                'post'   => $this->ID(),
657
-            ),
658
-            admin_url('admin.php')
659
-        );
660
-    }
661
-
662
-
663
-    /**
664
-     * Returns the link to a settings page for the object.
665
-     *
666
-     * @return string
667
-     */
668
-    public function get_admin_settings_link()
669
-    {
670
-        return $this->get_admin_edit_link();
671
-    }
672
-
673
-
674
-    /**
675
-     * Returns the link to the "overview" for the object (typically the "list table" view).
676
-     *
677
-     * @return string
678
-     */
679
-    public function get_admin_overview_link()
680
-    {
681
-        EE_Registry::instance()->load_helper('URL');
682
-        return EEH_URL::add_query_args_and_nonce(
683
-            array(
684
-                'page'   => 'espresso_registrations',
685
-                'action' => 'contact_list',
686
-            ),
687
-            admin_url('admin.php')
688
-        );
689
-    }
26
+	/**
27
+	 * Sets some dynamic defaults
28
+	 *
29
+	 * @param array  $fieldValues
30
+	 * @param bool   $bydb
31
+	 * @param string $timezone
32
+	 * @param array  $date_formats
33
+	 */
34
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35
+	{
36
+		if (! isset($fieldValues['ATT_full_name'])) {
37
+			$fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
38
+			$lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
+			$fieldValues['ATT_full_name'] = $fname . $lname;
40
+		}
41
+		if (! isset($fieldValues['ATT_slug'])) {
42
+			//			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44
+		}
45
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47
+		}
48
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
49
+	}
50
+
51
+
52
+	/**
53
+	 * @param array  $props_n_values          incoming values
54
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
55
+	 *                                        used.)
56
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
57
+	 *                                        date_format and the second value is the time format
58
+	 * @return EE_Attendee
59
+	 */
60
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
61
+	{
62
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
63
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
64
+	}
65
+
66
+
67
+	/**
68
+	 * @param array  $props_n_values  incoming values from the database
69
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
70
+	 *                                the website will be used.
71
+	 * @return EE_Attendee
72
+	 */
73
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
74
+	{
75
+		return new self($props_n_values, true, $timezone);
76
+	}
77
+
78
+
79
+	/**
80
+	 *        Set Attendee First Name
81
+	 *
82
+	 * @access        public
83
+	 * @param string $fname
84
+	 */
85
+	public function set_fname($fname = '')
86
+	{
87
+		$this->set('ATT_fname', $fname);
88
+	}
89
+
90
+
91
+	/**
92
+	 *        Set Attendee Last Name
93
+	 *
94
+	 * @access        public
95
+	 * @param string $lname
96
+	 */
97
+	public function set_lname($lname = '')
98
+	{
99
+		$this->set('ATT_lname', $lname);
100
+	}
101
+
102
+
103
+	/**
104
+	 *        Set Attendee Address
105
+	 *
106
+	 * @access        public
107
+	 * @param string $address
108
+	 */
109
+	public function set_address($address = '')
110
+	{
111
+		$this->set('ATT_address', $address);
112
+	}
113
+
114
+
115
+	/**
116
+	 *        Set Attendee Address2
117
+	 *
118
+	 * @access        public
119
+	 * @param        string $address2
120
+	 */
121
+	public function set_address2($address2 = '')
122
+	{
123
+		$this->set('ATT_address2', $address2);
124
+	}
125
+
126
+
127
+	/**
128
+	 *        Set Attendee City
129
+	 *
130
+	 * @access        public
131
+	 * @param        string $city
132
+	 */
133
+	public function set_city($city = '')
134
+	{
135
+		$this->set('ATT_city', $city);
136
+	}
137
+
138
+
139
+	/**
140
+	 *        Set Attendee State ID
141
+	 *
142
+	 * @access        public
143
+	 * @param        int $STA_ID
144
+	 */
145
+	public function set_state($STA_ID = 0)
146
+	{
147
+		$this->set('STA_ID', $STA_ID);
148
+	}
149
+
150
+
151
+	/**
152
+	 *        Set Attendee Country ISO Code
153
+	 *
154
+	 * @access        public
155
+	 * @param        string $CNT_ISO
156
+	 */
157
+	public function set_country($CNT_ISO = '')
158
+	{
159
+		$this->set('CNT_ISO', $CNT_ISO);
160
+	}
161
+
162
+
163
+	/**
164
+	 *        Set Attendee Zip/Postal Code
165
+	 *
166
+	 * @access        public
167
+	 * @param        string $zip
168
+	 */
169
+	public function set_zip($zip = '')
170
+	{
171
+		$this->set('ATT_zip', $zip);
172
+	}
173
+
174
+
175
+	/**
176
+	 *        Set Attendee Email Address
177
+	 *
178
+	 * @access        public
179
+	 * @param        string $email
180
+	 */
181
+	public function set_email($email = '')
182
+	{
183
+		$this->set('ATT_email', $email);
184
+	}
185
+
186
+
187
+	/**
188
+	 *        Set Attendee Phone
189
+	 *
190
+	 * @access        public
191
+	 * @param        string $phone
192
+	 */
193
+	public function set_phone($phone = '')
194
+	{
195
+		$this->set('ATT_phone', $phone);
196
+	}
197
+
198
+
199
+	/**
200
+	 *        set deleted
201
+	 *
202
+	 * @access        public
203
+	 * @param        bool $ATT_deleted
204
+	 */
205
+	public function set_deleted($ATT_deleted = false)
206
+	{
207
+		$this->set('ATT_deleted', $ATT_deleted);
208
+	}
209
+
210
+
211
+	/**
212
+	 * Returns the value for the post_author id saved with the cpt
213
+	 *
214
+	 * @since 4.5.0
215
+	 * @return int
216
+	 */
217
+	public function wp_user()
218
+	{
219
+		return $this->get('ATT_author');
220
+	}
221
+
222
+
223
+	/**
224
+	 *        get Attendee First Name
225
+	 *
226
+	 * @access        public
227
+	 * @return string
228
+	 */
229
+	public function fname()
230
+	{
231
+		return $this->get('ATT_fname');
232
+	}
233
+
234
+
235
+	/**
236
+	 * echoes out the attendee's first name
237
+	 *
238
+	 * @return void
239
+	 */
240
+	public function e_full_name()
241
+	{
242
+		echo $this->full_name();
243
+	}
244
+
245
+
246
+	/**
247
+	 * Returns the first and last name concatenated together with a space.
248
+	 *
249
+	 * @param bool $apply_html_entities
250
+	 * @return string
251
+	 */
252
+	public function full_name($apply_html_entities = false)
253
+	{
254
+		$full_name = array(
255
+			$this->fname(),
256
+			$this->lname()
257
+		);
258
+		$full_name = array_filter($full_name);
259
+		$full_name = implode(' ', $full_name);
260
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
261
+	}
262
+
263
+
264
+	/**
265
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
266
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
267
+	 * attendee.
268
+	 *
269
+	 * @param bool $apply_html_entities
270
+	 * @return string
271
+	 */
272
+	public function ATT_full_name($apply_html_entities = false)
273
+	{
274
+		return $apply_html_entities
275
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
276
+			: $this->get('ATT_full_name');
277
+	}
278
+
279
+
280
+	/**
281
+	 *        get Attendee Last Name
282
+	 *
283
+	 * @access        public
284
+	 * @return string
285
+	 */
286
+	public function lname()
287
+	{
288
+		return $this->get('ATT_lname');
289
+	}
290
+
291
+
292
+	/**
293
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
294
+	 *
295
+	 * @return array numerically indexed, with each part of the address that is known.
296
+	 * Eg, if the user only responded to state and country,
297
+	 * it would be array(0=>'Alabama',1=>'USA')
298
+	 * @return array
299
+	 */
300
+	public function full_address_as_array()
301
+	{
302
+		$full_address_array     = array();
303
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
304
+		foreach ($initial_address_fields as $address_field_name) {
305
+			$address_fields_value = $this->get($address_field_name);
306
+			if (! empty($address_fields_value)) {
307
+				$full_address_array[] = $address_fields_value;
308
+			}
309
+		}
310
+		//now handle state and country
311
+		$state_obj = $this->state_obj();
312
+		if (! empty($state_obj)) {
313
+			$full_address_array[] = $state_obj->name();
314
+		}
315
+		$country_obj = $this->country_obj();
316
+		if (! empty($country_obj)) {
317
+			$full_address_array[] = $country_obj->name();
318
+		}
319
+		//lastly get the xip
320
+		$zip_value = $this->zip();
321
+		if (! empty($zip_value)) {
322
+			$full_address_array[] = $zip_value;
323
+		}
324
+		return $full_address_array;
325
+	}
326
+
327
+
328
+	/**
329
+	 *        get Attendee Address
330
+	 *
331
+	 * @return string
332
+	 */
333
+	public function address()
334
+	{
335
+		return $this->get('ATT_address');
336
+	}
337
+
338
+
339
+	/**
340
+	 *        get Attendee Address2
341
+	 *
342
+	 * @return string
343
+	 */
344
+	public function address2()
345
+	{
346
+		return $this->get('ATT_address2');
347
+	}
348
+
349
+
350
+	/**
351
+	 *        get Attendee City
352
+	 *
353
+	 * @return string
354
+	 */
355
+	public function city()
356
+	{
357
+		return $this->get('ATT_city');
358
+	}
359
+
360
+
361
+	/**
362
+	 *        get Attendee State ID
363
+	 *
364
+	 * @return string
365
+	 */
366
+	public function state_ID()
367
+	{
368
+		return $this->get('STA_ID');
369
+	}
370
+
371
+
372
+	/**
373
+	 * @return string
374
+	 */
375
+	public function state_abbrev()
376
+	{
377
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
378
+	}
379
+
380
+
381
+	/**
382
+	 * Gets the state set to this attendee
383
+	 *
384
+	 * @return EE_State
385
+	 */
386
+	public function state_obj()
387
+	{
388
+		return $this->get_first_related('State');
389
+	}
390
+
391
+
392
+	/**
393
+	 * Returns the state's name, otherwise 'Unknown'
394
+	 *
395
+	 * @return string
396
+	 */
397
+	public function state_name()
398
+	{
399
+		if ($this->state_obj()) {
400
+			return $this->state_obj()->name();
401
+		} else {
402
+			return '';
403
+		}
404
+	}
405
+
406
+
407
+	/**
408
+	 * either displays the state abbreviation or the state name, as determined
409
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
410
+	 * defaults to abbreviation
411
+	 *
412
+	 * @return string
413
+	 */
414
+	public function state()
415
+	{
416
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
417
+			return $this->state_abbrev();
418
+		} else {
419
+			return $this->state_name();
420
+		}
421
+	}
422
+
423
+
424
+	/**
425
+	 *    get Attendee Country ISO Code
426
+	 *
427
+	 * @return string
428
+	 */
429
+	public function country_ID()
430
+	{
431
+		return $this->get('CNT_ISO');
432
+	}
433
+
434
+
435
+	/**
436
+	 * Gets country set for this attendee
437
+	 *
438
+	 * @return EE_Country
439
+	 */
440
+	public function country_obj()
441
+	{
442
+		return $this->get_first_related('Country');
443
+	}
444
+
445
+
446
+	/**
447
+	 * Returns the country's name if known, otherwise 'Unknown'
448
+	 *
449
+	 * @return string
450
+	 */
451
+	public function country_name()
452
+	{
453
+		if ($this->country_obj()) {
454
+			return $this->country_obj()->name();
455
+		} else {
456
+			return '';
457
+		}
458
+	}
459
+
460
+
461
+	/**
462
+	 * either displays the country ISO2 code or the country name, as determined
463
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
464
+	 * defaults to abbreviation
465
+	 *
466
+	 * @return string
467
+	 */
468
+	public function country()
469
+	{
470
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
471
+			return $this->country_ID();
472
+		} else {
473
+			return $this->country_name();
474
+		}
475
+	}
476
+
477
+
478
+	/**
479
+	 *        get Attendee Zip/Postal Code
480
+	 *
481
+	 * @return string
482
+	 */
483
+	public function zip()
484
+	{
485
+		return $this->get('ATT_zip');
486
+	}
487
+
488
+
489
+	/**
490
+	 *        get Attendee Email Address
491
+	 *
492
+	 * @return string
493
+	 */
494
+	public function email()
495
+	{
496
+		return $this->get('ATT_email');
497
+	}
498
+
499
+
500
+	/**
501
+	 *        get Attendee Phone #
502
+	 *
503
+	 * @return string
504
+	 */
505
+	public function phone()
506
+	{
507
+		return $this->get('ATT_phone');
508
+	}
509
+
510
+
511
+	/**
512
+	 *    get deleted
513
+	 *
514
+	 * @return        bool
515
+	 */
516
+	public function deleted()
517
+	{
518
+		return $this->get('ATT_deleted');
519
+	}
520
+
521
+
522
+	/**
523
+	 * Gets registrations of this attendee
524
+	 *
525
+	 * @param array $query_params
526
+	 * @return EE_Registration[]
527
+	 */
528
+	public function get_registrations($query_params = array())
529
+	{
530
+		return $this->get_many_related('Registration', $query_params);
531
+	}
532
+
533
+
534
+	/**
535
+	 * Gets the most recent registration of this attendee
536
+	 *
537
+	 * @return EE_Registration
538
+	 */
539
+	public function get_most_recent_registration()
540
+	{
541
+		return $this->get_first_related('Registration',
542
+			array('order_by' => array('REG_date' => 'DESC'))); //null, 'REG_date', 'DESC', '=', 'OBJECT_K');
543
+	}
544
+
545
+
546
+	/**
547
+	 * Gets the most recent registration for this attend at this event
548
+	 *
549
+	 * @param int $event_id
550
+	 * @return EE_Registration
551
+	 */
552
+	public function get_most_recent_registration_for_event($event_id)
553
+	{
554
+		return $this->get_first_related('Registration',
555
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
556
+	}
557
+
558
+
559
+	/**
560
+	 * returns any events attached to this attendee ($_Event property);
561
+	 *
562
+	 * @return array
563
+	 */
564
+	public function events()
565
+	{
566
+		return $this->get_many_related('Event');
567
+	}
568
+
569
+
570
+	/**
571
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
572
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
573
+	 * used to save the billing info
574
+	 *
575
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
576
+	 * @return EE_Form_Section_Proper|null
577
+	 */
578
+	public function billing_info_for_payment_method($payment_method)
579
+	{
580
+		$pm_type = $payment_method->type_obj();
581
+		if (! $pm_type instanceof EE_PMT_Base) {
582
+			return null;
583
+		}
584
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
585
+		if (! $billing_info) {
586
+			return null;
587
+		}
588
+		$billing_form = $pm_type->billing_form();
589
+		if ($billing_form instanceof EE_Form_Section_Proper) {
590
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
591
+		}
592
+		return $billing_form;
593
+	}
594
+
595
+
596
+	/**
597
+	 * Gets the postmeta key that holds this attendee's billing info for the
598
+	 * specified payment method
599
+	 *
600
+	 * @param EE_Payment_Method $payment_method
601
+	 * @return string
602
+	 */
603
+	public function get_billing_info_postmeta_name($payment_method)
604
+	{
605
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
606
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
607
+		} else {
608
+			return null;
609
+		}
610
+	}
611
+
612
+
613
+	/**
614
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
615
+	 * retrieve it
616
+	 *
617
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
618
+	 * @param EE_Payment_Method             $payment_method
619
+	 * @return boolean
620
+	 */
621
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
622
+	{
623
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
624
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
625
+			return false;
626
+		}
627
+		$billing_form->clean_sensitive_data();
628
+		return update_post_meta($this->ID(), $this->get_billing_info_postmeta_name($payment_method),
629
+			$billing_form->input_values(true));
630
+	}
631
+
632
+
633
+	/**
634
+	 * Return the link to the admin details for the object.
635
+	 *
636
+	 * @return string
637
+	 */
638
+	public function get_admin_details_link()
639
+	{
640
+		return $this->get_admin_edit_link();
641
+	}
642
+
643
+
644
+	/**
645
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
646
+	 *
647
+	 * @return string
648
+	 */
649
+	public function get_admin_edit_link()
650
+	{
651
+		EE_Registry::instance()->load_helper('URL');
652
+		return EEH_URL::add_query_args_and_nonce(
653
+			array(
654
+				'page'   => 'espresso_registrations',
655
+				'action' => 'edit_attendee',
656
+				'post'   => $this->ID(),
657
+			),
658
+			admin_url('admin.php')
659
+		);
660
+	}
661
+
662
+
663
+	/**
664
+	 * Returns the link to a settings page for the object.
665
+	 *
666
+	 * @return string
667
+	 */
668
+	public function get_admin_settings_link()
669
+	{
670
+		return $this->get_admin_edit_link();
671
+	}
672
+
673
+
674
+	/**
675
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
676
+	 *
677
+	 * @return string
678
+	 */
679
+	public function get_admin_overview_link()
680
+	{
681
+		EE_Registry::instance()->load_helper('URL');
682
+		return EEH_URL::add_query_args_and_nonce(
683
+			array(
684
+				'page'   => 'espresso_registrations',
685
+				'action' => 'contact_list',
686
+			),
687
+			admin_url('admin.php')
688
+		);
689
+	}
690 690
 
691 691
 
692 692
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 /**
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
      */
34 34
     protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
35 35
     {
36
-        if (! isset($fieldValues['ATT_full_name'])) {
37
-            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
36
+        if ( ! isset($fieldValues['ATT_full_name'])) {
37
+            $fname                        = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : '';
38 38
             $lname                        = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
39
-            $fieldValues['ATT_full_name'] = $fname . $lname;
39
+            $fieldValues['ATT_full_name'] = $fname.$lname;
40 40
         }
41
-        if (! isset($fieldValues['ATT_slug'])) {
41
+        if ( ! isset($fieldValues['ATT_slug'])) {
42 42
             //			$fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
43 43
             $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
44 44
         }
45
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
45
+        if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
46 46
             $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
47 47
         }
48 48
         parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
@@ -303,22 +303,22 @@  discard block
 block discarded – undo
303 303
         $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
304 304
         foreach ($initial_address_fields as $address_field_name) {
305 305
             $address_fields_value = $this->get($address_field_name);
306
-            if (! empty($address_fields_value)) {
306
+            if ( ! empty($address_fields_value)) {
307 307
                 $full_address_array[] = $address_fields_value;
308 308
             }
309 309
         }
310 310
         //now handle state and country
311 311
         $state_obj = $this->state_obj();
312
-        if (! empty($state_obj)) {
312
+        if ( ! empty($state_obj)) {
313 313
             $full_address_array[] = $state_obj->name();
314 314
         }
315 315
         $country_obj = $this->country_obj();
316
-        if (! empty($country_obj)) {
316
+        if ( ! empty($country_obj)) {
317 317
             $full_address_array[] = $country_obj->name();
318 318
         }
319 319
         //lastly get the xip
320 320
         $zip_value = $this->zip();
321
-        if (! empty($zip_value)) {
321
+        if ( ! empty($zip_value)) {
322 322
             $full_address_array[] = $zip_value;
323 323
         }
324 324
         return $full_address_array;
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
     public function get_most_recent_registration_for_event($event_id)
553 553
     {
554 554
         return $this->get_first_related('Registration',
555
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')));//, '=', 'OBJECT_K' );
555
+            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))); //, '=', 'OBJECT_K' );
556 556
     }
557 557
 
558 558
 
@@ -578,11 +578,11 @@  discard block
 block discarded – undo
578 578
     public function billing_info_for_payment_method($payment_method)
579 579
     {
580 580
         $pm_type = $payment_method->type_obj();
581
-        if (! $pm_type instanceof EE_PMT_Base) {
581
+        if ( ! $pm_type instanceof EE_PMT_Base) {
582 582
             return null;
583 583
         }
584 584
         $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
585
-        if (! $billing_info) {
585
+        if ( ! $billing_info) {
586 586
             return null;
587 587
         }
588 588
         $billing_form = $pm_type->billing_form();
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
     public function get_billing_info_postmeta_name($payment_method)
604 604
     {
605 605
         if ($payment_method->type_obj() instanceof EE_PMT_Base) {
606
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
606
+            return 'billing_info_'.$payment_method->type_obj()->system_name();
607 607
         } else {
608 608
             return null;
609 609
         }
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      */
621 621
     public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
622 622
     {
623
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
623
+        if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
624 624
             EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
625 625
             return false;
626 626
         }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Div_Per_Section_Layout.strategy.php 2 patches
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -14,132 +14,132 @@
 block discarded – undo
14 14
 class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base
15 15
 {
16 16
 
17
-    /**
18
-     * opening div tag for a form
19
-     *
20
-     * @return string
21
-     */
22
-    public function layout_form_begin()
23
-    {
24
-        return EEH_HTML::div(
25
-            '',
26
-            $this->_form_section->html_id(),
27
-            $this->_form_section->html_class(),
28
-            $this->_form_section->html_style()
29
-        );
30
-    }
31
-
32
-
33
-
34
-    /**
35
-     * Lays out the row for the input, including label and errors
36
-     *
37
-     * @param EE_Form_Input_Base $input
38
-     * @return string
39
-     * @throws \EE_Error
40
-     */
41
-    public function layout_input($input)
42
-    {
43
-        $html = '';
44
-        // set something unique for the id
45
-        $html_id = (string)$input->html_id() !== ''
46
-            ? (string)$input->html_id()
47
-            : spl_object_hash($input);
48
-        // and add a generic input type class
49
-        $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
50
-        if ($input instanceof EE_Hidden_Input) {
51
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
52
-        } else if ($input instanceof EE_Submit_Input) {
53
-            $html .= EEH_HTML::div(
54
-                $input->get_html_for_input(),
55
-                $html_id . '-submit-dv',
56
-                "{$input->html_class()}-submit-dv {$html_class}"
57
-            );
58
-        } else if ($input instanceof EE_Select_Input) {
59
-            $html .= EEH_HTML::div(
60
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
61
-                EEH_HTML::nl() . $input->get_html_for_errors() .
62
-                EEH_HTML::nl() . $input->get_html_for_input() .
63
-                EEH_HTML::nl() . $input->get_html_for_help(),
64
-                $html_id . '-input-dv',
65
-                "{$input->html_class()}-input-dv {$html_class}"
66
-            );
67
-        } else if ($input instanceof EE_Form_Input_With_Options_Base) {
68
-            $html .= EEH_HTML::div(
69
-                EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
-                EEH_HTML::nl() . $input->get_html_for_errors() .
71
-                EEH_HTML::nl() . $input->get_html_for_input() .
72
-                EEH_HTML::nl() . $input->get_html_for_help(),
73
-                $html_id . '-input-dv',
74
-                "{$input->html_class()}-input-dv {$html_class}"
75
-            );
76
-        } else {
77
-            $html .= EEH_HTML::div(
78
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
79
-                EEH_HTML::nl() . $input->get_html_for_errors() .
80
-                EEH_HTML::nl() . $input->get_html_for_input() .
81
-                EEH_HTML::nl() . $input->get_html_for_help(),
82
-                $html_id . '-input-dv',
83
-                "{$input->html_class()}-input-dv {$html_class}"
84
-            );
85
-        }
86
-        return $html;
87
-    }
88
-
89
-
90
-
91
-    /**
92
-     *
93
-     * _display_label_for_option_type_question
94
-     * Gets the HTML for the 'label', which is just text for this (because labels
95
-     * should be for each input)
96
-     *
97
-     * @param EE_Form_Input_With_Options_Base $input
98
-     * @return string
99
-     */
100
-    protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
101
-    {
102
-        if ($input->display_html_label_text()) {
103
-            return EEH_HTML::div(
104
-                $input->required()
105
-                    ? $input->html_label_text() . EEH_HTML::span('*', '', 'ee-asterisk')
106
-                    : $input->html_label_text(),
107
-                $input->html_label_id(),
108
-                $input->required()
109
-                    ? 'ee-required-label ' . $input->html_label_class()
110
-                    : $input->html_label_class(),
111
-                $input->html_label_style(),
112
-                $input->html_other_attributes()
113
-            );
114
-        }
115
-        return '';
116
-    }
117
-
118
-
119
-
120
-    /**
121
-     * Lays out a row for the subsection
122
-     *
123
-     * @param EE_Form_Section_Proper $form_section
124
-     * @return string
125
-     */
126
-    public function layout_subsection($form_section)
127
-    {
128
-        //		d( $form_section );
129
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
130
-    }
131
-
132
-
133
-
134
-    /**
135
-     * closing div tag for a form
136
-     *
137
-     * @return string
138
-     */
139
-    public function layout_form_end()
140
-    {
141
-        return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
142
-    }
17
+	/**
18
+	 * opening div tag for a form
19
+	 *
20
+	 * @return string
21
+	 */
22
+	public function layout_form_begin()
23
+	{
24
+		return EEH_HTML::div(
25
+			'',
26
+			$this->_form_section->html_id(),
27
+			$this->_form_section->html_class(),
28
+			$this->_form_section->html_style()
29
+		);
30
+	}
31
+
32
+
33
+
34
+	/**
35
+	 * Lays out the row for the input, including label and errors
36
+	 *
37
+	 * @param EE_Form_Input_Base $input
38
+	 * @return string
39
+	 * @throws \EE_Error
40
+	 */
41
+	public function layout_input($input)
42
+	{
43
+		$html = '';
44
+		// set something unique for the id
45
+		$html_id = (string)$input->html_id() !== ''
46
+			? (string)$input->html_id()
47
+			: spl_object_hash($input);
48
+		// and add a generic input type class
49
+		$html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
50
+		if ($input instanceof EE_Hidden_Input) {
51
+			$html .= EEH_HTML::nl() . $input->get_html_for_input();
52
+		} else if ($input instanceof EE_Submit_Input) {
53
+			$html .= EEH_HTML::div(
54
+				$input->get_html_for_input(),
55
+				$html_id . '-submit-dv',
56
+				"{$input->html_class()}-submit-dv {$html_class}"
57
+			);
58
+		} else if ($input instanceof EE_Select_Input) {
59
+			$html .= EEH_HTML::div(
60
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
61
+				EEH_HTML::nl() . $input->get_html_for_errors() .
62
+				EEH_HTML::nl() . $input->get_html_for_input() .
63
+				EEH_HTML::nl() . $input->get_html_for_help(),
64
+				$html_id . '-input-dv',
65
+				"{$input->html_class()}-input-dv {$html_class}"
66
+			);
67
+		} else if ($input instanceof EE_Form_Input_With_Options_Base) {
68
+			$html .= EEH_HTML::div(
69
+				EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
+				EEH_HTML::nl() . $input->get_html_for_errors() .
71
+				EEH_HTML::nl() . $input->get_html_for_input() .
72
+				EEH_HTML::nl() . $input->get_html_for_help(),
73
+				$html_id . '-input-dv',
74
+				"{$input->html_class()}-input-dv {$html_class}"
75
+			);
76
+		} else {
77
+			$html .= EEH_HTML::div(
78
+				EEH_HTML::nl(1) . $input->get_html_for_label() .
79
+				EEH_HTML::nl() . $input->get_html_for_errors() .
80
+				EEH_HTML::nl() . $input->get_html_for_input() .
81
+				EEH_HTML::nl() . $input->get_html_for_help(),
82
+				$html_id . '-input-dv',
83
+				"{$input->html_class()}-input-dv {$html_class}"
84
+			);
85
+		}
86
+		return $html;
87
+	}
88
+
89
+
90
+
91
+	/**
92
+	 *
93
+	 * _display_label_for_option_type_question
94
+	 * Gets the HTML for the 'label', which is just text for this (because labels
95
+	 * should be for each input)
96
+	 *
97
+	 * @param EE_Form_Input_With_Options_Base $input
98
+	 * @return string
99
+	 */
100
+	protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input)
101
+	{
102
+		if ($input->display_html_label_text()) {
103
+			return EEH_HTML::div(
104
+				$input->required()
105
+					? $input->html_label_text() . EEH_HTML::span('*', '', 'ee-asterisk')
106
+					: $input->html_label_text(),
107
+				$input->html_label_id(),
108
+				$input->required()
109
+					? 'ee-required-label ' . $input->html_label_class()
110
+					: $input->html_label_class(),
111
+				$input->html_label_style(),
112
+				$input->html_other_attributes()
113
+			);
114
+		}
115
+		return '';
116
+	}
117
+
118
+
119
+
120
+	/**
121
+	 * Lays out a row for the subsection
122
+	 *
123
+	 * @param EE_Form_Section_Proper $form_section
124
+	 * @return string
125
+	 */
126
+	public function layout_subsection($form_section)
127
+	{
128
+		//		d( $form_section );
129
+		return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
130
+	}
131
+
132
+
133
+
134
+	/**
135
+	 * closing div tag for a form
136
+	 *
137
+	 * @return string
138
+	 */
139
+	public function layout_form_end()
140
+	{
141
+		return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class());
142
+	}
143 143
 
144 144
 
145 145
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -42,44 +42,44 @@  discard block
 block discarded – undo
42 42
     {
43 43
         $html = '';
44 44
         // set something unique for the id
45
-        $html_id = (string)$input->html_id() !== ''
46
-            ? (string)$input->html_id()
45
+        $html_id = (string) $input->html_id() !== ''
46
+            ? (string) $input->html_id()
47 47
             : spl_object_hash($input);
48 48
         // and add a generic input type class
49
-        $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv';
49
+        $html_class = sanitize_key(str_replace('_', '-', get_class($input))).'-dv';
50 50
         if ($input instanceof EE_Hidden_Input) {
51
-            $html .= EEH_HTML::nl() . $input->get_html_for_input();
51
+            $html .= EEH_HTML::nl().$input->get_html_for_input();
52 52
         } else if ($input instanceof EE_Submit_Input) {
53 53
             $html .= EEH_HTML::div(
54 54
                 $input->get_html_for_input(),
55
-                $html_id . '-submit-dv',
55
+                $html_id.'-submit-dv',
56 56
                 "{$input->html_class()}-submit-dv {$html_class}"
57 57
             );
58 58
         } else if ($input instanceof EE_Select_Input) {
59 59
             $html .= EEH_HTML::div(
60
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
61
-                EEH_HTML::nl() . $input->get_html_for_errors() .
62
-                EEH_HTML::nl() . $input->get_html_for_input() .
63
-                EEH_HTML::nl() . $input->get_html_for_help(),
64
-                $html_id . '-input-dv',
60
+                EEH_HTML::nl(1).$input->get_html_for_label().
61
+                EEH_HTML::nl().$input->get_html_for_errors().
62
+                EEH_HTML::nl().$input->get_html_for_input().
63
+                EEH_HTML::nl().$input->get_html_for_help(),
64
+                $html_id.'-input-dv',
65 65
                 "{$input->html_class()}-input-dv {$html_class}"
66 66
             );
67 67
         } else if ($input instanceof EE_Form_Input_With_Options_Base) {
68 68
             $html .= EEH_HTML::div(
69
-                EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) .
70
-                EEH_HTML::nl() . $input->get_html_for_errors() .
71
-                EEH_HTML::nl() . $input->get_html_for_input() .
72
-                EEH_HTML::nl() . $input->get_html_for_help(),
73
-                $html_id . '-input-dv',
69
+                EEH_HTML::nl().$this->_display_label_for_option_type_question($input).
70
+                EEH_HTML::nl().$input->get_html_for_errors().
71
+                EEH_HTML::nl().$input->get_html_for_input().
72
+                EEH_HTML::nl().$input->get_html_for_help(),
73
+                $html_id.'-input-dv',
74 74
                 "{$input->html_class()}-input-dv {$html_class}"
75 75
             );
76 76
         } else {
77 77
             $html .= EEH_HTML::div(
78
-                EEH_HTML::nl(1) . $input->get_html_for_label() .
79
-                EEH_HTML::nl() . $input->get_html_for_errors() .
80
-                EEH_HTML::nl() . $input->get_html_for_input() .
81
-                EEH_HTML::nl() . $input->get_html_for_help(),
82
-                $html_id . '-input-dv',
78
+                EEH_HTML::nl(1).$input->get_html_for_label().
79
+                EEH_HTML::nl().$input->get_html_for_errors().
80
+                EEH_HTML::nl().$input->get_html_for_input().
81
+                EEH_HTML::nl().$input->get_html_for_help(),
82
+                $html_id.'-input-dv',
83 83
                 "{$input->html_class()}-input-dv {$html_class}"
84 84
             );
85 85
         }
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
         if ($input->display_html_label_text()) {
103 103
             return EEH_HTML::div(
104 104
                 $input->required()
105
-                    ? $input->html_label_text() . EEH_HTML::span('*', '', 'ee-asterisk')
105
+                    ? $input->html_label_text().EEH_HTML::span('*', '', 'ee-asterisk')
106 106
                     : $input->html_label_text(),
107 107
                 $input->html_label_id(),
108 108
                 $input->required()
109
-                    ? 'ee-required-label ' . $input->html_label_class()
109
+                    ? 'ee-required-label '.$input->html_label_class()
110 110
                     : $input->html_label_class(),
111 111
                 $input->html_label_style(),
112 112
                 $input->html_other_attributes()
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     public function layout_subsection($form_section)
127 127
     {
128 128
         //		d( $form_section );
129
-        return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
129
+        return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1);
130 130
     }
131 131
 
132 132
 
Please login to merge, or discard this patch.