Completed
Branch FET/rest-relation-endpoints (77afa0)
by
unknown
28:32 queued 18:38
created
core/db_models/EEM_Country.model.php 2 patches
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -11,112 +11,112 @@
 block discarded – undo
11 11
 class EEM_Country extends EEM_Base
12 12
 {
13 13
 
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
16
-    // array of all countries
17
-    private static $_all_countries = false;
18
-    // array of all active countries
19
-    private static $_active_countries = false;
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16
+	// array of all countries
17
+	private static $_all_countries = false;
18
+	// array of all active countries
19
+	private static $_active_countries = false;
20 20
 
21 21
 
22 22
 
23
-    /**
24
-     * Resets the country
25
-     * @return EEM_Country
26
-     */
27
-    public static function reset($timezone = null)
28
-    {
29
-        self::$_active_countries = null;
30
-        self::$_all_countries = null;
31
-        return parent::reset($timezone);
32
-    }
23
+	/**
24
+	 * Resets the country
25
+	 * @return EEM_Country
26
+	 */
27
+	public static function reset($timezone = null)
28
+	{
29
+		self::$_active_countries = null;
30
+		self::$_all_countries = null;
31
+		return parent::reset($timezone);
32
+	}
33 33
 
34
-    protected function __construct($timezone = null)
35
-    {
36
-        $this->singular_item = esc_html__('Country', 'event_espresso');
37
-        $this->plural_item = esc_html__('Countries', 'event_espresso');
34
+	protected function __construct($timezone = null)
35
+	{
36
+		$this->singular_item = esc_html__('Country', 'event_espresso');
37
+		$this->plural_item = esc_html__('Countries', 'event_espresso');
38 38
 
39 39
 
40
-        $this->_tables = array(
41
-            'Country'=> new EE_Primary_Table('esp_country', 'CNT_ISO')
42
-        );
43
-        $this->_fields = array(
44
-            'Country'=>array(
45
-                'CNT_active' => new EE_Boolean_Field('CNT_active', esc_html__('Country Appears in Dropdown Select Lists', 'event_espresso'), false, true),
46
-                'CNT_ISO'=> new EE_Primary_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso')),
47
-                'CNT_ISO3'=>new EE_All_Caps_Text_Field('CNT_ISO3', esc_html__('Country ISO3 Code', 'event_espresso'), false, ''),
48
-                'RGN_ID'=>new EE_Integer_Field('RGN_ID', esc_html__('Region ID', 'event_espresso'), false, 0),// should be a foreign key, but no region table exists yet
49
-                'CNT_name'=>new EE_Plain_Text_Field('CNT_name', esc_html__('Country Name', 'event_espresso'), false, ''),
50
-                'CNT_cur_code'=>new EE_All_Caps_Text_Field('CNT_cur_code', esc_html__('Country Currency Code', 'event_espresso'), false),
51
-                'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
52
-                'CNT_cur_plural' => new EE_Plain_Text_Field('CNT_cur_plural', esc_html__('Currency Name Plural', 'event_espresso'), false),
53
-                'CNT_cur_sign' => new EE_Plain_Text_Field('CNT_cur_sign', esc_html__('Currency Sign', 'event_espresso'), false),
54
-                'CNT_cur_sign_b4' => new EE_Boolean_Field('CNT_cur_sign_b4', esc_html__('Currency Sign Before Number', 'event_espresso'), false, true),
55
-                'CNT_cur_dec_plc' => new EE_Integer_Field('CNT_cur_dec_plc', esc_html__('Currency Decimal Places', 'event_espresso'), false, 2),
56
-                'CNT_cur_dec_mrk' => new EE_Plain_Text_Field('CNT_cur_dec_mrk', esc_html__('Currency Decimal Mark', 'event_espresso'), false, '.'),
57
-                'CNT_cur_thsnds' => new EE_Plain_Text_Field('CNT_cur_thsnds', esc_html__('Currency Thousands Separator', 'event_espresso'), false, ','),
58
-                'CNT_tel_code' => new EE_Plain_Text_Field('CNT_tel_code', esc_html__('Country Telephone Code', 'event_espresso'), false, ''),
59
-                'CNT_is_EU' => new EE_Boolean_Field('CNT_is_EU', esc_html__('Country is Member of EU', 'event_espresso'), false, false)
60
-            ));
61
-        $this->_model_relations = array(
62
-            'Attendee'=>new EE_Has_Many_Relation(),
63
-            'State'=>new EE_Has_Many_Relation(),
64
-            'Venue'=>new EE_Has_Many_Relation(),
65
-        );
66
-        // only anyone to view, but only those with the default role can do anything
67
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
40
+		$this->_tables = array(
41
+			'Country'=> new EE_Primary_Table('esp_country', 'CNT_ISO')
42
+		);
43
+		$this->_fields = array(
44
+			'Country'=>array(
45
+				'CNT_active' => new EE_Boolean_Field('CNT_active', esc_html__('Country Appears in Dropdown Select Lists', 'event_espresso'), false, true),
46
+				'CNT_ISO'=> new EE_Primary_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso')),
47
+				'CNT_ISO3'=>new EE_All_Caps_Text_Field('CNT_ISO3', esc_html__('Country ISO3 Code', 'event_espresso'), false, ''),
48
+				'RGN_ID'=>new EE_Integer_Field('RGN_ID', esc_html__('Region ID', 'event_espresso'), false, 0),// should be a foreign key, but no region table exists yet
49
+				'CNT_name'=>new EE_Plain_Text_Field('CNT_name', esc_html__('Country Name', 'event_espresso'), false, ''),
50
+				'CNT_cur_code'=>new EE_All_Caps_Text_Field('CNT_cur_code', esc_html__('Country Currency Code', 'event_espresso'), false),
51
+				'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
52
+				'CNT_cur_plural' => new EE_Plain_Text_Field('CNT_cur_plural', esc_html__('Currency Name Plural', 'event_espresso'), false),
53
+				'CNT_cur_sign' => new EE_Plain_Text_Field('CNT_cur_sign', esc_html__('Currency Sign', 'event_espresso'), false),
54
+				'CNT_cur_sign_b4' => new EE_Boolean_Field('CNT_cur_sign_b4', esc_html__('Currency Sign Before Number', 'event_espresso'), false, true),
55
+				'CNT_cur_dec_plc' => new EE_Integer_Field('CNT_cur_dec_plc', esc_html__('Currency Decimal Places', 'event_espresso'), false, 2),
56
+				'CNT_cur_dec_mrk' => new EE_Plain_Text_Field('CNT_cur_dec_mrk', esc_html__('Currency Decimal Mark', 'event_espresso'), false, '.'),
57
+				'CNT_cur_thsnds' => new EE_Plain_Text_Field('CNT_cur_thsnds', esc_html__('Currency Thousands Separator', 'event_espresso'), false, ','),
58
+				'CNT_tel_code' => new EE_Plain_Text_Field('CNT_tel_code', esc_html__('Country Telephone Code', 'event_espresso'), false, ''),
59
+				'CNT_is_EU' => new EE_Boolean_Field('CNT_is_EU', esc_html__('Country is Member of EU', 'event_espresso'), false, false)
60
+			));
61
+		$this->_model_relations = array(
62
+			'Attendee'=>new EE_Has_Many_Relation(),
63
+			'State'=>new EE_Has_Many_Relation(),
64
+			'Venue'=>new EE_Has_Many_Relation(),
65
+		);
66
+		// only anyone to view, but only those with the default role can do anything
67
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
68 68
 
69
-        parent::__construct($timezone);
70
-    }
69
+		parent::__construct($timezone);
70
+	}
71 71
 
72 72
 
73 73
 
74 74
 
75
-    /**
76
-    *       _get_countries
77
-    *
78
-    *       @access     public
79
-    *       @return         array
80
-    */
81
-    public function get_all_countries()
82
-    {
83
-        if (! self::$_all_countries) {
84
-            self::$_all_countries = $this->get_all(array( 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array( 0,99999 )));
85
-        }
86
-        return self::$_all_countries;
87
-    }
75
+	/**
76
+	 *       _get_countries
77
+	 *
78
+	 *       @access     public
79
+	 *       @return         array
80
+	 */
81
+	public function get_all_countries()
82
+	{
83
+		if (! self::$_all_countries) {
84
+			self::$_all_countries = $this->get_all(array( 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array( 0,99999 )));
85
+		}
86
+		return self::$_all_countries;
87
+	}
88 88
 
89
-    /**
90
-    *       _get_countries
91
-    *       Gets and caches the list of active countries. If you know the list of active countries
92
-    *       has changed during this request, first use EEM_Country::reset() to flush the cache
93
-    *       @access     public
94
-    *       @return         array
95
-    */
96
-    public function get_all_active_countries()
97
-    {
98
-        if (! self::$_active_countries) {
99
-            self::$_active_countries =  $this->get_all(array( array( 'CNT_active' => true ), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array( 0, 99999 )));
100
-        }
101
-        return self::$_active_countries;
102
-    }
89
+	/**
90
+	 *       _get_countries
91
+	 *       Gets and caches the list of active countries. If you know the list of active countries
92
+	 *       has changed during this request, first use EEM_Country::reset() to flush the cache
93
+	 *       @access     public
94
+	 *       @return         array
95
+	 */
96
+	public function get_all_active_countries()
97
+	{
98
+		if (! self::$_active_countries) {
99
+			self::$_active_countries =  $this->get_all(array( array( 'CNT_active' => true ), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array( 0, 99999 )));
100
+		}
101
+		return self::$_active_countries;
102
+	}
103 103
 
104
-    /**
105
-     * Gets the country's name by its ISO
106
-     * @param string $country_ISO
107
-     * @return string
108
-     */
109
-    public function get_country_name_by_ISO($country_ISO)
110
-    {
111
-        if (isset(self::$_all_countries[ $country_ISO ]) &&
112
-                self::$_all_countries[ $country_ISO ] instanceof EE_Country ) {
113
-            return self::$_all_countries[ $country_ISO ]->name();
114
-        }
115
-        $names = $this->get_col(array( array( 'CNT_ISO' => $country_ISO ), 'limit' => 1), 'CNT_name');
116
-        if (is_array($names) && ! empty($names)) {
117
-            return reset($names);
118
-        } else {
119
-            return '';
120
-        }
121
-    }
104
+	/**
105
+	 * Gets the country's name by its ISO
106
+	 * @param string $country_ISO
107
+	 * @return string
108
+	 */
109
+	public function get_country_name_by_ISO($country_ISO)
110
+	{
111
+		if (isset(self::$_all_countries[ $country_ISO ]) &&
112
+				self::$_all_countries[ $country_ISO ] instanceof EE_Country ) {
113
+			return self::$_all_countries[ $country_ISO ]->name();
114
+		}
115
+		$names = $this->get_col(array( array( 'CNT_ISO' => $country_ISO ), 'limit' => 1), 'CNT_name');
116
+		if (is_array($names) && ! empty($names)) {
117
+			return reset($names);
118
+		} else {
119
+			return '';
120
+		}
121
+	}
122 122
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
                 'CNT_active' => new EE_Boolean_Field('CNT_active', esc_html__('Country Appears in Dropdown Select Lists', 'event_espresso'), false, true),
46 46
                 'CNT_ISO'=> new EE_Primary_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso')),
47 47
                 'CNT_ISO3'=>new EE_All_Caps_Text_Field('CNT_ISO3', esc_html__('Country ISO3 Code', 'event_espresso'), false, ''),
48
-                'RGN_ID'=>new EE_Integer_Field('RGN_ID', esc_html__('Region ID', 'event_espresso'), false, 0),// should be a foreign key, but no region table exists yet
48
+                'RGN_ID'=>new EE_Integer_Field('RGN_ID', esc_html__('Region ID', 'event_espresso'), false, 0), // should be a foreign key, but no region table exists yet
49 49
                 'CNT_name'=>new EE_Plain_Text_Field('CNT_name', esc_html__('Country Name', 'event_espresso'), false, ''),
50 50
                 'CNT_cur_code'=>new EE_All_Caps_Text_Field('CNT_cur_code', esc_html__('Country Currency Code', 'event_espresso'), false),
51 51
                 'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             'Venue'=>new EE_Has_Many_Relation(),
65 65
         );
66 66
         // only anyone to view, but only those with the default role can do anything
67
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
67
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
68 68
 
69 69
         parent::__construct($timezone);
70 70
     }
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
     */
81 81
     public function get_all_countries()
82 82
     {
83
-        if (! self::$_all_countries) {
84
-            self::$_all_countries = $this->get_all(array( 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array( 0,99999 )));
83
+        if ( ! self::$_all_countries) {
84
+            self::$_all_countries = $this->get_all(array('order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array(0, 99999)));
85 85
         }
86 86
         return self::$_all_countries;
87 87
     }
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
     */
96 96
     public function get_all_active_countries()
97 97
     {
98
-        if (! self::$_active_countries) {
99
-            self::$_active_countries =  $this->get_all(array( array( 'CNT_active' => true ), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array( 0, 99999 )));
98
+        if ( ! self::$_active_countries) {
99
+            self::$_active_countries = $this->get_all(array(array('CNT_active' => true), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array(0, 99999)));
100 100
         }
101 101
         return self::$_active_countries;
102 102
     }
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function get_country_name_by_ISO($country_ISO)
110 110
     {
111
-        if (isset(self::$_all_countries[ $country_ISO ]) &&
112
-                self::$_all_countries[ $country_ISO ] instanceof EE_Country ) {
113
-            return self::$_all_countries[ $country_ISO ]->name();
111
+        if (isset(self::$_all_countries[$country_ISO]) &&
112
+                self::$_all_countries[$country_ISO] instanceof EE_Country) {
113
+            return self::$_all_countries[$country_ISO]->name();
114 114
         }
115
-        $names = $this->get_col(array( array( 'CNT_ISO' => $country_ISO ), 'limit' => 1), 'CNT_name');
115
+        $names = $this->get_col(array(array('CNT_ISO' => $country_ISO), 'limit' => 1), 'CNT_name');
116 116
         if (is_array($names) && ! empty($names)) {
117 117
             return reset($names);
118 118
         } else {
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.76.rc.001');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.76.rc.001');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.