Completed
Branch Gutenberg/espresso-cpt-editor (d57906)
by
unknown
78:21 queued 69:49
created
core/services/locators/Locator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 use  EventEspresso\core\exceptions\InvalidDataTypeException;
6 6
 use FilesystemIterator;
7 7
 
8
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
9
-	exit( 'No direct script access allowed' );
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10 10
 }
11 11
 
12 12
 
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
 	 * @param array $flags controls how files are found and/or file data is returned
36 36
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
37 37
 	 */
38
-	public function __construct( $flags = array() ) {
39
-		if ( empty( $flags ) ) {
38
+	public function __construct($flags = array()) {
39
+		if (empty($flags)) {
40 40
 			$flags = array(
41 41
 				FilesystemIterator::SKIP_DOTS,
42 42
 				FilesystemIterator::UNIX_PATHS,
43 43
 				FilesystemIterator::CURRENT_AS_PATHNAME
44 44
 			);
45 45
 		}
46
-		$this->setFlags( $flags );
46
+		$this->setFlags($flags);
47 47
 	}
48 48
 
49 49
 
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	 * @param array $flags
55 55
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
56 56
 	 */
57
-	public function setFlags( $flags ) {
58
-		if ( ! is_array( $flags ) ) {
59
-			throw new InvalidDataTypeException( '$flags', $flags, 'array' );
57
+	public function setFlags($flags) {
58
+		if ( ! is_array($flags)) {
59
+			throw new InvalidDataTypeException('$flags', $flags, 'array');
60 60
 		}
61 61
 		$this->flags = $flags;
62 62
 	}
Please login to merge, or discard this patch.
core/EE_Data_Migration_Manager.core.php 4 patches
Braces   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			//it's 4.2-style.eg Core.4.1.0
209 209
 			$plugin_slug = $parts[0];//eg Core
210 210
 			$version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0
211
-		}else{
211
+		} else{
212 212
 			//it's 4.1-style: eg 4.1.0
213 213
 			$plugin_slug = 'Core';
214 214
 			$version_string = $plugin_slug_and_version_string;//eg 4.1.0
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 			if($class instanceof EE_Data_Migration_Script_Base){
232 232
 				$class->instantiate_from_array_of_properties($data_migration_data);
233 233
 				return $class;
234
-			}else{
234
+			} else{
235 235
 				//huh, so its an object but not a data migration script?? that shouldn't happen
236 236
 				//just leave it as an array (which will probably just get ignored)
237 237
 				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class']));
238 238
 			}
239
-		}else{
239
+		} else{
240 240
 			//so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists
241 241
 			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name));
242 242
 		}
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 						//sometimes we also like to know which was the last incomplete script (or if there are any at all)
267 267
 						$this->_last_ran_incomplete_script = $class;
268 268
 					}
269
-				}catch(EE_Error $e){
269
+				} catch(EE_Error $e){
270 270
 					//ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
271 271
 					$data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']);
272 272
 				}
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 				//so we want the data migrations to happen. SO, we're going to say the DB is at that state
368 368
 //				echo "4.1.0 is greater than $previous_version_installed! update the option";
369 369
 				$db_state = array('Core'=>$previous_version_installed);
370
-			}else{
370
+			} else{
371 371
 //					echo "4.1.0 is SMALLER than $previous_version_installed";
372 372
 					$db_state = array('Core'=>EVENT_ESPRESSO_VERSION);
373 373
 			}
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 						$migrates_to_version = $script->migrates_to_version();
436 436
 						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
437 437
 						unset($script_class_and_filepaths_available[$classname]);
438
-					}else{
438
+					} else{
439 439
 						//it must have a status that indicates it has finished, so we don't want to try and run it again
440 440
 					}
441
-				}else{
441
+				} else{
442 442
 					//it exists but it's not  a proper data migration script
443 443
 					//maybe the script got renamed? or was simply removed from EE?
444 444
 					//either way, its certainly not runnable!
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 		}
479 479
 		if($include_completed_scripts){
480 480
 			return $this->_last_ran_script;
481
-		}else{
481
+		} else{
482 482
 			return $this->_last_ran_incomplete_script;
483 483
 		}
484 484
 	}
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 				$this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script;
540 540
 			}
541 541
 			$current_script_name = get_class($currently_executing_script);
542
-		}catch(Exception $e){
542
+		} catch(Exception $e){
543 543
 			//an exception occurred while trying to get migration scripts
544 544
 
545 545
 			$message =  sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() );
@@ -604,14 +604,14 @@  discard block
 block discarded – undo
604 604
 					);
605 605
 					break;
606 606
 			}
607
-		}catch(Exception $e){
607
+		} catch(Exception $e){
608 608
 			//ok so some exception was thrown which killed the data migration script
609 609
 			//double-check we have a real script
610 610
 			if($currently_executing_script instanceof EE_Data_Migration_Script_Base){
611 611
 				$script_name = $currently_executing_script->pretty_name();
612 612
 				$currently_executing_script->set_broken();
613 613
 				$currently_executing_script->add_error($e->getMessage());
614
-			}else{
614
+			} else{
615 615
 				$script_name = __("Error getting Migration Script", "event_espresso");
616 616
 			}
617 617
 			$response_array = array(
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 		ob_start();
655 655
 		try{
656 656
 			$response = $this->migration_step();
657
-		}catch(Exception $e){
657
+		} catch(Exception $e){
658 658
 			$response = array(
659 659
 				'records_to_migrate'=>0,
660 660
 				'records_migrated'=>0,
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		$current_database_state = get_option(self::current_database_state);
704 704
 		if( ! isset( $current_database_state[ $slug ] ) ) {
705 705
 			return true;
706
-		}else{
706
+		} else{
707 707
 			//just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
708 708
 			$version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3);
709 709
 			$version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 );
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 			//ok then just add this error to its list of errors
804 804
 			$last_ran_migration_script_properties['_errors'][] = $error_message;
805 805
 			$last_ran_migration_script_properties['_status'] = self::status_fatal_error;
806
-		}else{
806
+		} else{
807 807
 			//so we don't even know which script was last running
808 808
 			//use the data migration error stub, which is designed specifically for this type of thing
809 809
 			$general_migration_error = new EE_DMS_Unknown_1_0_0();
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 					if( $old_option_value != $script_array_for_saving){
840 840
 						$successful_updates = update_option($option_name,$script_array_for_saving);
841 841
 					}
842
-				}else{//we don't know what this array-thing is. So just save it as-is
842
+				} else{//we don't know what this array-thing is. So just save it as-is
843 843
 	//				$array_of_migrations[$version_string] = $array_or_migration_obj;
844 844
 					if($old_option_value != $array_or_migration_obj){
845 845
 						$successful_updates = update_option($option_name,$array_or_migration_obj);
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 				}
907 907
 				//if it wasn't for core, we must keep searching for one that is!
908 908
 				continue;
909
-			}else{
909
+			} else{
910 910
 				$champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname);
911 911
 				$contender_migrates_to = $this->script_migrates_to_version($classname);
912 912
 				if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 		$migrations_ran = $this->get_data_migrations_ran();
934 934
 		if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){
935 935
 			return $migrations_ran[ $plugin_slug ][ $version ];
936
-		}else{
936
+		} else{
937 937
 			return NULL;
938 938
 		}
939 939
 	}
@@ -955,9 +955,9 @@  discard block
 block discarded – undo
955 955
 		if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){
956 956
 			//if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it)
957 957
 			$last_ran_script->set_completed();
958
-		}elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) {
958
+		} elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) {
959 959
 			$last_ran_script->reattempt();
960
-		}else{
960
+		} else{
961 961
 			throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) );
962 962
 		}
963 963
 		return $this->_save_migrations_ran();
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 			if( ! $most_up_to_date_dms ) {
996 996
 				//if there is NO DMS for this plugin, obviously there's no schema to verify anyways
997 997
 				$verify_db = false;
998
-			}else{
998
+			} else{
999 999
 				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms );
1000 1000
 				$verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to );
1001 1001
 			}
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 						false,
1005 1005
 						$verify_db
1006 1006
 					);
1007
-			}else{
1007
+			} else{
1008 1008
 				//just loop through the addons to make sure their database is setup
1009 1009
 				foreach( EE_Registry::instance()->addons as $addon ) {
1010 1010
 					if( $addon->name() == $plugin_slug ) {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 use EventEspresso\core\exceptions\InvalidDataTypeException;
4 4
 use EventEspresso\core\exceptions\InvalidInterfaceException;
5 5
 use EventEspresso\core\interfaces\ResettableInterface;
6
-
7 6
 use EventEspresso\core\services\database\TableManager;
8 7
 use EventEspresso\core\services\database\TableAnalysis;
9 8
 
Please login to merge, or discard this patch.
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 	protected $script_migration_versions;
137 137
 
138 138
 	/**
139
-     * 	@var EE_Data_Migration_Manager $_instance
139
+	 * 	@var EE_Data_Migration_Manager $_instance
140 140
 	 * 	@access 	private
141
-     */
141
+	 */
142 142
 	private static $_instance = NULL;
143 143
 
144 144
 
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 	 */
323 323
 	public function get_data_migration_script_folders(){
324 324
 		return  apply_filters(
325
-		    'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
326
-            array('Core' => EE_CORE.'data_migration_scripts')
327
-        );
325
+			'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
326
+			array('Core' => EE_CORE.'data_migration_scripts')
327
+		);
328 328
 	}
329 329
 
330 330
 	/**
@@ -337,15 +337,15 @@  discard block
 block discarded – undo
337 337
 	 * @throws EE_Error
338 338
 	 */
339 339
 	public function script_migrates_to_version($migration_script_name, $eeAddonClass = ''){
340
-	    if(isset($this->script_migration_versions[ $migration_script_name ])){
341
-	        return $this->script_migration_versions[ $migration_script_name ];
342
-        }
340
+		if(isset($this->script_migration_versions[ $migration_script_name ])){
341
+			return $this->script_migration_versions[ $migration_script_name ];
342
+		}
343 343
 		$dms_info = $this->parse_dms_classname($migration_script_name);
344
-        $this->script_migration_versions[ $migration_script_name ] = array(
344
+		$this->script_migration_versions[ $migration_script_name ] = array(
345 345
 			'slug'=> $eeAddonClass !== '' ? $eeAddonClass : $dms_info[ 'slug' ],
346 346
 			'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ]
347
-        );
348
-        return $this->script_migration_versions[ $migration_script_name ];
347
+		);
348
+		return $this->script_migration_versions[ $migration_script_name ];
349 349
 	}
350 350
 
351 351
 	/**
@@ -736,60 +736,60 @@  discard block
 block discarded – undo
736 736
 	}
737 737
 
738 738
 
739
-    /**
740
-     * Gets all the data migration scripts available in the core folder and folders
741
-     * in addons. Has the side effect of adding them for autoloading
742
-     *
743
-     * @return array keys are expected classnames, values are their filepaths
744
-     * @throws InvalidInterfaceException
745
-     * @throws InvalidDataTypeException
746
-     * @throws EE_Error
747
-     * @throws InvalidArgumentException
748
-     */
749
-    public function get_all_data_migration_scripts_available()
750
-    {
751
-        if (! $this->_data_migration_class_to_filepath_map) {
752
-            $this->_data_migration_class_to_filepath_map = array();
753
-            foreach ($this->get_data_migration_script_folders() as $eeAddonClass => $folder_path) {
754
-                // strip any placeholders added to classname to make it a unique array key
755
-                $eeAddonClass = trim($eeAddonClass, '*');
756
-                $eeAddonClass = $eeAddonClass === 'Core' || class_exists($eeAddonClass)
757
-                    ? $eeAddonClass
758
-                    : '';
759
-                $folder_path  = EEH_File::end_with_directory_separator($folder_path);
760
-                $files        = glob($folder_path . '*.dms.php');
761
-                if (empty($files)) {
762
-                    continue;
763
-                }
764
-                foreach ($files as $file) {
765
-                    $pos_of_last_slash = strrpos($file, DS);
766
-                    $classname         = str_replace('.dms.php', '', substr($file, $pos_of_last_slash + 1));
767
-                    $migrates_to       = $this->script_migrates_to_version($classname, $eeAddonClass);
768
-                    $slug              = $migrates_to['slug'];
769
-                    //check that the slug as contained in the DMS is associated with
770
-                    //the slug of an addon or core
771
-                    if ($slug !== 'Core' && EE_Registry::instance()->get_addon_by_name($slug) === null) {
772
-                        EE_Error::doing_it_wrong(
773
-                            __FUNCTION__,
774
-                            sprintf(
775
-                                esc_html__(
776
-                                    'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ',
777
-                                    'event_espresso'
778
-                                ),
779
-                                $classname,
780
-                                $slug,
781
-                                implode(', ', array_keys(EE_Registry::instance()->get_addons_by_name()))
782
-                            ),
783
-                            '4.3.0.alpha.019'
784
-                        );
785
-                    }
786
-                    $this->_data_migration_class_to_filepath_map[ $classname ] = $file;
787
-                }
788
-            }
789
-            EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
790
-        }
791
-        return $this->_data_migration_class_to_filepath_map;
792
-    }
739
+	/**
740
+	 * Gets all the data migration scripts available in the core folder and folders
741
+	 * in addons. Has the side effect of adding them for autoloading
742
+	 *
743
+	 * @return array keys are expected classnames, values are their filepaths
744
+	 * @throws InvalidInterfaceException
745
+	 * @throws InvalidDataTypeException
746
+	 * @throws EE_Error
747
+	 * @throws InvalidArgumentException
748
+	 */
749
+	public function get_all_data_migration_scripts_available()
750
+	{
751
+		if (! $this->_data_migration_class_to_filepath_map) {
752
+			$this->_data_migration_class_to_filepath_map = array();
753
+			foreach ($this->get_data_migration_script_folders() as $eeAddonClass => $folder_path) {
754
+				// strip any placeholders added to classname to make it a unique array key
755
+				$eeAddonClass = trim($eeAddonClass, '*');
756
+				$eeAddonClass = $eeAddonClass === 'Core' || class_exists($eeAddonClass)
757
+					? $eeAddonClass
758
+					: '';
759
+				$folder_path  = EEH_File::end_with_directory_separator($folder_path);
760
+				$files        = glob($folder_path . '*.dms.php');
761
+				if (empty($files)) {
762
+					continue;
763
+				}
764
+				foreach ($files as $file) {
765
+					$pos_of_last_slash = strrpos($file, DS);
766
+					$classname         = str_replace('.dms.php', '', substr($file, $pos_of_last_slash + 1));
767
+					$migrates_to       = $this->script_migrates_to_version($classname, $eeAddonClass);
768
+					$slug              = $migrates_to['slug'];
769
+					//check that the slug as contained in the DMS is associated with
770
+					//the slug of an addon or core
771
+					if ($slug !== 'Core' && EE_Registry::instance()->get_addon_by_name($slug) === null) {
772
+						EE_Error::doing_it_wrong(
773
+							__FUNCTION__,
774
+							sprintf(
775
+								esc_html__(
776
+									'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ',
777
+									'event_espresso'
778
+								),
779
+								$classname,
780
+								$slug,
781
+								implode(', ', array_keys(EE_Registry::instance()->get_addons_by_name()))
782
+							),
783
+							'4.3.0.alpha.019'
784
+						);
785
+					}
786
+					$this->_data_migration_class_to_filepath_map[ $classname ] = $file;
787
+				}
788
+			}
789
+			EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
790
+		}
791
+		return $this->_data_migration_class_to_filepath_map;
792
+	}
793 793
 
794 794
 
795 795
 
@@ -961,12 +961,12 @@  discard block
 block discarded – undo
961 961
 	}
962 962
 
963 963
 /**
964
-	 * Resets the borked data migration scripts so they're no longer borked
965
-	 * so we can again attempt to migrate
966
-	 *
967
-	 * @return bool
968
-	 * @throws EE_Error
969
-	 */
964
+ * Resets the borked data migration scripts so they're no longer borked
965
+ * so we can again attempt to migrate
966
+ *
967
+ * @return bool
968
+ * @throws EE_Error
969
+ */
970 970
 	public function reattempt(){
971 971
 		//find if the last-ran script was borked
972 972
 		//set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
Please login to merge, or discard this patch.
Spacing   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * of this EE installation. Keys should be the name of the version the script upgraded to
86 86
 	 * @var EE_Data_Migration_Script_Base[]
87 87
 	 */
88
-	private $_data_migrations_ran =null;
88
+	private $_data_migrations_ran = null;
89 89
 	/**
90 90
 	 * The last ran script. It's nice to store this somewhere accessible, as its easiest
91 91
 	 * to know which was the last run by which is the newest wp option; but in most of the code
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	public static function instance() {
152 152
 		// check if class object is instantiated
153
-		if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) {
153
+		if ( ! self::$_instance instanceof EE_Data_Migration_Manager) {
154 154
 			self::$_instance = new self();
155 155
 		}
156 156
 		return self::$_instance;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * all new usages of the singleton should be made with Classname::instance()) and returns it
161 161
 	 * @return EE_Data_Migration_Manager
162 162
 	 */
163
-	public static function reset(){
163
+	public static function reset() {
164 164
 		self::$_instance = NULL;
165 165
 		return self::instance();
166 166
 	}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	/**
171 171
 	 * constructor
172 172
 	 */
173
-	private function __construct(){
173
+	private function __construct() {
174 174
 		$this->stati_that_indicate_to_continue_migrations = array(
175 175
 			self::status_continue,
176 176
 			self::status_completed
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 		);
190 190
 		//make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class
191 191
 		//to be defined, because right now it doesn't get autoloaded on its own
192
-		EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE );
193
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE );
194
-		EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE );
195
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE );
196
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE );
197
-		$this->_table_manager = EE_Registry::instance()->create( 'TableManager', array(), true );
198
-		$this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
192
+		EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE);
193
+		EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE);
194
+		EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE);
195
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE);
196
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE);
197
+		$this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true);
198
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
199 199
 	}
200 200
 
201 201
 
@@ -208,21 +208,21 @@  discard block
 block discarded – undo
208 208
 	 * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set)
209 209
 	 * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0')
210 210
 	 */
211
-	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){
211
+	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) {
212 212
 		$plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name);
213 213
 		//check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style)
214
-		$parts = explode(".",$plugin_slug_and_version_string);
214
+		$parts = explode(".", $plugin_slug_and_version_string);
215 215
 
216
-		if(count($parts) == 4){
216
+		if (count($parts) == 4) {
217 217
 			//it's 4.2-style.eg Core.4.1.0
218
-			$plugin_slug = $parts[0];//eg Core
218
+			$plugin_slug = $parts[0]; //eg Core
219 219
 			$version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0
220
-		}else{
220
+		} else {
221 221
 			//it's 4.1-style: eg 4.1.0
222 222
 			$plugin_slug = 'Core';
223
-			$version_string = $plugin_slug_and_version_string;//eg 4.1.0
223
+			$version_string = $plugin_slug_and_version_string; //eg 4.1.0
224 224
 		}
225
-		return array($plugin_slug,$version_string);
225
+		return array($plugin_slug, $version_string);
226 226
 	}
227 227
 
228 228
 	/**
@@ -233,21 +233,21 @@  discard block
 block discarded – undo
233 233
 	 * @return EE_Data_Migration_Script_Base
234 234
 	 * @throws EE_Error
235 235
 	 */
236
-	private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){
236
+	private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) {
237 237
 		$data_migration_data = maybe_unserialize($dms_option_value);
238
-		if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){
238
+		if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) {
239 239
 			$class = new $data_migration_data['class'];
240
-			if($class instanceof EE_Data_Migration_Script_Base){
240
+			if ($class instanceof EE_Data_Migration_Script_Base) {
241 241
 				$class->instantiate_from_array_of_properties($data_migration_data);
242 242
 				return $class;
243
-			}else{
243
+			} else {
244 244
 				//huh, so its an object but not a data migration script?? that shouldn't happen
245 245
 				//just leave it as an array (which will probably just get ignored)
246
-				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class']));
246
+				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class']));
247 247
 			}
248
-		}else{
248
+		} else {
249 249
 			//so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists
250
-			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name));
250
+			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name));
251 251
 		}
252 252
 	}
253 253
 	/**
@@ -255,34 +255,34 @@  discard block
 block discarded – undo
255 255
 	 * the last ran which hasn't finished yet
256 256
 	 * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy arrays in there - which should probably be ignored)
257 257
 	 */
258
-	public function get_data_migrations_ran(){
259
-		if( ! $this->_data_migrations_ran ){
258
+	public function get_data_migrations_ran() {
259
+		if ( ! $this->_data_migrations_ran) {
260 260
 			//setup autoloaders for each of the scripts in there
261 261
 			$this->get_all_data_migration_scripts_available();
262
-			$data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
262
+			$data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
263 263
 
264 264
 			$data_migrations_ran = array();
265 265
 			//convert into data migration script classes where possible
266
-			foreach($data_migrations_options as $data_migration_option){
267
-				list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
266
+			foreach ($data_migrations_options as $data_migration_option) {
267
+				list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
268 268
 
269
-				try{
270
-					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']);
269
+				try {
270
+					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']);
271 271
 					$data_migrations_ran[$plugin_slug][$version_string] = $class;
272 272
 					//ok so far THIS is the 'last-ran-script'... unless we find another on next iteration
273 273
 					$this->_last_ran_script = $class;
274
-					if( ! $class->is_completed()){
274
+					if ( ! $class->is_completed()) {
275 275
 						//sometimes we also like to know which was the last incomplete script (or if there are any at all)
276 276
 						$this->_last_ran_incomplete_script = $class;
277 277
 					}
278
-				}catch(EE_Error $e){
278
+				} catch (EE_Error $e) {
279 279
 					//ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
280 280
 					$data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']);
281 281
 				}
282 282
 			}
283 283
 			//so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays
284 284
 			$this->_data_migrations_ran = $data_migrations_ran;
285
-			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){
285
+			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) {
286 286
 				$this->_data_migrations_ran = array();
287 287
 			}
288 288
 		}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param        $new_table
300 300
 	 * @return mixed string or int
301 301
 	 */
302
-	public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){
302
+	public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) {
303 303
 		$script = EE_Registry::instance()->load_dms($script_name);
304 304
 		$mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table);
305 305
 		return $mapping;
@@ -310,9 +310,9 @@  discard block
 block discarded – undo
310 310
 	 * option returned in this array is the most-recently ran DMS option
311 311
 	 * @return array
312 312
 	 */
313
-	 public function get_all_migration_script_options(){
313
+	 public function get_all_migration_script_options() {
314 314
 		global $wpdb;
315
-		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A);
315
+		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A);
316 316
 	}
317 317
 
318 318
 	/**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the
321 321
 	 * folder name.
322 322
 	 */
323
-	public function get_data_migration_script_folders(){
323
+	public function get_data_migration_script_folders() {
324 324
 		return  apply_filters(
325 325
 		    'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
326 326
             array('Core' => EE_CORE.'data_migration_scripts')
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 	 * }
337 337
 	 * @throws EE_Error
338 338
 	 */
339
-	public function script_migrates_to_version($migration_script_name, $eeAddonClass = ''){
340
-	    if(isset($this->script_migration_versions[ $migration_script_name ])){
341
-	        return $this->script_migration_versions[ $migration_script_name ];
339
+	public function script_migrates_to_version($migration_script_name, $eeAddonClass = '') {
340
+	    if (isset($this->script_migration_versions[$migration_script_name])) {
341
+	        return $this->script_migration_versions[$migration_script_name];
342 342
         }
343 343
 		$dms_info = $this->parse_dms_classname($migration_script_name);
344
-        $this->script_migration_versions[ $migration_script_name ] = array(
345
-			'slug'=> $eeAddonClass !== '' ? $eeAddonClass : $dms_info[ 'slug' ],
346
-			'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ]
344
+        $this->script_migration_versions[$migration_script_name] = array(
345
+			'slug'=> $eeAddonClass !== '' ? $eeAddonClass : $dms_info['slug'],
346
+			'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version']
347 347
         );
348
-        return $this->script_migration_versions[ $migration_script_name ];
348
+        return $this->script_migration_versions[$migration_script_name];
349 349
 	}
350 350
 
351 351
 	/**
@@ -354,13 +354,13 @@  discard block
 block discarded – undo
354 354
 	 * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints)
355 355
 	 * @throws EE_Error
356 356
 	 */
357
-	public function parse_dms_classname($classname){
357
+	public function parse_dms_classname($classname) {
358 358
 		$matches = array();
359
-		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches);
360
-		if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){
361
-				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"),$classname));
359
+		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches);
360
+		if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) {
361
+				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"), $classname));
362 362
 		}
363
-		return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4]));
363
+		return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4]));
364 364
 	}
365 365
 	/**
366 366
 	 * Ensures that the option indicating the current DB version is set. This should only be
@@ -369,33 +369,33 @@  discard block
 block discarded – undo
369 369
 	 * to 4.1.x.
370 370
 	 * @return string of current db state
371 371
 	 */
372
-	public function ensure_current_database_state_is_set(){
373
-		$espresso_db_core_updates = get_option( 'espresso_db_update', array() );
372
+	public function ensure_current_database_state_is_set() {
373
+		$espresso_db_core_updates = get_option('espresso_db_update', array());
374 374
 		$db_state = get_option(EE_Data_Migration_Manager::current_database_state);
375
-		if( ! $db_state ){
375
+		if ( ! $db_state) {
376 376
 			//mark the DB as being in the state as the last version in there.
377 377
 			//this is done to trigger maintenance mode and do data migration scripts
378 378
 			//if the admin installed this version of EE over 3.1.x or 4.0.x
379 379
 			//otherwise, the normal maintenance mode code is fine
380 380
 			$previous_versions_installed = array_keys($espresso_db_core_updates);
381 381
 			$previous_version_installed = end($previous_versions_installed);
382
-			if(version_compare('4.1.0', $previous_version_installed)){
382
+			if (version_compare('4.1.0', $previous_version_installed)) {
383 383
 				//last installed version was less than 4.1
384 384
 				//so we want the data migrations to happen. SO, we're going to say the DB is at that state
385 385
 //				echo "4.1.0 is greater than $previous_version_installed! update the option";
386 386
 				$db_state = array('Core'=>$previous_version_installed);
387
-			}else{
387
+			} else {
388 388
 //					echo "4.1.0 is SMALLER than $previous_version_installed";
389 389
 					$db_state = array('Core'=>EVENT_ESPRESSO_VERSION);
390 390
 			}
391
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
391
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
392 392
 		}
393 393
 		//in 4.1, $db_state would have only been a simple string like '4.1.0',
394 394
 		//but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's
395 395
 		//db, and possibly other keys for other addons like 'Calendar','Permissions',etc
396
-		if( ! is_array($db_state)){
396
+		if ( ! is_array($db_state)) {
397 397
 			$db_state = array('Core'=>$db_state);
398
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
398
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
399 399
 		}
400 400
 		return $db_state;
401 401
 	}
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	 * or they don't apply), returns an empty array
407 407
 	 * @return EE_Data_Migration_Script_Base[]
408 408
 	 */
409
-	public function check_for_applicable_data_migration_scripts(){
409
+	public function check_for_applicable_data_migration_scripts() {
410 410
 		//get the option describing what options have already run
411 411
 		$scripts_ran = $this->get_data_migrations_ran();
412 412
 		//$scripts_ran = array('4.1.0.core'=>array('monkey'=>null));
@@ -419,62 +419,62 @@  discard block
 block discarded – undo
419 419
 		$iteration = 0;
420 420
 		$next_database_state_to_consider = $current_database_state;
421 421
 		$theoretical_database_state = NULL;
422
-		do{
422
+		do {
423 423
 			//the next state after the currently-considered one will start off looking the same as the current, but we may make additions...
424 424
 			$theoretical_database_state = $next_database_state_to_consider;
425 425
 			//the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?)
426
-			foreach($script_class_and_filepaths_available as $classname => $filepath){
426
+			foreach ($script_class_and_filepaths_available as $classname => $filepath) {
427 427
 
428 428
 				$migrates_to_version = $this->script_migrates_to_version($classname);
429
-				$script_converts_plugin_slug = $migrates_to_version[ 'slug' ];
430
-				$script_converts_to_version = $migrates_to_version[ 'version' ];
429
+				$script_converts_plugin_slug = $migrates_to_version['slug'];
430
+				$script_converts_to_version = $migrates_to_version['version'];
431 431
 				//check if this version script is DONE or not; or if it's never been ran
432
-				if(		! $scripts_ran ||
432
+				if ( ! $scripts_ran ||
433 433
 						! isset($scripts_ran[$script_converts_plugin_slug]) ||
434
-						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){
434
+						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) {
435 435
 					//we haven't ran this conversion script before
436 436
 					//now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available
437
-					$script = new $classname( $this->_get_table_manager(), $this->_get_table_analysis() );
437
+					$script = new $classname($this->_get_table_manager(), $this->_get_table_analysis());
438 438
 					/* @var $script EE_Data_Migration_Script_Base */
439 439
 					$can_migrate = $script->can_migrate_from_version($theoretical_database_state);
440
-					if($can_migrate){
440
+					if ($can_migrate) {
441 441
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
442 442
 						$migrates_to_version = $script->migrates_to_version();
443
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
443
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
444 444
 						unset($script_class_and_filepaths_available[$classname]);
445 445
 					}
446
-				} elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){
446
+				} elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) {
447 447
 					//this script has been ran, or at least started
448 448
 					$script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version];
449
-					if( $script->get_status() != self::status_completed){
449
+					if ($script->get_status() != self::status_completed) {
450 450
 						//this script is already underway... keep going with it
451 451
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
452 452
 						$migrates_to_version = $script->migrates_to_version();
453
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
453
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
454 454
 						unset($script_class_and_filepaths_available[$classname]);
455
-					}else{
455
+					} else {
456 456
 						//it must have a status that indicates it has finished, so we don't want to try and run it again
457 457
 					}
458
-				}else{
458
+				} else {
459 459
 					//it exists but it's not  a proper data migration script
460 460
 					//maybe the script got renamed? or was simply removed from EE?
461 461
 					//either way, its certainly not runnable!
462 462
 				}
463 463
 			}
464 464
 			$iteration++;
465
-		}while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6);
465
+		}while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6);
466 466
 		//ok we have all the scripts that should run, now let's make them into flat array
467 467
 		$scripts_that_should_run = array();
468
-		foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){
468
+		foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) {
469 469
 			ksort($scripts_at_priority);
470
-			foreach($scripts_at_priority as $scripts){
471
-				foreach($scripts as $script){
470
+			foreach ($scripts_at_priority as $scripts) {
471
+				foreach ($scripts as $script) {
472 472
 					$scripts_that_should_run[get_class($script)] = $script;
473 473
 				}
474 474
 			}
475 475
 		}
476 476
 
477
-		do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run );
477
+		do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run);
478 478
 		return $scripts_that_should_run;
479 479
 	}
480 480
 
@@ -488,14 +488,14 @@  discard block
 block discarded – undo
488 488
 	 * @param bool $include_completed_scripts
489 489
 	 * @return EE_Data_Migration_Script_Base
490 490
 	 */
491
-	public function get_last_ran_script($include_completed_scripts = false){
491
+	public function get_last_ran_script($include_completed_scripts = false) {
492 492
 		//make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script
493
-		if( ! $this->_data_migrations_ran){
493
+		if ( ! $this->_data_migrations_ran) {
494 494
 			$this->get_data_migrations_ran();
495 495
 		}
496
-		if($include_completed_scripts){
496
+		if ($include_completed_scripts) {
497 497
 			return $this->_last_ran_script;
498
-		}else{
498
+		} else {
499 499
 			return $this->_last_ran_incomplete_script;
500 500
 		}
501 501
 	}
@@ -518,19 +518,19 @@  discard block
 block discarded – undo
518 518
 	 * 		@type string $message string describing what was done during this step
519 519
 	 * }
520 520
 	 */
521
-	public function migration_step( $step_size = 0 ){
521
+	public function migration_step($step_size = 0) {
522 522
 
523 523
 		//bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535
524
-		if ( class_exists( 'EE_CPT_Strategy' ) ) {
525
-			remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 );
524
+		if (class_exists('EE_CPT_Strategy')) {
525
+			remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5);
526 526
 		}
527 527
 
528
-		try{
528
+		try {
529 529
 			$currently_executing_script = $this->get_last_ran_script();
530
-			if( ! $currently_executing_script){
530
+			if ( ! $currently_executing_script) {
531 531
 				//Find the next script that needs to execute
532 532
 				$scripts = $this->check_for_applicable_data_migration_scripts();
533
-				if( ! $scripts ){
533
+				if ( ! $scripts) {
534 534
 					//huh, no more scripts to run... apparently we're done!
535 535
 					//but dont forget to make sure initial data is there
536 536
 					//we should be good to allow them to exit maintenance mode now
@@ -551,18 +551,18 @@  discard block
 block discarded – undo
551 551
 				//and add to the array/wp option showing the scripts ran
552 552
 //				$this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script;
553 553
 				$migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script));
554
-				$plugin_slug = $migrates_to[ 'slug' ];
555
-				$version = $migrates_to[ 'version' ];
554
+				$plugin_slug = $migrates_to['slug'];
555
+				$version = $migrates_to['version'];
556 556
 				$this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script;
557 557
 			}
558 558
 			$current_script_name = get_class($currently_executing_script);
559
-		}catch(Exception $e){
559
+		} catch (Exception $e) {
560 560
 			//an exception occurred while trying to get migration scripts
561 561
 
562
-			$message =  sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() );
562
+			$message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString());
563 563
 			//record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations
564 564
 			//but that's ok-- it's just an FYI to support that we couldn't even run any data migrations
565
-			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message));
565
+			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message));
566 566
 			return array(
567 567
 				'records_to_migrate'=>1,
568 568
 				'records_migrated'=>0,
@@ -572,16 +572,16 @@  discard block
 block discarded – undo
572 572
 			);
573 573
 		}
574 574
 		//ok so we definitely have a data migration script
575
-		try{
575
+		try {
576 576
 			//how big of a bite do we want to take? Allow users to easily override via their wp-config
577
-			if( ! absint( $step_size ) > 0 ){
578
-				$step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
577
+			if ( ! absint($step_size) > 0) {
578
+				$step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
579 579
 			}
580 580
 			//do what we came to do!
581 581
 			$currently_executing_script->migration_step($step_size);
582 582
 			//can we wrap it up and verify default data?
583 583
 			$init_dbs = false;
584
-			switch($currently_executing_script->get_status()){
584
+			switch ($currently_executing_script->get_status()) {
585 585
 				case EE_Data_Migration_Manager::status_continue:
586 586
 					$response_array = array(
587 587
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
@@ -593,16 +593,16 @@  discard block
 block discarded – undo
593 593
 				case EE_Data_Migration_Manager::status_completed:
594 594
 					//ok so THAT script has completed
595 595
 					$this->update_current_database_state_to($this->script_migrates_to_version($current_script_name));
596
-					$response_array =  array(
596
+					$response_array = array(
597 597
 							'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
598 598
 							'records_migrated'=>$currently_executing_script->count_records_migrated(),
599 599
 							'status'=> EE_Data_Migration_Manager::status_completed,
600 600
 							'message'=>$currently_executing_script->get_feedback_message(),
601
-							'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name())
601
+							'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name())
602 602
 						);
603 603
 					//check if there are any more after this one.
604 604
 					$scripts_remaining = $this->check_for_applicable_data_migration_scripts();
605
-					if( ! $scripts_remaining ){
605
+					if ( ! $scripts_remaining) {
606 606
 						//we should be good to allow them to exit maintenance mode now
607 607
 						EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance));
608 608
 						////huh, no more scripts to run... apparently we're done!
@@ -616,39 +616,39 @@  discard block
 block discarded – undo
616 616
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
617 617
 						'records_migrated'=>$currently_executing_script->count_records_migrated(),
618 618
 						'status'=> $currently_executing_script->get_status(),
619
-						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())),
619
+						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())),
620 620
 						'script'=>$currently_executing_script->pretty_name()
621 621
 					);
622 622
 					break;
623 623
 			}
624
-		}catch(Exception $e){
624
+		} catch (Exception $e) {
625 625
 			//ok so some exception was thrown which killed the data migration script
626 626
 			//double-check we have a real script
627
-			if($currently_executing_script instanceof EE_Data_Migration_Script_Base){
627
+			if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) {
628 628
 				$script_name = $currently_executing_script->pretty_name();
629 629
 				$currently_executing_script->set_broken();
630 630
 				$currently_executing_script->add_error($e->getMessage());
631
-			}else{
631
+			} else {
632 632
 				$script_name = __("Error getting Migration Script", "event_espresso");
633 633
 			}
634 634
 			$response_array = array(
635 635
 				'records_to_migrate'=>1,
636 636
 				'records_migrated'=>0,
637 637
 				'status'=>self::status_fatal_error,
638
-				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()),
638
+				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()),
639 639
 				'script'=>$script_name
640 640
 			);
641 641
 		}
642 642
 		$successful_save = $this->_save_migrations_ran();
643
-		if($successful_save !== TRUE){
643
+		if ($successful_save !== TRUE) {
644 644
 			//ok so the current wp option didn't save. that's tricky, because we'd like to update it
645 645
 			//and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION!
646 646
 			//however, if we throw an exception, and return that, then the next request
647 647
 			//won't have as much info in it, and it may be able to save
648
-			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save));
648
+			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save));
649 649
 		}
650 650
 		//if we're all done, initialize EE plugins' default data etc.
651
-		if( $init_dbs ) {
651
+		if ($init_dbs) {
652 652
 			$this->initialize_db_for_enqueued_ee_plugins();
653 653
 		}
654 654
 		return $response_array;
@@ -666,23 +666,23 @@  discard block
 block discarded – undo
666 666
 	 * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into errors, notifications, and successes
667 667
 	 * 'script'=>a pretty name of the script currently running
668 668
 	 */
669
-	public function response_to_migration_ajax_request(){
669
+	public function response_to_migration_ajax_request() {
670 670
 //		//start output buffer just to make sure we don't mess up the json
671 671
 		ob_start();
672
-		try{
672
+		try {
673 673
 			$response = $this->migration_step();
674
-		}catch(Exception $e){
674
+		} catch (Exception $e) {
675 675
 			$response = array(
676 676
 				'records_to_migrate'=>0,
677 677
 				'records_migrated'=>0,
678 678
 				'status'=> EE_Data_Migration_Manager::status_fatal_error,
679
-				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()),
679
+				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()),
680 680
 				'script'=>'Unknown');
681 681
 			$this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString());
682 682
 		}
683 683
 		$warnings_etc = @ob_get_contents();
684 684
 		ob_end_clean();
685
-		$response['message'] .=$warnings_etc;
685
+		$response['message'] .= $warnings_etc;
686 686
 		return $response;
687 687
 	}
688 688
 
@@ -695,14 +695,14 @@  discard block
 block discarded – undo
695 695
 	 * }
696 696
 	 * @return void
697 697
 	 */
698
-	public function update_current_database_state_to($slug_and_version = null){
699
-		if( ! $slug_and_version ){
698
+	public function update_current_database_state_to($slug_and_version = null) {
699
+		if ( ! $slug_and_version) {
700 700
 			//no version was provided, assume it should be at the current code version
701 701
 			$slug_and_version = array('slug' => 'Core', 'version' => espresso_version());
702 702
 		}
703 703
 		$current_database_state = get_option(self::current_database_state);
704
-		$current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ];
705
-		update_option(self::current_database_state,$current_database_state);
704
+		$current_database_state[$slug_and_version['slug']] = $slug_and_version['version'];
705
+		update_option(self::current_database_state, $current_database_state);
706 706
 	}
707 707
 
708 708
 	/**
@@ -713,20 +713,20 @@  discard block
 block discarded – undo
713 713
 	 * }
714 714
 	 * @return boolean
715 715
 	 */
716
-	public function database_needs_updating_to( $slug_and_version ) {
716
+	public function database_needs_updating_to($slug_and_version) {
717 717
 
718
-		$slug = $slug_and_version[ 'slug' ];
719
-		$version = $slug_and_version[ 'version' ];
718
+		$slug = $slug_and_version['slug'];
719
+		$version = $slug_and_version['version'];
720 720
 		$current_database_state = get_option(self::current_database_state);
721
-		if( ! isset( $current_database_state[ $slug ] ) ) {
721
+		if ( ! isset($current_database_state[$slug])) {
722 722
 			return true;
723
-		}else{
723
+		} else {
724 724
 			//just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
725
-			$version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3);
726
-			$version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 );
725
+			$version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3);
726
+			$version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3);
727 727
 			$needs_updating = false;
728
-			foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) {
729
-				if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) {
728
+			foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) {
729
+				if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) {
730 730
 					$needs_updating = true;
731 731
 					break;
732 732
 				}
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      */
749 749
     public function get_all_data_migration_scripts_available()
750 750
     {
751
-        if (! $this->_data_migration_class_to_filepath_map) {
751
+        if ( ! $this->_data_migration_class_to_filepath_map) {
752 752
             $this->_data_migration_class_to_filepath_map = array();
753 753
             foreach ($this->get_data_migration_script_folders() as $eeAddonClass => $folder_path) {
754 754
                 // strip any placeholders added to classname to make it a unique array key
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
                     ? $eeAddonClass
758 758
                     : '';
759 759
                 $folder_path  = EEH_File::end_with_directory_separator($folder_path);
760
-                $files        = glob($folder_path . '*.dms.php');
760
+                $files        = glob($folder_path.'*.dms.php');
761 761
                 if (empty($files)) {
762 762
                     continue;
763 763
                 }
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
                             '4.3.0.alpha.019'
784 784
                         );
785 785
                     }
786
-                    $this->_data_migration_class_to_filepath_map[ $classname ] = $file;
786
+                    $this->_data_migration_class_to_filepath_map[$classname] = $file;
787 787
                 }
788 788
             }
789 789
             EEH_Autoloader::register_autoloader($this->_data_migration_class_to_filepath_map);
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 	 * from each addon, and check if they need updating,
799 799
 	 * @return boolean
800 800
 	 */
801
-	public function addons_need_updating(){
801
+	public function addons_need_updating() {
802 802
 		return false;
803 803
 	}
804 804
 	/**
@@ -807,25 +807,25 @@  discard block
 block discarded – undo
807 807
 	 * @param string $error_message
808 808
 	 * @throws EE_Error
809 809
 	 */
810
-	public function add_error_to_migrations_ran($error_message){
810
+	public function add_error_to_migrations_ran($error_message) {
811 811
 		//get last-ran migration script
812 812
 		global $wpdb;
813
-		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",ARRAY_A);
813
+		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", ARRAY_A);
814 814
 
815 815
 		$last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null;
816 816
 		//now, tread lightly because we're here because a FATAL non-catchable error
817 817
 		//was thrown last time when we were trying to run a data migration script
818 818
 		//so the fatal error could have happened while getting the migration script
819 819
 		//or doing running it...
820
-		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$last_migration_script_option['option_name']) : null;
820
+		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $last_migration_script_option['option_name']) : null;
821 821
 
822 822
 		//check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet
823 823
 		//because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done)
824
-		if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){
824
+		if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) {
825 825
 			//ok then just add this error to its list of errors
826 826
 			$last_ran_migration_script_properties['_errors'][] = $error_message;
827 827
 			$last_ran_migration_script_properties['_status'] = self::status_fatal_error;
828
-		}else{
828
+		} else {
829 829
 			//so we don't even know which script was last running
830 830
 			//use the data migration error stub, which is designed specifically for this type of thing
831 831
 			$general_migration_error = new EE_DMS_Unknown_1_0_0();
@@ -835,39 +835,39 @@  discard block
 block discarded – undo
835 835
 			$versions_migrated_to = 'Unknown.1.0.0';
836 836
 			//now just to make sure appears as last (in case the were previously a fatal error like this)
837 837
 			//delete the old one
838
-			delete_option( self::data_migration_script_option_prefix . $versions_migrated_to );
838
+			delete_option(self::data_migration_script_option_prefix.$versions_migrated_to);
839 839
 		}
840
-		update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties);
840
+		update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties);
841 841
 
842 842
 	}
843 843
 	/**
844 844
 	 * saves what data migrations have ran to the database
845 845
 	 * @return mixed TRUE if successfully saved migrations ran, string if an error occurred
846 846
 	 */
847
-	protected function _save_migrations_ran(){
848
-		if($this->_data_migrations_ran == null){
847
+	protected function _save_migrations_ran() {
848
+		if ($this->_data_migrations_ran == null) {
849 849
 			$this->get_data_migrations_ran();
850 850
 		}
851 851
 		//now, we don't want to save actual classes to the DB because that's messy
852 852
 		$successful_updates = true;
853
-		foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){
854
-			foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){
853
+		foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) {
854
+			foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) {
855 855
 	//			echo "saving migration script to $version_string<br>";
856 856
 				$plugin_slug_for_use_in_option_name = $plugin_slug.".";
857 857
 				$option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string;
858 858
 				$old_option_value = get_option($option_name);
859
-				if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){
859
+				if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) {
860 860
 					$script_array_for_saving = $array_or_migration_obj->properties_as_array();
861
-					if( $old_option_value != $script_array_for_saving){
862
-						$successful_updates = update_option($option_name,$script_array_for_saving);
861
+					if ($old_option_value != $script_array_for_saving) {
862
+						$successful_updates = update_option($option_name, $script_array_for_saving);
863 863
 					}
864
-				}else{//we don't know what this array-thing is. So just save it as-is
864
+				} else {//we don't know what this array-thing is. So just save it as-is
865 865
 	//				$array_of_migrations[$version_string] = $array_or_migration_obj;
866
-					if($old_option_value != $array_or_migration_obj){
867
-						$successful_updates = update_option($option_name,$array_or_migration_obj);
866
+					if ($old_option_value != $array_or_migration_obj) {
867
+						$successful_updates = update_option($option_name, $array_or_migration_obj);
868 868
 					}
869 869
 				}
870
-				if( ! $successful_updates ){
870
+				if ( ! $successful_updates) {
871 871
 					global $wpdb;
872 872
 					return $wpdb->last_error;
873 873
 				}
@@ -891,17 +891,17 @@  discard block
 block discarded – undo
891 891
 	 * @return EE_Data_Migration_Script_Base
892 892
 	 * @throws EE_Error
893 893
 	 */
894
-	function _instantiate_script_from_properties_array($properties_array){
895
-		if( ! isset($properties_array['class'])){
896
-			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array)));
894
+	function _instantiate_script_from_properties_array($properties_array) {
895
+		if ( ! isset($properties_array['class'])) {
896
+			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array)));
897 897
 		}
898 898
 		$class_name = $properties_array['class'];
899
-		if( ! class_exists($class_name)){
900
-			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name));
899
+		if ( ! class_exists($class_name)) {
900
+			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name));
901 901
 		}
902 902
 		$class = new $class_name;
903
-		if( ! $class instanceof EE_Data_Migration_Script_Base){
904
-			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),$class_name,get_class($class)));
903
+		if ( ! $class instanceof EE_Data_Migration_Script_Base) {
904
+			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"), $class_name, get_class($class)));
905 905
 		}
906 906
 		$class->instantiate_from_array_of_properties($properties_array);
907 907
 		return $class;
@@ -913,25 +913,25 @@  discard block
 block discarded – undo
913 913
 	 * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core'
914 914
 	 * @return string
915 915
 	 */
916
-	public function get_most_up_to_date_dms($plugin_slug = 'Core'){
916
+	public function get_most_up_to_date_dms($plugin_slug = 'Core') {
917 917
 		$class_to_filepath_map = $this->get_all_data_migration_scripts_available();
918 918
 		$most_up_to_date_dms_classname = NULL;
919
-		foreach($class_to_filepath_map as $classname => $filepath){
920
-			if($most_up_to_date_dms_classname === NULL){
919
+		foreach ($class_to_filepath_map as $classname => $filepath) {
920
+			if ($most_up_to_date_dms_classname === NULL) {
921 921
 				$migrates_to = $this->script_migrates_to_version($classname);
922
-				$this_plugin_slug = $migrates_to[ 'slug' ];
922
+				$this_plugin_slug = $migrates_to['slug'];
923 923
 //				$version_string = $migrates_to[ 'version' ];
924 924
 //				$details = $this->parse_dms_classname($classname);
925
-				if($this_plugin_slug == $plugin_slug){
925
+				if ($this_plugin_slug == $plugin_slug) {
926 926
 					//if it's for core, it wins
927 927
 					$most_up_to_date_dms_classname = $classname;
928 928
 				}
929 929
 				//if it wasn't for core, we must keep searching for one that is!
930 930
 				continue;
931
-			}else{
932
-				$champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname);
931
+			} else {
932
+				$champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname);
933 933
 				$contender_migrates_to = $this->script_migrates_to_version($classname);
934
-				if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){
934
+				if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) {
935 935
 					//so the contenders version is higher and its for Core
936 936
 					$most_up_to_date_dms_classname = $classname;
937 937
 				}
@@ -951,11 +951,11 @@  discard block
 block discarded – undo
951 951
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
952 952
 	 * @return EE_Data_Migration_Script_Base
953 953
 	 */
954
-	public function get_migration_ran( $version, $plugin_slug = 'Core' ) {
954
+	public function get_migration_ran($version, $plugin_slug = 'Core') {
955 955
 		$migrations_ran = $this->get_data_migrations_ran();
956
-		if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){
957
-			return $migrations_ran[ $plugin_slug ][ $version ];
958
-		}else{
956
+		if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) {
957
+			return $migrations_ran[$plugin_slug][$version];
958
+		} else {
959 959
 			return NULL;
960 960
 		}
961 961
 	}
@@ -967,20 +967,20 @@  discard block
 block discarded – undo
967 967
 	 * @return bool
968 968
 	 * @throws EE_Error
969 969
 	 */
970
-	public function reattempt(){
970
+	public function reattempt() {
971 971
 		//find if the last-ran script was borked
972 972
 		//set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
973 973
 		//add an 'error' saying that we attempted to reset
974 974
 		//does it have a stage that was borked too? if so make it no longer borked
975 975
 		//add an 'error' saying we attempted to reset
976 976
 		$last_ran_script = $this->get_last_ran_script();
977
-		if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){
977
+		if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) {
978 978
 			//if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it)
979 979
 			$last_ran_script->set_completed();
980
-		}elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) {
980
+		}elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) {
981 981
 			$last_ran_script->reattempt();
982
-		}else{
983
-			throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) );
982
+		} else {
983
+			throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script, true)));
984 984
 		}
985 985
 		return $this->_save_migrations_ran();
986 986
 	}
@@ -990,19 +990,19 @@  discard block
 block discarded – undo
990 990
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
991 991
 	 * @return boolean
992 992
 	 */
993
-	public function migration_has_ran( $version, $plugin_slug = 'Core' ) {
994
-		return $this->get_migration_ran( $version, $plugin_slug ) !== NULL;
993
+	public function migration_has_ran($version, $plugin_slug = 'Core') {
994
+		return $this->get_migration_ran($version, $plugin_slug) !== NULL;
995 995
 	}
996 996
 	/**
997 997
 	 * Enqueues this ee plugin to have its data initialized
998 998
 	 * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value
999 999
 	 */
1000
-	public function enqueue_db_initialization_for( $plugin_slug ) {
1000
+	public function enqueue_db_initialization_for($plugin_slug) {
1001 1001
 		$queue = $this->get_db_initialization_queue();
1002
-		if( ! in_array( $plugin_slug, $queue ) ) {
1002
+		if ( ! in_array($plugin_slug, $queue)) {
1003 1003
 			$queue[] = $plugin_slug;
1004 1004
 		}
1005
-		update_option( self::db_init_queue_option_name, $queue );
1005
+		update_option(self::db_init_queue_option_name, $queue);
1006 1006
 	}
1007 1007
 	/**
1008 1008
 	 * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon
@@ -1012,26 +1012,26 @@  discard block
 block discarded – undo
1012 1012
 	public function initialize_db_for_enqueued_ee_plugins() {
1013 1013
 //		EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' );
1014 1014
 		$queue = $this->get_db_initialization_queue();
1015
-		foreach( $queue as $plugin_slug ) {
1016
-			$most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug );
1017
-			if( ! $most_up_to_date_dms ) {
1015
+		foreach ($queue as $plugin_slug) {
1016
+			$most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug);
1017
+			if ( ! $most_up_to_date_dms) {
1018 1018
 				//if there is NO DMS for this plugin, obviously there's no schema to verify anyways
1019 1019
 				$verify_db = false;
1020
-			}else{
1021
-				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms );
1022
-				$verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to );
1020
+			} else {
1021
+				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms);
1022
+				$verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to);
1023 1023
 			}
1024
-			if( $plugin_slug == 'Core' ){
1024
+			if ($plugin_slug == 'Core') {
1025 1025
 				EE_System::instance()->initialize_db_if_no_migrations_required(
1026 1026
 						false,
1027 1027
 						$verify_db
1028 1028
 					);
1029
-			}else{
1029
+			} else {
1030 1030
 				//just loop through the addons to make sure their database is setup
1031
-				foreach( EE_Registry::instance()->addons as $addon ) {
1032
-					if( $addon->name() == $plugin_slug ) {
1031
+				foreach (EE_Registry::instance()->addons as $addon) {
1032
+					if ($addon->name() == $plugin_slug) {
1033 1033
 
1034
-						$addon->initialize_db_if_no_migrations_required( $verify_db );
1034
+						$addon->initialize_db_if_no_migrations_required($verify_db);
1035 1035
 						break;
1036 1036
 					}
1037 1037
 				}
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 //		EEH_Debug_Tools::instance()->show_times();
1042 1042
 		//because we just initialized the DBs for the enqueued ee plugins
1043 1043
 		//we don't need to keep remembering which ones needed to be initialized
1044
-		delete_option( self::db_init_queue_option_name );
1044
+		delete_option(self::db_init_queue_option_name);
1045 1045
 	}
1046 1046
 
1047 1047
 	/**
@@ -1050,8 +1050,8 @@  discard block
 block discarded – undo
1050 1050
 	 * 'Core', or the return value of EE_Addon::name() for an addon
1051 1051
 	 * @return array
1052 1052
 	 */
1053
-	public function get_db_initialization_queue(){
1054
-		return get_option ( self::db_init_queue_option_name, array() );
1053
+	public function get_db_initialization_queue() {
1054
+		return get_option(self::db_init_queue_option_name, array());
1055 1055
 	}
1056 1056
 
1057 1057
 	/**
@@ -1061,13 +1061,13 @@  discard block
 block discarded – undo
1061 1061
 	 * @throws EE_Error
1062 1062
 	 */
1063 1063
 	protected function _get_table_analysis() {
1064
-		if( $this->_table_analysis instanceof TableAnalysis ) {
1064
+		if ($this->_table_analysis instanceof TableAnalysis) {
1065 1065
 			return $this->_table_analysis;
1066 1066
 		} else {
1067 1067
 			throw new EE_Error(
1068 1068
 				sprintf(
1069
-					__( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'),
1070
-					get_class( $this )
1069
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
1070
+					get_class($this)
1071 1071
 				)
1072 1072
 			);
1073 1073
 		}
@@ -1080,13 +1080,13 @@  discard block
 block discarded – undo
1080 1080
 	 * @throws EE_Error
1081 1081
 	 */
1082 1082
 	protected function _get_table_manager() {
1083
-		if( $this->_table_manager instanceof TableManager ) {
1083
+		if ($this->_table_manager instanceof TableManager) {
1084 1084
 			return $this->_table_manager;
1085 1085
 		} else {
1086 1086
 			throw new EE_Error(
1087 1087
 				sprintf(
1088
-					__( 'Table manager class on class %1$s is not set properly.', 'event_espresso'),
1089
-					get_class( $this )
1088
+					__('Table manager class on class %1$s is not set properly.', 'event_espresso'),
1089
+					get_class($this)
1090 1090
 				)
1091 1091
 			);
1092 1092
 		}
Please login to merge, or discard this patch.
core/domain/services/DomainService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\domain\services;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
Please login to merge, or discard this patch.
core/helpers/EEH_Class_Tools.helper.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -35,35 +35,35 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public static function get_called_class() {
37 37
 		$backtrace = debug_backtrace();
38
-		if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['class'] ) && ! isset( $backtrace[2]['file'] )) {
38
+		if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['class']) && ! isset($backtrace[2]['file'])) {
39 39
 			return $backtrace[2]['class'];
40
-		} else if ( isset( $backtrace[3] ) && is_array( $backtrace[3] ) && isset( $backtrace[3]['class'] ) && ! isset( $backtrace[3]['file'] )) {
40
+		} else if (isset($backtrace[3]) && is_array($backtrace[3]) && isset($backtrace[3]['class']) && ! isset($backtrace[3]['file'])) {
41 41
 			return $backtrace[3]['class'];
42
-		} else if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['file'] ) && isset( $backtrace[2]['line'] )) {
43
-			if ( self::$file_line == $backtrace[2]['file'] . $backtrace[2]['line'] ) {
42
+		} else if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['file']) && isset($backtrace[2]['line'])) {
43
+			if (self::$file_line == $backtrace[2]['file'].$backtrace[2]['line']) {
44 44
 				self::$i++;
45 45
 			} else {
46 46
 				self::$i = 0;
47
-				self::$file_line = $backtrace[2]['file'] . $backtrace[2]['line'];
47
+				self::$file_line = $backtrace[2]['file'].$backtrace[2]['line'];
48 48
 			}
49 49
 			// was  class method called via call_user_func ?
50
-			if ( $backtrace[2]['function'] == 'call_user_func' && isset( $backtrace[2]['args'] ) && is_array( $backtrace[2]['args'] )){
51
-				if ( isset( $backtrace[2]['args'][0] ) && isset( $backtrace[2]['args'][0][0] )) {
50
+			if ($backtrace[2]['function'] == 'call_user_func' && isset($backtrace[2]['args']) && is_array($backtrace[2]['args'])) {
51
+				if (isset($backtrace[2]['args'][0]) && isset($backtrace[2]['args'][0][0])) {
52 52
 					$called_class = $backtrace[2]['args'][0][0];
53 53
 					// is it an EE function ?
54
-					if ( strpos( $called_class, 'EE' ) === 0 ) {
55
-						$prefix_chars = strpos( $called_class, '_' ) + 1;
56
-						$prefix = substr( $called_class, 0, $prefix_chars );
57
-						$classname = substr( $called_class, $prefix_chars, strlen( $called_class ));
58
-						$classname = $prefix . str_replace( ' ', '_', ucwords( strtolower( str_replace( '_', ' ', $classname  ))));
54
+					if (strpos($called_class, 'EE') === 0) {
55
+						$prefix_chars = strpos($called_class, '_') + 1;
56
+						$prefix = substr($called_class, 0, $prefix_chars);
57
+						$classname = substr($called_class, $prefix_chars, strlen($called_class));
58
+						$classname = $prefix.str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname))));
59 59
 						return $classname;
60 60
 					}
61 61
 				}
62 62
 			} else {
63
-				$lines = file( $backtrace[2]['file'] );
64
-				preg_match_all( '/([a-zA-Z0-9\_]+)::' . $backtrace[2]['function'] . '/', $lines[$backtrace[2]['line']-1], $matches );
65
-				if ( isset( $matches[1] ) && isset( $matches[1][ self::$i ] )) {
66
-					return $matches[1][ self::$i ];
63
+				$lines = file($backtrace[2]['file']);
64
+				preg_match_all('/([a-zA-Z0-9\_]+)::'.$backtrace[2]['function'].'/', $lines[$backtrace[2]['line'] - 1], $matches);
65
+				if (isset($matches[1]) && isset($matches[1][self::$i])) {
66
+					return $matches[1][self::$i];
67 67
 				}
68 68
 			}
69 69
 		}
@@ -80,22 +80,22 @@  discard block
 block discarded – undo
80 80
 	 * 	@param 	string 	$hook
81 81
 	 * 	@return 	array
82 82
 	 */
83
-	public static function get_class_names_for_all_callbacks_on_hook( $hook = NULL ) {
83
+	public static function get_class_names_for_all_callbacks_on_hook($hook = NULL) {
84 84
 		global $wp_filter;
85 85
 		$class_names = array();
86 86
 		// are any callbacks registered for this hook ?
87
-		if ( isset( $wp_filter[ $hook ] )) {
87
+		if (isset($wp_filter[$hook])) {
88 88
 			// loop thru all of the callbacks attached to the deprecated hookpoint
89
-			foreach( $wp_filter[ $hook ] as $priority ) {
90
-				foreach( $priority as $callback ) {
89
+			foreach ($wp_filter[$hook] as $priority) {
90
+				foreach ($priority as $callback) {
91 91
 					// is the callback a non-static class method ?
92
-					if ( isset( $callback['function'] ) && is_array( $callback['function'] )) {
93
-						if ( isset( $callback['function'][0] ) && is_object( $callback['function'][0] )) {
94
-							$class_names[] = get_class( $callback['function'][0] );
92
+					if (isset($callback['function']) && is_array($callback['function'])) {
93
+						if (isset($callback['function'][0]) && is_object($callback['function'][0])) {
94
+							$class_names[] = get_class($callback['function'][0]);
95 95
 						}
96 96
 					// test for static method
97
-					} else if ( strpos( $callback['function'], '::' ) !== FALSE ) {
98
-						$class = explode( '::', $callback['function'] );
97
+					} else if (strpos($callback['function'], '::') !== FALSE) {
98
+						$class = explode('::', $callback['function']);
99 99
 						$class_names[] = $class[0];
100 100
 					} else {
101 101
 						// just a function
@@ -116,24 +116,24 @@  discard block
 block discarded – undo
116 116
 	 * 	@param		string 	$property
117 117
 	 * 	@return 		boolean
118 118
 	 */
119
-	public static function has_property( $class = NULL, $property = NULL ) {
119
+	public static function has_property($class = NULL, $property = NULL) {
120 120
 		// if $class or $property don't exist, then get out, cuz that would be like... fatal dude
121
-		if ( empty( $class ) || empty( $property )) {
121
+		if (empty($class) || empty($property)) {
122 122
 			return FALSE;
123 123
 		}
124 124
 		// if your hosting company doesn't cut the mustard
125
-		if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) {
125
+		if (version_compare(PHP_VERSION, '5.3.0') < 0) {
126 126
 			// just in case $class is an actual instantiated object
127
-			if ( is_object( $class )) {
128
-				return isset( $class->{$property} ) ? TRUE : FALSE;
127
+			if (is_object($class)) {
128
+				return isset($class->{$property} ) ? TRUE : FALSE;
129 129
 			} else {
130 130
 				// use reflection for < PHP 5.3 to get details using just the class name
131
-				$reflector = new ReflectionClass( $class );
132
-				return $reflector->hasProperty( $property );
131
+				$reflector = new ReflectionClass($class);
132
+				return $reflector->hasProperty($property);
133 133
 			}
134 134
 		} else {
135 135
 			// or try regular property exists method which works as expected in PHP 5.3+
136
-			return property_exists( $class, $property );
136
+			return property_exists($class, $property);
137 137
 		}
138 138
 	}
139 139
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 
145 145
 // if PHP version < 5.3
146
-if ( ! function_exists( 'get_called_class' )) {
146
+if ( ! function_exists('get_called_class')) {
147 147
 	/**
148 148
 	 * @return string
149 149
 	 */
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/helpers/EEH_Sideloader.helper.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 
30 30
 
31
-require_once( EE_HELPERS . 'EEH_Base.helper.php' );
31
+require_once(EE_HELPERS.'EEH_Base.helper.php');
32 32
 class EEH_Sideloader extends EEH_Base {
33 33
 
34 34
 	private $_upload_to;
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @access public
44 44
 	 * @param array $init array fo initializing the sideloader if keys match the properties.
45 45
 	 */
46
-	public function __construct( $init = array() ) {
47
-		$this->_init( $init );
46
+	public function __construct($init = array()) {
47
+		$this->_init($init);
48 48
 	}
49 49
 
50 50
 
@@ -55,24 +55,24 @@  discard block
 block discarded – undo
55 55
 	 * @param  array  $init array on init (keys match properties others ignored)
56 56
 	 * @return void
57 57
 	 */
58
-	private function _init( $init ) {
58
+	private function _init($init) {
59 59
 		$defaults = array(
60 60
 			'_upload_to' => $this->_get_wp_uploads_dir(),
61 61
 			'_upload_from' => '',
62 62
 			'_permissions' => 0644,
63
-			'_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default'
63
+			'_new_file_name' => 'EE_Sideloader_'.uniqid().'.default'
64 64
 			);
65 65
 
66
-		$props = array_merge( $defaults, $init );
66
+		$props = array_merge($defaults, $init);
67 67
 
68
-		foreach ( $props as $key => $val ) {
69
-			if ( EEH_Class_Tools::has_property( $this, $key ) ) {
68
+		foreach ($props as $key => $val) {
69
+			if (EEH_Class_Tools::has_property($this, $key)) {
70 70
 				$this->{$key} = $val;
71 71
 			}
72 72
 		}
73 73
 
74 74
 		//make sure we include the required wp file for needed functions
75
-		require_once( ABSPATH . 'wp-admin/includes/file.php' );
75
+		require_once(ABSPATH.'wp-admin/includes/file.php');
76 76
 	}
77 77
 
78 78
 
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
 	private function _get_wp_uploads_dir() {}
81 81
 
82 82
 	//setters
83
-	public function set_upload_to( $upload_to_folder ) {
83
+	public function set_upload_to($upload_to_folder) {
84 84
 		$this->_upload_to = $upload_to_folder;
85 85
 	}
86
-	public function set_upload_from( $upload_from_folder ) {
86
+	public function set_upload_from($upload_from_folder) {
87 87
 		$this->_upload_from_folder = $upload_from_folder;
88 88
 	}
89
-	public function set_permissions( $permissions ) {
89
+	public function set_permissions($permissions) {
90 90
 		$this->_permissions = $permissions;
91 91
 	}
92
-	public function set_new_file_name( $new_file_name ) {
92
+	public function set_new_file_name($new_file_name) {
93 93
 		$this->_new_file_name = $new_file_name;
94 94
 	}
95 95
 
@@ -111,34 +111,34 @@  discard block
 block discarded – undo
111 111
 	//upload methods
112 112
 	public function sideload() {
113 113
 		//setup temp dir
114
-		$temp_file = wp_tempnam( $this->_upload_from );
114
+		$temp_file = wp_tempnam($this->_upload_from);
115 115
 
116
-		if ( !$temp_file ) {
117
-			EE_Error::add_error( __('Something went wrong with the upload.  Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
116
+		if ( ! $temp_file) {
117
+			EE_Error::add_error(__('Something went wrong with the upload.  Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
118 118
 			return false;
119 119
 		}
120 120
 
121
-		do_action( 'AHEE__EEH_Sideloader__sideload__before', $this, $temp_file );
121
+		do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file);
122 122
 
123
-		$wp_remote_args = apply_filters( 'FHEE__EEH_Sideloader__sideload__wp_remote_args', array( 'timeout' => 500, 'stream' => true, 'filename' => $temp_file ), $this, $temp_file );
123
+		$wp_remote_args = apply_filters('FHEE__EEH_Sideloader__sideload__wp_remote_args', array('timeout' => 500, 'stream' => true, 'filename' => $temp_file), $this, $temp_file);
124 124
 
125
-		$response = wp_safe_remote_get( $this->_upload_from, $wp_remote_args );
125
+		$response = wp_safe_remote_get($this->_upload_from, $wp_remote_args);
126 126
 
127
-		if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
128
-			unlink( $temp_file );
129
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
130
-				EE_Error::add_error( sprintf( __('Unable to upload the file.  Either the path given to upload from is incorrect, or something else happened.  Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export( $response, true ), $this->_upload_from ), __FILE__, __FUNCTION__, __LINE__ );
127
+		if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) {
128
+			unlink($temp_file);
129
+			if (defined('WP_DEBUG') && WP_DEBUG) {
130
+				EE_Error::add_error(sprintf(__('Unable to upload the file.  Either the path given to upload from is incorrect, or something else happened.  Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export($response, true), $this->_upload_from), __FILE__, __FUNCTION__, __LINE__);
131 131
 			}
132 132
 			return false;
133 133
 		}
134 134
 
135 135
 		//possible md5 check
136
-		$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
137
-		if ( $content_md5 ) {
138
-			$md5_check = verify_file_md5( $temp_file, $content_md5 );
139
-			if ( is_wp_error( $md5_check ) ) {
140
-				unlink( $temp_file );
141
-				EE_Error::add_error( $md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
136
+		$content_md5 = wp_remote_retrieve_header($response, 'content-md5');
137
+		if ($content_md5) {
138
+			$md5_check = verify_file_md5($temp_file, $content_md5);
139
+			if (is_wp_error($md5_check)) {
140
+				unlink($temp_file);
141
+				EE_Error::add_error($md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
142 142
 				return false;
143 143
 			}
144 144
 		}
@@ -146,24 +146,24 @@  discard block
 block discarded – undo
146 146
 		$file = $temp_file;
147 147
 
148 148
 		//now we have the file, let's get it in the right directory with the right name.
149
-		$path = apply_filters( 'FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to . $this->_new_file_name, $this );
149
+		$path = apply_filters('FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to.$this->_new_file_name, $this);
150 150
 
151 151
 		//move file in
152
-		if ( false === @ rename( $file, $path ) ) {
153
-			unlink( $temp_file );
154
-			EE_Error::add_error(  sprintf( __('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso' ), $path ), __FILE__, __FUNCTION__, __LINE__ );
152
+		if (false === @ rename($file, $path)) {
153
+			unlink($temp_file);
154
+			EE_Error::add_error(sprintf(__('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso'), $path), __FILE__, __FUNCTION__, __LINE__);
155 155
 			return false;
156 156
 		}
157 157
 
158 158
 		//set permissions
159
-		$permissions = apply_filters( 'FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this );
160
-		chmod( $path, $permissions );
159
+		$permissions = apply_filters('FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this);
160
+		chmod($path, $permissions);
161 161
 
162 162
 		//that's it.  let's allow for actions after file uploaded.
163
-		do_action( 'AHEE__EE_Sideloader__sideload_after', $this, $path );
163
+		do_action('AHEE__EE_Sideloader__sideload_after', $this, $path);
164 164
 
165 165
 		//unlink tempfile
166
-		@unlink( $temp_file );
166
+		@unlink($temp_file);
167 167
 		return true;
168 168
 	}
169 169
 
Please login to merge, or discard this patch.
core/helpers/EEH_Venue_View.helper.php 3 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -208,7 +208,6 @@
 block discarded – undo
208 208
 	/**
209 209
 	 * If a venue is password protected, this will return the password form for gaining access
210 210
 	 * returns an empty string otherwise
211
-
212 211
 	 * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
213 212
 	 *
214 213
 	 * @return string
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
 	 * @param bool $password_check
46 46
 	 * @return \EE_Venue|null
47 47
 	 */
48
-	public static function get_venue( $VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true, $password_check = true ) {
49
-		$VNU_ID = absint( $VNU_ID );
48
+	public static function get_venue($VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true, $password_check = true) {
49
+		$VNU_ID = absint($VNU_ID);
50 50
 		// do we already have the Venue you are looking for?
51
-		if ( EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID ) {
51
+		if (EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
52 52
 			//If the Venue ID matches $VNU_ID, return the venue.
53
-			if( EEH_Venue_View::$_venue->ID() === $VNU_ID ) {
54
-				return EEH_Venue_View::_get_venue( $privacy_check );
53
+			if (EEH_Venue_View::$_venue->ID() === $VNU_ID) {
54
+				return EEH_Venue_View::_get_venue($privacy_check);
55 55
 			}
56 56
 			//If the Venue ID does not match, try pulling a venue using $VNU_ID.
57
-			$venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
58
-			if( $venue instanceof EE_Venue ) {
57
+			$venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
58
+			if ($venue instanceof EE_Venue) {
59 59
 				EEH_Venue_View::$_venue = $venue;
60
-				return EEH_Venue_View::_get_venue( $privacy_check );
60
+				return EEH_Venue_View::_get_venue($privacy_check);
61 61
 			}
62 62
 		}
63 63
 		// international newspaper?
64 64
 		global $post;
65
-		if ( $post instanceof WP_Post ) {
66
-			switch ( $post->post_type ) {
65
+		if ($post instanceof WP_Post) {
66
+			switch ($post->post_type) {
67 67
 				// if this is being called from an EE_Venue post,
68 68
 				// and the EE_Venue post corresponds to the EE_Venue that is being asked for,
69 69
 				// then we can try to just grab the attached EE_Venue object
@@ -71,31 +71,31 @@  discard block
 block discarded – undo
71 71
 					// the post already contains the related EE_Venue object AND one of the following is TRUE:
72 72
 					// the requested Venue ID matches the post ID OR...
73 73
 					// there was no specific Venue ID requested
74
-					if ( isset( $post->EE_Venue ) && ( $VNU_ID == $post->ID || ! $VNU_ID )) {
74
+					if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || ! $VNU_ID)) {
75 75
 						// use existing related EE_Venue object
76
-						EEH_Venue_View::$_venue =  $post->EE_Venue;
77
-					} else if ( $VNU_ID ) {
76
+						EEH_Venue_View::$_venue = $post->EE_Venue;
77
+					} else if ($VNU_ID) {
78 78
 						// there WAS a specific Venue ID requested, but it's NOT the current post object
79
-						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
79
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
80 80
 					} else {
81 81
 						// no specific Venue ID requested, so use post ID to generate EE_Venue object
82
-						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $post->ID );
82
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID);
83 83
 					}
84 84
 				break;
85 85
 
86 86
 				case 'espresso_events':
87
-					if ( $look_in_event ) {
87
+					if ($look_in_event) {
88 88
 						// grab the events related venues
89 89
 						$venues = EEH_Venue_View::get_event_venues();
90 90
 						// make sure the result is an array
91
-						$venues = is_array( $venues ) ? $venues : array();
91
+						$venues = is_array($venues) ? $venues : array();
92 92
 						// do we have an ID for a specific venue?
93
-						if ( $VNU_ID ) {
93
+						if ($VNU_ID) {
94 94
 							// loop thru the related venues
95
-							foreach( $venues as $venue ) {
96
-								if ( $venue instanceof EE_Venue ) {
95
+							foreach ($venues as $venue) {
96
+								if ($venue instanceof EE_Venue) {
97 97
 									// until we find the venue we're looking for
98
-									if ( $venue->ID() == $VNU_ID ) {
98
+									if ($venue->ID() == $VNU_ID) {
99 99
 										EEH_Venue_View::$_venue = $venue;
100 100
 										break;
101 101
 									}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 						// then the global post is an events post and this function was called with no argument
106 106
 						} else {
107 107
 							// just grab the first related event venue
108
-							EEH_Venue_View::$_venue = reset( $venues );
108
+							EEH_Venue_View::$_venue = reset($venues);
109 109
 						}
110 110
 					}
111 111
 				break;
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 			}
114 114
 		}
115 115
 		// now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID...
116
-		if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID ) {
116
+		if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
117 117
 			// sigh... pull it from the db
118
-			EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
118
+			EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
119 119
 		}
120
-		return EEH_Venue_View::_get_venue( $privacy_check, $password_check );
120
+		return EEH_Venue_View::_get_venue($privacy_check, $password_check);
121 121
 	}
122 122
 
123 123
 
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	 * @param bool $password_check
131 131
 	 * @return 	EE_Venue
132 132
 	 */
133
-	protected static function _get_venue( $privacy_check = true, $password_check = true ) {
133
+	protected static function _get_venue($privacy_check = true, $password_check = true) {
134 134
 		// check for private venues.
135 135
 		if (
136 136
 			EEH_Venue_View::$_venue instanceof EE_Venue
137 137
 			&& EEH_Venue_View::$_venue->status() == 'private'
138 138
 			&& $privacy_check
139
-			&& ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' )
139
+			&& ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')
140 140
 		) {
141 141
 			return null;
142 142
 		}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		if (
145 145
 			EEH_Venue_View::$_venue instanceof EE_Venue
146 146
 			&& $password_check
147
-			&& post_password_required( EEH_Venue_View::$_venue->ID() )
147
+			&& post_password_required(EEH_Venue_View::$_venue->ID())
148 148
 		) {
149 149
 			return null;
150 150
 		}
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	public static function get_event_venues() {
163 163
 		global $post;
164
-		if ( $post->post_type == 'espresso_events' ) {
165
-			if ( isset( $post->EE_Event ) && $post->EE_Event instanceof EE_Event ) {
164
+		if ($post->post_type == 'espresso_events') {
165
+			if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) {
166 166
 				return $post->EE_Event->venues();
167 167
 			}
168 168
 		}
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return bool|null
184 184
 	 */
185
-	public static function is_venue_private( $VNU_ID = false ) {
186
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true );
187
-		if ( ! $venue instanceof EE_Venue ) {
185
+	public static function is_venue_private($VNU_ID = false) {
186
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true);
187
+		if ( ! $venue instanceof EE_Venue) {
188 188
 			return null;
189 189
 		}
190 190
 
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
200 200
 	 * @return bool
201 201
 	 */
202
-	public static function is_venue_password_protected( $VNU_ID = false ) {
203
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true, false );
202
+	public static function is_venue_password_protected($VNU_ID = false) {
203
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
204 204
 		if (
205 205
 			$venue instanceof EE_Venue
206
-			&& post_password_required( $venue->ID() )
206
+			&& post_password_required($venue->ID())
207 207
 		) {
208 208
 			return true;
209 209
 		}
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return string
222 222
 	 */
223
-	public static function password_protected_venue_form( $VNU_ID = false ) {
224
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true, false );
223
+	public static function password_protected_venue_form($VNU_ID = false) {
224
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
225 225
 		if (
226 226
 			$venue instanceof EE_Venue
227
-			&& post_password_required( $venue->ID() )
227
+			&& post_password_required($venue->ID())
228 228
 		) {
229
-			return get_the_password_form( $venue->ID() );
229
+			return get_the_password_form($venue->ID());
230 230
 		}
231 231
 		return '';
232 232
 	}
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	 * @param int $VNU_ID
241 241
 	 * @return string
242 242
 	 */
243
-	public static function venue_description( $VNU_ID = 0 ) {
244
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
245
-		if ( $venue instanceof EE_Venue ) {
243
+	public static function venue_description($VNU_ID = 0) {
244
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
245
+		if ($venue instanceof EE_Venue) {
246 246
 			return$venue->description();
247 247
 		}
248 248
 		return '';
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
 	 * @param int $VNU_ID
258 258
 	 * @return string
259 259
 	 */
260
-	public static function venue_excerpt( $VNU_ID = 0 ) {
261
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
262
-		if ( $venue instanceof EE_Venue ) {
260
+	public static function venue_excerpt($VNU_ID = 0) {
261
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
262
+		if ($venue instanceof EE_Venue) {
263 263
 			$excerpt = $venue->excerpt() != NULL && $venue->excerpt() ? $venue->excerpt() : $venue->description();
264
-			$venue_link = ' ' . EEH_Venue_View::venue_details_link( $venue->ID(), __( 'more', 'event_espresso' ) . '&hellip;' );
265
-			return ! empty( $excerpt ) ? wp_trim_words( $excerpt, 25, '' ) . $venue_link : '';
264
+			$venue_link = ' '.EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso').'&hellip;');
265
+			return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '').$venue_link : '';
266 266
 		}
267 267
 		return '';
268 268
 	}
@@ -277,22 +277,22 @@  discard block
 block discarded – undo
277 277
 	 * @param bool $hide_uncategorized
278 278
 	 * @return string
279 279
 	 */
280
-	public static function venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE ) {
280
+	public static function venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE) {
281 281
 		$category_links = array();
282
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
283
-		if ( $venue instanceof EE_Venue ) {
282
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
283
+		if ($venue instanceof EE_Venue) {
284 284
 			// get category terms
285
-			if ( $venue_categories = get_the_terms( $venue->ID(), 'espresso_venue_categories' )) {
285
+			if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) {
286 286
 				// loop thru terms and create links
287
-				foreach ( $venue_categories as $term ) {
288
-					$url = get_term_link( $term, 'espresso_venue_categories' );
289
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
290
-						$category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a> ';
287
+				foreach ($venue_categories as $term) {
288
+					$url = get_term_link($term, 'espresso_venue_categories');
289
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
290
+						$category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a> ';
291 291
 					}
292 292
 				}
293 293
 			}
294 294
 		}
295
-		return implode( ', ', $category_links );
295
+		return implode(', ', $category_links);
296 296
 	}
297 297
 
298 298
 
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	 * @param bool $add_wrapper
308 308
 	 * @return string
309 309
 	 */
310
-	public static function venue_address( $type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true ) {
311
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
312
-		if ( $venue instanceof EE_Venue ) {
313
-			return EEH_Address::format( $venue, $type, $use_schema, $add_wrapper );
310
+	public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) {
311
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
312
+		if ($venue instanceof EE_Venue) {
313
+			return EEH_Address::format($venue, $type, $use_schema, $add_wrapper);
314 314
 		}
315 315
 		return '';
316 316
 	}
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 * @param int $VNU_ID
325 325
 	 * @return bool|string
326 326
 	 */
327
-	public static function venue_has_address( $VNU_ID = 0 ) {
328
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
329
-		if ( $venue instanceof EE_Venue ) {
330
-			return EEH_Address::format( $venue, 'inline', FALSE, FALSE );
327
+	public static function venue_has_address($VNU_ID = 0) {
328
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
329
+		if ($venue instanceof EE_Venue) {
330
+			return EEH_Address::format($venue, 'inline', FALSE, FALSE);
331 331
 		}
332 332
 		return false;
333 333
 	}
@@ -342,30 +342,30 @@  discard block
 block discarded – undo
342 342
 	 * @param int $VNU_ID
343 343
 	 * @return string
344 344
 	 */
345
-	public static function venue_name( $link_to = 'details', $VNU_ID = 0 ) {
346
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
347
-		if ( $venue instanceof EE_Venue ) {
345
+	public static function venue_name($link_to = 'details', $VNU_ID = 0) {
346
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
347
+		if ($venue instanceof EE_Venue) {
348 348
 			$venue_name = apply_filters(
349 349
 				'FHEE__EEH_Venue__venue_name__append_private_venue_name',
350 350
 				EEH_Venue_View::is_venue_private()
351
-					? EEH_Venue_View::$_venue->name() . "&nbsp;" . __( '(Private)', 'event_espresso' )
351
+					? EEH_Venue_View::$_venue->name()."&nbsp;".__('(Private)', 'event_espresso')
352 352
 					: EEH_Venue_View::$_venue->name(),
353 353
 				EEH_Venue_View::$_venue
354 354
 			);
355
-			$venue_name = EEH_Schema::name( $venue_name );
355
+			$venue_name = EEH_Schema::name($venue_name);
356 356
 
357 357
 			//if venue is trashed then ignore the "link to" setting because the venue is trashed.
358
-			if ( $venue->get('status') == 'trash' ) {
358
+			if ($venue->get('status') == 'trash') {
359 359
 				$link_to = '';
360 360
 			}
361
-			switch( $link_to ) {
361
+			switch ($link_to) {
362 362
 
363 363
 				case 'details' :
364
-					return EEH_Venue_View::venue_details_link( $venue->ID(), $venue_name );
364
+					return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name);
365 365
 				break;
366 366
 
367 367
 				case 'website' :
368
-					return EEH_Venue_View::venue_website_link( $venue->ID(), $venue_name );
368
+					return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name);
369 369
 				break;
370 370
 
371 371
 				default :
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 	 * @param    string $text
386 386
 	 * @return string
387 387
 	 */
388
-	public static function venue_details_link( $VNU_ID = 0, $text = '' ) {
389
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
390
-		if ( $venue instanceof EE_Venue ) {
391
-			return EEH_Schema::url( get_permalink( $venue->ID() ), $text );
388
+	public static function venue_details_link($VNU_ID = 0, $text = '') {
389
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
390
+		if ($venue instanceof EE_Venue) {
391
+			return EEH_Schema::url(get_permalink($venue->ID()), $text);
392 392
 		}
393 393
 		return '';
394 394
 	}
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
 	 * @param    string $text
404 404
 	 * @return string
405 405
 	 */
406
-	public static function venue_website_link( $VNU_ID = 0, $text = '' ) {
407
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
408
-		if ( $venue instanceof EE_Venue ) {
406
+	public static function venue_website_link($VNU_ID = 0, $text = '') {
407
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
408
+		if ($venue instanceof EE_Venue) {
409 409
 			$url = $venue->venue_url();
410
-			$text = ! empty( $text ) ? $text : $url;
411
-			return ! empty( $url ) ? EEH_Schema::url( $url, $text ) : '';
410
+			$text = ! empty($text) ? $text : $url;
411
+			return ! empty($url) ? EEH_Schema::url($url, $text) : '';
412 412
 		}
413 413
 		return '';
414 414
 	}
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
 	 * @param int $VNU_ID
423 423
 	 * @return string
424 424
 	 */
425
-	public static function venue_phone( $VNU_ID = 0) {
426
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
427
-		if ( $venue instanceof EE_Venue ) {
428
-			return EEH_Schema::telephone( $venue->phone() );
425
+	public static function venue_phone($VNU_ID = 0) {
426
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
427
+		if ($venue instanceof EE_Venue) {
428
+			return EEH_Schema::telephone($venue->phone());
429 429
 		}
430 430
 		return '';
431 431
 	}
@@ -441,48 +441,48 @@  discard block
 block discarded – undo
441 441
 	 * @param    array $gmap map options
442 442
 	 * @return string
443 443
 	 */
444
-	public static function venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array() ) {
444
+	public static function venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array()) {
445 445
 
446
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
447
-		if ( $venue instanceof EE_Venue ) {
446
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
447
+		if ($venue instanceof EE_Venue) {
448 448
 			// check for global espresso_events post and use it's ID if no map_ID is set
449 449
 			global $post;
450
-			$map_ID = empty( $map_ID ) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
450
+			$map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
451 451
 			// grab map settings
452 452
 			$map_cfg = EE_Registry::instance()->CFG->map_settings;
453 453
 			// are maps enabled ?
454
-			if ( $map_cfg->use_google_maps && $venue->enable_for_gmap() ) {
454
+			if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) {
455 455
 
456 456
 				$details_page = is_single();
457 457
 				$options = array();
458
-				$options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
458
+				$options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID.'-'.$venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
459 459
 
460
-				$options['location'] = EEH_Address::format( $venue, 'inline', FALSE, FALSE );
460
+				$options['location'] = EEH_Address::format($venue, 'inline', FALSE, FALSE);
461 461
 
462 462
 				$options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width;
463
-				$options['ee_map_width'] = isset( $gmap['ee_map_width'] ) && ! empty( $gmap['ee_map_width'] ) ? $gmap['ee_map_width'] : $options['ee_map_width'];
463
+				$options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width'];
464 464
 
465 465
 				$options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height;
466
-				$options['ee_map_height'] = isset( $gmap['ee_map_height'] ) && ! empty( $gmap['ee_map_height'] ) ? $gmap['ee_map_height'] : $options['ee_map_height'];
466
+				$options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height'];
467 467
 
468 468
 				$options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom;
469
-				$options['ee_map_zoom'] = isset( $gmap['ee_map_zoom'] ) && ! empty( $gmap['ee_map_zoom'] ) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
469
+				$options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
470 470
 
471 471
 				$options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav;
472
-				$options['ee_map_nav_display'] = isset( $gmap['ee_map_nav_display'] ) && ! empty( $gmap['ee_map_nav_display'] ) ? 'true' : $options['ee_map_nav_display'];;
472
+				$options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display']; ;
473 473
 
474 474
 				$options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size;
475
-				$options['ee_map_nav_size'] =  isset( $gmap['ee_map_nav_size'] ) && ! empty( $gmap['ee_map_nav_size'] )? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
475
+				$options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size']) ? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
476 476
 
477 477
 				$options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type;
478
-				$options['ee_map_type_control'] =  isset( $gmap['ee_map_type_control'] ) && ! empty( $gmap['ee_map_type_control'] )? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
478
+				$options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control']) ? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
479 479
 
480 480
 				$options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align;
481
-				$options['ee_map_align'] =  isset( $gmap['ee_map_align'] ) && ! empty( $gmap['ee_map_align'] )? $gmap['ee_map_align'] : $options['ee_map_align'];
481
+				$options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align']) ? $gmap['ee_map_align'] : $options['ee_map_align'];
482 482
 
483
-				$options['ee_static_url'] =  isset( $gmap['ee_static_url'] ) && ! empty( $gmap['ee_static_url'] ) ? (bool)absint( $gmap['ee_static_url'] ) : $venue->google_map_link();
483
+				$options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link();
484 484
 
485
-				return EEH_Maps::google_map( $options );
485
+				return EEH_Maps::google_map($options);
486 486
 
487 487
 			}
488 488
 		}
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 	 * @param array $atts like EEH_Maps::google_map_link
498 498
 	 * @return string
499 499
 	 */
500
-	public static function espresso_google_static_map( EE_Venue $venue, $atts = array() ){
500
+	public static function espresso_google_static_map(EE_Venue $venue, $atts = array()) {
501 501
 		$state = $venue->state_obj();
502 502
 		$country = $venue->country_obj();
503 503
 		$atts = shortcode_atts(
@@ -528,23 +528,23 @@  discard block
 block discarded – undo
528 528
 	 * @param string $after
529 529
 	 * @return string
530 530
 	 */
531
-	public static function edit_venue_link( $VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>' ) {
532
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
533
-		if ( $venue instanceof EE_Venue ) {
531
+	public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>') {
532
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
533
+		if ($venue instanceof EE_Venue) {
534 534
 			// can the user edit this post ?
535
-			if ( current_user_can( 'edit_post', $venue->ID() )) {
535
+			if (current_user_can('edit_post', $venue->ID())) {
536 536
 				// set link text
537
-				$link = ! empty( $link ) ? $link : __('edit this venue');
537
+				$link = ! empty($link) ? $link : __('edit this venue');
538 538
 				// generate nonce
539
-				$nonce = wp_create_nonce( 'edit_nonce' );
539
+				$nonce = wp_create_nonce('edit_nonce');
540 540
 				// generate url to venue editor for this venue
541
-				$url = add_query_arg( array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url( 'admin.php' ) );
541
+				$url = add_query_arg(array('page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce), admin_url('admin.php'));
542 542
 				// get edit CPT text
543
-				$post_type_obj = get_post_type_object( 'espresso_venues' );
543
+				$post_type_obj = get_post_type_object('espresso_venues');
544 544
 				// build final link html
545
-				$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';
545
+				$link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>';
546 546
 				// put it all together
547
-				return $before . apply_filters( 'edit_post_link', $link, $venue->ID() ) . $after;
547
+				return $before.apply_filters('edit_post_link', $link, $venue->ID()).$after;
548 548
 			}
549 549
 		}
550 550
 		return '';
Please login to merge, or discard this patch.
core/helpers/EEH_Inflector.helper.php 4 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -359,7 +359,7 @@
 block discarded – undo
359 359
     public static function ordinalize($number){
360 360
         if(in_array(($number % 100), range(11, 13))){
361 361
             return $number . 'th';
362
-        }else{
362
+        } else{
363 363
             switch(($number % 10)){
364 364
                 case 1:
365 365
                     return $number . 'st';
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
     /**
54 54
      * @param string $word
55
-     * @return mixed
55
+     * @return string
56 56
      */
57 57
     public static function singularize_and_upper( $word ) {
58 58
 		return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) );
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     /**
243 243
      * Camelizes all but the first word. This is handy converting a method which followed EE4 legacy naming convention
244 244
      * with the new PSR-based naming conventions
245
-     * @param $word
245
+     * @param string $word
246 246
      * @return string
247 247
      */
248 248
     public static function camelize_all_but_first($word){
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 
391 391
 
392 392
     /**
393
-     * @param $string
393
+     * @param string $string
394 394
      * @return string
395 395
      */
396 396
     public static function add_indefinite_article($string) {
Please login to merge, or discard this patch.
Indentation   +345 added lines, -345 removed lines patch added patch discarded remove patch
@@ -35,368 +35,368 @@
 block discarded – undo
35 35
  * @version $Revision 0.1 $
36 36
  */
37 37
 class EEH_Inflector{
38
-    // ------ CLASS METHODS ------ //
39
-    // ---- Public methods ---- //
40
-    // {{{ pluralize()
38
+	// ------ CLASS METHODS ------ //
39
+	// ---- Public methods ---- //
40
+	// {{{ pluralize()
41 41
 
42 42
 	/**
43 43
 	 * Just calls self::pluralize and strtolower on $word and returns it
44 44
 	 * @param string $word
45 45
 	 * @return string
46 46
 	 */
47
-    public static function pluralize_and_lower( $word ){
47
+	public static function pluralize_and_lower( $word ){
48 48
 		return strtolower( self::pluralize( $word ) );
49 49
 	}
50 50
 
51 51
 
52 52
 
53
-    /**
54
-     * @param string $word
55
-     * @return mixed
56
-     */
57
-    public static function singularize_and_upper( $word ) {
53
+	/**
54
+	 * @param string $word
55
+	 * @return mixed
56
+	 */
57
+	public static function singularize_and_upper( $word ) {
58 58
 		return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) );
59 59
 	}
60 60
 
61 61
 
62 62
 
63
-    /**
64
-     * Pluralizes English nouns.
65
-     *
66
-     * @access public
67
-     * @static
68
-     * @param    string    $word    English noun to pluralize
69
-     * @return string Plural noun
70
-     */
71
-    public static function pluralize($word){
72
-        $plural = array(
73
-            '/(quiz)$/i'               => '\1zes',
74
-            '/^(ox)$/i'                => '\1en',
75
-            '/([m|l])ouse$/i'          => '\1ice',
76
-            '/(matr|vert|ind)ix|ex$/i' => '\1ices',
77
-            '/(x|ch|ss|sh)$/i'         => '\1es',
78
-            '/([^aeiouy]|qu)ies$/i'    => '\1y',
79
-            '/([^aeiouy]|qu)y$/i'      => '\1ies',
80
-            '/(hive)$/i'               => '\1s',
81
-            '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
82
-            '/sis$/i'                  => 'ses',
83
-            '/([ti])um$/i'             => '\1a',
84
-            '/(buffal|tomat)o$/i'      => '\1oes',
85
-            '/(bu)s$/i'                => '\1ses',
86
-            '/(alias|status)/i'        => '\1es',
87
-            '/(octop|vir)us$/i'        => '\1i',
88
-            '/(ax|test)is$/i'          => '\1es',
89
-            '/s$/i'                    => 's',
90
-            '/$/'                      => 's');
91
-
92
-        $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
93
-
94
-        $irregular = array(
95
-            'person' => 'people',
96
-            'man'    => 'men',
97
-            'child'  => 'children',
98
-            'sex'    => 'sexes',
99
-            'move'   => 'moves');
100
-
101
-        $lowercased_word = strtolower($word);
102
-
103
-        foreach($uncountable as $_uncountable){
104
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
63
+	/**
64
+	 * Pluralizes English nouns.
65
+	 *
66
+	 * @access public
67
+	 * @static
68
+	 * @param    string    $word    English noun to pluralize
69
+	 * @return string Plural noun
70
+	 */
71
+	public static function pluralize($word){
72
+		$plural = array(
73
+			'/(quiz)$/i'               => '\1zes',
74
+			'/^(ox)$/i'                => '\1en',
75
+			'/([m|l])ouse$/i'          => '\1ice',
76
+			'/(matr|vert|ind)ix|ex$/i' => '\1ices',
77
+			'/(x|ch|ss|sh)$/i'         => '\1es',
78
+			'/([^aeiouy]|qu)ies$/i'    => '\1y',
79
+			'/([^aeiouy]|qu)y$/i'      => '\1ies',
80
+			'/(hive)$/i'               => '\1s',
81
+			'/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
82
+			'/sis$/i'                  => 'ses',
83
+			'/([ti])um$/i'             => '\1a',
84
+			'/(buffal|tomat)o$/i'      => '\1oes',
85
+			'/(bu)s$/i'                => '\1ses',
86
+			'/(alias|status)/i'        => '\1es',
87
+			'/(octop|vir)us$/i'        => '\1i',
88
+			'/(ax|test)is$/i'          => '\1es',
89
+			'/s$/i'                    => 's',
90
+			'/$/'                      => 's');
91
+
92
+		$uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
93
+
94
+		$irregular = array(
95
+			'person' => 'people',
96
+			'man'    => 'men',
97
+			'child'  => 'children',
98
+			'sex'    => 'sexes',
99
+			'move'   => 'moves');
100
+
101
+		$lowercased_word = strtolower($word);
102
+
103
+		foreach($uncountable as $_uncountable){
104
+			if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
105 105
 					! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){
106
-                return $word;
107
-            }
108
-        }
109
-
110
-        foreach($irregular as $_plural => $_singular){
111
-            if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
112
-                return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
113
-            }
114
-        }
115
-
116
-        foreach($plural as $rule => $replacement){
117
-            if(preg_match($rule, $word)){
118
-                return preg_replace($rule, $replacement, $word);
119
-            }
120
-        }
121
-        return false;
122
-    }
123
-
124
-    // }}}
125
-    // {{{ singularize()
126
-
127
-    /**
128
-     * Singularizes English nouns.
129
-     *
130
-     * @access public
131
-     * @static
132
-     * @param    string    $word    English noun to singularize
133
-     * @return string Singular noun.
134
-     */
135
-    public static function singularize($word){
136
-        $singular = array(
137
-            '/(quiz)zes$/i'                                                    => '\1',
138
-            '/(matr)ices$/i'                                                   => '\1ix',
139
-            '/(vert|ind)ices$/i'                                               => '\1ex',
140
-            '/^(ox)en/i'                                                       => '\1',
141
-            '/(alias|status)es$/i'                                             => '\1',
142
-            '/([octop|vir])i$/i'                                               => '\1us',
143
-            '/(cris|ax|test)es$/i'                                             => '\1is',
144
-            '/(shoe)s$/i'                                                      => '\1',
145
-            '/(o)es$/i'                                                        => '\1',
146
-            '/(bus)es$/i'                                                      => '\1',
147
-            '/([m|l])ice$/i'                                                   => '\1ouse',
148
-            '/(x|ch|ss|sh)es$/i'                                               => '\1',
149
-            '/(m)ovies$/i'                                                     => '\1ovie',
150
-            '/(s)eries$/i'                                                     => '\1eries',
151
-            '/([^aeiouy]|qu)ies$/i'                                            => '\1y',
152
-            '/([lr])ves$/i'                                                    => '\1f',
153
-            '/(tive)s$/i'                                                      => '\1',
154
-            '/(hive)s$/i'                                                      => '\1',
155
-            '/([^f])ves$/i'                                                    => '\1fe',
156
-            '/(^analy)ses$/i'                                                  => '\1sis',
157
-            '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
158
-            '/([ti])a$/i'                                                      => '\1um',
159
-            '/(n)ews$/i'                                                       => '\1ews',
160
-            '/s$/i'                                                            => '',
161
-        );
162
-
163
-        $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
164
-
165
-        $irregular = array(
166
-            'person' => 'people',
167
-            'man'    => 'men',
168
-            'child'  => 'children',
169
-            'sex'    => 'sexes',
170
-            'move'   => 'moves');
171
-
172
-        $lowercased_word = strtolower($word);
173
-        foreach($uncountable as $_uncountable){
174
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
175
-                return $word;
176
-            }
177
-        }
178
-
179
-        foreach($irregular as $_plural => $_singular){
180
-            if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
181
-                return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
182
-            }
183
-        }
184
-
185
-        foreach($singular as $rule => $replacement){
186
-            if(preg_match($rule, $word)){
187
-                return preg_replace($rule, $replacement, $word);
188
-            }
189
-        }
190
-
191
-        return $word;
192
-    }
193
-
194
-    // }}}
195
-    // {{{ titleize()
196
-
197
-    /**
198
-     * Converts an underscored or CamelCase word into a English
199
-     * sentence.
200
-     *
201
-     * The titleize static function converts text like "WelcomePage",
202
-     * "welcome_page" or  "welcome page" to this "Welcome
203
-     * Page".
204
-     * If second parameter is set to 'first' it will only
205
-     * capitalize the first character of the title.
206
-     *
207
-     * @access public
208
-     * @static
209
-     * @param    string    $word    Word to format as tile
210
-     * @param    string    $uppercase    If set to 'first' it will only uppercase the
211
-     * first character. Otherwise it will uppercase all
212
-     * the words in the title.
213
-     * @return string Text formatted as title
214
-     */
215
-    public static function titleize($word, $uppercase = ''){
216
-        $uppercase = $uppercase === 'first' ? 'ucfirst' : 'ucwords';
217
-        return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
218
-    }
219
-
220
-    // }}}
221
-    // {{{ camelize()
222
-
223
-    /**
224
-     * Returns given word as CamelCased
225
-     *
226
-     * Converts a word like "send_email" to "SendEmail". It
227
-     * will remove non alphanumeric character from the word, so
228
-     * "who's online" will be converted to "WhoSOnline"
229
-     *
230
-     * @access public
231
-     * @static
232
-     * @see variablize
233
-     * @param    string    $word    Word to convert to camel case
234
-     * @return string UpperCamelCasedWord
235
-     */
236
-    public static function camelize($word){
237
-        return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
238
-    }
239
-
240
-
241
-
242
-    /**
243
-     * Camelizes all but the first word. This is handy converting a method which followed EE4 legacy naming convention
244
-     * with the new PSR-based naming conventions
245
-     * @param $word
246
-     * @return string
247
-     */
248
-    public static function camelize_all_but_first($word){
249
-        return lcfirst(EEH_Inflector::camelize($word));
250
-    }
251
-    // }}}
252
-    // {{{ underscore()
253
-
254
-    /**
255
-     * Converts a word "into_it_s_underscored_version"
256
-     *
257
-     * Convert any "CamelCased" or "ordinary Word" into an
258
-     * "underscored_word".
259
-     *
260
-     * This can be really useful for creating friendly URLs.
261
-     *
262
-     * @access public
263
-     * @static
264
-     * @param    string    $word    Word to underscore
265
-     * @return string Underscored word
266
-     */
267
-    public static function underscore($word){
268
-        return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
269
-    }
270
-
271
-    // }}}
272
-    // {{{ humanize()
273
-
274
-    /**
275
-     * Returns a human-readable string from $word
276
-     *
277
-     * Returns a human-readable string from $word, by replacing
278
-     * underscores with a space, and by upper-casing the initial
279
-     * character by default.
280
-     *
281
-     * If you need to uppercase all the words you just have to
282
-     * pass 'all' as a second parameter.
283
-     *
284
-     * @access public
285
-     * @static
286
-     * @param    string    $word    String to "humanize"
287
-     * @param    string    $uppercase    If set to 'all' it will uppercase all the words
288
-     * instead of just the first one.
289
-     * @return string Human-readable word
290
-     */
291
-    public static function humanize($word, $uppercase = ''){
106
+				return $word;
107
+			}
108
+		}
109
+
110
+		foreach($irregular as $_plural => $_singular){
111
+			if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
112
+				return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
113
+			}
114
+		}
115
+
116
+		foreach($plural as $rule => $replacement){
117
+			if(preg_match($rule, $word)){
118
+				return preg_replace($rule, $replacement, $word);
119
+			}
120
+		}
121
+		return false;
122
+	}
123
+
124
+	// }}}
125
+	// {{{ singularize()
126
+
127
+	/**
128
+	 * Singularizes English nouns.
129
+	 *
130
+	 * @access public
131
+	 * @static
132
+	 * @param    string    $word    English noun to singularize
133
+	 * @return string Singular noun.
134
+	 */
135
+	public static function singularize($word){
136
+		$singular = array(
137
+			'/(quiz)zes$/i'                                                    => '\1',
138
+			'/(matr)ices$/i'                                                   => '\1ix',
139
+			'/(vert|ind)ices$/i'                                               => '\1ex',
140
+			'/^(ox)en/i'                                                       => '\1',
141
+			'/(alias|status)es$/i'                                             => '\1',
142
+			'/([octop|vir])i$/i'                                               => '\1us',
143
+			'/(cris|ax|test)es$/i'                                             => '\1is',
144
+			'/(shoe)s$/i'                                                      => '\1',
145
+			'/(o)es$/i'                                                        => '\1',
146
+			'/(bus)es$/i'                                                      => '\1',
147
+			'/([m|l])ice$/i'                                                   => '\1ouse',
148
+			'/(x|ch|ss|sh)es$/i'                                               => '\1',
149
+			'/(m)ovies$/i'                                                     => '\1ovie',
150
+			'/(s)eries$/i'                                                     => '\1eries',
151
+			'/([^aeiouy]|qu)ies$/i'                                            => '\1y',
152
+			'/([lr])ves$/i'                                                    => '\1f',
153
+			'/(tive)s$/i'                                                      => '\1',
154
+			'/(hive)s$/i'                                                      => '\1',
155
+			'/([^f])ves$/i'                                                    => '\1fe',
156
+			'/(^analy)ses$/i'                                                  => '\1sis',
157
+			'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
158
+			'/([ti])a$/i'                                                      => '\1um',
159
+			'/(n)ews$/i'                                                       => '\1ews',
160
+			'/s$/i'                                                            => '',
161
+		);
162
+
163
+		$uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
164
+
165
+		$irregular = array(
166
+			'person' => 'people',
167
+			'man'    => 'men',
168
+			'child'  => 'children',
169
+			'sex'    => 'sexes',
170
+			'move'   => 'moves');
171
+
172
+		$lowercased_word = strtolower($word);
173
+		foreach($uncountable as $_uncountable){
174
+			if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
175
+				return $word;
176
+			}
177
+		}
178
+
179
+		foreach($irregular as $_plural => $_singular){
180
+			if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
181
+				return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
182
+			}
183
+		}
184
+
185
+		foreach($singular as $rule => $replacement){
186
+			if(preg_match($rule, $word)){
187
+				return preg_replace($rule, $replacement, $word);
188
+			}
189
+		}
190
+
191
+		return $word;
192
+	}
193
+
194
+	// }}}
195
+	// {{{ titleize()
196
+
197
+	/**
198
+	 * Converts an underscored or CamelCase word into a English
199
+	 * sentence.
200
+	 *
201
+	 * The titleize static function converts text like "WelcomePage",
202
+	 * "welcome_page" or  "welcome page" to this "Welcome
203
+	 * Page".
204
+	 * If second parameter is set to 'first' it will only
205
+	 * capitalize the first character of the title.
206
+	 *
207
+	 * @access public
208
+	 * @static
209
+	 * @param    string    $word    Word to format as tile
210
+	 * @param    string    $uppercase    If set to 'first' it will only uppercase the
211
+	 * first character. Otherwise it will uppercase all
212
+	 * the words in the title.
213
+	 * @return string Text formatted as title
214
+	 */
215
+	public static function titleize($word, $uppercase = ''){
216
+		$uppercase = $uppercase === 'first' ? 'ucfirst' : 'ucwords';
217
+		return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
218
+	}
219
+
220
+	// }}}
221
+	// {{{ camelize()
222
+
223
+	/**
224
+	 * Returns given word as CamelCased
225
+	 *
226
+	 * Converts a word like "send_email" to "SendEmail". It
227
+	 * will remove non alphanumeric character from the word, so
228
+	 * "who's online" will be converted to "WhoSOnline"
229
+	 *
230
+	 * @access public
231
+	 * @static
232
+	 * @see variablize
233
+	 * @param    string    $word    Word to convert to camel case
234
+	 * @return string UpperCamelCasedWord
235
+	 */
236
+	public static function camelize($word){
237
+		return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
238
+	}
239
+
240
+
241
+
242
+	/**
243
+	 * Camelizes all but the first word. This is handy converting a method which followed EE4 legacy naming convention
244
+	 * with the new PSR-based naming conventions
245
+	 * @param $word
246
+	 * @return string
247
+	 */
248
+	public static function camelize_all_but_first($word){
249
+		return lcfirst(EEH_Inflector::camelize($word));
250
+	}
251
+	// }}}
252
+	// {{{ underscore()
253
+
254
+	/**
255
+	 * Converts a word "into_it_s_underscored_version"
256
+	 *
257
+	 * Convert any "CamelCased" or "ordinary Word" into an
258
+	 * "underscored_word".
259
+	 *
260
+	 * This can be really useful for creating friendly URLs.
261
+	 *
262
+	 * @access public
263
+	 * @static
264
+	 * @param    string    $word    Word to underscore
265
+	 * @return string Underscored word
266
+	 */
267
+	public static function underscore($word){
268
+		return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
269
+	}
270
+
271
+	// }}}
272
+	// {{{ humanize()
273
+
274
+	/**
275
+	 * Returns a human-readable string from $word
276
+	 *
277
+	 * Returns a human-readable string from $word, by replacing
278
+	 * underscores with a space, and by upper-casing the initial
279
+	 * character by default.
280
+	 *
281
+	 * If you need to uppercase all the words you just have to
282
+	 * pass 'all' as a second parameter.
283
+	 *
284
+	 * @access public
285
+	 * @static
286
+	 * @param    string    $word    String to "humanize"
287
+	 * @param    string    $uppercase    If set to 'all' it will uppercase all the words
288
+	 * instead of just the first one.
289
+	 * @return string Human-readable word
290
+	 */
291
+	public static function humanize($word, $uppercase = ''){
292 292
 		//make special exceptions for acronyms
293 293
 		$word = str_replace('wp_', 'WP_', $word );
294
-        $uppercase = $uppercase === 'all' ? 'ucwords' : 'ucfirst';
295
-        return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
296
-    }
297
-
298
-    // }}}
299
-    // {{{ variablize()
300
-
301
-    /**
302
-     * Same as camelize but first char is underscored
303
-     *
304
-     * Converts a word like "send_email" to "sendEmail". It
305
-     * will remove non alphanumeric character from the word, so
306
-     * "who's online" will be converted to "whoSOnline"
307
-     *
308
-     * @access public
309
-     * @static
310
-     * @see camelize
311
-     * @param    string    $word    Word to lowerCamelCase
312
-     * @return string Returns a lowerCamelCasedWord
313
-     */
314
-    public static function variablize($word){
315
-        $word = EEH_Inflector::camelize($word);
316
-        return strtolower($word[0]) . substr($word, 1);
317
-    }
318
-
319
-    // }}}
320
-    // {{{ tableize()
321
-
322
-    /**
323
-     * Converts a class name to its table name according to rails
324
-     * naming conventions.
325
-     *
326
-     * Converts "Person" to "people"
327
-     *
328
-     * @access public
329
-     * @static
330
-     * @see classify
331
-     * @param    string    $class_name    Class name for getting related table_name.
332
-     * @return string plural_table_name
333
-     */
334
-    public static function tableize($class_name){
335
-        return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
336
-    }
337
-
338
-    // }}}
339
-    // {{{ classify()
340
-
341
-    /**
342
-     * Converts a table name to its class name according to rails
343
-     * naming conventions.
344
-     *
345
-     * Converts "people" to "Person"
346
-     *
347
-     * @access public
348
-     * @static
349
-     * @see tableize
350
-     * @param    string    $table_name    Table name for getting related ClassName.
351
-     * @return string SingularClassName
352
-     */
353
-    public static function classify($table_name){
354
-        return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
355
-    }
356
-
357
-    // }}}
358
-    // {{{ ordinalize()
359
-
360
-    /**
361
-     * Converts number to its ordinal English form.
362
-     *
363
-     * This method converts 13 to 13th, 2 to 2nd ...
364
-     *
365
-     * @access public
366
-     * @static
367
-     * @param    integer    $number    Number to get its ordinal value
368
-     * @return string Ordinal representation of given string.
369
-     */
370
-    public static function ordinalize($number){
371
-        if(in_array(($number % 100), range(11, 13))){
372
-            return $number . 'th';
373
-        }else{
374
-            switch(($number % 10)){
375
-                case 1:
376
-                    return $number . 'st';
377
-                    break;
378
-                case 2:
379
-                    return $number . 'nd';
380
-                    break;
381
-                case 3:
382
-                    return $number . 'rd';
383
-                default:
384
-                    return $number . 'th';
385
-                    break;
386
-            }
387
-        }
388
-    }
389
-
390
-
391
-
392
-    /**
393
-     * @param $string
394
-     * @return string
395
-     */
396
-    public static function add_indefinite_article($string) {
397
-        if (strtolower($string) === 'null') {
398
-            return $string;
399
-        }
400
-        return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string;
401
-    }
294
+		$uppercase = $uppercase === 'all' ? 'ucwords' : 'ucfirst';
295
+		return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
296
+	}
297
+
298
+	// }}}
299
+	// {{{ variablize()
300
+
301
+	/**
302
+	 * Same as camelize but first char is underscored
303
+	 *
304
+	 * Converts a word like "send_email" to "sendEmail". It
305
+	 * will remove non alphanumeric character from the word, so
306
+	 * "who's online" will be converted to "whoSOnline"
307
+	 *
308
+	 * @access public
309
+	 * @static
310
+	 * @see camelize
311
+	 * @param    string    $word    Word to lowerCamelCase
312
+	 * @return string Returns a lowerCamelCasedWord
313
+	 */
314
+	public static function variablize($word){
315
+		$word = EEH_Inflector::camelize($word);
316
+		return strtolower($word[0]) . substr($word, 1);
317
+	}
318
+
319
+	// }}}
320
+	// {{{ tableize()
321
+
322
+	/**
323
+	 * Converts a class name to its table name according to rails
324
+	 * naming conventions.
325
+	 *
326
+	 * Converts "Person" to "people"
327
+	 *
328
+	 * @access public
329
+	 * @static
330
+	 * @see classify
331
+	 * @param    string    $class_name    Class name for getting related table_name.
332
+	 * @return string plural_table_name
333
+	 */
334
+	public static function tableize($class_name){
335
+		return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
336
+	}
337
+
338
+	// }}}
339
+	// {{{ classify()
340
+
341
+	/**
342
+	 * Converts a table name to its class name according to rails
343
+	 * naming conventions.
344
+	 *
345
+	 * Converts "people" to "Person"
346
+	 *
347
+	 * @access public
348
+	 * @static
349
+	 * @see tableize
350
+	 * @param    string    $table_name    Table name for getting related ClassName.
351
+	 * @return string SingularClassName
352
+	 */
353
+	public static function classify($table_name){
354
+		return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
355
+	}
356
+
357
+	// }}}
358
+	// {{{ ordinalize()
359
+
360
+	/**
361
+	 * Converts number to its ordinal English form.
362
+	 *
363
+	 * This method converts 13 to 13th, 2 to 2nd ...
364
+	 *
365
+	 * @access public
366
+	 * @static
367
+	 * @param    integer    $number    Number to get its ordinal value
368
+	 * @return string Ordinal representation of given string.
369
+	 */
370
+	public static function ordinalize($number){
371
+		if(in_array(($number % 100), range(11, 13))){
372
+			return $number . 'th';
373
+		}else{
374
+			switch(($number % 10)){
375
+				case 1:
376
+					return $number . 'st';
377
+					break;
378
+				case 2:
379
+					return $number . 'nd';
380
+					break;
381
+				case 3:
382
+					return $number . 'rd';
383
+				default:
384
+					return $number . 'th';
385
+					break;
386
+			}
387
+		}
388
+	}
389
+
390
+
391
+
392
+	/**
393
+	 * @param $string
394
+	 * @return string
395
+	 */
396
+	public static function add_indefinite_article($string) {
397
+		if (strtolower($string) === 'null') {
398
+			return $string;
399
+		}
400
+		return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string;
401
+	}
402 402
 }
403 403
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 // +----------------------------------------------------------------------+
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @since 0.1
35 35
  * @version $Revision 0.1 $
36 36
  */
37
-class EEH_Inflector{
37
+class EEH_Inflector {
38 38
     // ------ CLASS METHODS ------ //
39 39
     // ---- Public methods ---- //
40 40
     // {{{ pluralize()
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param string $word
45 45
 	 * @return string
46 46
 	 */
47
-    public static function pluralize_and_lower( $word ){
48
-		return strtolower( self::pluralize( $word ) );
47
+    public static function pluralize_and_lower($word) {
48
+		return strtolower(self::pluralize($word));
49 49
 	}
50 50
 
51 51
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
      * @param string $word
55 55
      * @return mixed
56 56
      */
57
-    public static function singularize_and_upper( $word ) {
58
-		return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) );
57
+    public static function singularize_and_upper($word) {
58
+		return str_replace(' ', '_', self::humanize(self::singularize($word), 'all'));
59 59
 	}
60 60
 
61 61
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @param    string    $word    English noun to pluralize
69 69
      * @return string Plural noun
70 70
      */
71
-    public static function pluralize($word){
71
+    public static function pluralize($word) {
72 72
         $plural = array(
73 73
             '/(quiz)$/i'               => '\1zes',
74 74
             '/^(ox)$/i'                => '\1en',
@@ -100,21 +100,21 @@  discard block
 block discarded – undo
100 100
 
101 101
         $lowercased_word = strtolower($word);
102 102
 
103
-        foreach($uncountable as $_uncountable){
104
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
105
-					! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){
103
+        foreach ($uncountable as $_uncountable) {
104
+            if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
105
+					! ctype_alpha($lowercased_word[strlen($lowercased_word) - strlen($_uncountable)])) {
106 106
                 return $word;
107 107
             }
108 108
         }
109 109
 
110
-        foreach($irregular as $_plural => $_singular){
111
-            if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
112
-                return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
110
+        foreach ($irregular as $_plural => $_singular) {
111
+            if (preg_match('/('.$_plural.')$/i', $word, $arr)) {
112
+                return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word);
113 113
             }
114 114
         }
115 115
 
116
-        foreach($plural as $rule => $replacement){
117
-            if(preg_match($rule, $word)){
116
+        foreach ($plural as $rule => $replacement) {
117
+            if (preg_match($rule, $word)) {
118 118
                 return preg_replace($rule, $replacement, $word);
119 119
             }
120 120
         }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      * @param    string    $word    English noun to singularize
133 133
      * @return string Singular noun.
134 134
      */
135
-    public static function singularize($word){
135
+    public static function singularize($word) {
136 136
         $singular = array(
137 137
             '/(quiz)zes$/i'                                                    => '\1',
138 138
             '/(matr)ices$/i'                                                   => '\1ix',
@@ -170,20 +170,20 @@  discard block
 block discarded – undo
170 170
             'move'   => 'moves');
171 171
 
172 172
         $lowercased_word = strtolower($word);
173
-        foreach($uncountable as $_uncountable){
174
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
173
+        foreach ($uncountable as $_uncountable) {
174
+            if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable) {
175 175
                 return $word;
176 176
             }
177 177
         }
178 178
 
179
-        foreach($irregular as $_plural => $_singular){
180
-            if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
181
-                return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
179
+        foreach ($irregular as $_plural => $_singular) {
180
+            if (preg_match('/('.$_singular.')$/i', $word, $arr)) {
181
+                return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word);
182 182
             }
183 183
         }
184 184
 
185
-        foreach($singular as $rule => $replacement){
186
-            if(preg_match($rule, $word)){
185
+        foreach ($singular as $rule => $replacement) {
186
+            if (preg_match($rule, $word)) {
187 187
                 return preg_replace($rule, $replacement, $word);
188 188
             }
189 189
         }
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
      * the words in the title.
213 213
      * @return string Text formatted as title
214 214
      */
215
-    public static function titleize($word, $uppercase = ''){
215
+    public static function titleize($word, $uppercase = '') {
216 216
         $uppercase = $uppercase === 'first' ? 'ucfirst' : 'ucwords';
217 217
         return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
218 218
     }
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      * @param    string    $word    Word to convert to camel case
234 234
      * @return string UpperCamelCasedWord
235 235
      */
236
-    public static function camelize($word){
236
+    public static function camelize($word) {
237 237
         return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
238 238
     }
239 239
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      * @param $word
246 246
      * @return string
247 247
      */
248
-    public static function camelize_all_but_first($word){
248
+    public static function camelize_all_but_first($word) {
249 249
         return lcfirst(EEH_Inflector::camelize($word));
250 250
     }
251 251
     // }}}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
      * @param    string    $word    Word to underscore
265 265
      * @return string Underscored word
266 266
      */
267
-    public static function underscore($word){
267
+    public static function underscore($word) {
268 268
         return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
269 269
     }
270 270
 
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
      * instead of just the first one.
289 289
      * @return string Human-readable word
290 290
      */
291
-    public static function humanize($word, $uppercase = ''){
291
+    public static function humanize($word, $uppercase = '') {
292 292
 		//make special exceptions for acronyms
293
-		$word = str_replace('wp_', 'WP_', $word );
293
+		$word = str_replace('wp_', 'WP_', $word);
294 294
         $uppercase = $uppercase === 'all' ? 'ucwords' : 'ucfirst';
295 295
         return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
296 296
     }
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
      * @param    string    $word    Word to lowerCamelCase
312 312
      * @return string Returns a lowerCamelCasedWord
313 313
      */
314
-    public static function variablize($word){
314
+    public static function variablize($word) {
315 315
         $word = EEH_Inflector::camelize($word);
316
-        return strtolower($word[0]) . substr($word, 1);
316
+        return strtolower($word[0]).substr($word, 1);
317 317
     }
318 318
 
319 319
     // }}}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      * @param    string    $class_name    Class name for getting related table_name.
332 332
      * @return string plural_table_name
333 333
      */
334
-    public static function tableize($class_name){
334
+    public static function tableize($class_name) {
335 335
         return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
336 336
     }
337 337
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
      * @param    string    $table_name    Table name for getting related ClassName.
351 351
      * @return string SingularClassName
352 352
      */
353
-    public static function classify($table_name){
353
+    public static function classify($table_name) {
354 354
         return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
355 355
     }
356 356
 
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
      * @param    integer    $number    Number to get its ordinal value
368 368
      * @return string Ordinal representation of given string.
369 369
      */
370
-    public static function ordinalize($number){
371
-        if(in_array(($number % 100), range(11, 13))){
372
-            return $number . 'th';
373
-        }else{
374
-            switch(($number % 10)){
370
+    public static function ordinalize($number) {
371
+        if (in_array(($number % 100), range(11, 13))) {
372
+            return $number.'th';
373
+        } else {
374
+            switch (($number % 10)) {
375 375
                 case 1:
376
-                    return $number . 'st';
376
+                    return $number.'st';
377 377
                     break;
378 378
                 case 2:
379
-                    return $number . 'nd';
379
+                    return $number.'nd';
380 380
                     break;
381 381
                 case 3:
382
-                    return $number . 'rd';
382
+                    return $number.'rd';
383 383
                 default:
384
-                    return $number . 'th';
384
+                    return $number.'th';
385 385
                     break;
386 386
             }
387 387
         }
@@ -397,6 +397,6 @@  discard block
 block discarded – undo
397 397
         if (strtolower($string) === 'null') {
398 398
             return $string;
399 399
         }
400
-        return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ') . $string;
400
+        return (stripos('aeiou', $string[0]) !== false ? 'an ' : 'a ').$string;
401 401
     }
402 402
 }
403 403
\ No newline at end of file
Please login to merge, or discard this patch.
core/CPTs/EE_CPT_Strategy.core.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@
 block discarded – undo
9 9
 class EE_CPT_Strategy extends EE_Base {
10 10
 
11 11
    /**
12
-     * 	EE_CPT_Strategy Object
13
-     * 	@private _instance
14
-	 * 	@private 	protected
15
-     */
12
+    * 	EE_CPT_Strategy Object
13
+    * 	@private _instance
14
+    * 	@private 	protected
15
+    */
16 16
 	private static $_instance;
17 17
 
18 18
 
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * CPT_Strategy
4 4
  *
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public static function instance() {
71 71
 		// check if class object is instantiated
72
-		if ( ! self::$_instance instanceof EE_CPT_Strategy ) {
72
+		if ( ! self::$_instance instanceof EE_CPT_Strategy) {
73 73
 			self::$_instance = new self();
74 74
 		}
75 75
 		return self::$_instance;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		$this->_CPTs = EE_Register_CPTs::get_CPTs();
87 87
 		$this->_CPT_endpoints = $this->_set_CPT_endpoints();
88 88
 		$this->_CPT_taxonomies = EE_Register_CPTs::get_taxonomies();
89
-		add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 5 );
89
+		add_action('pre_get_posts', array($this, 'pre_get_posts'), 5);
90 90
 	}
91 91
 
92 92
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	private function _set_CPT_endpoints() {
122 122
 		$_CPT_endpoints = array();
123
-		if ( is_array( $this->_CPTs )) {
124
-			foreach ( $this->_CPTs as $CPT_type => $CPT ) {
125
-				$_CPT_endpoints [ $CPT['plural_slug'] ] = $CPT_type;
123
+		if (is_array($this->_CPTs)) {
124
+			foreach ($this->_CPTs as $CPT_type => $CPT) {
125
+				$_CPT_endpoints [$CPT['plural_slug']] = $CPT_type;
126 126
 			}
127 127
 		}
128 128
 		return $_CPT_endpoints;
@@ -140,21 +140,21 @@  discard block
 block discarded – undo
140 140
 	 * @param WP_Query $WP_Query
141 141
 	 * @return void
142 142
 	 */
143
-	public function pre_get_posts( $WP_Query ) {
143
+	public function pre_get_posts($WP_Query) {
144 144
 		// check that post-type is set
145
-		if ( ! $WP_Query instanceof WP_Query ) {
145
+		if ( ! $WP_Query instanceof WP_Query) {
146 146
 			return;
147 147
 		}
148 148
 		// add our conditionals
149
-		$this->_set_EE_tags_on_WP_Query( $WP_Query );
149
+		$this->_set_EE_tags_on_WP_Query($WP_Query);
150 150
 		// check for terms
151
-		$this->_set_post_type_for_terms( $WP_Query );
151
+		$this->_set_post_type_for_terms($WP_Query);
152 152
 		// make sure paging is always set
153
-		$this->_set_paging( $WP_Query );
153
+		$this->_set_paging($WP_Query);
154 154
 		// is a taxonomy set ?
155
-		$this->_set_CPT_taxonomies_on_WP_Query( $WP_Query );
155
+		$this->_set_CPT_taxonomies_on_WP_Query($WP_Query);
156 156
 		// loop thru post_types if set
157
-		$this->_process_WP_Query_post_types( $WP_Query );
157
+		$this->_process_WP_Query_post_types($WP_Query);
158 158
 	}
159 159
 
160 160
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @param WP_Query $WP_Query
166 166
 	 * @return void
167 167
 	 */
168
-	private function _set_EE_tags_on_WP_Query( WP_Query $WP_Query) {
168
+	private function _set_EE_tags_on_WP_Query(WP_Query $WP_Query) {
169 169
 		$WP_Query->is_espresso_event_single = FALSE;
170 170
 		$WP_Query->is_espresso_event_archive = FALSE;
171 171
 		$WP_Query->is_espresso_event_taxonomy = FALSE;
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @return void
184 184
 	 */
185 185
 	private function _set_CPT_terms() {
186
-		if ( empty( $this->_CPT_terms )) {
186
+		if (empty($this->_CPT_terms)) {
187 187
 			$terms = EEM_Term::instance()->get_all_CPT_post_tags();
188
-			foreach ( $terms as $term ) {
189
-				if ( $term instanceof EE_Term ) {
190
-					$this->_CPT_terms[ $term->slug() ] = $term;
188
+			foreach ($terms as $term) {
189
+				if ($term instanceof EE_Term) {
190
+					$this->_CPT_terms[$term->slug()] = $term;
191 191
 				}
192 192
 			}
193 193
 		}
@@ -202,24 +202,24 @@  discard block
 block discarded – undo
202 202
 	 * @param $WP_Query
203 203
 	 * @return void
204 204
 	 */
205
-	private function _set_post_type_for_terms( WP_Query $WP_Query ) {
205
+	private function _set_post_type_for_terms(WP_Query $WP_Query) {
206 206
 		// is a tag set ?
207
-		if ( isset( $WP_Query->query['tag'] )) {
207
+		if (isset($WP_Query->query['tag'])) {
208 208
 			// set post_tags
209 209
 			$this->_set_CPT_terms();
210 210
 			// is this tag archive term in the list of terms used by our CPTs ?
211
-			$term = isset ( $this->_CPT_terms[ $WP_Query->query['tag'] ] ) ? $this->_CPT_terms[ $WP_Query->query['tag'] ] : NULL;
211
+			$term = isset ($this->_CPT_terms[$WP_Query->query['tag']]) ? $this->_CPT_terms[$WP_Query->query['tag']] : NULL;
212 212
 			// verify the term
213
-			if ( $term instanceof EE_Term ) {
214
-				$term->post_type  = array_merge( array( 'post', 'page' ), (array)$term->post_type );
215
-				$term->post_type = apply_filters( 'FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term );
213
+			if ($term instanceof EE_Term) {
214
+				$term->post_type = array_merge(array('post', 'page'), (array) $term->post_type);
215
+				$term->post_type = apply_filters('FHEE__EE_CPT_Strategy___set_post_type_for_terms__term_post_type', $term->post_type, $term);
216 216
 				// if a post type is already set
217
-				if ( isset( $WP_Query->query_vars['post_type'] )) {
217
+				if (isset($WP_Query->query_vars['post_type'])) {
218 218
 						// add to existing array
219
-						$term->post_type = array_merge ( (array)$WP_Query->query_vars['post_type'], $term->post_type );
219
+						$term->post_type = array_merge((array) $WP_Query->query_vars['post_type'], $term->post_type);
220 220
 				}
221 221
 				// just set post_type to our CPT
222
-				$WP_Query->set( 'post_type', array_unique( $term->post_type ) );
222
+				$WP_Query->set('post_type', array_unique($term->post_type));
223 223
 			}
224 224
 		}
225 225
 	}
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 	 * @param WP_Query $WP_Query
234 234
 	 * @return void
235 235
 	 */
236
-	public function _set_paging( $WP_Query ) {
237
-		if ( $WP_Query->is_main_query() && apply_filters( 'FHEE__EE_CPT_Strategy___set_paging', TRUE )) {
236
+	public function _set_paging($WP_Query) {
237
+		if ($WP_Query->is_main_query() && apply_filters('FHEE__EE_CPT_Strategy___set_paging', TRUE)) {
238 238
 			$page = get_query_var('page') ? get_query_var('page') : NULL;
239 239
 			$paged = get_query_var('paged') ? get_query_var('paged') : $page;
240
-			$WP_Query->set( 'paged', $paged );
240
+			$WP_Query->set('paged', $paged);
241 241
 		}
242 242
 	}
243 243
 
@@ -247,28 +247,28 @@  discard block
 block discarded – undo
247 247
 	 * @access protected
248 248
 	 * @param \WP_Query $WP_Query
249 249
 	 */
250
-	protected function _set_CPT_taxonomies_on_WP_Query( WP_Query $WP_Query ) {
250
+	protected function _set_CPT_taxonomies_on_WP_Query(WP_Query $WP_Query) {
251 251
 		// is a taxonomy set ?
252
-		if ( $WP_Query->is_tax ) {
252
+		if ($WP_Query->is_tax) {
253 253
 			// loop thru our taxonomies
254
-			foreach ( $this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details ) {
254
+			foreach ($this->_CPT_taxonomies as $CPT_taxonomy => $CPT_taxonomy_details) {
255 255
 				// check if one of our taxonomies is set as a query var
256
-				if ( isset( $WP_Query->query[ $CPT_taxonomy ] ) ) {
256
+				if (isset($WP_Query->query[$CPT_taxonomy])) {
257 257
 					// but which CPT does that correspond to??? hmmm... guess we gotta go looping
258
-					foreach ( $this->_CPTs as $post_type => $CPT ) {
258
+					foreach ($this->_CPTs as $post_type => $CPT) {
259 259
 						// verify our CPT has args, is public and has taxonomies set
260 260
 						if (
261
-							isset( $CPT['args'], $CPT['args']['public'] )
261
+							isset($CPT['args'], $CPT['args']['public'])
262 262
 							&& $CPT['args']['public']
263
-							&& ! empty( $CPT['args']['taxonomies'] )
264
-							&& in_array( $CPT_taxonomy, $CPT['args']['taxonomies'] )
263
+							&& ! empty($CPT['args']['taxonomies'])
264
+							&& in_array($CPT_taxonomy, $CPT['args']['taxonomies'])
265 265
 						) {
266 266
 							// if so, then add this CPT post_type to the current query's array of post_types'
267
-							$WP_Query->query_vars['post_type'] = isset( $WP_Query->query_vars['post_type'] )
267
+							$WP_Query->query_vars['post_type'] = isset($WP_Query->query_vars['post_type'])
268 268
 								? (array) $WP_Query->query_vars['post_type']
269 269
 								: array();
270 270
 							$WP_Query->query_vars['post_type'][] = $post_type;
271
-							switch ( $post_type ) {
271
+							switch ($post_type) {
272 272
 								case 'espresso_events' :
273 273
 									$WP_Query->is_espresso_event_taxonomy = true;
274 274
 									break;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 									break;
278 278
 								default :
279 279
 									do_action(
280
-										'AHEE__EE_CPT_Strategy___set_CPT_taxonomies_on_WP_Query__for_' . $post_type . '_post_type',
280
+										'AHEE__EE_CPT_Strategy___set_CPT_taxonomies_on_WP_Query__for_'.$post_type.'_post_type',
281 281
 										$WP_Query,
282 282
 										$this
283 283
 									);
@@ -295,24 +295,24 @@  discard block
 block discarded – undo
295 295
 	 * @access public
296 296
 	 * @param \WP_Query $WP_Query
297 297
 	 */
298
-	protected function _process_WP_Query_post_types( WP_Query $WP_Query ) {
299
-		if ( isset( $WP_Query->query_vars['post_type'] ) ) {
298
+	protected function _process_WP_Query_post_types(WP_Query $WP_Query) {
299
+		if (isset($WP_Query->query_vars['post_type'])) {
300 300
 			// loop thru post_types as array
301
-			foreach ( (array) $WP_Query->query_vars['post_type'] as $post_type ) {
301
+			foreach ((array) $WP_Query->query_vars['post_type'] as $post_type) {
302 302
 				// is current query for an EE CPT ?
303
-				if ( isset( $this->_CPTs[ $post_type ] ) ) {
303
+				if (isset($this->_CPTs[$post_type])) {
304 304
 					// is EE on or off ?
305
-					if ( EE_Maintenance_Mode::instance()->level() ) {
305
+					if (EE_Maintenance_Mode::instance()->level()) {
306 306
 						// reroute CPT template view to maintenance_mode.template.php
307
-						if ( ! has_filter( 'template_include', array( 'EE_Maintenance_Mode', 'template_include' ) ) ) {
308
-							add_filter( 'template_include', array( 'EE_Maintenance_Mode', 'template_include' ), 99999 );
307
+						if ( ! has_filter('template_include', array('EE_Maintenance_Mode', 'template_include'))) {
308
+							add_filter('template_include', array('EE_Maintenance_Mode', 'template_include'), 99999);
309 309
 						}
310
-						if ( has_filter( 'the_content', array( EE_Maintenance_Mode::instance(), 'the_content' ) ) ) {
311
-							add_filter( 'the_content', array( $this, 'inject_EE_shortcode_placeholder' ), 1 );
310
+						if (has_filter('the_content', array(EE_Maintenance_Mode::instance(), 'the_content'))) {
311
+							add_filter('the_content', array($this, 'inject_EE_shortcode_placeholder'), 1);
312 312
 						}
313 313
 						return;
314 314
 					}
315
-					$this->_generate_CptQueryModifier( $WP_Query, $post_type );
315
+					$this->_generate_CptQueryModifier($WP_Query, $post_type);
316 316
 				}
317 317
 			}
318 318
 		}
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 * @param \WP_Query $WP_Query
325 325
 	 * @param string    $post_type
326 326
 	 */
327
-	protected function _generate_CptQueryModifier( WP_Query $WP_Query, $post_type ) {
327
+	protected function _generate_CptQueryModifier(WP_Query $WP_Query, $post_type) {
328 328
 		$this->query_modifier = new EventEspresso\core\CPTs\CptQueryModifier(
329 329
 			$post_type,
330
-			$this->_CPTs[ $post_type ],
330
+			$this->_CPTs[$post_type],
331 331
 			$WP_Query,
332 332
 			EE_Registry::instance()->REQ
333 333
 		);
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
 	 * @param  $SQL
371 371
 	 * @return string
372 372
 	 */
373
-	public function posts_fields( $SQL ) {
374
-		if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) {
375
-			return $this->query_modifier->postsFields( $SQL );
373
+	public function posts_fields($SQL) {
374
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
375
+			return $this->query_modifier->postsFields($SQL);
376 376
 		}
377 377
 		return $SQL;
378 378
 	}
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
 	 * @param  $SQL
387 387
 	 * @return string
388 388
 	 */
389
-	public function posts_join( $SQL ) {
390
-		if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) {
391
-			return $this->query_modifier->postsJoin( $SQL );
389
+	public function posts_join($SQL) {
390
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
391
+			return $this->query_modifier->postsJoin($SQL);
392 392
 		}
393 393
 		return $SQL;
394 394
 	}
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
 	 * @param  \WP_Post[] $posts
403 403
 	 * @return \WP_Post[]
404 404
 	 */
405
-	public function the_posts( $posts ) {
406
-		if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) {
407
-			$this->query_modifier->thePosts( $posts );
405
+	public function the_posts($posts) {
406
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
407
+			$this->query_modifier->thePosts($posts);
408 408
 		}
409 409
 		return $posts;
410 410
 	}
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
 	 * @param $ID
420 420
 	 * @return string
421 421
 	 */
422
-	public function get_edit_post_link( $url, $ID ) {
423
-		if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) {
424
-			return $this->query_modifier->getEditPostLink( $url, $ID );
422
+	public function get_edit_post_link($url, $ID) {
423
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
424
+			return $this->query_modifier->getEditPostLink($url, $ID);
425 425
 		}
426 426
 		return '';
427 427
 	}
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
 	 * @access public
435 435
 	 * @param null $WP_Query
436 436
 	 */
437
-	protected function _do_template_filters( $WP_Query = null ) {
438
-		if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) {
437
+	protected function _do_template_filters($WP_Query = null) {
438
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
439 439
 			$this->query_modifier->addTemplateFilters();
440 440
 		}
441 441
 	}
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 	 * @param string $current_template Existing default template path derived for this page call.
450 450
 	 * @return string the path to the full template file.
451 451
 	 */
452
-	public function single_cpt_template( $current_template ) {
453
-		if ( $this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier ) {
454
-			return $this->query_modifier->singleCptTemplate( $current_template );
452
+	public function single_cpt_template($current_template) {
453
+		if ($this->query_modifier instanceof EventEspresso\Core\CPTs\CptQueryModifier) {
454
+			return $this->query_modifier->singleCptTemplate($current_template);
455 455
 		}
456 456
 		return $current_template;
457 457
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Currency_Payment_Method.model.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,22 +25,22 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEM_Currency_Payment_Method extends EEM_Base{
28
+class EEM_Currency_Payment_Method extends EEM_Base {
29 29
 	// private instance of the Attendee object
30 30
 	protected static $_instance = NULL;
31 31
 
32 32
 
33
-	protected function __construct( $timezone = NULL ) {
34
-		$this->singular_item = __('Currency Usable by Payment Method','event_espresso');
35
-		$this->plural_item = __('Currencies Usable by Payment Methods','event_espresso');
33
+	protected function __construct($timezone = NULL) {
34
+		$this->singular_item = __('Currency Usable by Payment Method', 'event_espresso');
35
+		$this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso');
36 36
 		$this->_tables = array(
37
-			'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method','CPM_ID')
37
+			'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
38 38
 		);
39 39
 		$this->_fields = array(
40 40
 			'Currency_Payment_Method'=>array(
41
-				'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID','event_espresso')),
42
-				'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code','event_espresso'), false, '', 'Currency'),
43
-				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID','event_espresso'), false, 0, 'Payment_Method')
41
+				'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')),
42
+				'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, '', 'Currency'),
43
+				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
44 44
 			)
45 45
 		);
46 46
 		$this->_model_relations = array(
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 			'Payment_Method'=>new EE_Belongs_To_Relation()
49 49
 		);
50 50
 		//this model is generally available for reading
51
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
51
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
52 52
 		$this->_caps_slug = 'payment_methods';
53
-		parent::__construct( $timezone );
53
+		parent::__construct($timezone);
54 54
 	}
55 55
 }
56 56
 
Please login to merge, or discard this patch.