Completed
Branch Gutenberg/use-new-wordpress-pa... (9fa7a4)
by
unknown
63:25 queued 48:18
created
core/EES_Shortcode.shortcode.php 2 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -12,184 +12,184 @@
 block discarded – undo
12 12
 abstract class EES_Shortcode extends EE_Base
13 13
 {
14 14
 
15
-    /**
16
-     * @protected   public
17
-     * @var     array $_attributes
18
-     */
19
-    protected $_attributes = array();
20
-
21
-
22
-
23
-    /**
24
-     * class constructor - should ONLY be instantiated by EE_Front_Controller
25
-     */
26
-    final public function __construct()
27
-    {
28
-        $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this));
29
-        // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier
30
-        add_shortcode($shortcode, array($this, 'process_shortcode'));
31
-        // make sure system knows this is an EE page
32
-        EE_Registry::instance()->REQ->set_espresso_page(true);
33
-    }
34
-
35
-
36
-
37
-    /**
38
-     * run - initial shortcode module setup called during "parse_request" hook by
39
-     * \EE_Front_Controller::_initialize_shortcodes() IF this shortcode is going to execute during this request !
40
-     * It may also get called by \EES_Shortcode::fallback_shortcode_processor() if the shortcode is being implemented
41
-     * by a theme or plugin in a non-standard way.
42
-     * Basically this method is primarily used for loading resources and assets like CSS or JS
43
-     * that will be required by the shortcode when it is actually processed.
44
-     * Please note that assets may not load if the fallback_shortcode_processor() is being used.
45
-     *
46
-     * @access    public
47
-     * @param WP $WP
48
-     * @return    void
49
-     */
50
-    abstract public function run(WP $WP);
51
-
52
-
53
-
54
-    /**
55
-     *  process_shortcode
56
-     *  this method is the callback function for the actual shortcode, and is what runs when WP encounters the shortcode within the_content
57
-     *
58
-     *  @access     public
59
-     *  @param      array   $attributes
60
-     *  @return     mixed
61
-     */
62
-    abstract public function process_shortcode($attributes = array());
63
-
64
-
65
-
66
-    /**
67
-     *    instance - returns instance of child class object
68
-     *
69
-     * @access  public
70
-     * @param   string $shortcode_class
71
-     * @return  \EES_Shortcode
72
-     */
73
-    final public static function instance($shortcode_class = null)
74
-    {
75
-        $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class();
76
-        if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) {
77
-            return null;
78
-        }
79
-        $shortcode = str_replace('EES_', '', strtoupper($shortcode_class));
80
-        $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode})
81
-            ? EE_Registry::instance()->shortcodes->{$shortcode}
82
-            : null;
83
-        return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self'
84
-            ? $shortcode_obj
85
-            : new $shortcode_class();
86
-    }
87
-
88
-
89
-
90
-
91
-    /**
92
-     *    fallback_shortcode_processor - create instance and call process_shortcode
93
-     *    NOTE: shortcode may not function perfectly dues to missing assets, but it's better than not having things work at all
94
-     *
95
-     * @access  public
96
-     * @param   $attributes
97
-     * @return  mixed
98
-     */
99
-    final public static function fallback_shortcode_processor($attributes)
100
-    {
101
-        if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
102
-            return null;
103
-        }
104
-        // what shortcode was actually parsed ?
105
-        $shortcode_class = get_called_class();
106
-        // notify rest of system that fallback processor was triggered
107
-        add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true');
108
-        // get instance of actual shortcode
109
-        $shortcode_obj = self::instance($shortcode_class);
110
-        // verify class
111
-        if ($shortcode_obj instanceof EES_Shortcode) {
112
-            global $wp;
113
-            $shortcode_obj->run($wp);
114
-            // set attributes and run the shortcode
115
-            $shortcode_obj->_attributes = (array) $attributes;
116
-            return $shortcode_obj->process_shortcode($shortcode_obj->_attributes);
117
-        } else {
118
-            return null;
119
-        }
120
-    }
121
-
122
-
123
-
124
-
125
-    /**
126
-     *    invalid_shortcode_processor -  used in cases where we know the shortcode is invalid, most likely due to a deactivated addon, and simply returns an empty string
127
-     *
128
-     * @access  public
129
-     * @param   $attributes
130
-     * @return  string
131
-     */
132
-    final public static function invalid_shortcode_processor($attributes)
133
-    {
134
-        return '';
135
-    }
136
-
137
-
138
-
139
-
140
-
141
-    /**
142
-     * Performs basic sanitization on shortcode attributes
143
-     * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
144
-     * most attributes will by default be sanitized using the sanitize_text_field() function.
145
-     * This can be overridden by supplying an array for the $custom_sanitization param,
146
-     * where keys match keys in your attributes array,
147
-     * and values represent the sanitization function you wish to be applied to that attribute.
148
-     * So for example, if you had an integer attribute named "event_id"
149
-     * that you wanted to be sanitized using absint(),
150
-     * then you would pass the following for your $custom_sanitization array:
151
-     *      array('event_id' => 'absint')
152
-     * all other attributes would be sanitized using the defaults in the switch statement below
153
-     *
154
-     * @param array $attributes
155
-     * @param array $custom_sanitization
156
-     * @return array
157
-     */
158
-    public static function sanitize_attributes(array $attributes, $custom_sanitization = array())
159
-    {
160
-        foreach ($attributes as $key => $value) {
161
-            // is a custom sanitization callback specified ?
162
-            if (isset($custom_sanitization[ $key ])) {
163
-                $callback = $custom_sanitization[ $key ];
164
-                if ($callback === 'skip_sanitization') {
165
-                    $attributes[ $key ] = $value;
166
-                    continue;
167
-                } elseif (function_exists($callback)) {
168
-                    $attributes[ $key ] = $callback($value);
169
-                    continue;
170
-                }
171
-            }
172
-            switch (true) {
173
-                case $value === null:
174
-                case is_int($value):
175
-                case is_float($value):
176
-                    // typical booleans
177
-                case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true):
178
-                    $attributes[ $key ] = $value;
179
-                    break;
180
-                case is_string($value):
181
-                    $attributes[ $key ] = sanitize_text_field($value);
182
-                    break;
183
-                case is_array($value):
184
-                    $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value);
185
-                    break;
186
-                default:
187
-                    // only remaining data types are Object and Resource
188
-                    // which are not allowed as shortcode attributes
189
-                    $attributes[ $key ] = null;
190
-                    break;
191
-            }
192
-        }
193
-        return $attributes;
194
-    }
15
+	/**
16
+	 * @protected   public
17
+	 * @var     array $_attributes
18
+	 */
19
+	protected $_attributes = array();
20
+
21
+
22
+
23
+	/**
24
+	 * class constructor - should ONLY be instantiated by EE_Front_Controller
25
+	 */
26
+	final public function __construct()
27
+	{
28
+		$shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this));
29
+		// assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier
30
+		add_shortcode($shortcode, array($this, 'process_shortcode'));
31
+		// make sure system knows this is an EE page
32
+		EE_Registry::instance()->REQ->set_espresso_page(true);
33
+	}
34
+
35
+
36
+
37
+	/**
38
+	 * run - initial shortcode module setup called during "parse_request" hook by
39
+	 * \EE_Front_Controller::_initialize_shortcodes() IF this shortcode is going to execute during this request !
40
+	 * It may also get called by \EES_Shortcode::fallback_shortcode_processor() if the shortcode is being implemented
41
+	 * by a theme or plugin in a non-standard way.
42
+	 * Basically this method is primarily used for loading resources and assets like CSS or JS
43
+	 * that will be required by the shortcode when it is actually processed.
44
+	 * Please note that assets may not load if the fallback_shortcode_processor() is being used.
45
+	 *
46
+	 * @access    public
47
+	 * @param WP $WP
48
+	 * @return    void
49
+	 */
50
+	abstract public function run(WP $WP);
51
+
52
+
53
+
54
+	/**
55
+	 *  process_shortcode
56
+	 *  this method is the callback function for the actual shortcode, and is what runs when WP encounters the shortcode within the_content
57
+	 *
58
+	 *  @access     public
59
+	 *  @param      array   $attributes
60
+	 *  @return     mixed
61
+	 */
62
+	abstract public function process_shortcode($attributes = array());
63
+
64
+
65
+
66
+	/**
67
+	 *    instance - returns instance of child class object
68
+	 *
69
+	 * @access  public
70
+	 * @param   string $shortcode_class
71
+	 * @return  \EES_Shortcode
72
+	 */
73
+	final public static function instance($shortcode_class = null)
74
+	{
75
+		$shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class();
76
+		if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) {
77
+			return null;
78
+		}
79
+		$shortcode = str_replace('EES_', '', strtoupper($shortcode_class));
80
+		$shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode})
81
+			? EE_Registry::instance()->shortcodes->{$shortcode}
82
+			: null;
83
+		return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self'
84
+			? $shortcode_obj
85
+			: new $shortcode_class();
86
+	}
87
+
88
+
89
+
90
+
91
+	/**
92
+	 *    fallback_shortcode_processor - create instance and call process_shortcode
93
+	 *    NOTE: shortcode may not function perfectly dues to missing assets, but it's better than not having things work at all
94
+	 *
95
+	 * @access  public
96
+	 * @param   $attributes
97
+	 * @return  mixed
98
+	 */
99
+	final public static function fallback_shortcode_processor($attributes)
100
+	{
101
+		if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
102
+			return null;
103
+		}
104
+		// what shortcode was actually parsed ?
105
+		$shortcode_class = get_called_class();
106
+		// notify rest of system that fallback processor was triggered
107
+		add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true');
108
+		// get instance of actual shortcode
109
+		$shortcode_obj = self::instance($shortcode_class);
110
+		// verify class
111
+		if ($shortcode_obj instanceof EES_Shortcode) {
112
+			global $wp;
113
+			$shortcode_obj->run($wp);
114
+			// set attributes and run the shortcode
115
+			$shortcode_obj->_attributes = (array) $attributes;
116
+			return $shortcode_obj->process_shortcode($shortcode_obj->_attributes);
117
+		} else {
118
+			return null;
119
+		}
120
+	}
121
+
122
+
123
+
124
+
125
+	/**
126
+	 *    invalid_shortcode_processor -  used in cases where we know the shortcode is invalid, most likely due to a deactivated addon, and simply returns an empty string
127
+	 *
128
+	 * @access  public
129
+	 * @param   $attributes
130
+	 * @return  string
131
+	 */
132
+	final public static function invalid_shortcode_processor($attributes)
133
+	{
134
+		return '';
135
+	}
136
+
137
+
138
+
139
+
140
+
141
+	/**
142
+	 * Performs basic sanitization on shortcode attributes
143
+	 * Since incoming attributes from the shortcode usage in the WP editor will all be strings,
144
+	 * most attributes will by default be sanitized using the sanitize_text_field() function.
145
+	 * This can be overridden by supplying an array for the $custom_sanitization param,
146
+	 * where keys match keys in your attributes array,
147
+	 * and values represent the sanitization function you wish to be applied to that attribute.
148
+	 * So for example, if you had an integer attribute named "event_id"
149
+	 * that you wanted to be sanitized using absint(),
150
+	 * then you would pass the following for your $custom_sanitization array:
151
+	 *      array('event_id' => 'absint')
152
+	 * all other attributes would be sanitized using the defaults in the switch statement below
153
+	 *
154
+	 * @param array $attributes
155
+	 * @param array $custom_sanitization
156
+	 * @return array
157
+	 */
158
+	public static function sanitize_attributes(array $attributes, $custom_sanitization = array())
159
+	{
160
+		foreach ($attributes as $key => $value) {
161
+			// is a custom sanitization callback specified ?
162
+			if (isset($custom_sanitization[ $key ])) {
163
+				$callback = $custom_sanitization[ $key ];
164
+				if ($callback === 'skip_sanitization') {
165
+					$attributes[ $key ] = $value;
166
+					continue;
167
+				} elseif (function_exists($callback)) {
168
+					$attributes[ $key ] = $callback($value);
169
+					continue;
170
+				}
171
+			}
172
+			switch (true) {
173
+				case $value === null:
174
+				case is_int($value):
175
+				case is_float($value):
176
+					// typical booleans
177
+				case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true):
178
+					$attributes[ $key ] = $value;
179
+					break;
180
+				case is_string($value):
181
+					$attributes[ $key ] = sanitize_text_field($value);
182
+					break;
183
+				case is_array($value):
184
+					$attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value);
185
+					break;
186
+				default:
187
+					// only remaining data types are Object and Resource
188
+					// which are not allowed as shortcode attributes
189
+					$attributes[ $key ] = null;
190
+					break;
191
+			}
192
+		}
193
+		return $attributes;
194
+	}
195 195
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         // what shortcode was actually parsed ?
105 105
         $shortcode_class = get_called_class();
106 106
         // notify rest of system that fallback processor was triggered
107
-        add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true');
107
+        add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true');
108 108
         // get instance of actual shortcode
109 109
         $shortcode_obj = self::instance($shortcode_class);
110 110
         // verify class
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
     {
160 160
         foreach ($attributes as $key => $value) {
161 161
             // is a custom sanitization callback specified ?
162
-            if (isset($custom_sanitization[ $key ])) {
163
-                $callback = $custom_sanitization[ $key ];
162
+            if (isset($custom_sanitization[$key])) {
163
+                $callback = $custom_sanitization[$key];
164 164
                 if ($callback === 'skip_sanitization') {
165
-                    $attributes[ $key ] = $value;
165
+                    $attributes[$key] = $value;
166 166
                     continue;
167 167
                 } elseif (function_exists($callback)) {
168
-                    $attributes[ $key ] = $callback($value);
168
+                    $attributes[$key] = $callback($value);
169 169
                     continue;
170 170
                 }
171 171
             }
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
                 case is_float($value):
176 176
                     // typical booleans
177 177
                 case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true):
178
-                    $attributes[ $key ] = $value;
178
+                    $attributes[$key] = $value;
179 179
                     break;
180 180
                 case is_string($value):
181
-                    $attributes[ $key ] = sanitize_text_field($value);
181
+                    $attributes[$key] = sanitize_text_field($value);
182 182
                     break;
183 183
                 case is_array($value):
184
-                    $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value);
184
+                    $attributes[$key] = \EES_Shortcode::sanitize_attributes($value);
185 185
                     break;
186 186
                 default:
187 187
                     // only remaining data types are Object and Resource
188 188
                     // which are not allowed as shortcode attributes
189
-                    $attributes[ $key ] = null;
189
+                    $attributes[$key] = null;
190 190
                     break;
191 191
             }
192 192
         }
Please login to merge, or discard this patch.
core/EE_Base_Class_Repository.core.php 1 patch
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -16,108 +16,108 @@
 block discarded – undo
16 16
 abstract class EE_Base_Class_Repository extends EE_Object_Repository implements EEI_Deletable
17 17
 {
18 18
 
19
-    /**
20
-     * EE_Base_Class_Repository constructor.
21
-     */
22
-    public function __construct()
23
-    {
24
-        $this->persist_method = 'save';
25
-    }
19
+	/**
20
+	 * EE_Base_Class_Repository constructor.
21
+	 */
22
+	public function __construct()
23
+	{
24
+		$this->persist_method = 'save';
25
+	}
26 26
 
27 27
 
28
-    /**
29
-     * save
30
-     *
31
-     * calls EE_Base_Class::save() on the current object
32
-     * an array of arguments can also be supplied that will be passed along to EE_Base_Class::save(),
33
-     * where each element of the $arguments array corresponds to a parameter for the callback method
34
-     * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' )
35
-     * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) )
36
-     *
37
-     * @access public
38
-     * @param array $arguments arrays of arguments that will be passed to the object's save method
39
-     * @return bool | int
40
-     */
41
-    public function save($arguments = array())
42
-    {
43
-        return $this->persist('save', $arguments);
44
-    }
28
+	/**
29
+	 * save
30
+	 *
31
+	 * calls EE_Base_Class::save() on the current object
32
+	 * an array of arguments can also be supplied that will be passed along to EE_Base_Class::save(),
33
+	 * where each element of the $arguments array corresponds to a parameter for the callback method
34
+	 * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' )
35
+	 * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) )
36
+	 *
37
+	 * @access public
38
+	 * @param array $arguments arrays of arguments that will be passed to the object's save method
39
+	 * @return bool | int
40
+	 */
41
+	public function save($arguments = array())
42
+	{
43
+		return $this->persist('save', $arguments);
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * save_all
49
-     *
50
-     * calls EE_Base_Class::save() on ALL objects in the repository
51
-     *
52
-     * @access public
53
-     * @return bool | int
54
-     */
55
-    public function save_all()
56
-    {
57
-        return $this->persist_all('save');
58
-    }
47
+	/**
48
+	 * save_all
49
+	 *
50
+	 * calls EE_Base_Class::save() on ALL objects in the repository
51
+	 *
52
+	 * @access public
53
+	 * @return bool | int
54
+	 */
55
+	public function save_all()
56
+	{
57
+		return $this->persist_all('save');
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     * Calls EE_Base_Class::delete() on the current object
63
-     * Keep in mind that this always detaches the object from the collection
64
-     * regardless of whether the delete was successful for the db.  This is because
65
-     * its possible that the object ONLY existed in the collection.
66
-     *
67
-     * @access public
68
-     * @return bool
69
-     */
70
-    public function delete()
71
-    {
72
-        $success = $this->_call_user_func_array_on_current('delete');
73
-        $this->remove($this->current());
74
-        return $success;
75
-    }
61
+	/**
62
+	 * Calls EE_Base_Class::delete() on the current object
63
+	 * Keep in mind that this always detaches the object from the collection
64
+	 * regardless of whether the delete was successful for the db.  This is because
65
+	 * its possible that the object ONLY existed in the collection.
66
+	 *
67
+	 * @access public
68
+	 * @return bool
69
+	 */
70
+	public function delete()
71
+	{
72
+		$success = $this->_call_user_func_array_on_current('delete');
73
+		$this->remove($this->current());
74
+		return $success;
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * delete_all
80
-     *
81
-     * calls EE_Base_Class::delete() on ALL objects in the repository
82
-     *
83
-     * @access public
84
-     * @return bool
85
-     */
86
-    public function delete_all()
87
-    {
88
-        $success = true;
89
-        $this->rewind();
90
-        while ($this->valid()) {
91
-            // any db error will result in false being returned
92
-            $success = $this->_call_user_func_array_on_current('delete') !== false ? $success : false;
93
-            // can't remove current object because valid() requires it
94
-            // so just capture current object temporarily
95
-            $object = $this->current();
96
-            // advance the pointer
97
-            $this->next();
98
-            // THEN remove the object from the repository
99
-            $this->remove($object);
100
-        }
101
-        return $success;
102
-    }
78
+	/**
79
+	 * delete_all
80
+	 *
81
+	 * calls EE_Base_Class::delete() on ALL objects in the repository
82
+	 *
83
+	 * @access public
84
+	 * @return bool
85
+	 */
86
+	public function delete_all()
87
+	{
88
+		$success = true;
89
+		$this->rewind();
90
+		while ($this->valid()) {
91
+			// any db error will result in false being returned
92
+			$success = $this->_call_user_func_array_on_current('delete') !== false ? $success : false;
93
+			// can't remove current object because valid() requires it
94
+			// so just capture current object temporarily
95
+			$object = $this->current();
96
+			// advance the pointer
97
+			$this->next();
98
+			// THEN remove the object from the repository
99
+			$this->remove($object);
100
+		}
101
+		return $success;
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * update_extra_meta
107
-     *
108
-     * calls EE_Base_Class::update_extra_meta() on the current object using the supplied values
109
-     *
110
-     * @access public
111
-     * @param string $meta_key
112
-     * @param string $meta_value
113
-     * @param string $previous_value
114
-     * @return bool | int
115
-     */
116
-    public function update_extra_meta($meta_key, $meta_value, $previous_value = null)
117
-    {
118
-        return $this->_call_user_func_array_on_current(
119
-            'update_extra_meta',
120
-            array($meta_key, $meta_value, $previous_value)
121
-        );
122
-    }
105
+	/**
106
+	 * update_extra_meta
107
+	 *
108
+	 * calls EE_Base_Class::update_extra_meta() on the current object using the supplied values
109
+	 *
110
+	 * @access public
111
+	 * @param string $meta_key
112
+	 * @param string $meta_value
113
+	 * @param string $previous_value
114
+	 * @return bool | int
115
+	 */
116
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = null)
117
+	{
118
+		return $this->_call_user_func_array_on_current(
119
+			'update_extra_meta',
120
+			array($meta_key, $meta_value, $previous_value)
121
+		);
122
+	}
123 123
 }
Please login to merge, or discard this patch.
core/EE_Configurable.core.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -10,143 +10,143 @@
 block discarded – undo
10 10
 abstract class EE_Configurable extends EE_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @var $_config
15
-     * @type EE_Config_Base
16
-     */
17
-    protected $_config;
18
-
19
-    /**
20
-     * @var $_config_section
21
-     * @type string
22
-     */
23
-    protected $_config_section = '';
24
-
25
-    /**
26
-     * @var $_config_class
27
-     * @type string
28
-     */
29
-    protected $_config_class = '';
30
-
31
-    /**
32
-     * @var $_config_name
33
-     * @type string
34
-     */
35
-    protected $_config_name = '';
36
-
37
-
38
-    /**
39
-     * @param string $config_section
40
-     */
41
-    public function set_config_section($config_section = '')
42
-    {
43
-        $this->_config_section = ! empty($config_section) ? $config_section : 'modules';
44
-    }
45
-
46
-
47
-    /**
48
-     * @return mixed
49
-     */
50
-    public function config_section()
51
-    {
52
-        return $this->_config_section;
53
-    }
54
-
55
-
56
-    /**
57
-     * @param string $config_class
58
-     */
59
-    public function set_config_class($config_class = '')
60
-    {
61
-        $this->_config_class = $config_class;
62
-    }
63
-
64
-
65
-    /**
66
-     * @return mixed
67
-     */
68
-    public function config_class()
69
-    {
70
-        return $this->_config_class;
71
-    }
72
-
73
-
74
-    /**
75
-     * @param mixed $config_name
76
-     */
77
-    public function set_config_name($config_name)
78
-    {
79
-        $this->_config_name = ! empty($config_name) ? $config_name : get_called_class();
80
-    }
81
-
82
-
83
-    /**
84
-     * @return mixed
85
-     */
86
-    public function config_name()
87
-    {
88
-        return $this->_config_name;
89
-    }
90
-
91
-
92
-    /**
93
-     *    set_config
94
-     *    this method integrates directly with EE_Config to set up the config object for this class
95
-     *
96
-     * @access    protected
97
-     * @param    EE_Config_Base $config_obj
98
-     * @return    mixed    EE_Config_Base | NULL
99
-     */
100
-    protected function _set_config(EE_Config_Base $config_obj = null)
101
-    {
102
-        return EE_Config::instance()->set_config(
103
-            $this->config_section(),
104
-            $this->config_name(),
105
-            $this->config_class(),
106
-            $config_obj
107
-        );
108
-    }
109
-
110
-
111
-    /**
112
-     *    _update_config
113
-     *    this method integrates directly with EE_Config to update an existing config object for this class
114
-     *
115
-     * @access    protected
116
-     * @param    EE_Config_Base $config_obj
117
-     * @throws \EE_Error
118
-     * @return    mixed    EE_Config_Base | NULL
119
-     */
120
-    public function _update_config(EE_Config_Base $config_obj = null)
121
-    {
122
-        $config_class = $this->config_class();
123
-        if (! $config_obj instanceof $config_class) {
124
-            throw new EE_Error(
125
-                sprintf(
126
-                    __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
127
-                    print_r($config_obj, true),
128
-                    $config_class
129
-                )
130
-            );
131
-        }
132
-        return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj);
133
-    }
134
-
135
-
136
-    /**
137
-     * gets the class's config object
138
-     *
139
-     * @return EE_Config_Base
140
-     */
141
-    public function config()
142
-    {
143
-        if (empty($this->_config)) {
144
-            $this->_config = EE_Config::instance()->get_config(
145
-                $this->config_section(),
146
-                $this->config_name(),
147
-                $this->config_class()
148
-            );
149
-        }
150
-        return $this->_config;
151
-    }
13
+	/**
14
+	 * @var $_config
15
+	 * @type EE_Config_Base
16
+	 */
17
+	protected $_config;
18
+
19
+	/**
20
+	 * @var $_config_section
21
+	 * @type string
22
+	 */
23
+	protected $_config_section = '';
24
+
25
+	/**
26
+	 * @var $_config_class
27
+	 * @type string
28
+	 */
29
+	protected $_config_class = '';
30
+
31
+	/**
32
+	 * @var $_config_name
33
+	 * @type string
34
+	 */
35
+	protected $_config_name = '';
36
+
37
+
38
+	/**
39
+	 * @param string $config_section
40
+	 */
41
+	public function set_config_section($config_section = '')
42
+	{
43
+		$this->_config_section = ! empty($config_section) ? $config_section : 'modules';
44
+	}
45
+
46
+
47
+	/**
48
+	 * @return mixed
49
+	 */
50
+	public function config_section()
51
+	{
52
+		return $this->_config_section;
53
+	}
54
+
55
+
56
+	/**
57
+	 * @param string $config_class
58
+	 */
59
+	public function set_config_class($config_class = '')
60
+	{
61
+		$this->_config_class = $config_class;
62
+	}
63
+
64
+
65
+	/**
66
+	 * @return mixed
67
+	 */
68
+	public function config_class()
69
+	{
70
+		return $this->_config_class;
71
+	}
72
+
73
+
74
+	/**
75
+	 * @param mixed $config_name
76
+	 */
77
+	public function set_config_name($config_name)
78
+	{
79
+		$this->_config_name = ! empty($config_name) ? $config_name : get_called_class();
80
+	}
81
+
82
+
83
+	/**
84
+	 * @return mixed
85
+	 */
86
+	public function config_name()
87
+	{
88
+		return $this->_config_name;
89
+	}
90
+
91
+
92
+	/**
93
+	 *    set_config
94
+	 *    this method integrates directly with EE_Config to set up the config object for this class
95
+	 *
96
+	 * @access    protected
97
+	 * @param    EE_Config_Base $config_obj
98
+	 * @return    mixed    EE_Config_Base | NULL
99
+	 */
100
+	protected function _set_config(EE_Config_Base $config_obj = null)
101
+	{
102
+		return EE_Config::instance()->set_config(
103
+			$this->config_section(),
104
+			$this->config_name(),
105
+			$this->config_class(),
106
+			$config_obj
107
+		);
108
+	}
109
+
110
+
111
+	/**
112
+	 *    _update_config
113
+	 *    this method integrates directly with EE_Config to update an existing config object for this class
114
+	 *
115
+	 * @access    protected
116
+	 * @param    EE_Config_Base $config_obj
117
+	 * @throws \EE_Error
118
+	 * @return    mixed    EE_Config_Base | NULL
119
+	 */
120
+	public function _update_config(EE_Config_Base $config_obj = null)
121
+	{
122
+		$config_class = $this->config_class();
123
+		if (! $config_obj instanceof $config_class) {
124
+			throw new EE_Error(
125
+				sprintf(
126
+					__('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
127
+					print_r($config_obj, true),
128
+					$config_class
129
+				)
130
+			);
131
+		}
132
+		return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj);
133
+	}
134
+
135
+
136
+	/**
137
+	 * gets the class's config object
138
+	 *
139
+	 * @return EE_Config_Base
140
+	 */
141
+	public function config()
142
+	{
143
+		if (empty($this->_config)) {
144
+			$this->_config = EE_Config::instance()->get_config(
145
+				$this->config_section(),
146
+				$this->config_name(),
147
+				$this->config_class()
148
+			);
149
+		}
150
+		return $this->_config;
151
+	}
152 152
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@
 block discarded – undo
120 120
     public function _update_config(EE_Config_Base $config_obj = null)
121 121
     {
122 122
         $config_class = $this->config_class();
123
-        if (! $config_obj instanceof $config_class) {
123
+        if ( ! $config_obj instanceof $config_class) {
124 124
             throw new EE_Error(
125 125
                 sprintf(
126 126
                     __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
Please login to merge, or discard this patch.
core/db_models/EEM_Term_Taxonomy.model.php 2 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -10,128 +10,128 @@
 block discarded – undo
10 10
 class EEM_Term_Taxonomy extends EEM_Base
11 11
 {
12 12
 
13
-    // private instance of the Attendee object
14
-    protected static $_instance = null;
13
+	// private instance of the Attendee object
14
+	protected static $_instance = null;
15 15
 
16 16
 
17 17
 
18
-    protected function __construct($timezone = null)
19
-    {
20
-        $this->singular_item = __('Term Taxonomy', 'event_espresso');
21
-        $this->plural_item = __('Term Taxonomy', 'event_espresso');
22
-        $this->_tables = array(
23
-            'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'),
24
-        );
25
-        $this->_fields = array(
26
-            'Term_Taxonomy' => array(
27
-                'term_taxonomy_id' => new EE_Primary_Key_Int_Field(
28
-                    'term_taxonomy_id',
29
-                    __('Term-Taxonomy ID', 'event_espresso')
30
-                ),
31
-                'term_id'          => new EE_Foreign_Key_Int_Field(
32
-                    'term_id',
33
-                    __("Term Id", "event_espresso"),
34
-                    false,
35
-                    0,
36
-                    'Term'
37
-                ),
38
-                'taxonomy'         => new EE_Plain_Text_Field(
39
-                    'taxonomy',
40
-                    __('Taxonomy Name', 'event_espresso'),
41
-                    false,
42
-                    'category'
43
-                ),
44
-                'description'      => new EE_Post_Content_Field(
45
-                    'description',
46
-                    __("Description of Term", "event_espresso"),
47
-                    false,
48
-                    ''
49
-                ),
50
-                'parent'           => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0),
51
-                'term_count'       => new EE_Integer_Field(
52
-                    'count',
53
-                    __("Count of Objects attached", 'event_espresso'),
54
-                    false,
55
-                    0
56
-                ),
57
-            ),
58
-        );
59
-        $this->_model_relations = array(
60
-            'Term_Relationship' => new EE_Has_Many_Relation(),
61
-            'Term'              => new EE_Belongs_To_Relation(),
62
-        );
63
-        $cpt_models = array_keys(EE_Registry::instance()->cpt_models());
64
-        foreach ($cpt_models as $model_name) {
65
-            $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
66
-        }
67
-        $this->_wp_core_model = true;
68
-        $this->_indexes = array(
69
-            'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
70
-        );
71
-        $path_to_tax_model = '';
72
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
73
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
74
-            $path_to_tax_model
75
-        );
76
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
78
-        // add cap restrictions for editing relating to the "ee_edit_*"
79
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
80
-            array(
81
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
82
-            )
83
-        );
84
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
85
-            array(
86
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
87
-            )
88
-        );
89
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
90
-            array(
91
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
92
-            )
93
-        );
94
-        // add cap restrictions for deleting relating to the "ee_deleting_*"
95
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
96
-            array(
97
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
98
-            )
99
-        );
100
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
101
-            array(
102
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
103
-            )
104
-        );
105
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
106
-            array(
107
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
108
-            )
109
-        );
110
-        parent::__construct($timezone);
111
-        add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3);
112
-    }
18
+	protected function __construct($timezone = null)
19
+	{
20
+		$this->singular_item = __('Term Taxonomy', 'event_espresso');
21
+		$this->plural_item = __('Term Taxonomy', 'event_espresso');
22
+		$this->_tables = array(
23
+			'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'),
24
+		);
25
+		$this->_fields = array(
26
+			'Term_Taxonomy' => array(
27
+				'term_taxonomy_id' => new EE_Primary_Key_Int_Field(
28
+					'term_taxonomy_id',
29
+					__('Term-Taxonomy ID', 'event_espresso')
30
+				),
31
+				'term_id'          => new EE_Foreign_Key_Int_Field(
32
+					'term_id',
33
+					__("Term Id", "event_espresso"),
34
+					false,
35
+					0,
36
+					'Term'
37
+				),
38
+				'taxonomy'         => new EE_Plain_Text_Field(
39
+					'taxonomy',
40
+					__('Taxonomy Name', 'event_espresso'),
41
+					false,
42
+					'category'
43
+				),
44
+				'description'      => new EE_Post_Content_Field(
45
+					'description',
46
+					__("Description of Term", "event_espresso"),
47
+					false,
48
+					''
49
+				),
50
+				'parent'           => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0),
51
+				'term_count'       => new EE_Integer_Field(
52
+					'count',
53
+					__("Count of Objects attached", 'event_espresso'),
54
+					false,
55
+					0
56
+				),
57
+			),
58
+		);
59
+		$this->_model_relations = array(
60
+			'Term_Relationship' => new EE_Has_Many_Relation(),
61
+			'Term'              => new EE_Belongs_To_Relation(),
62
+		);
63
+		$cpt_models = array_keys(EE_Registry::instance()->cpt_models());
64
+		foreach ($cpt_models as $model_name) {
65
+			$this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
66
+		}
67
+		$this->_wp_core_model = true;
68
+		$this->_indexes = array(
69
+			'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
70
+		);
71
+		$path_to_tax_model = '';
72
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
73
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
74
+			$path_to_tax_model
75
+		);
76
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
77
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
78
+		// add cap restrictions for editing relating to the "ee_edit_*"
79
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
80
+			array(
81
+				$path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
82
+			)
83
+		);
84
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
85
+			array(
86
+				$path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
87
+			)
88
+		);
89
+		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
90
+			array(
91
+				$path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
92
+			)
93
+		);
94
+		// add cap restrictions for deleting relating to the "ee_deleting_*"
95
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
96
+			array(
97
+				$path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
98
+			)
99
+		);
100
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
101
+			array(
102
+				$path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
103
+			)
104
+		);
105
+		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
106
+			array(
107
+				$path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
108
+			)
109
+		);
110
+		parent::__construct($timezone);
111
+		add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3);
112
+	}
113 113
 
114 114
 
115 115
 
116
-    /**
117
-     * Makes sure that during REST API queries, we only return term-taxonomies
118
-     * for term taxonomies which should be shown in the rest api
119
-     *
120
-     * @param array    $model_query_params
121
-     * @param array    $querystring_query_params
122
-     * @param EEM_Base $model
123
-     * @return array
124
-     */
125
-    public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
126
-    {
127
-        if ($model === EEM_Term_Taxonomy::instance()) {
128
-            $taxonomies = get_taxonomies(array('show_in_rest' => true));
129
-            if (! empty($taxonomies)) {
130
-                $model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
131
-            }
132
-        }
133
-        return $model_query_params;
134
-    }
116
+	/**
117
+	 * Makes sure that during REST API queries, we only return term-taxonomies
118
+	 * for term taxonomies which should be shown in the rest api
119
+	 *
120
+	 * @param array    $model_query_params
121
+	 * @param array    $querystring_query_params
122
+	 * @param EEM_Base $model
123
+	 * @return array
124
+	 */
125
+	public static function rest_api_query_params($model_query_params, $querystring_query_params, $model)
126
+	{
127
+		if ($model === EEM_Term_Taxonomy::instance()) {
128
+			$taxonomies = get_taxonomies(array('show_in_rest' => true));
129
+			if (! empty($taxonomies)) {
130
+				$model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
131
+			}
132
+		}
133
+		return $model_query_params;
134
+	}
135 135
 }
136 136
 // End of file EEM_Term_Taxonomy.model.php
137 137
 // Location: /includes/models/EEM_Term_Taxonomy.model.php
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -62,49 +62,49 @@  discard block
 block discarded – undo
62 62
         );
63 63
         $cpt_models = array_keys(EE_Registry::instance()->cpt_models());
64 64
         foreach ($cpt_models as $model_name) {
65
-            $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship');
65
+            $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship');
66 66
         }
67 67
         $this->_wp_core_model = true;
68 68
         $this->_indexes = array(
69 69
             'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')),
70 70
         );
71 71
         $path_to_tax_model = '';
72
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
73
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected(
72
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
73
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected(
74 74
             $path_to_tax_model
75 75
         );
76
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
77
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
76
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = false;
77
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = false;
78 78
         // add cap restrictions for editing relating to the "ee_edit_*"
79
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
79
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
80 80
             array(
81
-                $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
81
+                $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'),
82 82
             )
83 83
         );
84
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
84
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
85 85
             array(
86
-                $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
86
+                $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'),
87 87
             )
88 88
         );
89
-        $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
89
+        $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
90 90
             array(
91
-                $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
91
+                $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'),
92 92
             )
93 93
         );
94 94
         // add cap restrictions for deleting relating to the "ee_deleting_*"
95
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
95
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
96 96
             array(
97
-                $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
97
+                $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'),
98 98
             )
99 99
         );
100
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
100
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
101 101
             array(
102
-                $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
102
+                $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'),
103 103
             )
104 104
         );
105
-        $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
105
+        $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
106 106
             array(
107
-                $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
107
+                $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'),
108 108
             )
109 109
         );
110 110
         parent::__construct($timezone);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         if ($model === EEM_Term_Taxonomy::instance()) {
128 128
             $taxonomies = get_taxonomies(array('show_in_rest' => true));
129
-            if (! empty($taxonomies)) {
129
+            if ( ! empty($taxonomies)) {
130 130
                 $model_query_params[0]['taxonomy'] = array('IN', $taxonomies);
131 131
             }
132 132
         }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency.model.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -11,66 +11,66 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Currency extends EEM_Base
13 13
 {
14
-        // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+		// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17
-    protected function __construct($timezone = null)
18
-    {
19
-        $this->singular_item = __('Currency', 'event_espresso');
20
-        $this->plural_item = __('Currencies', 'event_espresso');
21
-        $this->_tables = array(
22
-            'Currency'=> new EE_Primary_Table('esp_currency', 'CUR_code')
23
-        );
24
-        $this->_fields = array(
25
-            'Currency'=>array(
26
-                'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')),
27
-                'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false),
28
-                'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false),
29
-                'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false),
30
-                'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2),
31
-                'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true),
32
-            ));
33
-        $this->_model_relations = array(
34
-            'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'),
35
-        );
36
-        // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
17
+	protected function __construct($timezone = null)
18
+	{
19
+		$this->singular_item = __('Currency', 'event_espresso');
20
+		$this->plural_item = __('Currencies', 'event_espresso');
21
+		$this->_tables = array(
22
+			'Currency'=> new EE_Primary_Table('esp_currency', 'CUR_code')
23
+		);
24
+		$this->_fields = array(
25
+			'Currency'=>array(
26
+				'CUR_code'=> new EE_Primary_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso')),
27
+				'CUR_single' => new EE_Plain_Text_Field('CUR_single', __('Currency Name Singular', 'event_espresso'), false),
28
+				'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', __('Currency Name Plural', 'event_espresso'), false),
29
+				'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', __('Currency Sign', 'event_espresso'), false),
30
+				'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2),
31
+				'CUR_active'=>new EE_Boolean_Field('CUR_active', __('Active?', 'event_espresso'), false, true),
32
+			));
33
+		$this->_model_relations = array(
34
+			'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'),
35
+		);
36
+		// this model is generally available for reading
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38 38
 
39
-        parent::__construct($timezone);
40
-    }
39
+		parent::__construct($timezone);
40
+	}
41 41
 
42
-    /**
43
-     * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
-     * (may be overridden)
45
-     * @param array $query_params see EEM_Base::get_all
46
-     * @return EE_Currency[]
47
-     */
48
-    public function get_all_active($query_params = array())
49
-    {
50
-        $query_params[0]['CUR_active'] = true;
51
-        if (! isset($query_params['order_by'])) {
52
-            $query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC');
53
-        }
54
-        return $this->get_all($query_params);
55
-    }
56
-    /**
57
-     * Gets all the currencies which can be used by that payment method type
58
-     * @param EE_PMT_Base $payment_method_type
59
-     * @return EE_Currency[]
60
-     */
61
-    public function get_all_currencies_usable_by($payment_method_type)
62
-    {
63
-        if ($payment_method_type instanceof EE_PMT_Base &&
64
-                $payment_method_type->get_gateway()) {
65
-            $currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
66
-        } else {
67
-            $currencies_supported = EE_Gateway::all_currencies_supported;
68
-        }
69
-        if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
70
-            $currencies = $this->get_all_active();
71
-        } else {
72
-            $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported))));
73
-        }
74
-        return $currencies;
75
-    }
42
+	/**
43
+	 * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
+	 * (may be overridden)
45
+	 * @param array $query_params see EEM_Base::get_all
46
+	 * @return EE_Currency[]
47
+	 */
48
+	public function get_all_active($query_params = array())
49
+	{
50
+		$query_params[0]['CUR_active'] = true;
51
+		if (! isset($query_params['order_by'])) {
52
+			$query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC');
53
+		}
54
+		return $this->get_all($query_params);
55
+	}
56
+	/**
57
+	 * Gets all the currencies which can be used by that payment method type
58
+	 * @param EE_PMT_Base $payment_method_type
59
+	 * @return EE_Currency[]
60
+	 */
61
+	public function get_all_currencies_usable_by($payment_method_type)
62
+	{
63
+		if ($payment_method_type instanceof EE_PMT_Base &&
64
+				$payment_method_type->get_gateway()) {
65
+			$currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
66
+		} else {
67
+			$currencies_supported = EE_Gateway::all_currencies_supported;
68
+		}
69
+		if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
70
+			$currencies = $this->get_all_active();
71
+		} else {
72
+			$currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported))));
73
+		}
74
+		return $currencies;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             'Payment_Method'=>new EE_HABTM_Relation('Currency_Payment_Method'),
35 35
         );
36 36
         // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
37
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
38 38
 
39 39
         parent::__construct($timezone);
40 40
     }
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
     public function get_all_active($query_params = array())
49 49
     {
50 50
         $query_params[0]['CUR_active'] = true;
51
-        if (! isset($query_params['order_by'])) {
52
-            $query_params['order_by'] = array('CUR_code'=>'ASC','CUR_single'=>'ASC');
51
+        if ( ! isset($query_params['order_by'])) {
52
+            $query_params['order_by'] = array('CUR_code'=>'ASC', 'CUR_single'=>'ASC');
53 53
         }
54 54
         return $this->get_all($query_params);
55 55
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
70 70
             $currencies = $this->get_all_active();
71 71
         } else {
72
-            $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN',$currencies_supported))));
72
+            $currencies = $this->get_all_active(array(array('CUR_code'=>array('IN', $currencies_supported))));
73 73
         }
74 74
         return $currencies;
75 75
     }
Please login to merge, or discard this patch.
core/db_models/EEM_Event_Message_Template.model.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,95 +1,95 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
  /**
4
- *  EEM_Event_Message_Template
5
- *  Model for relation table between EEM_Message_Template_Group and EEM_Event
6
- *
7
- * @package     Event Espresso
8
- * @subpackage  models
9
- * @since           4.3.0
10
- * @author           Darren Ethier
11
- *
12
- * ------------------------------------------------------------------------
13
- */
4
+  *  EEM_Event_Message_Template
5
+  *  Model for relation table between EEM_Message_Template_Group and EEM_Event
6
+  *
7
+  * @package     Event Espresso
8
+  * @subpackage  models
9
+  * @since           4.3.0
10
+  * @author           Darren Ethier
11
+  *
12
+  * ------------------------------------------------------------------------
13
+  */
14 14
 class EEM_Event_Message_Template extends EEM_Base
15 15
 {
16 16
 
17
-    // private instance of the EEM_Event_Message_Template object
18
-    protected static $_instance = null;
17
+	// private instance of the EEM_Event_Message_Template object
18
+	protected static $_instance = null;
19 19
 
20
-    /**
21
-     * private constructor to prevent direct creation
22
-     * @Constructor
23
-     * @access private
24
-     * @return void
25
-     */
26
-    protected function __construct($timezone = null)
27
-    {
28
-        $this->singlular_item = __('Event Message Template', 'event_espresso');
29
-        $this->plural_item = __('Event Message Templates', 'event_espresso');
20
+	/**
21
+	 * private constructor to prevent direct creation
22
+	 * @Constructor
23
+	 * @access private
24
+	 * @return void
25
+	 */
26
+	protected function __construct($timezone = null)
27
+	{
28
+		$this->singlular_item = __('Event Message Template', 'event_espresso');
29
+		$this->plural_item = __('Event Message Templates', 'event_espresso');
30 30
 
31
-        $this->_tables = array(
32
-            'Event_Message_Template'=> new EE_Primary_Table('esp_event_message_template', 'EMT_ID')
33
-        );
34
-        $this->_fields = array(
35
-            'Event_Message_Template'=>array(
36
-                'EMT_ID'=>new EE_Primary_Key_Int_Field('EMT_ID', __('Event Message Template ID', 'event_espresso')),
37
-                'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('The ID to the Event', 'event_espresso'), false, 0, 'Event'),
38
-                'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('The ID to the Message Template Group', 'event_espresso'), false, 0, 'Message_Template_Group')
39
-            ));
40
-        $this->_model_relations = array(
41
-            'Event'=>new EE_Belongs_To_Relation(),
42
-            'Message_Template_Group'=>new EE_Belongs_To_Relation()
43
-        );
44
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public('Event');
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected('Event');
46
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected('Event');
47
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit);
31
+		$this->_tables = array(
32
+			'Event_Message_Template'=> new EE_Primary_Table('esp_event_message_template', 'EMT_ID')
33
+		);
34
+		$this->_fields = array(
35
+			'Event_Message_Template'=>array(
36
+				'EMT_ID'=>new EE_Primary_Key_Int_Field('EMT_ID', __('Event Message Template ID', 'event_espresso')),
37
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('The ID to the Event', 'event_espresso'), false, 0, 'Event'),
38
+				'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('The ID to the Message Template Group', 'event_espresso'), false, 0, 'Message_Template_Group')
39
+			));
40
+		$this->_model_relations = array(
41
+			'Event'=>new EE_Belongs_To_Relation(),
42
+			'Message_Template_Group'=>new EE_Belongs_To_Relation()
43
+		);
44
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public('Event');
45
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected('Event');
46
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected('Event');
47
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit);
48 48
 
49
-        parent::__construct($timezone);
50
-    }
49
+		parent::__construct($timezone);
50
+	}
51 51
 
52 52
 
53 53
 
54
-    /**
55
-     * helper method to simply return an array of event ids for events attached to the given
56
-     * message template group.
57
-     *
58
-     * @since 4.3.0
59
-     *
60
-     * @param  int    $GRP_ID The MTP group we want attached events for.
61
-     * @return  array               An array of event ids.
62
-     */
63
-    public function get_attached_event_ids($GRP_ID)
64
-    {
65
-        $event_ids = $this->_get_all_wpdb_results(array( array( 'GRP_ID' => $GRP_ID ) ), ARRAY_N, 'EVT_ID');
66
-        $event_ids = call_user_func_array('array_merge', $event_ids);
67
-        return $event_ids;
68
-    }
54
+	/**
55
+	 * helper method to simply return an array of event ids for events attached to the given
56
+	 * message template group.
57
+	 *
58
+	 * @since 4.3.0
59
+	 *
60
+	 * @param  int    $GRP_ID The MTP group we want attached events for.
61
+	 * @return  array               An array of event ids.
62
+	 */
63
+	public function get_attached_event_ids($GRP_ID)
64
+	{
65
+		$event_ids = $this->_get_all_wpdb_results(array( array( 'GRP_ID' => $GRP_ID ) ), ARRAY_N, 'EVT_ID');
66
+		$event_ids = call_user_func_array('array_merge', $event_ids);
67
+		return $event_ids;
68
+	}
69 69
 
70 70
 
71 71
 
72
-    /**
73
-     * helper method for clearing event/group relations for the given event ids and grp ids.
74
-     * @param  array $GRP_IDs  An array of GRP_IDs. Optional. If empty then there must be EVTIDs.
75
-     * @param  array $EVT_IDs  An array of EVT_IDs.  Optional. If empty then there must be
76
-     *                                 GRPIDs.
77
-     * @return int             How many rows were deleted.
78
-     */
79
-    public function delete_event_group_relations($GRP_IDs = array(), $EVT_IDs = array())
80
-    {
81
-        if (empty($GRP_IDs) && empty($EVT_IDs)) {
82
-            throw new EE_Error(sprintf(__('%s requires either an array of GRP_IDs or EVT_IDs or both, but both cannot be empty.', 'event_espresso'), __METHOD__));
83
-        }
72
+	/**
73
+	 * helper method for clearing event/group relations for the given event ids and grp ids.
74
+	 * @param  array $GRP_IDs  An array of GRP_IDs. Optional. If empty then there must be EVTIDs.
75
+	 * @param  array $EVT_IDs  An array of EVT_IDs.  Optional. If empty then there must be
76
+	 *                                 GRPIDs.
77
+	 * @return int             How many rows were deleted.
78
+	 */
79
+	public function delete_event_group_relations($GRP_IDs = array(), $EVT_IDs = array())
80
+	{
81
+		if (empty($GRP_IDs) && empty($EVT_IDs)) {
82
+			throw new EE_Error(sprintf(__('%s requires either an array of GRP_IDs or EVT_IDs or both, but both cannot be empty.', 'event_espresso'), __METHOD__));
83
+		}
84 84
 
85
-        if (!empty($GRP_IDs)) {
86
-            $where['GRP_ID'] = array( 'IN', (array) $GRP_IDs );
87
-        }
85
+		if (!empty($GRP_IDs)) {
86
+			$where['GRP_ID'] = array( 'IN', (array) $GRP_IDs );
87
+		}
88 88
 
89
-        if (!empty($EVT_IDs)) {
90
-            $where['EVT_ID'] = array( 'IN', (array) $EVT_IDs );
91
-        }
89
+		if (!empty($EVT_IDs)) {
90
+			$where['EVT_ID'] = array( 'IN', (array) $EVT_IDs );
91
+		}
92 92
 
93
-        return $this->delete(array( $where ), false);
94
-    }
93
+		return $this->delete(array( $where ), false);
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
             'Event'=>new EE_Belongs_To_Relation(),
42 42
             'Message_Template_Group'=>new EE_Belongs_To_Relation()
43 43
         );
44
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public('Event');
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected('Event');
46
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected('Event');
47
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit);
44
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event');
45
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event');
46
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event');
47
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit);
48 48
 
49 49
         parent::__construct($timezone);
50 50
     }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function get_attached_event_ids($GRP_ID)
64 64
     {
65
-        $event_ids = $this->_get_all_wpdb_results(array( array( 'GRP_ID' => $GRP_ID ) ), ARRAY_N, 'EVT_ID');
65
+        $event_ids = $this->_get_all_wpdb_results(array(array('GRP_ID' => $GRP_ID)), ARRAY_N, 'EVT_ID');
66 66
         $event_ids = call_user_func_array('array_merge', $event_ids);
67 67
         return $event_ids;
68 68
     }
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
             throw new EE_Error(sprintf(__('%s requires either an array of GRP_IDs or EVT_IDs or both, but both cannot be empty.', 'event_espresso'), __METHOD__));
83 83
         }
84 84
 
85
-        if (!empty($GRP_IDs)) {
86
-            $where['GRP_ID'] = array( 'IN', (array) $GRP_IDs );
85
+        if ( ! empty($GRP_IDs)) {
86
+            $where['GRP_ID'] = array('IN', (array) $GRP_IDs);
87 87
         }
88 88
 
89
-        if (!empty($EVT_IDs)) {
90
-            $where['EVT_ID'] = array( 'IN', (array) $EVT_IDs );
89
+        if ( ! empty($EVT_IDs)) {
90
+            $where['EVT_ID'] = array('IN', (array) $EVT_IDs);
91 91
         }
92 92
 
93
-        return $this->delete(array( $where ), false);
93
+        return $this->delete(array($where), false);
94 94
     }
95 95
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency_Payment_Method.model.php 2 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Currency_Payment_Method extends EEM_Base
13 13
 {
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17 17
 
18
-    protected function __construct($timezone = null)
19
-    {
20
-        $this->singular_item = __('Currency Usable by Payment Method', 'event_espresso');
21
-        $this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso');
22
-        $this->_tables = array(
23
-            'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
24
-        );
25
-        $this->_fields = array(
26
-            'Currency_Payment_Method'=>array(
27
-                'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')),
28
-                'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, '', 'Currency'),
29
-                'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
30
-            )
31
-        );
32
-        $this->_model_relations = array(
33
-            'Currency'=>new EE_Belongs_To_Relation(),
34
-            'Payment_Method'=>new EE_Belongs_To_Relation()
35
-        );
36
-        // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38
-        $this->_caps_slug = 'payment_methods';
39
-        parent::__construct($timezone);
40
-    }
18
+	protected function __construct($timezone = null)
19
+	{
20
+		$this->singular_item = __('Currency Usable by Payment Method', 'event_espresso');
21
+		$this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso');
22
+		$this->_tables = array(
23
+			'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
24
+		);
25
+		$this->_fields = array(
26
+			'Currency_Payment_Method'=>array(
27
+				'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')),
28
+				'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, '', 'Currency'),
29
+				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
30
+			)
31
+		);
32
+		$this->_model_relations = array(
33
+			'Currency'=>new EE_Belongs_To_Relation(),
34
+			'Payment_Method'=>new EE_Belongs_To_Relation()
35
+		);
36
+		// this model is generally available for reading
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38
+		$this->_caps_slug = 'payment_methods';
39
+		parent::__construct($timezone);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
             'Payment_Method'=>new EE_Belongs_To_Relation()
35 35
         );
36 36
         // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
37
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
38 38
         $this->_caps_slug = 'payment_methods';
39 39
         parent::__construct($timezone);
40 40
     }
Please login to merge, or discard this patch.
core/db_models/EEM_Change_Log.model.php 2 patches
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -11,93 +11,93 @@  discard block
 block discarded – undo
11 11
 class EEM_Change_Log extends EEM_Base
12 12
 {
13 13
 
14
-    /**
15
-     * the related object was created log type
16
-     */
17
-    const type_create = 'create';
18
-    /**
19
-     * the related object was updated (changed, or soft-deleted)
20
-     */
21
-    const type_update = 'update';
22
-    /**
23
-     * the related object was deleted permanently
24
-     */
25
-    const type_delete = 'delete';
26
-    /**
27
-     * the related item had something worth noting happen on it, but
28
-     * only for the purposes of debugging problems
29
-     */
30
-    const type_debug = 'debug';
31
-    /**
32
-     * the related item had an error occur on it
33
-     */
34
-    const type_error = 'error';
35
-    /**
36
-     * the related item is regarding some gateway interaction, like an IPN
37
-     * or request to process a payment
38
-     */
39
-    const type_gateway = 'gateway';
14
+	/**
15
+	 * the related object was created log type
16
+	 */
17
+	const type_create = 'create';
18
+	/**
19
+	 * the related object was updated (changed, or soft-deleted)
20
+	 */
21
+	const type_update = 'update';
22
+	/**
23
+	 * the related object was deleted permanently
24
+	 */
25
+	const type_delete = 'delete';
26
+	/**
27
+	 * the related item had something worth noting happen on it, but
28
+	 * only for the purposes of debugging problems
29
+	 */
30
+	const type_debug = 'debug';
31
+	/**
32
+	 * the related item had an error occur on it
33
+	 */
34
+	const type_error = 'error';
35
+	/**
36
+	 * the related item is regarding some gateway interaction, like an IPN
37
+	 * or request to process a payment
38
+	 */
39
+	const type_gateway = 'gateway';
40 40
 
41
-    /**
42
-     * private instance of the EEM_Change_Log object
43
-     *
44
-     * @access private
45
-     * @var EEM_Change_Log $_instance
46
-     */
47
-    protected static $_instance = null;
41
+	/**
42
+	 * private instance of the EEM_Change_Log object
43
+	 *
44
+	 * @access private
45
+	 * @var EEM_Change_Log $_instance
46
+	 */
47
+	protected static $_instance = null;
48 48
 
49 49
 
50
-    /**
51
-     * constructor
52
-     *
53
-     * @access protected
54
-     * @param null $timezone
55
-     * @throws EE_Error
56
-     */
57
-    protected function __construct($timezone = null)
58
-    {
59
-        global $current_user;
60
-        $this->singular_item       = esc_html__('Log', 'event_espresso');
61
-        $this->plural_item         = esc_html__('Logs', 'event_espresso');
62
-        $this->_tables             = array(
63
-            'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'),
64
-        );
65
-        $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
66
-        $this->_fields             = array(
67
-            'Log' => array(
68
-                'LOG_ID'      => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')),
69
-                'LOG_time'    => new EE_Datetime_Field(
70
-                    'LOG_time',
71
-                    esc_html__("Log Time", 'event_espresso'),
72
-                    false,
73
-                    EE_Datetime_Field::now
74
-                ),
75
-                'OBJ_ID'      => new EE_Foreign_Key_String_Field(
76
-                    'OBJ_ID',
77
-                    esc_html__("Object ID (int or string)", 'event_espresso'),
78
-                    true,
79
-                    null,
80
-                    $models_this_can_attach_to
81
-                ),
82
-                'OBJ_type'    => new EE_Any_Foreign_Model_Name_Field(
83
-                    'OBJ_type',
84
-                    esc_html__("Object Type", 'event_espresso'),
85
-                    true,
86
-                    null,
87
-                    $models_this_can_attach_to
88
-                ),
89
-                'LOG_type'    => new EE_Plain_Text_Field(
90
-                    'LOG_type',
91
-                    esc_html__("Type of log entry", "event_espresso"),
92
-                    false,
93
-                    self::type_debug
94
-                ),
95
-                'LOG_message' => new EE_Maybe_Serialized_Text_Field(
96
-                    'LOG_message',
97
-                    esc_html__("Log Message (body)", 'event_espresso'),
98
-                    true
99
-                ),
100
-                /*
50
+	/**
51
+	 * constructor
52
+	 *
53
+	 * @access protected
54
+	 * @param null $timezone
55
+	 * @throws EE_Error
56
+	 */
57
+	protected function __construct($timezone = null)
58
+	{
59
+		global $current_user;
60
+		$this->singular_item       = esc_html__('Log', 'event_espresso');
61
+		$this->plural_item         = esc_html__('Logs', 'event_espresso');
62
+		$this->_tables             = array(
63
+			'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'),
64
+		);
65
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
66
+		$this->_fields             = array(
67
+			'Log' => array(
68
+				'LOG_ID'      => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')),
69
+				'LOG_time'    => new EE_Datetime_Field(
70
+					'LOG_time',
71
+					esc_html__("Log Time", 'event_espresso'),
72
+					false,
73
+					EE_Datetime_Field::now
74
+				),
75
+				'OBJ_ID'      => new EE_Foreign_Key_String_Field(
76
+					'OBJ_ID',
77
+					esc_html__("Object ID (int or string)", 'event_espresso'),
78
+					true,
79
+					null,
80
+					$models_this_can_attach_to
81
+				),
82
+				'OBJ_type'    => new EE_Any_Foreign_Model_Name_Field(
83
+					'OBJ_type',
84
+					esc_html__("Object Type", 'event_espresso'),
85
+					true,
86
+					null,
87
+					$models_this_can_attach_to
88
+				),
89
+				'LOG_type'    => new EE_Plain_Text_Field(
90
+					'LOG_type',
91
+					esc_html__("Type of log entry", "event_espresso"),
92
+					false,
93
+					self::type_debug
94
+				),
95
+				'LOG_message' => new EE_Maybe_Serialized_Text_Field(
96
+					'LOG_message',
97
+					esc_html__("Log Message (body)", 'event_espresso'),
98
+					true
99
+				),
100
+				/*
101 101
                  * Note: when querying for a change log's user, the OBJ_ID and OBJ_type fields are used,
102 102
                  * not the LOG_wp_user field. E.g.,
103 103
                  * `EEM_Change_Log::instance()->get_all(array(array('WP_User.ID'=>1)))` will actually return
@@ -106,158 +106,158 @@  discard block
 block discarded – undo
106 106
                  *  If you want the latter, you can't use the model's magic joining. E.g, you would need to do
107 107
                  * `EEM_Change_Log::instance()->get_all(array(array('LOG_wp_user' => 1)))`.
108 108
                  */
109
-                'LOG_wp_user' => new EE_WP_User_Field(
110
-                    'LOG_wp_user',
111
-                    esc_html__("User who was logged in while this occurred", 'event_espresso'),
112
-                    true
113
-                ),
114
-            ),
115
-        );
116
-        $this->_model_relations    = array();
117
-        foreach ($models_this_can_attach_to as $model) {
118
-            if ($model != 'Change_Log') {
119
-                $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
120
-            }
121
-        }
122
-        // use completely custom caps for this
123
-        $this->_cap_restriction_generators = false;
124
-        // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
125
-        foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
126
-            $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ]
127
-                = new EE_Return_None_Where_Conditions();
128
-        }
129
-        parent::__construct($timezone);
130
-    }
109
+				'LOG_wp_user' => new EE_WP_User_Field(
110
+					'LOG_wp_user',
111
+					esc_html__("User who was logged in while this occurred", 'event_espresso'),
112
+					true
113
+				),
114
+			),
115
+		);
116
+		$this->_model_relations    = array();
117
+		foreach ($models_this_can_attach_to as $model) {
118
+			if ($model != 'Change_Log') {
119
+				$this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
120
+			}
121
+		}
122
+		// use completely custom caps for this
123
+		$this->_cap_restriction_generators = false;
124
+		// caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
125
+		foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
126
+			$this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ]
127
+				= new EE_Return_None_Where_Conditions();
128
+		}
129
+		parent::__construct($timezone);
130
+	}
131 131
 
132
-    /**
133
-     * @param string        $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct
134
-     * @param mixed         $message  array|string of the message you want to record
135
-     * @param EE_Base_Class $related_model_obj
136
-     * @return EE_Change_Log
137
-     * @throws EE_Error
138
-     */
139
-    public function log($log_type, $message, $related_model_obj)
140
-    {
141
-        if ($related_model_obj instanceof EE_Base_Class) {
142
-            $obj_id   = $related_model_obj->ID();
143
-            $obj_type = $related_model_obj->get_model()->get_this_model_name();
144
-        } else {
145
-            $obj_id   = null;
146
-            $obj_type = null;
147
-        }
148
-        /** @var EE_Change_Log $log */
149
-        $log = EE_Change_Log::new_instance(array(
150
-            'LOG_type'    => $log_type,
151
-            'LOG_message' => $message,
152
-            'OBJ_ID'      => $obj_id,
153
-            'OBJ_type'    => $obj_type,
154
-        ));
155
-        $log->save();
156
-        return $log;
157
-    }
132
+	/**
133
+	 * @param string        $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct
134
+	 * @param mixed         $message  array|string of the message you want to record
135
+	 * @param EE_Base_Class $related_model_obj
136
+	 * @return EE_Change_Log
137
+	 * @throws EE_Error
138
+	 */
139
+	public function log($log_type, $message, $related_model_obj)
140
+	{
141
+		if ($related_model_obj instanceof EE_Base_Class) {
142
+			$obj_id   = $related_model_obj->ID();
143
+			$obj_type = $related_model_obj->get_model()->get_this_model_name();
144
+		} else {
145
+			$obj_id   = null;
146
+			$obj_type = null;
147
+		}
148
+		/** @var EE_Change_Log $log */
149
+		$log = EE_Change_Log::new_instance(array(
150
+			'LOG_type'    => $log_type,
151
+			'LOG_message' => $message,
152
+			'OBJ_ID'      => $obj_id,
153
+			'OBJ_type'    => $obj_type,
154
+		));
155
+		$log->save();
156
+		return $log;
157
+	}
158 158
 
159 159
 
160
-    /**
161
-     * Adds a gateway log for the specified object, given its ID and type
162
-     *
163
-     * @param string $message
164
-     * @param mixed  $related_obj_id
165
-     * @param string $related_obj_type
166
-     * @throws EE_Error
167
-     * @return EE_Change_Log
168
-     */
169
-    public function gateway_log($message, $related_obj_id, $related_obj_type)
170
-    {
171
-        if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
172
-            throw new EE_Error(
173
-                sprintf(
174
-                    esc_html__(
175
-                        "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc",
176
-                        "event_espresso"
177
-                    ),
178
-                    $related_obj_type
179
-                )
180
-            );
181
-        }
182
-        /** @var EE_Change_Log $log */
183
-        $log = EE_Change_Log::new_instance(array(
184
-            'LOG_type'    => EEM_Change_Log::type_gateway,
185
-            'LOG_message' => $message,
186
-            'OBJ_ID'      => $related_obj_id,
187
-            'OBJ_type'    => $related_obj_type,
188
-        ));
189
-        $log->save();
190
-        return $log;
191
-    }
160
+	/**
161
+	 * Adds a gateway log for the specified object, given its ID and type
162
+	 *
163
+	 * @param string $message
164
+	 * @param mixed  $related_obj_id
165
+	 * @param string $related_obj_type
166
+	 * @throws EE_Error
167
+	 * @return EE_Change_Log
168
+	 */
169
+	public function gateway_log($message, $related_obj_id, $related_obj_type)
170
+	{
171
+		if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
172
+			throw new EE_Error(
173
+				sprintf(
174
+					esc_html__(
175
+						"'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc",
176
+						"event_espresso"
177
+					),
178
+					$related_obj_type
179
+				)
180
+			);
181
+		}
182
+		/** @var EE_Change_Log $log */
183
+		$log = EE_Change_Log::new_instance(array(
184
+			'LOG_type'    => EEM_Change_Log::type_gateway,
185
+			'LOG_message' => $message,
186
+			'OBJ_ID'      => $related_obj_id,
187
+			'OBJ_type'    => $related_obj_type,
188
+		));
189
+		$log->save();
190
+		return $log;
191
+	}
192 192
 
193 193
 
194
-    /**
195
-     * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential
196
-     *
197
-     * @param array $query_params @see EEM_Base::get_all
198
-     * @return array of arrays
199
-     * @throws EE_Error
200
-     */
201
-    public function get_all_efficiently($query_params)
202
-    {
203
-        return $this->_get_all_wpdb_results($query_params);
204
-    }
194
+	/**
195
+	 * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential
196
+	 *
197
+	 * @param array $query_params @see EEM_Base::get_all
198
+	 * @return array of arrays
199
+	 * @throws EE_Error
200
+	 */
201
+	public function get_all_efficiently($query_params)
202
+	{
203
+		return $this->_get_all_wpdb_results($query_params);
204
+	}
205 205
 
206 206
 
207
-    /**
208
-     * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use
209
-     * models after this, they may be out-of-sync with the database
210
-     *
211
-     * @param DateTime $datetime
212
-     * @return false|int
213
-     * @throws EE_Error
214
-     */
215
-    public function delete_gateway_logs_older_than(DateTime $datetime)
216
-    {
217
-        global $wpdb;
218
-        return $wpdb->query(
219
-            $wpdb->prepare(
220
-                'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
221
-                EEM_Change_Log::type_gateway,
222
-                $datetime->format(EE_Datetime_Field::mysql_timestamp_format)
223
-            )
224
-        );
225
-    }
207
+	/**
208
+	 * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use
209
+	 * models after this, they may be out-of-sync with the database
210
+	 *
211
+	 * @param DateTime $datetime
212
+	 * @return false|int
213
+	 * @throws EE_Error
214
+	 */
215
+	public function delete_gateway_logs_older_than(DateTime $datetime)
216
+	{
217
+		global $wpdb;
218
+		return $wpdb->query(
219
+			$wpdb->prepare(
220
+				'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
221
+				EEM_Change_Log::type_gateway,
222
+				$datetime->format(EE_Datetime_Field::mysql_timestamp_format)
223
+			)
224
+		);
225
+	}
226 226
 
227 227
 
228
-    /**
229
-     * Returns the map of type to pretty label for identifiers used for `LOG_type`.  Client code can register their own
230
-     * map vai the given filter.
231
-     *
232
-     * @return array
233
-     */
234
-    public static function get_pretty_label_map_for_registered_types()
235
-    {
236
-        return apply_filters(
237
-            'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types',
238
-            array(
239
-                self::type_create=>  esc_html__("Create", "event_espresso"),
240
-                self::type_update=>  esc_html__("Update", "event_espresso"),
241
-                self::type_delete => esc_html__("Delete", "event_espresso"),
242
-                self::type_debug=>  esc_html__("Debug", "event_espresso"),
243
-                self::type_error=>  esc_html__("Error", "event_espresso"),
244
-                self::type_gateway=> esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso')
245
-            )
246
-        );
247
-    }
228
+	/**
229
+	 * Returns the map of type to pretty label for identifiers used for `LOG_type`.  Client code can register their own
230
+	 * map vai the given filter.
231
+	 *
232
+	 * @return array
233
+	 */
234
+	public static function get_pretty_label_map_for_registered_types()
235
+	{
236
+		return apply_filters(
237
+			'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types',
238
+			array(
239
+				self::type_create=>  esc_html__("Create", "event_espresso"),
240
+				self::type_update=>  esc_html__("Update", "event_espresso"),
241
+				self::type_delete => esc_html__("Delete", "event_espresso"),
242
+				self::type_debug=>  esc_html__("Debug", "event_espresso"),
243
+				self::type_error=>  esc_html__("Error", "event_espresso"),
244
+				self::type_gateway=> esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso')
245
+			)
246
+		);
247
+	}
248 248
 
249 249
 
250
-    /**
251
-     * Return the pretty (localized) label for the given log type identifier.
252
-     * @param string $type_identifier
253
-     * @return string
254
-     */
255
-    public static function get_pretty_label_for_type($type_identifier)
256
-    {
257
-        $type_identifier_map = self::get_pretty_label_map_for_registered_types();
258
-        // we fallback to the incoming type identifier if there is no localized label for it.
259
-        return isset($type_identifier_map[ $type_identifier ])
260
-            ? $type_identifier_map[ $type_identifier ]
261
-            : $type_identifier;
262
-    }
250
+	/**
251
+	 * Return the pretty (localized) label for the given log type identifier.
252
+	 * @param string $type_identifier
253
+	 * @return string
254
+	 */
255
+	public static function get_pretty_label_for_type($type_identifier)
256
+	{
257
+		$type_identifier_map = self::get_pretty_label_map_for_registered_types();
258
+		// we fallback to the incoming type identifier if there is no localized label for it.
259
+		return isset($type_identifier_map[ $type_identifier ])
260
+			? $type_identifier_map[ $type_identifier ]
261
+			: $type_identifier;
262
+	}
263 263
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
                 ),
114 114
             ),
115 115
         );
116
-        $this->_model_relations    = array();
116
+        $this->_model_relations = array();
117 117
         foreach ($models_this_can_attach_to as $model) {
118 118
             if ($model != 'Change_Log') {
119
-                $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation();
119
+                $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
120 120
             }
121 121
         }
122 122
         // use completely custom caps for this
123 123
         $this->_cap_restriction_generators = false;
124 124
         // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
125 125
         foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
126
-            $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ]
126
+            $this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()]
127 127
                 = new EE_Return_None_Where_Conditions();
128 128
         }
129 129
         parent::__construct($timezone);
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function gateway_log($message, $related_obj_id, $related_obj_type)
170 170
     {
171
-        if (! EE_Registry::instance()->is_model_name($related_obj_type)) {
171
+        if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) {
172 172
             throw new EE_Error(
173 173
                 sprintf(
174 174
                     esc_html__(
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         global $wpdb;
218 218
         return $wpdb->query(
219 219
             $wpdb->prepare(
220
-                'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s',
220
+                'DELETE FROM '.$this->table().' WHERE LOG_type = %s AND LOG_time < %s',
221 221
                 EEM_Change_Log::type_gateway,
222 222
                 $datetime->format(EE_Datetime_Field::mysql_timestamp_format)
223 223
             )
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
     {
257 257
         $type_identifier_map = self::get_pretty_label_map_for_registered_types();
258 258
         // we fallback to the incoming type identifier if there is no localized label for it.
259
-        return isset($type_identifier_map[ $type_identifier ])
260
-            ? $type_identifier_map[ $type_identifier ]
259
+        return isset($type_identifier_map[$type_identifier])
260
+            ? $type_identifier_map[$type_identifier]
261 261
             : $type_identifier;
262 262
     }
263 263
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Ticket.model.php 2 patches
Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -10,320 +10,320 @@
 block discarded – undo
10 10
 class EEM_Ticket extends EEM_Soft_Delete_Base
11 11
 {
12 12
 
13
-    /**
14
-     * private instance of the EEM_Ticket object
15
-     *
16
-     * @var EEM_Ticket $_instance
17
-     */
18
-    protected static $_instance;
13
+	/**
14
+	 * private instance of the EEM_Ticket object
15
+	 *
16
+	 * @var EEM_Ticket $_instance
17
+	 */
18
+	protected static $_instance;
19 19
 
20 20
 
21
-    /**
22
-     * private constructor to prevent direct creation
23
-     *
24
-     * @Constructor
25
-     * @access private
26
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
27
-     *                         (and any incoming timezone data that gets saved).
28
-     *                         Note this just sends the timezone info to the date time model field objects.
29
-     *                         Default is NULL
30
-     *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
31
-     * @throws EE_Error
32
-     */
33
-    protected function __construct($timezone)
34
-    {
35
-        $this->singular_item = esc_html__('Ticket', 'event_espresso');
36
-        $this->plural_item = esc_html__('Tickets', 'event_espresso');
37
-        $this->_tables = array(
38
-            'Ticket' => new EE_Primary_Table('esp_ticket', 'TKT_ID'),
39
-        );
40
-        $this->_fields = array(
41
-            'Ticket' => array(
42
-                'TKT_ID'          => new EE_Primary_Key_Int_Field(
43
-                    'TKT_ID',
44
-                    esc_html__('Ticket ID', 'event_espresso')
45
-                ),
46
-                'TTM_ID'          => new EE_Foreign_Key_Int_Field(
47
-                    'TTM_ID',
48
-                    esc_html__('Ticket Template ID', 'event_espresso'),
49
-                    false,
50
-                    0,
51
-                    'Ticket_Template'
52
-                ),
53
-                'TKT_name'        => new EE_Plain_Text_Field(
54
-                    'TKT_name',
55
-                    esc_html__('Ticket Name', 'event_espresso'),
56
-                    false,
57
-                    ''
58
-                ),
59
-                'TKT_description' => new EE_Post_Content_Field(
60
-                    'TKT_description',
61
-                    esc_html__('Description of Ticket', 'event_espresso'),
62
-                    false,
63
-                    ''
64
-                ),
65
-                'TKT_start_date'  => new EE_Datetime_Field(
66
-                    'TKT_start_date',
67
-                    esc_html__('Start time/date of Ticket', 'event_espresso'),
68
-                    false,
69
-                    EE_Datetime_Field::now,
70
-                    $timezone
71
-                ),
72
-                'TKT_end_date'    => new EE_Datetime_Field(
73
-                    'TKT_end_date',
74
-                    esc_html__('End time/date of Ticket', 'event_espresso'),
75
-                    false,
76
-                    EE_Datetime_Field::now,
77
-                    $timezone
78
-                ),
79
-                'TKT_min'         => new EE_Integer_Field(
80
-                    'TKT_min',
81
-                    esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso'),
82
-                    false,
83
-                    0
84
-                ),
85
-                'TKT_max'         => new EE_Infinite_Integer_Field(
86
-                    'TKT_max',
87
-                    esc_html__(
88
-                        'Maximum quantity of this ticket that can be purchased in one transaction',
89
-                        'event_espresso'
90
-                    ),
91
-                    false,
92
-                    EE_INF
93
-                ),
94
-                'TKT_price'       => new EE_Money_Field(
95
-                    'TKT_price',
96
-                    esc_html__('Final calculated price for ticket', 'event_espresso'),
97
-                    false,
98
-                    0
99
-                ),
100
-                'TKT_sold'        => new EE_Integer_Field(
101
-                    'TKT_sold',
102
-                    esc_html__('Number of this ticket sold', 'event_espresso'),
103
-                    false,
104
-                    0
105
-                ),
106
-                'TKT_qty'         => new EE_Infinite_Integer_Field(
107
-                    'TKT_qty',
108
-                    esc_html__('Quantity of this ticket that is available', 'event_espresso'),
109
-                    false,
110
-                    EE_INF
111
-                ),
112
-                'TKT_reserved'    => new EE_Integer_Field(
113
-                    'TKT_reserved',
114
-                    esc_html__(
115
-                        'Quantity of this ticket that is reserved, but not yet fully purchased',
116
-                        'event_espresso'
117
-                    ),
118
-                    false,
119
-                    0
120
-                ),
121
-                'TKT_uses'        => new EE_Infinite_Integer_Field(
122
-                    'TKT_uses',
123
-                    esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'),
124
-                    false,
125
-                    EE_INF
126
-                ),
127
-                'TKT_required'    => new EE_Boolean_Field(
128
-                    'TKT_required',
129
-                    esc_html__(
130
-                        'Flag indicating whether this ticket must be purchased with a transaction',
131
-                        'event_espresso'
132
-                    ),
133
-                    false,
134
-                    false
135
-                ),
136
-                'TKT_taxable'     => new EE_Boolean_Field(
137
-                    'TKT_taxable',
138
-                    esc_html__(
139
-                        'Flag indicating whether there is tax applied on this ticket',
140
-                        'event_espresso'
141
-                    ),
142
-                    false,
143
-                    false
144
-                ),
145
-                'TKT_is_default'  => new EE_Boolean_Field(
146
-                    'TKT_is_default',
147
-                    esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso'),
148
-                    false,
149
-                    false
150
-                ),
151
-                'TKT_order'       => new EE_Integer_Field(
152
-                    'TKT_order',
153
-                    esc_html__(
154
-                        'The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)',
155
-                        'event_espresso'
156
-                    ),
157
-                    false,
158
-                    0
159
-                ),
160
-                'TKT_row'         => new EE_Integer_Field(
161
-                    'TKT_row',
162
-                    esc_html__('How tickets are displayed in the ui', 'event_espresso'),
163
-                    false,
164
-                    0
165
-                ),
166
-                'TKT_deleted'     => new EE_Trashed_Flag_Field(
167
-                    'TKT_deleted',
168
-                    esc_html__('Flag indicating if this has been archived or not', 'event_espresso'),
169
-                    false,
170
-                    false
171
-                ),
172
-                'TKT_wp_user'     => new EE_WP_User_Field(
173
-                    'TKT_wp_user',
174
-                    esc_html__('Ticket Creator ID', 'event_espresso'),
175
-                    false
176
-                ),
177
-                'TKT_parent'      => new EE_Integer_Field(
178
-                    'TKT_parent',
179
-                    esc_html__(
180
-                        'Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)',
181
-                        'event_espresso'
182
-                    ),
183
-                    true,
184
-                    0
185
-                ),
186
-            ),
187
-        );
188
-        $this->_model_relations = array(
189
-            'Datetime'        => new EE_HABTM_Relation('Datetime_Ticket'),
190
-            'Datetime_Ticket' => new EE_Has_Many_Relation(),
191
-            'Price'           => new EE_HABTM_Relation('Ticket_Price'),
192
-            'Ticket_Template' => new EE_Belongs_To_Relation(),
193
-            'Registration'    => new EE_Has_Many_Relation(),
194
-            'WP_User'         => new EE_Belongs_To_Relation(),
195
-        );
196
-        // this model is generally available for reading
197
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public(
198
-            'TKT_is_default',
199
-            'Datetime.Event'
200
-        );
201
-        // account for default tickets in the caps
202
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected(
203
-            'TKT_is_default',
204
-            'Datetime.Event'
205
-        );
206
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected(
207
-            'TKT_is_default',
208
-            'Datetime.Event'
209
-        );
210
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected(
211
-            'TKT_is_default',
212
-            'Datetime.Event'
213
-        );
214
-        parent::__construct($timezone);
215
-    }
21
+	/**
22
+	 * private constructor to prevent direct creation
23
+	 *
24
+	 * @Constructor
25
+	 * @access private
26
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings
27
+	 *                         (and any incoming timezone data that gets saved).
28
+	 *                         Note this just sends the timezone info to the date time model field objects.
29
+	 *                         Default is NULL
30
+	 *                         (and will be assumed using the set timezone in the 'timezone_string' wp option)
31
+	 * @throws EE_Error
32
+	 */
33
+	protected function __construct($timezone)
34
+	{
35
+		$this->singular_item = esc_html__('Ticket', 'event_espresso');
36
+		$this->plural_item = esc_html__('Tickets', 'event_espresso');
37
+		$this->_tables = array(
38
+			'Ticket' => new EE_Primary_Table('esp_ticket', 'TKT_ID'),
39
+		);
40
+		$this->_fields = array(
41
+			'Ticket' => array(
42
+				'TKT_ID'          => new EE_Primary_Key_Int_Field(
43
+					'TKT_ID',
44
+					esc_html__('Ticket ID', 'event_espresso')
45
+				),
46
+				'TTM_ID'          => new EE_Foreign_Key_Int_Field(
47
+					'TTM_ID',
48
+					esc_html__('Ticket Template ID', 'event_espresso'),
49
+					false,
50
+					0,
51
+					'Ticket_Template'
52
+				),
53
+				'TKT_name'        => new EE_Plain_Text_Field(
54
+					'TKT_name',
55
+					esc_html__('Ticket Name', 'event_espresso'),
56
+					false,
57
+					''
58
+				),
59
+				'TKT_description' => new EE_Post_Content_Field(
60
+					'TKT_description',
61
+					esc_html__('Description of Ticket', 'event_espresso'),
62
+					false,
63
+					''
64
+				),
65
+				'TKT_start_date'  => new EE_Datetime_Field(
66
+					'TKT_start_date',
67
+					esc_html__('Start time/date of Ticket', 'event_espresso'),
68
+					false,
69
+					EE_Datetime_Field::now,
70
+					$timezone
71
+				),
72
+				'TKT_end_date'    => new EE_Datetime_Field(
73
+					'TKT_end_date',
74
+					esc_html__('End time/date of Ticket', 'event_espresso'),
75
+					false,
76
+					EE_Datetime_Field::now,
77
+					$timezone
78
+				),
79
+				'TKT_min'         => new EE_Integer_Field(
80
+					'TKT_min',
81
+					esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso'),
82
+					false,
83
+					0
84
+				),
85
+				'TKT_max'         => new EE_Infinite_Integer_Field(
86
+					'TKT_max',
87
+					esc_html__(
88
+						'Maximum quantity of this ticket that can be purchased in one transaction',
89
+						'event_espresso'
90
+					),
91
+					false,
92
+					EE_INF
93
+				),
94
+				'TKT_price'       => new EE_Money_Field(
95
+					'TKT_price',
96
+					esc_html__('Final calculated price for ticket', 'event_espresso'),
97
+					false,
98
+					0
99
+				),
100
+				'TKT_sold'        => new EE_Integer_Field(
101
+					'TKT_sold',
102
+					esc_html__('Number of this ticket sold', 'event_espresso'),
103
+					false,
104
+					0
105
+				),
106
+				'TKT_qty'         => new EE_Infinite_Integer_Field(
107
+					'TKT_qty',
108
+					esc_html__('Quantity of this ticket that is available', 'event_espresso'),
109
+					false,
110
+					EE_INF
111
+				),
112
+				'TKT_reserved'    => new EE_Integer_Field(
113
+					'TKT_reserved',
114
+					esc_html__(
115
+						'Quantity of this ticket that is reserved, but not yet fully purchased',
116
+						'event_espresso'
117
+					),
118
+					false,
119
+					0
120
+				),
121
+				'TKT_uses'        => new EE_Infinite_Integer_Field(
122
+					'TKT_uses',
123
+					esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'),
124
+					false,
125
+					EE_INF
126
+				),
127
+				'TKT_required'    => new EE_Boolean_Field(
128
+					'TKT_required',
129
+					esc_html__(
130
+						'Flag indicating whether this ticket must be purchased with a transaction',
131
+						'event_espresso'
132
+					),
133
+					false,
134
+					false
135
+				),
136
+				'TKT_taxable'     => new EE_Boolean_Field(
137
+					'TKT_taxable',
138
+					esc_html__(
139
+						'Flag indicating whether there is tax applied on this ticket',
140
+						'event_espresso'
141
+					),
142
+					false,
143
+					false
144
+				),
145
+				'TKT_is_default'  => new EE_Boolean_Field(
146
+					'TKT_is_default',
147
+					esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso'),
148
+					false,
149
+					false
150
+				),
151
+				'TKT_order'       => new EE_Integer_Field(
152
+					'TKT_order',
153
+					esc_html__(
154
+						'The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)',
155
+						'event_espresso'
156
+					),
157
+					false,
158
+					0
159
+				),
160
+				'TKT_row'         => new EE_Integer_Field(
161
+					'TKT_row',
162
+					esc_html__('How tickets are displayed in the ui', 'event_espresso'),
163
+					false,
164
+					0
165
+				),
166
+				'TKT_deleted'     => new EE_Trashed_Flag_Field(
167
+					'TKT_deleted',
168
+					esc_html__('Flag indicating if this has been archived or not', 'event_espresso'),
169
+					false,
170
+					false
171
+				),
172
+				'TKT_wp_user'     => new EE_WP_User_Field(
173
+					'TKT_wp_user',
174
+					esc_html__('Ticket Creator ID', 'event_espresso'),
175
+					false
176
+				),
177
+				'TKT_parent'      => new EE_Integer_Field(
178
+					'TKT_parent',
179
+					esc_html__(
180
+						'Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)',
181
+						'event_espresso'
182
+					),
183
+					true,
184
+					0
185
+				),
186
+			),
187
+		);
188
+		$this->_model_relations = array(
189
+			'Datetime'        => new EE_HABTM_Relation('Datetime_Ticket'),
190
+			'Datetime_Ticket' => new EE_Has_Many_Relation(),
191
+			'Price'           => new EE_HABTM_Relation('Ticket_Price'),
192
+			'Ticket_Template' => new EE_Belongs_To_Relation(),
193
+			'Registration'    => new EE_Has_Many_Relation(),
194
+			'WP_User'         => new EE_Belongs_To_Relation(),
195
+		);
196
+		// this model is generally available for reading
197
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public(
198
+			'TKT_is_default',
199
+			'Datetime.Event'
200
+		);
201
+		// account for default tickets in the caps
202
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected(
203
+			'TKT_is_default',
204
+			'Datetime.Event'
205
+		);
206
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected(
207
+			'TKT_is_default',
208
+			'Datetime.Event'
209
+		);
210
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected(
211
+			'TKT_is_default',
212
+			'Datetime.Event'
213
+		);
214
+		parent::__construct($timezone);
215
+	}
216 216
 
217 217
 
218
-    /**
219
-     * This returns all tickets that are defaults from the db
220
-     *
221
-     * @return EE_Ticket[]
222
-     * @throws EE_Error
223
-     */
224
-    public function get_all_default_tickets()
225
-    {
226
-        /** @type EE_Ticket[] $tickets */
227
-        $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')));
228
-        // we need to set the start date and end date to today's date and the start of the default dtt
229
-        return $this->_set_default_dates($tickets);
230
-    }
218
+	/**
219
+	 * This returns all tickets that are defaults from the db
220
+	 *
221
+	 * @return EE_Ticket[]
222
+	 * @throws EE_Error
223
+	 */
224
+	public function get_all_default_tickets()
225
+	{
226
+		/** @type EE_Ticket[] $tickets */
227
+		$tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')));
228
+		// we need to set the start date and end date to today's date and the start of the default dtt
229
+		return $this->_set_default_dates($tickets);
230
+	}
231 231
 
232 232
 
233
-    /**
234
-     * sets up relevant start and end date for EE_Ticket (s)
235
-     *
236
-     * @param EE_Ticket[] $tickets
237
-     * @return EE_Ticket[]
238
-     * @throws EE_Error
239
-     */
240
-    private function _set_default_dates($tickets)
241
-    {
242
-        foreach ($tickets as $ticket) {
243
-            $ticket->set(
244
-                'TKT_start_date',
245
-                (int) $this->current_time_for_query('TKT_start_date', true)
246
-            );
247
-            $ticket->set(
248
-                'TKT_end_date',
249
-                (int) $this->current_time_for_query('TKT_end_date', true) + MONTH_IN_SECONDS
250
-            );
251
-            $ticket->set_end_time(
252
-                $this->convert_datetime_for_query(
253
-                    'TKT_end_date',
254
-                    '11:59 pm',
255
-                    'g:i a',
256
-                    $this->_timezone
257
-                )
258
-            );
259
-        }
260
-        return $tickets;
261
-    }
233
+	/**
234
+	 * sets up relevant start and end date for EE_Ticket (s)
235
+	 *
236
+	 * @param EE_Ticket[] $tickets
237
+	 * @return EE_Ticket[]
238
+	 * @throws EE_Error
239
+	 */
240
+	private function _set_default_dates($tickets)
241
+	{
242
+		foreach ($tickets as $ticket) {
243
+			$ticket->set(
244
+				'TKT_start_date',
245
+				(int) $this->current_time_for_query('TKT_start_date', true)
246
+			);
247
+			$ticket->set(
248
+				'TKT_end_date',
249
+				(int) $this->current_time_for_query('TKT_end_date', true) + MONTH_IN_SECONDS
250
+			);
251
+			$ticket->set_end_time(
252
+				$this->convert_datetime_for_query(
253
+					'TKT_end_date',
254
+					'11:59 pm',
255
+					'g:i a',
256
+					$this->_timezone
257
+				)
258
+			);
259
+		}
260
+		return $tickets;
261
+	}
262 262
 
263 263
 
264
-    /**
265
-     * Gets the total number of tickets available at a particular datetime (does
266
-     * NOT take int account the datetime's spaces available)
267
-     *
268
-     * @param int   $DTT_ID
269
-     * @param array $query_params
270
-     * @return int
271
-     */
272
-    public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array())
273
-    {
274
-        return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params);
275
-    }
264
+	/**
265
+	 * Gets the total number of tickets available at a particular datetime (does
266
+	 * NOT take int account the datetime's spaces available)
267
+	 *
268
+	 * @param int   $DTT_ID
269
+	 * @param array $query_params
270
+	 * @return int
271
+	 */
272
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array())
273
+	{
274
+		return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params);
275
+	}
276 276
 
277 277
 
278
-    /**
279
-     * Updates the TKT_sold quantity on all the tickets matching $query_params
280
-     *
281
-     * @param EE_Ticket[] $tickets
282
-     * @return void
283
-     * @throws EE_Error
284
-     */
285
-    public function update_tickets_sold($tickets)
286
-    {
287
-        foreach ($tickets as $ticket) {
288
-            /* @var  $ticket EE_Ticket */
289
-            $ticket->update_tickets_sold();
290
-        }
291
-    }
278
+	/**
279
+	 * Updates the TKT_sold quantity on all the tickets matching $query_params
280
+	 *
281
+	 * @param EE_Ticket[] $tickets
282
+	 * @return void
283
+	 * @throws EE_Error
284
+	 */
285
+	public function update_tickets_sold($tickets)
286
+	{
287
+		foreach ($tickets as $ticket) {
288
+			/* @var  $ticket EE_Ticket */
289
+			$ticket->update_tickets_sold();
290
+		}
291
+	}
292 292
 
293 293
 
294
-    /**
295
-     * returns an array of EE_Ticket objects with a non-zero value for TKT_reserved
296
-     *
297
-     * @return EE_Base_Class[]|EE_Ticket[]
298
-     * @throws EE_Error
299
-     */
300
-    public function get_tickets_with_reservations()
301
-    {
302
-        return $this->get_all(
303
-            array(
304
-                array(
305
-                    'TKT_reserved' => array('>', 0),
306
-                ),
307
-            )
308
-        );
309
-    }
294
+	/**
295
+	 * returns an array of EE_Ticket objects with a non-zero value for TKT_reserved
296
+	 *
297
+	 * @return EE_Base_Class[]|EE_Ticket[]
298
+	 * @throws EE_Error
299
+	 */
300
+	public function get_tickets_with_reservations()
301
+	{
302
+		return $this->get_all(
303
+			array(
304
+				array(
305
+					'TKT_reserved' => array('>', 0),
306
+				),
307
+			)
308
+		);
309
+	}
310 310
 
311 311
 
312
-    /**
313
-     * returns an array of EE_Ticket objects matching the supplied list of IDs
314
-     *
315
-     * @param array $ticket_IDs
316
-     * @return EE_Base_Class[]|EE_Ticket[]
317
-     * @throws EE_Error
318
-     */
319
-    public function get_tickets_with_IDs(array $ticket_IDs)
320
-    {
321
-        return $this->get_all(
322
-            array(
323
-                array(
324
-                    'TKT_ID' => array('IN', $ticket_IDs),
325
-                ),
326
-            )
327
-        );
328
-    }
312
+	/**
313
+	 * returns an array of EE_Ticket objects matching the supplied list of IDs
314
+	 *
315
+	 * @param array $ticket_IDs
316
+	 * @return EE_Base_Class[]|EE_Ticket[]
317
+	 * @throws EE_Error
318
+	 */
319
+	public function get_tickets_with_IDs(array $ticket_IDs)
320
+	{
321
+		return $this->get_all(
322
+			array(
323
+				array(
324
+					'TKT_ID' => array('IN', $ticket_IDs),
325
+				),
326
+			)
327
+		);
328
+	}
329 329
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -194,20 +194,20 @@
 block discarded – undo
194 194
             'WP_User'         => new EE_Belongs_To_Relation(),
195 195
         );
196 196
         // this model is generally available for reading
197
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public(
197
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public(
198 198
             'TKT_is_default',
199 199
             'Datetime.Event'
200 200
         );
201 201
         // account for default tickets in the caps
202
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected(
202
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected(
203 203
             'TKT_is_default',
204 204
             'Datetime.Event'
205 205
         );
206
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected(
206
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected(
207 207
             'TKT_is_default',
208 208
             'Datetime.Event'
209 209
         );
210
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected(
210
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected(
211 211
             'TKT_is_default',
212 212
             'Datetime.Event'
213 213
         );
Please login to merge, or discard this patch.