Completed
Branch ENHANCE/255/add-wp-version-to-... (cc1324)
by
unknown
17:11 queued 08:42
created
modules/feeds/EED_Feeds.module.php 2 patches
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -12,217 +12,217 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * @return EED_Feeds
17
-     */
18
-    public static function instance()
19
-    {
20
-        return parent::get_instance(__CLASS__);
21
-    }
22
-
23
-
24
-    /**
25
-     *    set_hooks - for hooking into EE Core, other modules, etc
26
-     *
27
-     * @access    public
28
-     * @return    void
29
-     */
30
-    public static function set_hooks()
31
-    {
32
-        add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
33
-        add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
34
-        add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
35
-        add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
36
-    }
37
-
38
-    /**
39
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
40
-     *
41
-     * @access    public
42
-     * @return    void
43
-     */
44
-    public static function set_hooks_admin()
45
-    {
46
-    }
47
-
48
-
49
-    /**
50
-     *    run - initial module setup
51
-     *
52
-     * @access    public
53
-     * @return    void
54
-     */
55
-    public function run($WP)
56
-    {
57
-    }
58
-
59
-
60
-    /**
61
-     *    default_feed
62
-     *
63
-     * @access    public
64
-     * @param    type    rss2, atom, rss, rdf, rssjs
65
-     * @return    string
66
-     */
67
-    public static function default_feed($type = 'rss2')
68
-    {
69
-        // rss2, atom, rss, rdf, rssjs
70
-        $type = 'rss2';
71
-        return $type;
72
-    }
73
-
74
-
75
-    /**
76
-     *    parse_request
77
-     *
78
-     * @access    public
79
-     * @return    void
80
-     */
81
-    public static function parse_request()
82
-    {
83
-        if (EE_Registry::instance()->REQ->is_set('post_type')) {
84
-            // define path to templates
85
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
-            // what kinda post_type are we dealing with ?
87
-            switch (EE_Registry::instance()->REQ->get('post_type')) {
88
-                case 'espresso_events':
89
-                    // for rss2, atom, rss, rdf
90
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
91
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
-                    // for json ( also uses the above filter )
93
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
94
-                    break;
95
-                case 'espresso_venues':
96
-                    // for rss2, atom, rss, rdf
97
-                    add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
98
-                    add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
-                    // for json ( also uses the above filter )
100
-                    add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
101
-                    break;
102
-            }
103
-        }
104
-    }
105
-
106
-
107
-    /**
108
-     *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
109
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
110
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
111
-     *    espresso_attendees post_type
112
-     *
113
-     * @access    public
114
-     * @param    string $SQL the JOIN clause for the comment feed query
115
-     * @return    void
116
-     */
117
-    public static function comment_feed_join($SQL)
118
-    {
119
-        global $wpdb;
120
-        // check for wp_posts table in JOIN clause
121
-        if (strpos($SQL, $wpdb->posts) !== false) {
122
-            add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
123
-        }
124
-        return $SQL;
125
-    }
126
-
127
-
128
-    /**
129
-     *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
130
-     *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
131
-     *    so this little snippet of SQL taps into the comment feed query and removes comments for the
132
-     *    espresso_attendees post_type
133
-     *
134
-     * @access    public
135
-     * @param    string $SQL the WHERE clause for the comment feed query
136
-     * @return    void
137
-     */
138
-    public static function comment_feed_where($SQL)
139
-    {
140
-        global $wp_query, $wpdb;
141
-        if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
142
-            $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
143
-        }
144
-        return $SQL;
145
-    }
146
-
147
-
148
-    /**
149
-     *    the_event_feed
150
-     *
151
-     * @access    public
152
-     * @param    string $content
153
-     * @return    void
154
-     */
155
-    public static function the_event_feed($content)
156
-    {
157
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
-            global $post;
159
-            $template_args = array(
160
-                'EVT_ID'            => $post->ID,
161
-                'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162
-            );
163
-            $content = EEH_Template::display_template(
164
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
-                $template_args,
166
-                true
167
-            );
168
-        }
169
-        return $content;
170
-    }
171
-
172
-
173
-    /**
174
-     *    the_event_rssjs_feed
175
-     *
176
-     * @access    public
177
-     * @param    object $item
178
-     * @return    void
179
-     */
180
-    public static function the_event_rssjs_feed($item)
181
-    {
182
-        if (is_feed() && isset($item->description)) {
183
-            $item->description = EED_Feeds::the_event_feed($item->description);
184
-        }
185
-        return $item;
186
-    }
187
-
188
-
189
-    /**
190
-     *    the_venue_feed
191
-     *
192
-     * @access    public
193
-     * @param    string $content
194
-     * @return    void
195
-     */
196
-    public static function the_venue_feed($content)
197
-    {
198
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
-            global $post;
200
-            $template_args = array(
201
-                'VNU_ID'            => $post->ID,
202
-                'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203
-            );
204
-            $content = EEH_Template::display_template(
205
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
-                $template_args,
207
-                true
208
-            );
209
-        }
210
-        return $content;
211
-    }
212
-
213
-
214
-    /**
215
-     *    the_venue_rssjs_feed
216
-     *
217
-     * @access    public
218
-     * @param    object $item
219
-     * @return    void
220
-     */
221
-    public static function the_venue_rssjs_feed($item)
222
-    {
223
-        if (is_feed() && isset($item->description)) {
224
-            $item->description = EED_Feeds::the_venue_feed($item->description);
225
-        }
226
-        return $item;
227
-    }
15
+	/**
16
+	 * @return EED_Feeds
17
+	 */
18
+	public static function instance()
19
+	{
20
+		return parent::get_instance(__CLASS__);
21
+	}
22
+
23
+
24
+	/**
25
+	 *    set_hooks - for hooking into EE Core, other modules, etc
26
+	 *
27
+	 * @access    public
28
+	 * @return    void
29
+	 */
30
+	public static function set_hooks()
31
+	{
32
+		add_action('parse_request', array('EED_Feeds', 'parse_request'), 10);
33
+		add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1);
34
+		add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2);
35
+		add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2);
36
+	}
37
+
38
+	/**
39
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
40
+	 *
41
+	 * @access    public
42
+	 * @return    void
43
+	 */
44
+	public static function set_hooks_admin()
45
+	{
46
+	}
47
+
48
+
49
+	/**
50
+	 *    run - initial module setup
51
+	 *
52
+	 * @access    public
53
+	 * @return    void
54
+	 */
55
+	public function run($WP)
56
+	{
57
+	}
58
+
59
+
60
+	/**
61
+	 *    default_feed
62
+	 *
63
+	 * @access    public
64
+	 * @param    type    rss2, atom, rss, rdf, rssjs
65
+	 * @return    string
66
+	 */
67
+	public static function default_feed($type = 'rss2')
68
+	{
69
+		// rss2, atom, rss, rdf, rssjs
70
+		$type = 'rss2';
71
+		return $type;
72
+	}
73
+
74
+
75
+	/**
76
+	 *    parse_request
77
+	 *
78
+	 * @access    public
79
+	 * @return    void
80
+	 */
81
+	public static function parse_request()
82
+	{
83
+		if (EE_Registry::instance()->REQ->is_set('post_type')) {
84
+			// define path to templates
85
+			define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
86
+			// what kinda post_type are we dealing with ?
87
+			switch (EE_Registry::instance()->REQ->get('post_type')) {
88
+				case 'espresso_events':
89
+					// for rss2, atom, rss, rdf
90
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1);
91
+					add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1);
92
+					// for json ( also uses the above filter )
93
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1);
94
+					break;
95
+				case 'espresso_venues':
96
+					// for rss2, atom, rss, rdf
97
+					add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1);
98
+					add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1);
99
+					// for json ( also uses the above filter )
100
+					add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1);
101
+					break;
102
+			}
103
+		}
104
+	}
105
+
106
+
107
+	/**
108
+	 *    comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
109
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
110
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
111
+	 *    espresso_attendees post_type
112
+	 *
113
+	 * @access    public
114
+	 * @param    string $SQL the JOIN clause for the comment feed query
115
+	 * @return    void
116
+	 */
117
+	public static function comment_feed_join($SQL)
118
+	{
119
+		global $wpdb;
120
+		// check for wp_posts table in JOIN clause
121
+		if (strpos($SQL, $wpdb->posts) !== false) {
122
+			add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true');
123
+		}
124
+		return $SQL;
125
+	}
126
+
127
+
128
+	/**
129
+	 *    comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC
130
+	 *    WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT
131
+	 *    so this little snippet of SQL taps into the comment feed query and removes comments for the
132
+	 *    espresso_attendees post_type
133
+	 *
134
+	 * @access    public
135
+	 * @param    string $SQL the WHERE clause for the comment feed query
136
+	 * @return    void
137
+	 */
138
+	public static function comment_feed_where($SQL)
139
+	{
140
+		global $wp_query, $wpdb;
141
+		if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) {
142
+			$SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'";
143
+		}
144
+		return $SQL;
145
+	}
146
+
147
+
148
+	/**
149
+	 *    the_event_feed
150
+	 *
151
+	 * @access    public
152
+	 * @param    string $content
153
+	 * @return    void
154
+	 */
155
+	public static function the_event_feed($content)
156
+	{
157
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
158
+			global $post;
159
+			$template_args = array(
160
+				'EVT_ID'            => $post->ID,
161
+				'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162
+			);
163
+			$content = EEH_Template::display_template(
164
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
165
+				$template_args,
166
+				true
167
+			);
168
+		}
169
+		return $content;
170
+	}
171
+
172
+
173
+	/**
174
+	 *    the_event_rssjs_feed
175
+	 *
176
+	 * @access    public
177
+	 * @param    object $item
178
+	 * @return    void
179
+	 */
180
+	public static function the_event_rssjs_feed($item)
181
+	{
182
+		if (is_feed() && isset($item->description)) {
183
+			$item->description = EED_Feeds::the_event_feed($item->description);
184
+		}
185
+		return $item;
186
+	}
187
+
188
+
189
+	/**
190
+	 *    the_venue_feed
191
+	 *
192
+	 * @access    public
193
+	 * @param    string $content
194
+	 * @return    void
195
+	 */
196
+	public static function the_venue_feed($content)
197
+	{
198
+		if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
199
+			global $post;
200
+			$template_args = array(
201
+				'VNU_ID'            => $post->ID,
202
+				'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203
+			);
204
+			$content = EEH_Template::display_template(
205
+				RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
206
+				$template_args,
207
+				true
208
+			);
209
+		}
210
+		return $content;
211
+	}
212
+
213
+
214
+	/**
215
+	 *    the_venue_rssjs_feed
216
+	 *
217
+	 * @access    public
218
+	 * @param    object $item
219
+	 * @return    void
220
+	 */
221
+	public static function the_venue_rssjs_feed($item)
222
+	{
223
+		if (is_feed() && isset($item->description)) {
224
+			$item->description = EED_Feeds::the_venue_feed($item->description);
225
+		}
226
+		return $item;
227
+	}
228 228
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     {
83 83
         if (EE_Registry::instance()->REQ->is_set('post_type')) {
84 84
             // define path to templates
85
-            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/');
85
+            define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/');
86 86
             // what kinda post_type are we dealing with ?
87 87
             switch (EE_Registry::instance()->REQ->get('post_type')) {
88 88
                 case 'espresso_events':
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public static function the_event_feed($content)
156 156
     {
157
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) {
157
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) {
158 158
             global $post;
159 159
             $template_args = array(
160 160
                 'EVT_ID'            => $post->ID,
161 161
                 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
162 162
             );
163 163
             $content = EEH_Template::display_template(
164
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php',
164
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php',
165 165
                 $template_args,
166 166
                 true
167 167
             );
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
      */
196 196
     public static function the_venue_feed($content)
197 197
     {
198
-        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) {
198
+        if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) {
199 199
             global $post;
200 200
             $template_args = array(
201 201
                 'VNU_ID'            => $post->ID,
202 202
                 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content,
203 203
             );
204 204
             $content = EEH_Template::display_template(
205
-                RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php',
205
+                RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php',
206 206
                 $template_args,
207 207
                 true
208 208
             );
Please login to merge, or discard this patch.
modules/venues_archive/EED_Venues_Archive.module.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -29,176 +29,176 @@
 block discarded – undo
29 29
 class EED_Venues_Archive extends EED_Module
30 30
 {
31 31
 
32
-    /**
33
-     * @return EED_Venues_Archive
34
-     */
35
-    public static function instance()
36
-    {
37
-        return parent::get_instance(__CLASS__);
38
-    }
39
-
40
-
41
-    /**
42
-     * set_hooks - for hooking into EE Core, other modules, etc
43
-     *
44
-     * @return void
45
-     * @throws InvalidArgumentException
46
-     * @throws InvalidDataTypeException
47
-     * @throws InvalidInterfaceException
48
-     */
49
-    public static function set_hooks()
50
-    {
51
-        /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
-        $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
-        );
55
-        $custom_post_types = $custom_post_type_definitions->getDefinitions();
56
-        EE_Config::register_route(
57
-            $custom_post_types['espresso_venues']['plural_slug'],
58
-            'Venues_Archive',
59
-            'run'
60
-        );
61
-    }
62
-
63
-    /**
64
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
-     *
66
-     * @access    public
67
-     * @return    void
68
-     */
69
-    public static function set_hooks_admin()
70
-    {
71
-    }
72
-
73
-
74
-    /**
75
-     * run - initial module setup
76
-     *
77
-     * @access    public
78
-     * @param \WP $WP
79
-     */
80
-    public function run($WP)
81
-    {
82
-        // check what template is loaded
83
-        add_filter('template_include', array($this, 'template_include'), 999, 1);
84
-        add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
-    }
86
-
87
-
88
-    /**
89
-     * template_include
90
-     *
91
-     * @access public
92
-     * @param  string $template
93
-     * @return string
94
-     */
95
-    public function template_include($template)
96
-    {
97
-        // not a custom template?
98
-        if (EE_Registry::instance()->load_core('Front_Controller', array(), false, true)
99
-                                   ->get_selected_template() != 'archive-espresso_venues.php'
100
-        ) {
101
-            EEH_Template::load_espresso_theme_functions();
102
-            // then add extra event data via hooks
103
-            add_filter('the_title', array($this, 'the_title'), 100, 1);
104
-            // don't know if theme uses the_excerpt
105
-            add_filter('the_excerpt', array($this, 'venue_details'), 100);
106
-            // or the_content
107
-            add_filter('the_content', array($this, 'venue_details'), 100);
108
-            // don't display entry meta because the existing theme will take care of that
109
-            add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
110
-        }
111
-        return $template;
112
-    }
113
-
114
-
115
-    /**
116
-     * the_title
117
-     *
118
-     * @access public
119
-     * @param  string $title
120
-     * @return string
121
-     */
122
-    public function the_title($title = '')
123
-    {
124
-        return $title;
125
-    }
126
-
127
-
128
-    /**
129
-     *    venue_details
130
-     *
131
-     * @access public
132
-     * @param  string $content
133
-     * @return string
134
-     */
135
-    public function venue_details($content)
136
-    {
137
-        global $post;
138
-        if ($post->post_type == 'espresso_venues'
139
-            && ! post_password_required()
140
-        ) {
141
-            // since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
142
-            // it uses the_content() for displaying the $post->post_content
143
-            // so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
144
-            // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
145
-            remove_filter('the_excerpt', array($this, 'venue_details'), 100);
146
-            remove_filter('the_content', array($this, 'venue_details'), 100);
147
-            // add filters we want
148
-            add_filter('the_content', array($this, 'venue_location'), 110);
149
-            add_filter('the_excerpt', array($this, 'venue_location'), 110);
150
-            // now load our template
151
-            $template = EEH_Template::locate_template('content-espresso_venues-details.php');
152
-            // now add our filter back in, plus some others
153
-            add_filter('the_excerpt', array($this, 'venue_details'), 100);
154
-            add_filter('the_content', array($this, 'venue_details'), 100);
155
-            // remove other filters we added so they won't get applied to the next post
156
-            remove_filter('the_content', array($this, 'venue_location'), 110);
157
-            remove_filter('the_excerpt', array($this, 'venue_location'), 110);
158
-            // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
159
-        }
160
-        return ! empty($template) ? $template : $content;
161
-    }
162
-
163
-
164
-    /**
165
-     * venue_location
166
-     *
167
-     * @access public
168
-     * @param  string $content
169
-     * @return string
170
-     */
171
-    public function venue_location($content)
172
-    {
173
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
174
-    }
175
-
176
-
177
-    /**
178
-     *    wp_enqueue_scripts
179
-     *
180
-     * @access    public
181
-     * @return    void
182
-     */
183
-    public function wp_enqueue_scripts()
184
-    {
185
-        // get some style
186
-        if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
187
-            // first check theme folder
188
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
189
-                wp_register_style(
190
-                    $this->theme,
191
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
192
-                    array('dashicons', 'espresso_default')
193
-                );
194
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
195
-                wp_register_style(
196
-                    $this->theme,
197
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
198
-                    array('dashicons', 'espresso_default')
199
-                );
200
-            }
201
-            wp_enqueue_style($this->theme);
202
-        }
203
-    }
32
+	/**
33
+	 * @return EED_Venues_Archive
34
+	 */
35
+	public static function instance()
36
+	{
37
+		return parent::get_instance(__CLASS__);
38
+	}
39
+
40
+
41
+	/**
42
+	 * set_hooks - for hooking into EE Core, other modules, etc
43
+	 *
44
+	 * @return void
45
+	 * @throws InvalidArgumentException
46
+	 * @throws InvalidDataTypeException
47
+	 * @throws InvalidInterfaceException
48
+	 */
49
+	public static function set_hooks()
50
+	{
51
+		/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */
52
+		$custom_post_type_definitions = LoaderFactory::getLoader()->getShared(
53
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
54
+		);
55
+		$custom_post_types = $custom_post_type_definitions->getDefinitions();
56
+		EE_Config::register_route(
57
+			$custom_post_types['espresso_venues']['plural_slug'],
58
+			'Venues_Archive',
59
+			'run'
60
+		);
61
+	}
62
+
63
+	/**
64
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
65
+	 *
66
+	 * @access    public
67
+	 * @return    void
68
+	 */
69
+	public static function set_hooks_admin()
70
+	{
71
+	}
72
+
73
+
74
+	/**
75
+	 * run - initial module setup
76
+	 *
77
+	 * @access    public
78
+	 * @param \WP $WP
79
+	 */
80
+	public function run($WP)
81
+	{
82
+		// check what template is loaded
83
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
84
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
85
+	}
86
+
87
+
88
+	/**
89
+	 * template_include
90
+	 *
91
+	 * @access public
92
+	 * @param  string $template
93
+	 * @return string
94
+	 */
95
+	public function template_include($template)
96
+	{
97
+		// not a custom template?
98
+		if (EE_Registry::instance()->load_core('Front_Controller', array(), false, true)
99
+								   ->get_selected_template() != 'archive-espresso_venues.php'
100
+		) {
101
+			EEH_Template::load_espresso_theme_functions();
102
+			// then add extra event data via hooks
103
+			add_filter('the_title', array($this, 'the_title'), 100, 1);
104
+			// don't know if theme uses the_excerpt
105
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
106
+			// or the_content
107
+			add_filter('the_content', array($this, 'venue_details'), 100);
108
+			// don't display entry meta because the existing theme will take care of that
109
+			add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false');
110
+		}
111
+		return $template;
112
+	}
113
+
114
+
115
+	/**
116
+	 * the_title
117
+	 *
118
+	 * @access public
119
+	 * @param  string $title
120
+	 * @return string
121
+	 */
122
+	public function the_title($title = '')
123
+	{
124
+		return $title;
125
+	}
126
+
127
+
128
+	/**
129
+	 *    venue_details
130
+	 *
131
+	 * @access public
132
+	 * @param  string $content
133
+	 * @return string
134
+	 */
135
+	public function venue_details($content)
136
+	{
137
+		global $post;
138
+		if ($post->post_type == 'espresso_venues'
139
+			&& ! post_password_required()
140
+		) {
141
+			// since the 'content-espresso_venues-details.php' template might be used directly from within a theme,
142
+			// it uses the_content() for displaying the $post->post_content
143
+			// so in order to load a template that uses the_content() from within a callback being used to filter the_content(),
144
+			// we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb)
145
+			remove_filter('the_excerpt', array($this, 'venue_details'), 100);
146
+			remove_filter('the_content', array($this, 'venue_details'), 100);
147
+			// add filters we want
148
+			add_filter('the_content', array($this, 'venue_location'), 110);
149
+			add_filter('the_excerpt', array($this, 'venue_location'), 110);
150
+			// now load our template
151
+			$template = EEH_Template::locate_template('content-espresso_venues-details.php');
152
+			// now add our filter back in, plus some others
153
+			add_filter('the_excerpt', array($this, 'venue_details'), 100);
154
+			add_filter('the_content', array($this, 'venue_details'), 100);
155
+			// remove other filters we added so they won't get applied to the next post
156
+			remove_filter('the_content', array($this, 'venue_location'), 110);
157
+			remove_filter('the_excerpt', array($this, 'venue_location'), 110);
158
+			// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
159
+		}
160
+		return ! empty($template) ? $template : $content;
161
+	}
162
+
163
+
164
+	/**
165
+	 * venue_location
166
+	 *
167
+	 * @access public
168
+	 * @param  string $content
169
+	 * @return string
170
+	 */
171
+	public function venue_location($content)
172
+	{
173
+		return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
174
+	}
175
+
176
+
177
+	/**
178
+	 *    wp_enqueue_scripts
179
+	 *
180
+	 * @access    public
181
+	 * @return    void
182
+	 */
183
+	public function wp_enqueue_scripts()
184
+	{
185
+		// get some style
186
+		if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
187
+			// first check theme folder
188
+			if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
189
+				wp_register_style(
190
+					$this->theme,
191
+					get_stylesheet_directory_uri() . $this->theme . '/style.css',
192
+					array('dashicons', 'espresso_default')
193
+				);
194
+			} elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
195
+				wp_register_style(
196
+					$this->theme,
197
+					EE_TEMPLATES_URL . $this->theme . '/style.css',
198
+					array('dashicons', 'espresso_default')
199
+				);
200
+			}
201
+			wp_enqueue_style($this->theme);
202
+		}
203
+	}
204 204
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function venue_location($content)
172 172
     {
173
-        return $content . EEH_Template::locate_template('content-espresso_venues-location.php');
173
+        return $content.EEH_Template::locate_template('content-espresso_venues-location.php');
174 174
     }
175 175
 
176 176
 
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
         // get some style
186 186
         if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) {
187 187
             // first check theme folder
188
-            if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) {
188
+            if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) {
189 189
                 wp_register_style(
190 190
                     $this->theme,
191
-                    get_stylesheet_directory_uri() . $this->theme . '/style.css',
191
+                    get_stylesheet_directory_uri().$this->theme.'/style.css',
192 192
                     array('dashicons', 'espresso_default')
193 193
                 );
194
-            } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) {
194
+            } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) {
195 195
                 wp_register_style(
196 196
                     $this->theme,
197
-                    EE_TEMPLATES_URL . $this->theme . '/style.css',
197
+                    EE_TEMPLATES_URL.$this->theme.'/style.css',
198 198
                     array('dashicons', 'espresso_default')
199 199
                 );
200 200
             }
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 2 patches
Indentation   +438 added lines, -438 removed lines patch added patch discarded remove patch
@@ -17,442 +17,442 @@
 block discarded – undo
17 17
 class EED_Ticket_Selector extends EED_Module
18 18
 {
19 19
 
20
-    /**
21
-     * @var DisplayTicketSelector $ticket_selector
22
-     */
23
-    private static $ticket_selector;
24
-
25
-    /**
26
-     * @var TicketSelectorIframeEmbedButton $iframe_embed_button
27
-     */
28
-    private static $iframe_embed_button;
29
-
30
-
31
-    /**
32
-     * @return EED_Module|EED_Ticket_Selector
33
-     */
34
-    public static function instance()
35
-    {
36
-        return parent::get_instance(__CLASS__);
37
-    }
38
-
39
-
40
-    /**
41
-     * @return void
42
-     */
43
-    protected function set_config()
44
-    {
45
-        $this->set_config_section('template_settings');
46
-        $this->set_config_class('EE_Ticket_Selector_Config');
47
-        $this->set_config_name('EED_Ticket_Selector');
48
-    }
49
-
50
-
51
-    /**
52
-     *    set_hooks - for hooking into EE Core, other modules, etc
53
-     *
54
-     * @return void
55
-     */
56
-    public static function set_hooks()
57
-    {
58
-        // routing
59
-        EE_Config::register_route(
60
-            'iframe',
61
-            'EED_Ticket_Selector',
62
-            'ticket_selector_iframe',
63
-            'ticket_selector'
64
-        );
65
-        EE_Config::register_route(
66
-            'process_ticket_selections',
67
-            'EED_Ticket_Selector',
68
-            'process_ticket_selections'
69
-        );
70
-        EE_Config::register_route(
71
-            'cancel_ticket_selections',
72
-            'EED_Ticket_Selector',
73
-            'cancel_ticket_selections'
74
-        );
75
-        add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
76
-        add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
77
-        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0);
78
-        add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
79
-        EED_Ticket_Selector::loadIframeAssets();
80
-    }
81
-
82
-
83
-    /**
84
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
85
-     *
86
-     * @return void
87
-     */
88
-    public static function set_hooks_admin()
89
-    {
90
-        // hook into the end of the \EE_Admin_Page::_load_page_dependencies()
91
-        // to load assets for "espresso_events" page on the "edit" route (action)
92
-        add_action(
93
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit',
94
-            array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'),
95
-            10
96
-        );
97
-        /**
98
-         * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
99
-         * registrations work.
100
-         */
101
-        add_action(
102
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
103
-            array('EED_Ticket_Selector', 'set_definitions'),
104
-            10
105
-        );
106
-    }
107
-
108
-
109
-    /**
110
-     *    set_definitions
111
-     *
112
-     * @return void
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidDataTypeException
115
-     * @throws InvalidInterfaceException
116
-     */
117
-    public static function set_definitions()
118
-    {
119
-        // don't do this twice
120
-        if (defined('TICKET_SELECTOR_ASSETS_URL')) {
121
-            return;
122
-        }
123
-        define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
124
-        define(
125
-            'TICKET_SELECTOR_TEMPLATES_PATH',
126
-            str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
127
-        );
128
-        // if config is not set, initialize
129
-        if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
130
-        ) {
131
-            EED_Ticket_Selector::instance()->set_config();
132
-            EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance(
133
-            )->config();
134
-        }
135
-    }
136
-
137
-
138
-    /**
139
-     * @return DisplayTicketSelector
140
-     */
141
-    public static function ticketSelector()
142
-    {
143
-        if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
144
-            EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe());
145
-        }
146
-        return EED_Ticket_Selector::$ticket_selector;
147
-    }
148
-
149
-
150
-    /**
151
-     * gets the ball rolling
152
-     *
153
-     * @param WP $WP
154
-     * @return void
155
-     */
156
-    public function run($WP)
157
-    {
158
-    }
159
-
160
-
161
-    /**
162
-     * @return TicketSelectorIframeEmbedButton
163
-     */
164
-    public static function getIframeEmbedButton()
165
-    {
166
-        if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
167
-            self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
168
-        }
169
-        return self::$iframe_embed_button;
170
-    }
171
-
172
-
173
-    /**
174
-     * ticket_selector_iframe_embed_button
175
-     *
176
-     * @return void
177
-     * @throws EE_Error
178
-     */
179
-    public static function ticket_selector_iframe_embed_button()
180
-    {
181
-        $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
182
-        $iframe_embed_button->addEventEditorIframeEmbedButton();
183
-    }
184
-
185
-
186
-    /**
187
-     * ticket_selector_iframe
188
-     *
189
-     * @return void
190
-     * @throws DomainException
191
-     * @throws EE_Error
192
-     */
193
-    public function ticket_selector_iframe()
194
-    {
195
-        $ticket_selector_iframe = new TicketSelectorIframe();
196
-        $ticket_selector_iframe->display();
197
-    }
198
-
199
-
200
-    /**
201
-     * creates buttons for selecting number of attendees for an event
202
-     *
203
-     * @param  WP_Post|int $event
204
-     * @param  bool        $view_details
205
-     * @return string
206
-     * @throws EE_Error
207
-     */
208
-    public static function display_ticket_selector($event = null, $view_details = false)
209
-    {
210
-        return EED_Ticket_Selector::ticketSelector()->display($event, $view_details);
211
-    }
212
-
213
-
214
-    /**
215
-     * @return array  or FALSE
216
-     * @throws \ReflectionException
217
-     * @throws \EE_Error
218
-     * @throws InvalidArgumentException
219
-     * @throws InvalidInterfaceException
220
-     * @throws InvalidDataTypeException
221
-     */
222
-    public function process_ticket_selections()
223
-    {
224
-        /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */
225
-        $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector');
226
-        return $form->processTicketSelections();
227
-    }
228
-
229
-
230
-    /**
231
-     * @return string
232
-     * @throws InvalidArgumentException
233
-     * @throws InvalidInterfaceException
234
-     * @throws InvalidDataTypeException
235
-     * @throws EE_Error
236
-     */
237
-    public static function cancel_ticket_selections()
238
-    {
239
-        /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */
240
-        $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector');
241
-        return $form->cancelTicketSelections();
242
-    }
243
-
244
-
245
-    /**
246
-     * @return void
247
-     */
248
-    public static function translate_js_strings()
249
-    {
250
-        EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
251
-            'please select a datetime',
252
-            'event_espresso'
253
-        );
254
-    }
255
-
256
-
257
-    /**
258
-     * @return void
259
-     */
260
-    public static function load_tckt_slctr_assets()
261
-    {
262
-        if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) {
263
-            // add some style
264
-            wp_register_style(
265
-                'ticket_selector',
266
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
267
-                array(),
268
-                EVENT_ESPRESSO_VERSION
269
-            );
270
-            wp_enqueue_style('ticket_selector');
271
-            // make it dance
272
-            wp_register_script(
273
-                'ticket_selector',
274
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
275
-                array('espresso_core'),
276
-                EVENT_ESPRESSO_VERSION,
277
-                true
278
-            );
279
-            wp_enqueue_script('ticket_selector');
280
-            require_once EE_LIBRARIES
281
-                         . 'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php';
282
-            \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
283
-        }
284
-    }
285
-
286
-
287
-    /**
288
-     * @return void
289
-     */
290
-    public static function loadIframeAssets()
291
-    {
292
-        // for event lists
293
-        add_filter(
294
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
295
-            array('EED_Ticket_Selector', 'iframeCss')
296
-        );
297
-        add_filter(
298
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
299
-            array('EED_Ticket_Selector', 'iframeJs')
300
-        );
301
-        // for ticket selectors
302
-        add_filter(
303
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
304
-            array('EED_Ticket_Selector', 'iframeCss')
305
-        );
306
-        add_filter(
307
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
308
-            array('EED_Ticket_Selector', 'iframeJs')
309
-        );
310
-    }
311
-
312
-
313
-    /**
314
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
315
-     *
316
-     * @param array $iframe_css
317
-     * @return array
318
-     */
319
-    public static function iframeCss(array $iframe_css)
320
-    {
321
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
322
-        return $iframe_css;
323
-    }
324
-
325
-
326
-    /**
327
-     * Informs the rest of the forms system what CSS and JS is needed to display the input
328
-     *
329
-     * @param array $iframe_js
330
-     * @return array
331
-     */
332
-    public static function iframeJs(array $iframe_js)
333
-    {
334
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
335
-        return $iframe_js;
336
-    }
337
-
338
-
339
-    /****************************** DEPRECATED ******************************/
340
-
341
-
342
-    /**
343
-     * @deprecated
344
-     * @return string
345
-     * @throws EE_Error
346
-     */
347
-    public static function display_view_details_btn()
348
-    {
349
-        // todo add doing_it_wrong() notice during next major version
350
-        return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
351
-    }
352
-
353
-
354
-    /**
355
-     * @deprecated
356
-     * @return string
357
-     * @throws EE_Error
358
-     */
359
-    public static function display_ticket_selector_submit()
360
-    {
361
-        // todo add doing_it_wrong() notice during next major version
362
-        return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
363
-    }
364
-
365
-
366
-    /**
367
-     * @deprecated
368
-     * @param string $permalink_string
369
-     * @param int    $id
370
-     * @param string $new_title
371
-     * @param string $new_slug
372
-     * @return string
373
-     * @throws InvalidArgumentException
374
-     * @throws InvalidDataTypeException
375
-     * @throws InvalidInterfaceException
376
-     */
377
-    public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
378
-    {
379
-        // todo add doing_it_wrong() notice during next major version
380
-        if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
381
-            && EE_Registry::instance()->REQ->get('action') === 'edit'
382
-        ) {
383
-            $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
384
-            $iframe_embed_button->addEventEditorIframeEmbedButton();
385
-        }
386
-        return '';
387
-    }
388
-
389
-
390
-    /**
391
-     * @deprecated
392
-     * @param int    $ID
393
-     * @param string $external_url
394
-     * @return string
395
-     */
396
-    public static function ticket_selector_form_open($ID = 0, $external_url = '')
397
-    {
398
-        // todo add doing_it_wrong() notice during next major version
399
-        return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
400
-    }
401
-
402
-
403
-    /**
404
-     * @deprecated
405
-     * @return string
406
-     */
407
-    public static function ticket_selector_form_close()
408
-    {
409
-        // todo add doing_it_wrong() notice during next major version
410
-        return EED_Ticket_Selector::ticketSelector()->formClose();
411
-    }
412
-
413
-
414
-    /**
415
-     * @deprecated
416
-     * @return string
417
-     */
418
-    public static function no_tkt_slctr_end_dv()
419
-    {
420
-        // todo add doing_it_wrong() notice during next major version
421
-        return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
422
-    }
423
-
424
-
425
-    /**
426
-     * @deprecated 4.9.13
427
-     * @return string
428
-     */
429
-    public static function tkt_slctr_end_dv()
430
-    {
431
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
432
-    }
433
-
434
-
435
-    /**
436
-     * @deprecated
437
-     * @return string
438
-     */
439
-    public static function clear_tkt_slctr()
440
-    {
441
-        return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
442
-    }
443
-
444
-
445
-    /**
446
-     * @deprecated
447
-     */
448
-    public static function load_tckt_slctr_assets_admin()
449
-    {
450
-        // todo add doing_it_wrong() notice during next major version
451
-        if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
452
-            && EE_Registry::instance()->REQ->get('action') === 'edit'
453
-        ) {
454
-            $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
455
-            $iframe_embed_button->embedButtonAssets();
456
-        }
457
-    }
20
+	/**
21
+	 * @var DisplayTicketSelector $ticket_selector
22
+	 */
23
+	private static $ticket_selector;
24
+
25
+	/**
26
+	 * @var TicketSelectorIframeEmbedButton $iframe_embed_button
27
+	 */
28
+	private static $iframe_embed_button;
29
+
30
+
31
+	/**
32
+	 * @return EED_Module|EED_Ticket_Selector
33
+	 */
34
+	public static function instance()
35
+	{
36
+		return parent::get_instance(__CLASS__);
37
+	}
38
+
39
+
40
+	/**
41
+	 * @return void
42
+	 */
43
+	protected function set_config()
44
+	{
45
+		$this->set_config_section('template_settings');
46
+		$this->set_config_class('EE_Ticket_Selector_Config');
47
+		$this->set_config_name('EED_Ticket_Selector');
48
+	}
49
+
50
+
51
+	/**
52
+	 *    set_hooks - for hooking into EE Core, other modules, etc
53
+	 *
54
+	 * @return void
55
+	 */
56
+	public static function set_hooks()
57
+	{
58
+		// routing
59
+		EE_Config::register_route(
60
+			'iframe',
61
+			'EED_Ticket_Selector',
62
+			'ticket_selector_iframe',
63
+			'ticket_selector'
64
+		);
65
+		EE_Config::register_route(
66
+			'process_ticket_selections',
67
+			'EED_Ticket_Selector',
68
+			'process_ticket_selections'
69
+		);
70
+		EE_Config::register_route(
71
+			'cancel_ticket_selections',
72
+			'EED_Ticket_Selector',
73
+			'cancel_ticket_selections'
74
+		);
75
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
76
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
77
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0);
78
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
79
+		EED_Ticket_Selector::loadIframeAssets();
80
+	}
81
+
82
+
83
+	/**
84
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
85
+	 *
86
+	 * @return void
87
+	 */
88
+	public static function set_hooks_admin()
89
+	{
90
+		// hook into the end of the \EE_Admin_Page::_load_page_dependencies()
91
+		// to load assets for "espresso_events" page on the "edit" route (action)
92
+		add_action(
93
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit',
94
+			array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'),
95
+			10
96
+		);
97
+		/**
98
+		 * Make sure assets for the ticket selector are loaded on the espresso registrations route so  admin side
99
+		 * registrations work.
100
+		 */
101
+		add_action(
102
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration',
103
+			array('EED_Ticket_Selector', 'set_definitions'),
104
+			10
105
+		);
106
+	}
107
+
108
+
109
+	/**
110
+	 *    set_definitions
111
+	 *
112
+	 * @return void
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidDataTypeException
115
+	 * @throws InvalidInterfaceException
116
+	 */
117
+	public static function set_definitions()
118
+	{
119
+		// don't do this twice
120
+		if (defined('TICKET_SELECTOR_ASSETS_URL')) {
121
+			return;
122
+		}
123
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
124
+		define(
125
+			'TICKET_SELECTOR_TEMPLATES_PATH',
126
+			str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
127
+		);
128
+		// if config is not set, initialize
129
+		if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
130
+		) {
131
+			EED_Ticket_Selector::instance()->set_config();
132
+			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance(
133
+			)->config();
134
+		}
135
+	}
136
+
137
+
138
+	/**
139
+	 * @return DisplayTicketSelector
140
+	 */
141
+	public static function ticketSelector()
142
+	{
143
+		if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
144
+			EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe());
145
+		}
146
+		return EED_Ticket_Selector::$ticket_selector;
147
+	}
148
+
149
+
150
+	/**
151
+	 * gets the ball rolling
152
+	 *
153
+	 * @param WP $WP
154
+	 * @return void
155
+	 */
156
+	public function run($WP)
157
+	{
158
+	}
159
+
160
+
161
+	/**
162
+	 * @return TicketSelectorIframeEmbedButton
163
+	 */
164
+	public static function getIframeEmbedButton()
165
+	{
166
+		if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
167
+			self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
168
+		}
169
+		return self::$iframe_embed_button;
170
+	}
171
+
172
+
173
+	/**
174
+	 * ticket_selector_iframe_embed_button
175
+	 *
176
+	 * @return void
177
+	 * @throws EE_Error
178
+	 */
179
+	public static function ticket_selector_iframe_embed_button()
180
+	{
181
+		$iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
182
+		$iframe_embed_button->addEventEditorIframeEmbedButton();
183
+	}
184
+
185
+
186
+	/**
187
+	 * ticket_selector_iframe
188
+	 *
189
+	 * @return void
190
+	 * @throws DomainException
191
+	 * @throws EE_Error
192
+	 */
193
+	public function ticket_selector_iframe()
194
+	{
195
+		$ticket_selector_iframe = new TicketSelectorIframe();
196
+		$ticket_selector_iframe->display();
197
+	}
198
+
199
+
200
+	/**
201
+	 * creates buttons for selecting number of attendees for an event
202
+	 *
203
+	 * @param  WP_Post|int $event
204
+	 * @param  bool        $view_details
205
+	 * @return string
206
+	 * @throws EE_Error
207
+	 */
208
+	public static function display_ticket_selector($event = null, $view_details = false)
209
+	{
210
+		return EED_Ticket_Selector::ticketSelector()->display($event, $view_details);
211
+	}
212
+
213
+
214
+	/**
215
+	 * @return array  or FALSE
216
+	 * @throws \ReflectionException
217
+	 * @throws \EE_Error
218
+	 * @throws InvalidArgumentException
219
+	 * @throws InvalidInterfaceException
220
+	 * @throws InvalidDataTypeException
221
+	 */
222
+	public function process_ticket_selections()
223
+	{
224
+		/** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */
225
+		$form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector');
226
+		return $form->processTicketSelections();
227
+	}
228
+
229
+
230
+	/**
231
+	 * @return string
232
+	 * @throws InvalidArgumentException
233
+	 * @throws InvalidInterfaceException
234
+	 * @throws InvalidDataTypeException
235
+	 * @throws EE_Error
236
+	 */
237
+	public static function cancel_ticket_selections()
238
+	{
239
+		/** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */
240
+		$form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector');
241
+		return $form->cancelTicketSelections();
242
+	}
243
+
244
+
245
+	/**
246
+	 * @return void
247
+	 */
248
+	public static function translate_js_strings()
249
+	{
250
+		EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__(
251
+			'please select a datetime',
252
+			'event_espresso'
253
+		);
254
+	}
255
+
256
+
257
+	/**
258
+	 * @return void
259
+	 */
260
+	public static function load_tckt_slctr_assets()
261
+	{
262
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) {
263
+			// add some style
264
+			wp_register_style(
265
+				'ticket_selector',
266
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
267
+				array(),
268
+				EVENT_ESPRESSO_VERSION
269
+			);
270
+			wp_enqueue_style('ticket_selector');
271
+			// make it dance
272
+			wp_register_script(
273
+				'ticket_selector',
274
+				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
275
+				array('espresso_core'),
276
+				EVENT_ESPRESSO_VERSION,
277
+				true
278
+			);
279
+			wp_enqueue_script('ticket_selector');
280
+			require_once EE_LIBRARIES
281
+						 . 'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php';
282
+			\EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts();
283
+		}
284
+	}
285
+
286
+
287
+	/**
288
+	 * @return void
289
+	 */
290
+	public static function loadIframeAssets()
291
+	{
292
+		// for event lists
293
+		add_filter(
294
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
295
+			array('EED_Ticket_Selector', 'iframeCss')
296
+		);
297
+		add_filter(
298
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
299
+			array('EED_Ticket_Selector', 'iframeJs')
300
+		);
301
+		// for ticket selectors
302
+		add_filter(
303
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
304
+			array('EED_Ticket_Selector', 'iframeCss')
305
+		);
306
+		add_filter(
307
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
308
+			array('EED_Ticket_Selector', 'iframeJs')
309
+		);
310
+	}
311
+
312
+
313
+	/**
314
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
315
+	 *
316
+	 * @param array $iframe_css
317
+	 * @return array
318
+	 */
319
+	public static function iframeCss(array $iframe_css)
320
+	{
321
+		$iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
322
+		return $iframe_css;
323
+	}
324
+
325
+
326
+	/**
327
+	 * Informs the rest of the forms system what CSS and JS is needed to display the input
328
+	 *
329
+	 * @param array $iframe_js
330
+	 * @return array
331
+	 */
332
+	public static function iframeJs(array $iframe_js)
333
+	{
334
+		$iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
335
+		return $iframe_js;
336
+	}
337
+
338
+
339
+	/****************************** DEPRECATED ******************************/
340
+
341
+
342
+	/**
343
+	 * @deprecated
344
+	 * @return string
345
+	 * @throws EE_Error
346
+	 */
347
+	public static function display_view_details_btn()
348
+	{
349
+		// todo add doing_it_wrong() notice during next major version
350
+		return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton();
351
+	}
352
+
353
+
354
+	/**
355
+	 * @deprecated
356
+	 * @return string
357
+	 * @throws EE_Error
358
+	 */
359
+	public static function display_ticket_selector_submit()
360
+	{
361
+		// todo add doing_it_wrong() notice during next major version
362
+		return EED_Ticket_Selector::ticketSelector()->displaySubmitButton();
363
+	}
364
+
365
+
366
+	/**
367
+	 * @deprecated
368
+	 * @param string $permalink_string
369
+	 * @param int    $id
370
+	 * @param string $new_title
371
+	 * @param string $new_slug
372
+	 * @return string
373
+	 * @throws InvalidArgumentException
374
+	 * @throws InvalidDataTypeException
375
+	 * @throws InvalidInterfaceException
376
+	 */
377
+	public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '')
378
+	{
379
+		// todo add doing_it_wrong() notice during next major version
380
+		if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
381
+			&& EE_Registry::instance()->REQ->get('action') === 'edit'
382
+		) {
383
+			$iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
384
+			$iframe_embed_button->addEventEditorIframeEmbedButton();
385
+		}
386
+		return '';
387
+	}
388
+
389
+
390
+	/**
391
+	 * @deprecated
392
+	 * @param int    $ID
393
+	 * @param string $external_url
394
+	 * @return string
395
+	 */
396
+	public static function ticket_selector_form_open($ID = 0, $external_url = '')
397
+	{
398
+		// todo add doing_it_wrong() notice during next major version
399
+		return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url);
400
+	}
401
+
402
+
403
+	/**
404
+	 * @deprecated
405
+	 * @return string
406
+	 */
407
+	public static function ticket_selector_form_close()
408
+	{
409
+		// todo add doing_it_wrong() notice during next major version
410
+		return EED_Ticket_Selector::ticketSelector()->formClose();
411
+	}
412
+
413
+
414
+	/**
415
+	 * @deprecated
416
+	 * @return string
417
+	 */
418
+	public static function no_tkt_slctr_end_dv()
419
+	{
420
+		// todo add doing_it_wrong() notice during next major version
421
+		return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv();
422
+	}
423
+
424
+
425
+	/**
426
+	 * @deprecated 4.9.13
427
+	 * @return string
428
+	 */
429
+	public static function tkt_slctr_end_dv()
430
+	{
431
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
432
+	}
433
+
434
+
435
+	/**
436
+	 * @deprecated
437
+	 * @return string
438
+	 */
439
+	public static function clear_tkt_slctr()
440
+	{
441
+		return EED_Ticket_Selector::ticketSelector()->clearTicketSelector();
442
+	}
443
+
444
+
445
+	/**
446
+	 * @deprecated
447
+	 */
448
+	public static function load_tckt_slctr_assets_admin()
449
+	{
450
+		// todo add doing_it_wrong() notice during next major version
451
+		if (EE_Registry::instance()->REQ->get('page') === 'espresso_events'
452
+			&& EE_Registry::instance()->REQ->get('action') === 'edit'
453
+		) {
454
+			$iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton();
455
+			$iframe_embed_button->embedButtonAssets();
456
+		}
457
+	}
458 458
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
         if (defined('TICKET_SELECTOR_ASSETS_URL')) {
121 121
             return;
122 122
         }
123
-        define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/');
123
+        define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets/');
124 124
         define(
125 125
             'TICKET_SELECTOR_TEMPLATES_PATH',
126
-            str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'
126
+            str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'
127 127
         );
128 128
         // if config is not set, initialize
129
-        if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
129
+        if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config
130 130
         ) {
131 131
             EED_Ticket_Selector::instance()->set_config();
132 132
             EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance(
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public static function ticketSelector()
142 142
     {
143
-        if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
143
+        if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) {
144 144
             EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe());
145 145
         }
146 146
         return EED_Ticket_Selector::$ticket_selector;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      */
164 164
     public static function getIframeEmbedButton()
165 165
     {
166
-        if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
166
+        if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) {
167 167
             self::$iframe_embed_button = new TicketSelectorIframeEmbedButton();
168 168
         }
169 169
         return self::$iframe_embed_button;
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             // add some style
264 264
             wp_register_style(
265 265
                 'ticket_selector',
266
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css',
266
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css',
267 267
                 array(),
268 268
                 EVENT_ESPRESSO_VERSION
269 269
             );
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
             // make it dance
272 272
             wp_register_script(
273 273
                 'ticket_selector',
274
-                TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js',
274
+                TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js',
275 275
                 array('espresso_core'),
276 276
                 EVENT_ESPRESSO_VERSION,
277 277
                 true
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
      */
319 319
     public static function iframeCss(array $iframe_css)
320 320
     {
321
-        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css';
321
+        $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css';
322 322
         return $iframe_css;
323 323
     }
324 324
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      */
332 332
     public static function iframeJs(array $iframe_js)
333 333
     {
334
-        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js';
334
+        $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js';
335 335
         return $iframe_js;
336 336
     }
337 337
 
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_State_Select_Input.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -12,94 +12,94 @@
 block discarded – undo
12 12
  */
13 13
 class EE_State_Select_Input extends EE_Select_Input
14 14
 {
15
-    /**
16
-     * @var string the name of the EE_State field to use for option values in the HTML form input.
17
-     */
18
-    protected $valueFieldName;
15
+	/**
16
+	 * @var string the name of the EE_State field to use for option values in the HTML form input.
17
+	 */
18
+	protected $valueFieldName;
19 19
 
20
-    /**
21
-     * @param EE_State[]|array|null $state_options. If a flat array of string is provided,
22
-     * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for
23
-     * the keys (which will become the option values). If null or empty is passed, all active states will be used,
24
-     * and $input_settings['value_field_name'] will again be used.     *
25
-     * @param array $input_settings same as parent, but also {
26
-     *   @type string $value_field_name the name of the field to use
27
-     *   for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`.
28
-     * }
29
-     * @throws EE_Error
30
-     * @throws InvalidArgumentException
31
-     * @throws InvalidDataTypeException
32
-     * @throws InvalidInterfaceException
33
-     * @throws ReflectionException
34
-     */
35
-    public function __construct($state_options, $input_settings = array())
36
-    {
37
-        if (isset($input_settings['value_field_name'])) {
38
-            $this->valueFieldName = $input_settings['value_field_name'];
39
-            if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40
-                throw new InvalidArgumentException(
41
-                    sprintf(
42
-                        esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
43
-                        $this->valueFieldName()
44
-                    )
45
-                );
46
-            }
47
-        } else {
48
-            $this->valueFieldName = 'STA_ID';
49
-        }
50
-        $state_options = apply_filters(
51
-            'FHEE__EE_State_Select_Input____construct__state_options',
52
-            $this->get_state_answer_options($state_options),
53
-            $this
54
-        );
55
-        $input_settings['html_class'] = isset($input_settings['html_class'])
56
-            ? $input_settings['html_class'] . ' ee-state-select-js'
57
-            : 'ee-state-select-js';
58
-        parent::__construct($state_options, $input_settings);
59
-    }
20
+	/**
21
+	 * @param EE_State[]|array|null $state_options. If a flat array of string is provided,
22
+	 * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for
23
+	 * the keys (which will become the option values). If null or empty is passed, all active states will be used,
24
+	 * and $input_settings['value_field_name'] will again be used.     *
25
+	 * @param array $input_settings same as parent, but also {
26
+	 *   @type string $value_field_name the name of the field to use
27
+	 *   for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`.
28
+	 * }
29
+	 * @throws EE_Error
30
+	 * @throws InvalidArgumentException
31
+	 * @throws InvalidDataTypeException
32
+	 * @throws InvalidInterfaceException
33
+	 * @throws ReflectionException
34
+	 */
35
+	public function __construct($state_options, $input_settings = array())
36
+	{
37
+		if (isset($input_settings['value_field_name'])) {
38
+			$this->valueFieldName = $input_settings['value_field_name'];
39
+			if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) {
40
+				throw new InvalidArgumentException(
41
+					sprintf(
42
+						esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'),
43
+						$this->valueFieldName()
44
+					)
45
+				);
46
+			}
47
+		} else {
48
+			$this->valueFieldName = 'STA_ID';
49
+		}
50
+		$state_options = apply_filters(
51
+			'FHEE__EE_State_Select_Input____construct__state_options',
52
+			$this->get_state_answer_options($state_options),
53
+			$this
54
+		);
55
+		$input_settings['html_class'] = isset($input_settings['html_class'])
56
+			? $input_settings['html_class'] . ' ee-state-select-js'
57
+			: 'ee-state-select-js';
58
+		parent::__construct($state_options, $input_settings);
59
+	}
60 60
 
61
-    /**
62
-     * Returns the name of the state field used for the HTML option values.
63
-     * @since 4.10.0.p
64
-     * @return string
65
-     */
66
-    public function valueFieldName()
67
-    {
68
-        return $this->valueFieldName;
69
-    }
61
+	/**
62
+	 * Returns the name of the state field used for the HTML option values.
63
+	 * @since 4.10.0.p
64
+	 * @return string
65
+	 */
66
+	public function valueFieldName()
67
+	{
68
+		return $this->valueFieldName;
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * get_state_answer_options
74
-     *
75
-     * @param array $state_options
76
-     * @return array
77
-     * @throws EE_Error
78
-     * @throws InvalidArgumentException
79
-     * @throws ReflectionException
80
-     * @throws InvalidDataTypeException
81
-     * @throws InvalidInterfaceException
82
-     */
83
-    public function get_state_answer_options($state_options = null)
84
-    {
85
-        // if passed something that is NOT an array
86
-        if (! is_array($state_options) || empty($state_options)) {
87
-            // get possibly cached list of states
88
-            $states = EEM_State::instance()->get_all_active_states();
89
-        }
90
-        if (is_array($state_options) && reset($state_options) instanceof EE_State) {
91
-            $states = $state_options;
92
-            $state_options = array();
93
-        }
94
-        if (! empty($states)) {
95
-            // set the default
96
-            $state_options[''][''] = '';
97
-            foreach ($states as $state) {
98
-                if ($state instanceof EE_State) {
99
-                    $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
100
-                }
101
-            }
102
-        }
103
-        return $state_options;
104
-    }
72
+	/**
73
+	 * get_state_answer_options
74
+	 *
75
+	 * @param array $state_options
76
+	 * @return array
77
+	 * @throws EE_Error
78
+	 * @throws InvalidArgumentException
79
+	 * @throws ReflectionException
80
+	 * @throws InvalidDataTypeException
81
+	 * @throws InvalidInterfaceException
82
+	 */
83
+	public function get_state_answer_options($state_options = null)
84
+	{
85
+		// if passed something that is NOT an array
86
+		if (! is_array($state_options) || empty($state_options)) {
87
+			// get possibly cached list of states
88
+			$states = EEM_State::instance()->get_all_active_states();
89
+		}
90
+		if (is_array($state_options) && reset($state_options) instanceof EE_State) {
91
+			$states = $state_options;
92
+			$state_options = array();
93
+		}
94
+		if (! empty($states)) {
95
+			// set the default
96
+			$state_options[''][''] = '';
97
+			foreach ($states as $state) {
98
+				if ($state instanceof EE_State) {
99
+					$state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name();
100
+				}
101
+			}
102
+		}
103
+		return $state_options;
104
+	}
105 105
 }
Please login to merge, or discard this patch.
form_sections/payment_methods/EE_Billing_Attendee_Info_Form.form.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -14,172 +14,172 @@
 block discarded – undo
14 14
 class EE_Billing_Attendee_Info_Form extends EE_Billing_Info_Form
15 15
 {
16 16
 
17
-    /**
18
-     *
19
-     * @param EE_Payment_Method $payment_method
20
-     * @param array $options_array @see EE_Form_Section_Proper::__construct()
21
-     */
22
-    public function __construct(EE_Payment_Method $payment_method, $options_array = array())
23
-    {
24
-        $options_array['subsections'] = array_merge(
25
-            array(
26
-                'first_name'    => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )),
27
-                'last_name'     => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )),
28
-                'email'             => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email', 'event_espresso') )),
29
-                'address'           => new EE_Text_Input(array( 'html_label_text'=>  __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )),
30
-                'address2'      => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )),
31
-                'city'                  => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )),
32
-                'state'                 => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))),
33
-                'country'           => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))),
34
-                'zip'                   => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )),
35
-                'phone'         => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )),
36
-            ),
37
-            isset($options_array['subsections']) ? $options_array['subsections'] : array()
38
-        );
17
+	/**
18
+	 *
19
+	 * @param EE_Payment_Method $payment_method
20
+	 * @param array $options_array @see EE_Form_Section_Proper::__construct()
21
+	 */
22
+	public function __construct(EE_Payment_Method $payment_method, $options_array = array())
23
+	{
24
+		$options_array['subsections'] = array_merge(
25
+			array(
26
+				'first_name'    => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-fname', 'html_label_text' => __('First Name', 'event_espresso') )),
27
+				'last_name'     => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-lname', 'html_label_text' => __('Last Name', 'event_espresso') )),
28
+				'email'             => new EE_Email_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-email', 'html_label_text' => __('Email', 'event_espresso') )),
29
+				'address'           => new EE_Text_Input(array( 'html_label_text'=>  __('Address', 'event_espresso'), 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-address' )),
30
+				'address2'      => new EE_Text_Input(array( 'html_label_text'=> __('Address 2', 'event_espresso'), 'html_class' => 'ee-billing-qstn ee-billing-qstn-address2' )),
31
+				'city'                  => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-city', 'html_label_text' => __('City', 'event_espresso') )),
32
+				'state'                 => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__state_field', new EE_State_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-state', 'html_label_text' => __('State', 'event_espresso') ))),
33
+				'country'           => apply_filters('FHEE__EE_Billing_Attendee_Info_Form__country_field', new EE_Country_Select_Input(null, array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-country', 'html_label_text' => __('Country', 'event_espresso') ))),
34
+				'zip'                   => new EE_Text_Input(array( 'required'=>true, 'html_class' => 'ee-billing-qstn ee-billing-qstn-zip', 'html_label_text' => __('Zip', 'event_espresso') )),
35
+				'phone'         => new EE_Text_Input(array( 'html_class' => 'ee-billing-qstn ee-billing-qstn-phone', 'html_label_text' => __('Phone', 'event_espresso') )),
36
+			),
37
+			isset($options_array['subsections']) ? $options_array['subsections'] : array()
38
+		);
39 39
 
40
-        parent::__construct($payment_method, $options_array);
41
-    }
40
+		parent::__construct($payment_method, $options_array);
41
+	}
42 42
 
43
-    /**
44
-     * Sets the defaults for the billing form according to the attendee's details
45
-     * @param EE_Attendee $attendee
46
-     */
47
-    public function populate_from_attendee($attendee)
48
-    {
49
-        $attendee = EEM_Attendee::instance()->ensure_is_obj($attendee);
43
+	/**
44
+	 * Sets the defaults for the billing form according to the attendee's details
45
+	 * @param EE_Attendee $attendee
46
+	 */
47
+	public function populate_from_attendee($attendee)
48
+	{
49
+		$attendee = EEM_Attendee::instance()->ensure_is_obj($attendee);
50 50
 
51
-        /** @var $attendee EE_Attendee */
52
-        $this->populate_defaults(
53
-            apply_filters(
54
-                'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee',
55
-                array(
56
-                    'first_name'=>$attendee->fname(),
57
-                    'last_name'=>$attendee->lname(),
58
-                    'email'=>$attendee->email(),
59
-                    'address'=>$attendee->address(),
60
-                    'address2'=>$attendee->address2(),
61
-                    'city'=>$attendee->city(),
62
-                    'state'=> $this->getAttendeeStateValueForForm($attendee),
63
-                    'country'=> $attendee->country_ID(),
64
-                    'zip'=>$attendee->zip(),
65
-                    'phone'=>$attendee->phone(),
66
-                ),
67
-                $attendee,
68
-                $this
69
-            )
70
-        );
71
-    }
51
+		/** @var $attendee EE_Attendee */
52
+		$this->populate_defaults(
53
+			apply_filters(
54
+				'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee',
55
+				array(
56
+					'first_name'=>$attendee->fname(),
57
+					'last_name'=>$attendee->lname(),
58
+					'email'=>$attendee->email(),
59
+					'address'=>$attendee->address(),
60
+					'address2'=>$attendee->address2(),
61
+					'city'=>$attendee->city(),
62
+					'state'=> $this->getAttendeeStateValueForForm($attendee),
63
+					'country'=> $attendee->country_ID(),
64
+					'zip'=>$attendee->zip(),
65
+					'phone'=>$attendee->phone(),
66
+				),
67
+				$attendee,
68
+				$this
69
+			)
70
+		);
71
+	}
72 72
 
73
-    /**
74
-     * Gets the default value to use for the billing form's state value.
75
-     * @since 4.10.0.p
76
-     * @param EE_Attendee $attendee
77
-     * @return string
78
-     * @throws EE_Error2
79
-     */
80
-    protected function getAttendeeStateValueForForm(EE_Attendee $attendee)
81
-    {
82
-        // If the state input was removed, just return a blank string.
83
-        if (! $this->has_subsection('state')) {
84
-            return '';
85
-        }
86
-        $state_input =  $this->get_input('state', false);
87
-        if ($state_input instanceof EE_State_Select_Input) {
88
-            $state_field_to_use =  $state_input->valueFieldName();
89
-        } else {
90
-            $state_field_to_use = 'STA_ID';
91
-        }
92
-        switch ($state_field_to_use) {
93
-            case 'STA_abbrev':
94
-                $state_value = $attendee->state_abbrev();
95
-                break;
96
-            case 'STA_name':
97
-                $state_value = $attendee->state_name();
98
-                break;
99
-            default:
100
-                $state_value = $attendee->state_ID();
101
-        }
102
-        return $state_value;
103
-    }
73
+	/**
74
+	 * Gets the default value to use for the billing form's state value.
75
+	 * @since 4.10.0.p
76
+	 * @param EE_Attendee $attendee
77
+	 * @return string
78
+	 * @throws EE_Error2
79
+	 */
80
+	protected function getAttendeeStateValueForForm(EE_Attendee $attendee)
81
+	{
82
+		// If the state input was removed, just return a blank string.
83
+		if (! $this->has_subsection('state')) {
84
+			return '';
85
+		}
86
+		$state_input =  $this->get_input('state', false);
87
+		if ($state_input instanceof EE_State_Select_Input) {
88
+			$state_field_to_use =  $state_input->valueFieldName();
89
+		} else {
90
+			$state_field_to_use = 'STA_ID';
91
+		}
92
+		switch ($state_field_to_use) {
93
+			case 'STA_abbrev':
94
+				$state_value = $attendee->state_abbrev();
95
+				break;
96
+			case 'STA_name':
97
+				$state_value = $attendee->state_name();
98
+				break;
99
+			default:
100
+				$state_value = $attendee->state_ID();
101
+		}
102
+		return $state_value;
103
+	}
104 104
 
105 105
 
106 106
 
107
-    /**
108
-     * copy_billing_form_data_to_attendee
109
-     * copies info from the billing form to the attendee's details
110
-     * @param \EE_Attendee $attendee - the attendee object to copy details to
111
-     * @return \EE_Attendee
112
-     */
113
-    public function copy_billing_form_data_to_attendee(EE_Attendee $attendee)
114
-    {
115
-        // grab billing form data
116
-        $data = $this->valid_data();
117
-        // copy first_name
118
-        if (! empty($data['first_name'])) {
119
-            $attendee->set_fname($data['first_name']);
120
-        }
121
-        // copy last_name
122
-        if (! empty($data['last_name'])) {
123
-            $attendee->set_lname($data['last_name']);
124
-        }
125
-        // copy email
126
-        if (! empty($data['email'])) {
127
-            $attendee->set_email($data['email']);
128
-        }
129
-        // copy address
130
-        if (! empty($data['address'])) {
131
-            $attendee->set_address($data['address']);
132
-        }
133
-        // copy address2
134
-        if (! empty($data['address2'])) {
135
-            $attendee->set_address2($data['address2']);
136
-        }
137
-        // copy city
138
-        if (! empty($data['city'])) {
139
-            $attendee->set_city($data['city']);
140
-        }
141
-        // copy state
142
-        if (! empty($data['state'])) {
143
-            $attendee->set_state($data['state']);
144
-        }
145
-        // copy country
146
-        if (! empty($data['country'])) {
147
-            $attendee->set_country($data['country']);
148
-        }
149
-        // copy zip
150
-        if (! empty($data['zip'])) {
151
-            $attendee->set_zip($data['zip']);
152
-        }
153
-        // copy phone
154
-        if (! empty($data['phone'])) {
155
-            $attendee->set_phone($data['phone']);
156
-        }
157
-        return $attendee;
158
-    }
107
+	/**
108
+	 * copy_billing_form_data_to_attendee
109
+	 * copies info from the billing form to the attendee's details
110
+	 * @param \EE_Attendee $attendee - the attendee object to copy details to
111
+	 * @return \EE_Attendee
112
+	 */
113
+	public function copy_billing_form_data_to_attendee(EE_Attendee $attendee)
114
+	{
115
+		// grab billing form data
116
+		$data = $this->valid_data();
117
+		// copy first_name
118
+		if (! empty($data['first_name'])) {
119
+			$attendee->set_fname($data['first_name']);
120
+		}
121
+		// copy last_name
122
+		if (! empty($data['last_name'])) {
123
+			$attendee->set_lname($data['last_name']);
124
+		}
125
+		// copy email
126
+		if (! empty($data['email'])) {
127
+			$attendee->set_email($data['email']);
128
+		}
129
+		// copy address
130
+		if (! empty($data['address'])) {
131
+			$attendee->set_address($data['address']);
132
+		}
133
+		// copy address2
134
+		if (! empty($data['address2'])) {
135
+			$attendee->set_address2($data['address2']);
136
+		}
137
+		// copy city
138
+		if (! empty($data['city'])) {
139
+			$attendee->set_city($data['city']);
140
+		}
141
+		// copy state
142
+		if (! empty($data['state'])) {
143
+			$attendee->set_state($data['state']);
144
+		}
145
+		// copy country
146
+		if (! empty($data['country'])) {
147
+			$attendee->set_country($data['country']);
148
+		}
149
+		// copy zip
150
+		if (! empty($data['zip'])) {
151
+			$attendee->set_zip($data['zip']);
152
+		}
153
+		// copy phone
154
+		if (! empty($data['phone'])) {
155
+			$attendee->set_phone($data['phone']);
156
+		}
157
+		return $attendee;
158
+	}
159 159
 
160 160
 
161
-    /**
162
-     * create_attendee_from_billing_form_data
163
-     * uses info from the billing form to create a new attendee
164
-     * @return \EE_Attendee
165
-     */
166
-    public function create_attendee_from_billing_form_data()
167
-    {
168
-        // grab billing form data
169
-        $data = $this->valid_data();
170
-        return EE_Attendee::new_instance(array(
171
-            'ATT_fname'         => ! empty($data['first_name']) ? $data['first_name'] : '',
172
-            'ATT_lname'         => ! empty($data['last_name']) ? $data['last_name'] : '',
173
-            'ATT_email'         => ! empty($data['email']) ? $data['email'] : '',
174
-            'ATT_address'       => ! empty($data['address']) ? $data['address'] : '',
175
-            'ATT_address2'  => ! empty($data['address2']) ? $data['address2'] : '',
176
-            'ATT_city'          => ! empty($data['city']) ? $data['city'] : '',
177
-            'STA_ID'                => ! empty($data['state']) ? $data['state'] : '',
178
-            'CNT_ISO'           => ! empty($data['country']) ? $data['country'] : '',
179
-            'ATT_zip'               => ! empty($data['zip']) ? $data['zip'] : '',
180
-            'ATT_phone'         => ! empty($data['phone']) ? $data['phone'] : '',
181
-        ));
182
-    }
161
+	/**
162
+	 * create_attendee_from_billing_form_data
163
+	 * uses info from the billing form to create a new attendee
164
+	 * @return \EE_Attendee
165
+	 */
166
+	public function create_attendee_from_billing_form_data()
167
+	{
168
+		// grab billing form data
169
+		$data = $this->valid_data();
170
+		return EE_Attendee::new_instance(array(
171
+			'ATT_fname'         => ! empty($data['first_name']) ? $data['first_name'] : '',
172
+			'ATT_lname'         => ! empty($data['last_name']) ? $data['last_name'] : '',
173
+			'ATT_email'         => ! empty($data['email']) ? $data['email'] : '',
174
+			'ATT_address'       => ! empty($data['address']) ? $data['address'] : '',
175
+			'ATT_address2'  => ! empty($data['address2']) ? $data['address2'] : '',
176
+			'ATT_city'          => ! empty($data['city']) ? $data['city'] : '',
177
+			'STA_ID'                => ! empty($data['state']) ? $data['state'] : '',
178
+			'CNT_ISO'           => ! empty($data['country']) ? $data['country'] : '',
179
+			'ATT_zip'               => ! empty($data['zip']) ? $data['zip'] : '',
180
+			'ATT_phone'         => ! empty($data['phone']) ? $data['phone'] : '',
181
+		));
182
+	}
183 183
 }
184 184
 
185 185
 // End of file EE_Billing_Attendee_Info_Form.form.php
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_PMT_Base.lib.php 2 patches
Indentation   +808 added lines, -808 removed lines patch added patch discarded remove patch
@@ -21,812 +21,812 @@
 block discarded – undo
21 21
 abstract class EE_PMT_Base
22 22
 {
23 23
 
24
-    const onsite = 'on-site';
25
-    const offsite = 'off-site';
26
-    const offline = 'off-line';
27
-
28
-    /**
29
-     * @var EE_Payment_Method
30
-     */
31
-    protected $_pm_instance = null;
32
-
33
-    /**
34
-     * @var boolean
35
-     */
36
-    protected $_requires_https = false;
37
-
38
-    /**
39
-     * @var boolean
40
-     */
41
-    protected $_has_billing_form;
42
-
43
-    /**
44
-     * @var EE_Gateway
45
-     */
46
-    protected $_gateway = null;
47
-
48
-    /**
49
-     * @var EE_Payment_Method_Form
50
-     */
51
-    protected $_settings_form = null;
52
-
53
-    /**
54
-     * @var EE_Form_Section_Proper
55
-     */
56
-    protected $_billing_form = null;
57
-
58
-    /**
59
-     * @var boolean
60
-     */
61
-    protected $_cache_billing_form = true;
62
-
63
-    /**
64
-     * String of the absolute path to the folder containing this file, with a trailing slash.
65
-     * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
66
-     *
67
-     * @var string
68
-     */
69
-    protected $_file_folder = null;
70
-
71
-    /**
72
-     * String to the absolute URL to this file (useful for getting its web-accessible resources
73
-     * like images, js, or css)
74
-     *
75
-     * @var string
76
-     */
77
-    protected $_file_url = null;
78
-
79
-    /**
80
-     * Pretty name for the payment method
81
-     *
82
-     * @var string
83
-     */
84
-    protected $_pretty_name = null;
85
-
86
-    /**
87
-     *
88
-     * @var string
89
-     */
90
-    protected $_default_button_url = null;
91
-
92
-    /**
93
-     *
94
-     * @var string
95
-     */
96
-    protected $_default_description = null;
97
-
98
-
99
-    /**
100
-     *
101
-     * @param EE_Payment_Method $pm_instance
102
-     * @throws EE_Error
103
-     * @return EE_PMT_Base
104
-     */
105
-    public function __construct($pm_instance = null)
106
-    {
107
-        if ($pm_instance instanceof EE_Payment_Method) {
108
-            $this->set_instance($pm_instance);
109
-        }
110
-        if ($this->_gateway) {
111
-            $this->_gateway->set_payment_model(EEM_Payment::instance());
112
-            $this->_gateway->set_payment_log(EEM_Change_Log::instance());
113
-            $this->_gateway->set_template_helper(new EEH_Template());
114
-            $this->_gateway->set_line_item_helper(new EEH_Line_Item());
115
-            $this->_gateway->set_money_helper(new EEH_Money());
116
-            $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
117
-            $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
118
-            do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
119
-        }
120
-        if (! isset($this->_has_billing_form)) {
121
-            // by default, On Site gateways have a billing form
122
-            if ($this->payment_occurs() == EE_PMT_Base::onsite) {
123
-                $this->set_has_billing_form(true);
124
-            } else {
125
-                $this->set_has_billing_form(false);
126
-            }
127
-        }
128
-
129
-        if (! $this->_pretty_name) {
130
-            throw new EE_Error(
131
-                sprintf(
132
-                    __(
133
-                        "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized",
134
-                        "event_espresso"
135
-                    )
136
-                )
137
-            );
138
-        }
139
-        // if the child didn't specify a default button, use the credit card one
140
-        if ($this->_default_button_url === null) {
141
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png';
142
-        }
143
-    }
144
-
145
-
146
-    /**
147
-     * @param boolean $has_billing_form
148
-     */
149
-    public function set_has_billing_form($has_billing_form)
150
-    {
151
-        $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
152
-    }
153
-
154
-
155
-    /**
156
-     * sets the file_folder property
157
-     */
158
-    protected function _set_file_folder()
159
-    {
160
-        $reflector = new ReflectionClass(get_class($this));
161
-        $fn = $reflector->getFileName();
162
-        $this->_file_folder = dirname($fn) . '/';
163
-    }
164
-
165
-
166
-    /**
167
-     * sets the file URL with a trailing slash for this PMT
168
-     */
169
-    protected function _set_file_url()
170
-    {
171
-        $plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR);
172
-        $file_folder_fixed = str_replace('\\', '/', $this->file_folder());
173
-        $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
174
-        $this->_file_url = set_url_scheme($file_path);
175
-    }
176
-
177
-    /**
178
-     * Gets the default description on all payment methods of this type
179
-     *
180
-     * @return string
181
-     */
182
-    public function default_description()
183
-    {
184
-        return $this->_default_description;
185
-    }
186
-
187
-
188
-    /**
189
-     * Returns the folder containing the PMT child class, with a trailing slash
190
-     *
191
-     * @return string
192
-     */
193
-    public function file_folder()
194
-    {
195
-        if (! $this->_file_folder) {
196
-            $this->_set_file_folder();
197
-        }
198
-        return $this->_file_folder;
199
-    }
200
-
201
-
202
-    /**
203
-     * @return string
204
-     */
205
-    public function file_url()
206
-    {
207
-        if (! $this->_file_url) {
208
-            $this->_set_file_url();
209
-        }
210
-        return $this->_file_url;
211
-    }
212
-
213
-
214
-    /**
215
-     * Sets the payment method instance this payment method type is for.
216
-     * Its important teh payment method instance is set before
217
-     *
218
-     * @param EE_Payment_Method $payment_method_instance
219
-     */
220
-    public function set_instance($payment_method_instance)
221
-    {
222
-        $this->_pm_instance = $payment_method_instance;
223
-        // if they have already requested the settings form, make sure its
224
-        // data matches this model object
225
-        if ($this->_settings_form) {
226
-            $this->settings_form()->populate_model_obj($payment_method_instance);
227
-        }
228
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
229
-            $this->_gateway->set_settings($payment_method_instance->settings_array());
230
-        }
231
-    }
232
-
233
-
234
-    /**
235
-     * Gets teh form for displaying to admins where they setup the payment method
236
-     *
237
-     * @return EE_Payment_Method_Form
238
-     */
239
-    public function settings_form()
240
-    {
241
-        if (! $this->_settings_form) {
242
-            $this->_settings_form = $this->generate_new_settings_form();
243
-            $this->_settings_form->set_payment_method_type($this);
244
-            // if we have already assigned a model object to this pmt, make
245
-            // sure its reflected in teh form we just generated
246
-            if ($this->_pm_instance) {
247
-                $this->_settings_form->populate_model_obj($this->_pm_instance);
248
-            }
249
-        }
250
-        return $this->_settings_form;
251
-    }
252
-
253
-
254
-    /**
255
-     * Gets the form for all the settings related to this payment method type
256
-     *
257
-     * @return EE_Payment_Method_Form
258
-     */
259
-    abstract public function generate_new_settings_form();
260
-
261
-
262
-    /**
263
-     * Sets the form for settings. This may be useful if we have already received
264
-     * a form submission and have form data it in, and want to use it anytime we're showing
265
-     * this payment method type's settings form later in the request
266
-     *
267
-     * @param EE_Payment_Method_Form $form
268
-     */
269
-    public function set_settings_form($form)
270
-    {
271
-        $this->_settings_form = $form;
272
-    }
273
-
274
-
275
-    /**
276
-     * @return boolean
277
-     */
278
-    public function has_billing_form()
279
-    {
280
-        return $this->_has_billing_form;
281
-    }
282
-
283
-
284
-    /**
285
-     * Gets the form for displaying to attendees where they can enter their billing info
286
-     * which will be sent to teh gateway (can be null)
287
-     *
288
-     * @param \EE_Transaction $transaction
289
-     * @param array           $extra_args
290
-     * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
291
-     */
292
-    public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
293
-    {
294
-        // has billing form already been regenerated ? or overwrite cache?
295
-        if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296
-            $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
297
-        }
298
-        // if we know who the attendee is, and this is a billing form
299
-        // that uses attendee info, populate it
300
-        if (apply_filters(
301
-            'FHEE__populate_billing_form_fields_from_attendee',
302
-            ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form
303
-                && $transaction instanceof EE_Transaction
304
-                && $transaction->primary_registration() instanceof EE_Registration
305
-                && $transaction->primary_registration()->attendee() instanceof EE_Attendee
306
-            ),
307
-            $this->_billing_form,
308
-            $transaction
309
-        )) {
310
-            $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
311
-        }
312
-        return $this->_billing_form;
313
-    }
314
-
315
-
316
-    /**
317
-     * Creates the billing form for this payment method type
318
-     *
319
-     * @param \EE_Transaction $transaction
320
-     * @return \EE_Billing_Info_Form
321
-     */
322
-    abstract public function generate_new_billing_form(EE_Transaction $transaction = null);
323
-
324
-
325
-    /**
326
-     * apply_billing_form_debug_settings
327
-     * applies debug data to the form
328
-     *
329
-     * @param \EE_Billing_Info_Form $billing_form
330
-     * @return \EE_Billing_Info_Form
331
-     */
332
-    public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
333
-    {
334
-        return $billing_form;
335
-    }
336
-
337
-
338
-    /**
339
-     * Sets the billing form for this payment method type. You may want to use this
340
-     * if you have form
341
-     *
342
-     * @param EE_Payment_Method $form
343
-     */
344
-    public function set_billing_form($form)
345
-    {
346
-        $this->_billing_form = $form;
347
-    }
348
-
349
-
350
-    /**
351
-     * Returns whether or not this payment method requires HTTPS to be used
352
-     *
353
-     * @return boolean
354
-     */
355
-    public function requires_https()
356
-    {
357
-        return $this->_requires_https;
358
-    }
359
-
360
-
361
-    /**
362
-     *
363
-     * @param EE_Transaction       $transaction
364
-     * @param float                $amount
365
-     * @param EE_Billing_Info_Form $billing_info
366
-     * @param string               $return_url
367
-     * @param string               $fail_url
368
-     * @param string               $method
369
-     * @param bool                 $by_admin
370
-     * @return EE_Payment
371
-     * @throws EE_Error
372
-     */
373
-    public function process_payment(
374
-        EE_Transaction $transaction,
375
-        $amount = null,
376
-        $billing_info = null,
377
-        $return_url = null,
378
-        $fail_url = '',
379
-        $method = 'CART',
380
-        $by_admin = false
381
-    ) {
382
-        // @todo: add surcharge for the payment method, if any
383
-        if ($this->_gateway) {
384
-            // there is a gateway, so we're going to make a payment object
385
-            // but wait! do they already have a payment in progress that we thought was failed?
386
-            $duplicate_properties = array(
387
-                'STS_ID'               => EEM_Payment::status_id_failed,
388
-                'TXN_ID'               => $transaction->ID(),
389
-                'PMD_ID'               => $this->_pm_instance->ID(),
390
-                'PAY_source'           => $method,
391
-                'PAY_amount'           => $amount !== null ? $amount : $transaction->remaining(),
392
-                'PAY_gateway_response' => null,
393
-            );
394
-            $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
395
-            // if we didn't already have a payment in progress for the same thing,
396
-            // then we actually want to make a new payment
397
-            if (! $payment instanceof EE_Payment) {
398
-                $payment = EE_Payment::new_instance(
399
-                    array_merge(
400
-                        $duplicate_properties,
401
-                        array(
402
-                            'PAY_timestamp'       => time(),
403
-                            'PAY_txn_id_chq_nmbr' => null,
404
-                            'PAY_po_number'       => null,
405
-                            'PAY_extra_accntng'   => null,
406
-                            'PAY_details'         => null,
407
-                        )
408
-                    )
409
-                );
410
-            }
411
-            // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
412
-            $payment->save();
413
-            $billing_values = $this->_get_billing_values_from_form($billing_info);
414
-
415
-            //  Offsite Gateway
416
-            if ($this->_gateway instanceof EE_Offsite_Gateway) {
417
-                $payment = $this->_gateway->set_redirection_info(
418
-                    $payment,
419
-                    $billing_values,
420
-                    $return_url,
421
-                    EE_Config::instance()->core->txn_page_url(
422
-                        array(
423
-                            'e_reg_url_link'    => $transaction->primary_registration()->reg_url_link(),
424
-                            'ee_payment_method' => $this->_pm_instance->slug(),
425
-                        )
426
-                    ),
427
-                    $fail_url
428
-                );
429
-                $payment->save();
430
-                //  Onsite Gateway
431
-            } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
432
-                $payment = $this->_gateway->do_direct_payment($payment, $billing_values);
433
-                $payment->save();
434
-            } else {
435
-                throw new EE_Error(
436
-                    sprintf(
437
-                        __(
438
-                            'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)',
439
-                            'event_espresso'
440
-                        ),
441
-                        get_class($this),
442
-                        gettype($this->_gateway)
443
-                    )
444
-                );
445
-            }
446
-        } else {
447
-            // no gateway provided
448
-            // there is no payment. Must be an offline gateway
449
-            // create a payment object anyways, but dont save it
450
-            $payment = EE_Payment::new_instance(
451
-                array(
452
-                    'STS_ID'        => EEM_Payment::status_id_pending,
453
-                    'TXN_ID'        => $transaction->ID(),
454
-                    'PMD_ID'        => $transaction->payment_method_ID(),
455
-                    'PAY_amount'    => 0.00,
456
-                    'PAY_timestamp' => time(),
457
-                )
458
-            );
459
-        }
460
-
461
-        // if there is billing info, clean it and save it now
462
-        if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
463
-            $this->_save_billing_info_to_attendee($billing_info, $transaction);
464
-        }
465
-
466
-        return $payment;
467
-    }
468
-
469
-    /**
470
-     * Gets the values we want to pass onto the gateway. Normally these
471
-     * are just the 'pretty' values, but there may be times the data may need
472
-     * a  little massaging. Proper subsections will become arrays of inputs
473
-     *
474
-     * @param EE_Billing_Info_Form $billing_form
475
-     * @return array
476
-     */
477
-    protected function _get_billing_values_from_form($billing_form)
478
-    {
479
-        if ($billing_form instanceof EE_Form_Section_Proper) {
480
-            return $billing_form->input_pretty_values(true);
481
-        } else {
482
-            return null;
483
-        }
484
-    }
485
-
486
-
487
-    /**
488
-     * Handles an instant payment notification when the transaction is known (by default).
489
-     *
490
-     * @param array          $req_data
491
-     * @param EE_Transaction $transaction
492
-     * @return EE_Payment
493
-     * @throws EE_Error
494
-     */
495
-    public function handle_ipn($req_data, $transaction)
496
-    {
497
-        $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
498
-        if (! $this->_gateway instanceof EE_Offsite_Gateway) {
499
-            throw new EE_Error(
500
-                sprintf(
501
-                    __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
502
-                    print_r($this->_gateway, true)
503
-                )
504
-            );
505
-        }
506
-        $payment = $this->_gateway->handle_payment_update($req_data, $transaction);
507
-        return $payment;
508
-    }
509
-
510
-
511
-    /**
512
-     * Saves the billing info onto the attendee of the primary registrant on this transaction, and
513
-     * cleans it first.
514
-     *
515
-     * @param EE_Billing_Attendee_Info_Form $billing_form
516
-     * @param EE_Transaction                $transaction
517
-     * @return boolean success
518
-     */
519
-    protected function _save_billing_info_to_attendee($billing_form, $transaction)
520
-    {
521
-        if (! $transaction || ! $transaction instanceof EE_Transaction) {
522
-            EE_Error::add_error(
523
-                __("Cannot save billing info because no transaction was specified", "event_espresso"),
524
-                __FILE__,
525
-                __FUNCTION__,
526
-                __LINE__
527
-            );
528
-            return false;
529
-        }
530
-        $primary_reg = $transaction->primary_registration();
531
-        if (! $primary_reg) {
532
-            EE_Error::add_error(
533
-                __("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
534
-                __FILE__,
535
-                __FUNCTION__,
536
-                __LINE__
537
-            );
538
-            return false;
539
-        }
540
-        $attendee = $primary_reg->attendee();
541
-        if (! $attendee) {
542
-            EE_Error::add_error(
543
-                __(
544
-                    "Cannot save billing info because the transaction's primary registration has no attendee!",
545
-                    "event_espresso"
546
-                ),
547
-                __FILE__,
548
-                __FUNCTION__,
549
-                __LINE__
550
-            );
551
-            return false;
552
-        }
553
-        return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
554
-    }
555
-
556
-
557
-    /**
558
-     * Gets the payment this IPN is for. Children may often want to
559
-     * override this to inspect the request
560
-     *
561
-     * @param EE_Transaction $transaction
562
-     * @param array          $req_data
563
-     * @return EE_Payment
564
-     */
565
-    protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
566
-    {
567
-        return $transaction->last_payment();
568
-    }
569
-
570
-
571
-    /**
572
-     * In case generic code cannot provide the payment processor with a specific payment method
573
-     * and transaction, it will try calling this method on each activate payment method.
574
-     * If the payment method is able to identify the request as being for it, it should fetch
575
-     * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
576
-     * handle the IPN
577
-     *
578
-     * @param array $req_data
579
-     * @return EE_Payment only if this payment method can find the info its needs from $req_data
580
-     * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
581
-     * @throws EE_Error
582
-     */
583
-    public function handle_unclaimed_ipn($req_data = array())
584
-    {
585
-        throw new EE_Error(
586
-            sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))
587
-        );
588
-    }
589
-
590
-
591
-    /**
592
-     * Logic to be accomplished when the payment attempt is complete.
593
-     * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
594
-     * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
595
-     * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
596
-     * of the payment). Fed a transaction because it's always assumed to be the last payment that
597
-     * we're dealing with. Returns that last payment (if there is one)
598
-     *
599
-     * @param EE_Transaction $transaction
600
-     * @return EE_Payment
601
-     */
602
-    public function finalize_payment_for($transaction)
603
-    {
604
-        return $transaction->last_payment();
605
-    }
606
-
607
-
608
-    /**
609
-     * Whether or not this payment method's gateway supports sending refund requests
610
-     *
611
-     * @return boolean
612
-     */
613
-    public function supports_sending_refunds()
614
-    {
615
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
616
-            return $this->_gateway->supports_sending_refunds();
617
-        } else {
618
-            return false;
619
-        }
620
-    }
621
-
622
-
623
-    /**
624
-     *
625
-     * @param EE_Payment $payment
626
-     * @param array      $refund_info
627
-     * @throws EE_Error
628
-     * @return EE_Payment
629
-     */
630
-    public function process_refund(EE_Payment $payment, $refund_info = array())
631
-    {
632
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
633
-            return $this->_gateway->do_direct_refund($payment, $refund_info);
634
-        } else {
635
-            throw new EE_Error(
636
-                sprintf(
637
-                    __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
638
-                    get_class($this)
639
-                )
640
-            );
641
-        }
642
-    }
643
-
644
-
645
-    /**
646
-     * Returns one the class's constants onsite,offsite, or offline, depending on this
647
-     * payment method's gateway.
648
-     *
649
-     * @return string
650
-     * @throws EE_Error
651
-     */
652
-    public function payment_occurs()
653
-    {
654
-        if (! $this->_gateway) {
655
-            return EE_PMT_Base::offline;
656
-        } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
657
-            return EE_PMT_Base::onsite;
658
-        } elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
659
-            return EE_PMT_Base::offsite;
660
-        } else {
661
-            throw new EE_Error(
662
-                sprintf(
663
-                    __(
664
-                        "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those",
665
-                        "event_espresso"
666
-                    ),
667
-                    get_class($this)
668
-                )
669
-            );
670
-        }
671
-    }
672
-
673
-
674
-    /**
675
-     * For adding any html output ab ove the payment overview.
676
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
677
-     * Other gateways may want to override this, such as offline gateways.
678
-     *
679
-     * @param EE_Payment $payment
680
-     * @return string
681
-     */
682
-    public function payment_overview_content(EE_Payment $payment)
683
-    {
684
-        return EEH_Template::display_template(
685
-            EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php',
686
-            array('payment_method' => $this->_pm_instance, 'payment' => $payment),
687
-            true
688
-        );
689
-    }
690
-
691
-
692
-    /**
693
-     * @return array where keys are the help tab name,
694
-     * values are: array {
695
-     * @type string $title         i18n name for the help tab
696
-     * @type string $filename      name of the file located in ./help_tabs/ (ie, in a folder next to this file)
697
-     * @type array  $template_args any arguments you want passed to the template file while rendering.
698
-     *                Keys will be variable names and values with be their values.
699
-     */
700
-    public function help_tabs_config()
701
-    {
702
-        return array();
703
-    }
704
-
705
-
706
-    /**
707
-     * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
708
-     * the payment method's table's PMT_type column)
709
-     *
710
-     * @return string
711
-     */
712
-    public function system_name()
713
-    {
714
-        $classname = get_class($this);
715
-        return str_replace("EE_PMT_", '', $classname);
716
-    }
717
-
718
-
719
-    /**
720
-     * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding
721
-     * this method.
722
-     * @return string
723
-     */
724
-    public function defaultFrontendName()
725
-    {
726
-        return $this->pretty_name();
727
-    }
728
-
729
-
730
-    /**
731
-     * A pretty i18n version of the PMT name
732
-     *
733
-     * @return string
734
-     */
735
-    public function pretty_name()
736
-    {
737
-        return $this->_pretty_name;
738
-    }
739
-
740
-
741
-    /**
742
-     * Gets the default absolute URL to the payment method type's button
743
-     *
744
-     * @return string
745
-     */
746
-    public function default_button_url()
747
-    {
748
-        return $this->_default_button_url;
749
-    }
750
-
751
-
752
-    /**
753
-     * Gets the gateway used by this payment method (if any)
754
-     *
755
-     * @return EE_Gateway
756
-     */
757
-    public function get_gateway()
758
-    {
759
-        return $this->_gateway;
760
-    }
761
-
762
-
763
-    /**
764
-     * @return string html for the link to a help tab
765
-     */
766
-    public function get_help_tab_link()
767
-    {
768
-        return EEH_Template::get_help_tab_link(
769
-            $this->get_help_tab_name(),
770
-            'espresso_payment_settings',
771
-            'default'
772
-        );
773
-    }
774
-
775
-
776
-    /**
777
-     * Returns the name of the help tab for this PMT
778
-     *
779
-     * @return string
780
-     */
781
-    public function get_help_tab_name()
782
-    {
783
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
784
-    }
785
-
786
-    /**
787
-     * The name of the wp capability that should be associated with the usage of
788
-     * this PMT by an admin
789
-     *
790
-     * @return string
791
-     */
792
-    public function cap_name()
793
-    {
794
-        return 'ee_payment_method_' . strtolower($this->system_name());
795
-    }
796
-
797
-    /**
798
-     * Called by client code to tell the gateway that if it wants to change
799
-     * the transaction or line items or registrations related to teh payment it already
800
-     * processed (we think, but possibly not) that now's the time to do it.
801
-     * It is expected that gateways will store any info they need for this on the PAY_details,
802
-     * or maybe an extra meta value
803
-     *
804
-     * @param EE_Payment $payment
805
-     * @return void
806
-     */
807
-    public function update_txn_based_on_payment($payment)
808
-    {
809
-        if ($this->_gateway instanceof EE_Gateway) {
810
-            $this->_gateway->update_txn_based_on_payment($payment);
811
-        }
812
-    }
813
-
814
-    /**
815
-     * Returns a string of HTML describing this payment method type for an admin,
816
-     * primarily intended for them to read before activating it.
817
-     * The easiest way to set this is to create a folder 'templates' alongside
818
-     * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
819
-     * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
820
-     * then you'd create a file named "templates" in the same folder as it, and name the file
821
-     * "foo_bar_intro.template.php", and its content will be returned by this method
822
-     *
823
-     * @return string
824
-     */
825
-    public function introductory_html()
826
-    {
827
-        return EEH_Template::locate_template(
828
-            $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php',
829
-            array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
830
-        );
831
-    }
24
+	const onsite = 'on-site';
25
+	const offsite = 'off-site';
26
+	const offline = 'off-line';
27
+
28
+	/**
29
+	 * @var EE_Payment_Method
30
+	 */
31
+	protected $_pm_instance = null;
32
+
33
+	/**
34
+	 * @var boolean
35
+	 */
36
+	protected $_requires_https = false;
37
+
38
+	/**
39
+	 * @var boolean
40
+	 */
41
+	protected $_has_billing_form;
42
+
43
+	/**
44
+	 * @var EE_Gateway
45
+	 */
46
+	protected $_gateway = null;
47
+
48
+	/**
49
+	 * @var EE_Payment_Method_Form
50
+	 */
51
+	protected $_settings_form = null;
52
+
53
+	/**
54
+	 * @var EE_Form_Section_Proper
55
+	 */
56
+	protected $_billing_form = null;
57
+
58
+	/**
59
+	 * @var boolean
60
+	 */
61
+	protected $_cache_billing_form = true;
62
+
63
+	/**
64
+	 * String of the absolute path to the folder containing this file, with a trailing slash.
65
+	 * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
66
+	 *
67
+	 * @var string
68
+	 */
69
+	protected $_file_folder = null;
70
+
71
+	/**
72
+	 * String to the absolute URL to this file (useful for getting its web-accessible resources
73
+	 * like images, js, or css)
74
+	 *
75
+	 * @var string
76
+	 */
77
+	protected $_file_url = null;
78
+
79
+	/**
80
+	 * Pretty name for the payment method
81
+	 *
82
+	 * @var string
83
+	 */
84
+	protected $_pretty_name = null;
85
+
86
+	/**
87
+	 *
88
+	 * @var string
89
+	 */
90
+	protected $_default_button_url = null;
91
+
92
+	/**
93
+	 *
94
+	 * @var string
95
+	 */
96
+	protected $_default_description = null;
97
+
98
+
99
+	/**
100
+	 *
101
+	 * @param EE_Payment_Method $pm_instance
102
+	 * @throws EE_Error
103
+	 * @return EE_PMT_Base
104
+	 */
105
+	public function __construct($pm_instance = null)
106
+	{
107
+		if ($pm_instance instanceof EE_Payment_Method) {
108
+			$this->set_instance($pm_instance);
109
+		}
110
+		if ($this->_gateway) {
111
+			$this->_gateway->set_payment_model(EEM_Payment::instance());
112
+			$this->_gateway->set_payment_log(EEM_Change_Log::instance());
113
+			$this->_gateway->set_template_helper(new EEH_Template());
114
+			$this->_gateway->set_line_item_helper(new EEH_Line_Item());
115
+			$this->_gateway->set_money_helper(new EEH_Money());
116
+			$this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
117
+			$this->_gateway->set_unsupported_character_remover(new AsciiOnly());
118
+			do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
119
+		}
120
+		if (! isset($this->_has_billing_form)) {
121
+			// by default, On Site gateways have a billing form
122
+			if ($this->payment_occurs() == EE_PMT_Base::onsite) {
123
+				$this->set_has_billing_form(true);
124
+			} else {
125
+				$this->set_has_billing_form(false);
126
+			}
127
+		}
128
+
129
+		if (! $this->_pretty_name) {
130
+			throw new EE_Error(
131
+				sprintf(
132
+					__(
133
+						"You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized",
134
+						"event_espresso"
135
+					)
136
+				)
137
+			);
138
+		}
139
+		// if the child didn't specify a default button, use the credit card one
140
+		if ($this->_default_button_url === null) {
141
+			$this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png';
142
+		}
143
+	}
144
+
145
+
146
+	/**
147
+	 * @param boolean $has_billing_form
148
+	 */
149
+	public function set_has_billing_form($has_billing_form)
150
+	{
151
+		$this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
152
+	}
153
+
154
+
155
+	/**
156
+	 * sets the file_folder property
157
+	 */
158
+	protected function _set_file_folder()
159
+	{
160
+		$reflector = new ReflectionClass(get_class($this));
161
+		$fn = $reflector->getFileName();
162
+		$this->_file_folder = dirname($fn) . '/';
163
+	}
164
+
165
+
166
+	/**
167
+	 * sets the file URL with a trailing slash for this PMT
168
+	 */
169
+	protected function _set_file_url()
170
+	{
171
+		$plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR);
172
+		$file_folder_fixed = str_replace('\\', '/', $this->file_folder());
173
+		$file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
174
+		$this->_file_url = set_url_scheme($file_path);
175
+	}
176
+
177
+	/**
178
+	 * Gets the default description on all payment methods of this type
179
+	 *
180
+	 * @return string
181
+	 */
182
+	public function default_description()
183
+	{
184
+		return $this->_default_description;
185
+	}
186
+
187
+
188
+	/**
189
+	 * Returns the folder containing the PMT child class, with a trailing slash
190
+	 *
191
+	 * @return string
192
+	 */
193
+	public function file_folder()
194
+	{
195
+		if (! $this->_file_folder) {
196
+			$this->_set_file_folder();
197
+		}
198
+		return $this->_file_folder;
199
+	}
200
+
201
+
202
+	/**
203
+	 * @return string
204
+	 */
205
+	public function file_url()
206
+	{
207
+		if (! $this->_file_url) {
208
+			$this->_set_file_url();
209
+		}
210
+		return $this->_file_url;
211
+	}
212
+
213
+
214
+	/**
215
+	 * Sets the payment method instance this payment method type is for.
216
+	 * Its important teh payment method instance is set before
217
+	 *
218
+	 * @param EE_Payment_Method $payment_method_instance
219
+	 */
220
+	public function set_instance($payment_method_instance)
221
+	{
222
+		$this->_pm_instance = $payment_method_instance;
223
+		// if they have already requested the settings form, make sure its
224
+		// data matches this model object
225
+		if ($this->_settings_form) {
226
+			$this->settings_form()->populate_model_obj($payment_method_instance);
227
+		}
228
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
229
+			$this->_gateway->set_settings($payment_method_instance->settings_array());
230
+		}
231
+	}
232
+
233
+
234
+	/**
235
+	 * Gets teh form for displaying to admins where they setup the payment method
236
+	 *
237
+	 * @return EE_Payment_Method_Form
238
+	 */
239
+	public function settings_form()
240
+	{
241
+		if (! $this->_settings_form) {
242
+			$this->_settings_form = $this->generate_new_settings_form();
243
+			$this->_settings_form->set_payment_method_type($this);
244
+			// if we have already assigned a model object to this pmt, make
245
+			// sure its reflected in teh form we just generated
246
+			if ($this->_pm_instance) {
247
+				$this->_settings_form->populate_model_obj($this->_pm_instance);
248
+			}
249
+		}
250
+		return $this->_settings_form;
251
+	}
252
+
253
+
254
+	/**
255
+	 * Gets the form for all the settings related to this payment method type
256
+	 *
257
+	 * @return EE_Payment_Method_Form
258
+	 */
259
+	abstract public function generate_new_settings_form();
260
+
261
+
262
+	/**
263
+	 * Sets the form for settings. This may be useful if we have already received
264
+	 * a form submission and have form data it in, and want to use it anytime we're showing
265
+	 * this payment method type's settings form later in the request
266
+	 *
267
+	 * @param EE_Payment_Method_Form $form
268
+	 */
269
+	public function set_settings_form($form)
270
+	{
271
+		$this->_settings_form = $form;
272
+	}
273
+
274
+
275
+	/**
276
+	 * @return boolean
277
+	 */
278
+	public function has_billing_form()
279
+	{
280
+		return $this->_has_billing_form;
281
+	}
282
+
283
+
284
+	/**
285
+	 * Gets the form for displaying to attendees where they can enter their billing info
286
+	 * which will be sent to teh gateway (can be null)
287
+	 *
288
+	 * @param \EE_Transaction $transaction
289
+	 * @param array           $extra_args
290
+	 * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
291
+	 */
292
+	public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
293
+	{
294
+		// has billing form already been regenerated ? or overwrite cache?
295
+		if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296
+			$this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
297
+		}
298
+		// if we know who the attendee is, and this is a billing form
299
+		// that uses attendee info, populate it
300
+		if (apply_filters(
301
+			'FHEE__populate_billing_form_fields_from_attendee',
302
+			($this->_billing_form instanceof EE_Billing_Attendee_Info_Form
303
+				&& $transaction instanceof EE_Transaction
304
+				&& $transaction->primary_registration() instanceof EE_Registration
305
+				&& $transaction->primary_registration()->attendee() instanceof EE_Attendee
306
+			),
307
+			$this->_billing_form,
308
+			$transaction
309
+		)) {
310
+			$this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
311
+		}
312
+		return $this->_billing_form;
313
+	}
314
+
315
+
316
+	/**
317
+	 * Creates the billing form for this payment method type
318
+	 *
319
+	 * @param \EE_Transaction $transaction
320
+	 * @return \EE_Billing_Info_Form
321
+	 */
322
+	abstract public function generate_new_billing_form(EE_Transaction $transaction = null);
323
+
324
+
325
+	/**
326
+	 * apply_billing_form_debug_settings
327
+	 * applies debug data to the form
328
+	 *
329
+	 * @param \EE_Billing_Info_Form $billing_form
330
+	 * @return \EE_Billing_Info_Form
331
+	 */
332
+	public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
333
+	{
334
+		return $billing_form;
335
+	}
336
+
337
+
338
+	/**
339
+	 * Sets the billing form for this payment method type. You may want to use this
340
+	 * if you have form
341
+	 *
342
+	 * @param EE_Payment_Method $form
343
+	 */
344
+	public function set_billing_form($form)
345
+	{
346
+		$this->_billing_form = $form;
347
+	}
348
+
349
+
350
+	/**
351
+	 * Returns whether or not this payment method requires HTTPS to be used
352
+	 *
353
+	 * @return boolean
354
+	 */
355
+	public function requires_https()
356
+	{
357
+		return $this->_requires_https;
358
+	}
359
+
360
+
361
+	/**
362
+	 *
363
+	 * @param EE_Transaction       $transaction
364
+	 * @param float                $amount
365
+	 * @param EE_Billing_Info_Form $billing_info
366
+	 * @param string               $return_url
367
+	 * @param string               $fail_url
368
+	 * @param string               $method
369
+	 * @param bool                 $by_admin
370
+	 * @return EE_Payment
371
+	 * @throws EE_Error
372
+	 */
373
+	public function process_payment(
374
+		EE_Transaction $transaction,
375
+		$amount = null,
376
+		$billing_info = null,
377
+		$return_url = null,
378
+		$fail_url = '',
379
+		$method = 'CART',
380
+		$by_admin = false
381
+	) {
382
+		// @todo: add surcharge for the payment method, if any
383
+		if ($this->_gateway) {
384
+			// there is a gateway, so we're going to make a payment object
385
+			// but wait! do they already have a payment in progress that we thought was failed?
386
+			$duplicate_properties = array(
387
+				'STS_ID'               => EEM_Payment::status_id_failed,
388
+				'TXN_ID'               => $transaction->ID(),
389
+				'PMD_ID'               => $this->_pm_instance->ID(),
390
+				'PAY_source'           => $method,
391
+				'PAY_amount'           => $amount !== null ? $amount : $transaction->remaining(),
392
+				'PAY_gateway_response' => null,
393
+			);
394
+			$payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
395
+			// if we didn't already have a payment in progress for the same thing,
396
+			// then we actually want to make a new payment
397
+			if (! $payment instanceof EE_Payment) {
398
+				$payment = EE_Payment::new_instance(
399
+					array_merge(
400
+						$duplicate_properties,
401
+						array(
402
+							'PAY_timestamp'       => time(),
403
+							'PAY_txn_id_chq_nmbr' => null,
404
+							'PAY_po_number'       => null,
405
+							'PAY_extra_accntng'   => null,
406
+							'PAY_details'         => null,
407
+						)
408
+					)
409
+				);
410
+			}
411
+			// make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
412
+			$payment->save();
413
+			$billing_values = $this->_get_billing_values_from_form($billing_info);
414
+
415
+			//  Offsite Gateway
416
+			if ($this->_gateway instanceof EE_Offsite_Gateway) {
417
+				$payment = $this->_gateway->set_redirection_info(
418
+					$payment,
419
+					$billing_values,
420
+					$return_url,
421
+					EE_Config::instance()->core->txn_page_url(
422
+						array(
423
+							'e_reg_url_link'    => $transaction->primary_registration()->reg_url_link(),
424
+							'ee_payment_method' => $this->_pm_instance->slug(),
425
+						)
426
+					),
427
+					$fail_url
428
+				);
429
+				$payment->save();
430
+				//  Onsite Gateway
431
+			} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
432
+				$payment = $this->_gateway->do_direct_payment($payment, $billing_values);
433
+				$payment->save();
434
+			} else {
435
+				throw new EE_Error(
436
+					sprintf(
437
+						__(
438
+							'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)',
439
+							'event_espresso'
440
+						),
441
+						get_class($this),
442
+						gettype($this->_gateway)
443
+					)
444
+				);
445
+			}
446
+		} else {
447
+			// no gateway provided
448
+			// there is no payment. Must be an offline gateway
449
+			// create a payment object anyways, but dont save it
450
+			$payment = EE_Payment::new_instance(
451
+				array(
452
+					'STS_ID'        => EEM_Payment::status_id_pending,
453
+					'TXN_ID'        => $transaction->ID(),
454
+					'PMD_ID'        => $transaction->payment_method_ID(),
455
+					'PAY_amount'    => 0.00,
456
+					'PAY_timestamp' => time(),
457
+				)
458
+			);
459
+		}
460
+
461
+		// if there is billing info, clean it and save it now
462
+		if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
463
+			$this->_save_billing_info_to_attendee($billing_info, $transaction);
464
+		}
465
+
466
+		return $payment;
467
+	}
468
+
469
+	/**
470
+	 * Gets the values we want to pass onto the gateway. Normally these
471
+	 * are just the 'pretty' values, but there may be times the data may need
472
+	 * a  little massaging. Proper subsections will become arrays of inputs
473
+	 *
474
+	 * @param EE_Billing_Info_Form $billing_form
475
+	 * @return array
476
+	 */
477
+	protected function _get_billing_values_from_form($billing_form)
478
+	{
479
+		if ($billing_form instanceof EE_Form_Section_Proper) {
480
+			return $billing_form->input_pretty_values(true);
481
+		} else {
482
+			return null;
483
+		}
484
+	}
485
+
486
+
487
+	/**
488
+	 * Handles an instant payment notification when the transaction is known (by default).
489
+	 *
490
+	 * @param array          $req_data
491
+	 * @param EE_Transaction $transaction
492
+	 * @return EE_Payment
493
+	 * @throws EE_Error
494
+	 */
495
+	public function handle_ipn($req_data, $transaction)
496
+	{
497
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
498
+		if (! $this->_gateway instanceof EE_Offsite_Gateway) {
499
+			throw new EE_Error(
500
+				sprintf(
501
+					__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
502
+					print_r($this->_gateway, true)
503
+				)
504
+			);
505
+		}
506
+		$payment = $this->_gateway->handle_payment_update($req_data, $transaction);
507
+		return $payment;
508
+	}
509
+
510
+
511
+	/**
512
+	 * Saves the billing info onto the attendee of the primary registrant on this transaction, and
513
+	 * cleans it first.
514
+	 *
515
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
516
+	 * @param EE_Transaction                $transaction
517
+	 * @return boolean success
518
+	 */
519
+	protected function _save_billing_info_to_attendee($billing_form, $transaction)
520
+	{
521
+		if (! $transaction || ! $transaction instanceof EE_Transaction) {
522
+			EE_Error::add_error(
523
+				__("Cannot save billing info because no transaction was specified", "event_espresso"),
524
+				__FILE__,
525
+				__FUNCTION__,
526
+				__LINE__
527
+			);
528
+			return false;
529
+		}
530
+		$primary_reg = $transaction->primary_registration();
531
+		if (! $primary_reg) {
532
+			EE_Error::add_error(
533
+				__("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
534
+				__FILE__,
535
+				__FUNCTION__,
536
+				__LINE__
537
+			);
538
+			return false;
539
+		}
540
+		$attendee = $primary_reg->attendee();
541
+		if (! $attendee) {
542
+			EE_Error::add_error(
543
+				__(
544
+					"Cannot save billing info because the transaction's primary registration has no attendee!",
545
+					"event_espresso"
546
+				),
547
+				__FILE__,
548
+				__FUNCTION__,
549
+				__LINE__
550
+			);
551
+			return false;
552
+		}
553
+		return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
554
+	}
555
+
556
+
557
+	/**
558
+	 * Gets the payment this IPN is for. Children may often want to
559
+	 * override this to inspect the request
560
+	 *
561
+	 * @param EE_Transaction $transaction
562
+	 * @param array          $req_data
563
+	 * @return EE_Payment
564
+	 */
565
+	protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
566
+	{
567
+		return $transaction->last_payment();
568
+	}
569
+
570
+
571
+	/**
572
+	 * In case generic code cannot provide the payment processor with a specific payment method
573
+	 * and transaction, it will try calling this method on each activate payment method.
574
+	 * If the payment method is able to identify the request as being for it, it should fetch
575
+	 * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
576
+	 * handle the IPN
577
+	 *
578
+	 * @param array $req_data
579
+	 * @return EE_Payment only if this payment method can find the info its needs from $req_data
580
+	 * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
581
+	 * @throws EE_Error
582
+	 */
583
+	public function handle_unclaimed_ipn($req_data = array())
584
+	{
585
+		throw new EE_Error(
586
+			sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))
587
+		);
588
+	}
589
+
590
+
591
+	/**
592
+	 * Logic to be accomplished when the payment attempt is complete.
593
+	 * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
594
+	 * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
595
+	 * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
596
+	 * of the payment). Fed a transaction because it's always assumed to be the last payment that
597
+	 * we're dealing with. Returns that last payment (if there is one)
598
+	 *
599
+	 * @param EE_Transaction $transaction
600
+	 * @return EE_Payment
601
+	 */
602
+	public function finalize_payment_for($transaction)
603
+	{
604
+		return $transaction->last_payment();
605
+	}
606
+
607
+
608
+	/**
609
+	 * Whether or not this payment method's gateway supports sending refund requests
610
+	 *
611
+	 * @return boolean
612
+	 */
613
+	public function supports_sending_refunds()
614
+	{
615
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
616
+			return $this->_gateway->supports_sending_refunds();
617
+		} else {
618
+			return false;
619
+		}
620
+	}
621
+
622
+
623
+	/**
624
+	 *
625
+	 * @param EE_Payment $payment
626
+	 * @param array      $refund_info
627
+	 * @throws EE_Error
628
+	 * @return EE_Payment
629
+	 */
630
+	public function process_refund(EE_Payment $payment, $refund_info = array())
631
+	{
632
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
633
+			return $this->_gateway->do_direct_refund($payment, $refund_info);
634
+		} else {
635
+			throw new EE_Error(
636
+				sprintf(
637
+					__('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
638
+					get_class($this)
639
+				)
640
+			);
641
+		}
642
+	}
643
+
644
+
645
+	/**
646
+	 * Returns one the class's constants onsite,offsite, or offline, depending on this
647
+	 * payment method's gateway.
648
+	 *
649
+	 * @return string
650
+	 * @throws EE_Error
651
+	 */
652
+	public function payment_occurs()
653
+	{
654
+		if (! $this->_gateway) {
655
+			return EE_PMT_Base::offline;
656
+		} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
657
+			return EE_PMT_Base::onsite;
658
+		} elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
659
+			return EE_PMT_Base::offsite;
660
+		} else {
661
+			throw new EE_Error(
662
+				sprintf(
663
+					__(
664
+						"Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those",
665
+						"event_espresso"
666
+					),
667
+					get_class($this)
668
+				)
669
+			);
670
+		}
671
+	}
672
+
673
+
674
+	/**
675
+	 * For adding any html output ab ove the payment overview.
676
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
677
+	 * Other gateways may want to override this, such as offline gateways.
678
+	 *
679
+	 * @param EE_Payment $payment
680
+	 * @return string
681
+	 */
682
+	public function payment_overview_content(EE_Payment $payment)
683
+	{
684
+		return EEH_Template::display_template(
685
+			EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php',
686
+			array('payment_method' => $this->_pm_instance, 'payment' => $payment),
687
+			true
688
+		);
689
+	}
690
+
691
+
692
+	/**
693
+	 * @return array where keys are the help tab name,
694
+	 * values are: array {
695
+	 * @type string $title         i18n name for the help tab
696
+	 * @type string $filename      name of the file located in ./help_tabs/ (ie, in a folder next to this file)
697
+	 * @type array  $template_args any arguments you want passed to the template file while rendering.
698
+	 *                Keys will be variable names and values with be their values.
699
+	 */
700
+	public function help_tabs_config()
701
+	{
702
+		return array();
703
+	}
704
+
705
+
706
+	/**
707
+	 * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
708
+	 * the payment method's table's PMT_type column)
709
+	 *
710
+	 * @return string
711
+	 */
712
+	public function system_name()
713
+	{
714
+		$classname = get_class($this);
715
+		return str_replace("EE_PMT_", '', $classname);
716
+	}
717
+
718
+
719
+	/**
720
+	 * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding
721
+	 * this method.
722
+	 * @return string
723
+	 */
724
+	public function defaultFrontendName()
725
+	{
726
+		return $this->pretty_name();
727
+	}
728
+
729
+
730
+	/**
731
+	 * A pretty i18n version of the PMT name
732
+	 *
733
+	 * @return string
734
+	 */
735
+	public function pretty_name()
736
+	{
737
+		return $this->_pretty_name;
738
+	}
739
+
740
+
741
+	/**
742
+	 * Gets the default absolute URL to the payment method type's button
743
+	 *
744
+	 * @return string
745
+	 */
746
+	public function default_button_url()
747
+	{
748
+		return $this->_default_button_url;
749
+	}
750
+
751
+
752
+	/**
753
+	 * Gets the gateway used by this payment method (if any)
754
+	 *
755
+	 * @return EE_Gateway
756
+	 */
757
+	public function get_gateway()
758
+	{
759
+		return $this->_gateway;
760
+	}
761
+
762
+
763
+	/**
764
+	 * @return string html for the link to a help tab
765
+	 */
766
+	public function get_help_tab_link()
767
+	{
768
+		return EEH_Template::get_help_tab_link(
769
+			$this->get_help_tab_name(),
770
+			'espresso_payment_settings',
771
+			'default'
772
+		);
773
+	}
774
+
775
+
776
+	/**
777
+	 * Returns the name of the help tab for this PMT
778
+	 *
779
+	 * @return string
780
+	 */
781
+	public function get_help_tab_name()
782
+	{
783
+		return 'ee_' . strtolower($this->system_name()) . '_help_tab';
784
+	}
785
+
786
+	/**
787
+	 * The name of the wp capability that should be associated with the usage of
788
+	 * this PMT by an admin
789
+	 *
790
+	 * @return string
791
+	 */
792
+	public function cap_name()
793
+	{
794
+		return 'ee_payment_method_' . strtolower($this->system_name());
795
+	}
796
+
797
+	/**
798
+	 * Called by client code to tell the gateway that if it wants to change
799
+	 * the transaction or line items or registrations related to teh payment it already
800
+	 * processed (we think, but possibly not) that now's the time to do it.
801
+	 * It is expected that gateways will store any info they need for this on the PAY_details,
802
+	 * or maybe an extra meta value
803
+	 *
804
+	 * @param EE_Payment $payment
805
+	 * @return void
806
+	 */
807
+	public function update_txn_based_on_payment($payment)
808
+	{
809
+		if ($this->_gateway instanceof EE_Gateway) {
810
+			$this->_gateway->update_txn_based_on_payment($payment);
811
+		}
812
+	}
813
+
814
+	/**
815
+	 * Returns a string of HTML describing this payment method type for an admin,
816
+	 * primarily intended for them to read before activating it.
817
+	 * The easiest way to set this is to create a folder 'templates' alongside
818
+	 * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
819
+	 * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
820
+	 * then you'd create a file named "templates" in the same folder as it, and name the file
821
+	 * "foo_bar_intro.template.php", and its content will be returned by this method
822
+	 *
823
+	 * @return string
824
+	 */
825
+	public function introductory_html()
826
+	{
827
+		return EEH_Template::locate_template(
828
+			$this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php',
829
+			array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
830
+		);
831
+	}
832 832
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
             $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
118 118
             do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
119 119
         }
120
-        if (! isset($this->_has_billing_form)) {
120
+        if ( ! isset($this->_has_billing_form)) {
121 121
             // by default, On Site gateways have a billing form
122 122
             if ($this->payment_occurs() == EE_PMT_Base::onsite) {
123 123
                 $this->set_has_billing_form(true);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             }
127 127
         }
128 128
 
129
-        if (! $this->_pretty_name) {
129
+        if ( ! $this->_pretty_name) {
130 130
             throw new EE_Error(
131 131
                 sprintf(
132 132
                     __(
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         }
139 139
         // if the child didn't specify a default button, use the credit card one
140 140
         if ($this->_default_button_url === null) {
141
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png';
141
+            $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods/pay-by-credit-card.png';
142 142
         }
143 143
     }
144 144
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     {
160 160
         $reflector = new ReflectionClass(get_class($this));
161 161
         $fn = $reflector->getFileName();
162
-        $this->_file_folder = dirname($fn) . '/';
162
+        $this->_file_folder = dirname($fn).'/';
163 163
     }
164 164
 
165 165
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public function file_folder()
194 194
     {
195
-        if (! $this->_file_folder) {
195
+        if ( ! $this->_file_folder) {
196 196
             $this->_set_file_folder();
197 197
         }
198 198
         return $this->_file_folder;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public function file_url()
206 206
     {
207
-        if (! $this->_file_url) {
207
+        if ( ! $this->_file_url) {
208 208
             $this->_set_file_url();
209 209
         }
210 210
         return $this->_file_url;
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public function settings_form()
240 240
     {
241
-        if (! $this->_settings_form) {
241
+        if ( ! $this->_settings_form) {
242 242
             $this->_settings_form = $this->generate_new_settings_form();
243 243
             $this->_settings_form->set_payment_method_type($this);
244 244
             // if we have already assigned a model object to this pmt, make
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
     public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
293 293
     {
294 294
         // has billing form already been regenerated ? or overwrite cache?
295
-        if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
295
+        if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296 296
             $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
297 297
         }
298 298
         // if we know who the attendee is, and this is a billing form
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
             $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
395 395
             // if we didn't already have a payment in progress for the same thing,
396 396
             // then we actually want to make a new payment
397
-            if (! $payment instanceof EE_Payment) {
397
+            if ( ! $payment instanceof EE_Payment) {
398 398
                 $payment = EE_Payment::new_instance(
399 399
                     array_merge(
400 400
                         $duplicate_properties,
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
     public function handle_ipn($req_data, $transaction)
496 496
     {
497 497
         $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
498
-        if (! $this->_gateway instanceof EE_Offsite_Gateway) {
498
+        if ( ! $this->_gateway instanceof EE_Offsite_Gateway) {
499 499
             throw new EE_Error(
500 500
                 sprintf(
501 501
                     __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      */
519 519
     protected function _save_billing_info_to_attendee($billing_form, $transaction)
520 520
     {
521
-        if (! $transaction || ! $transaction instanceof EE_Transaction) {
521
+        if ( ! $transaction || ! $transaction instanceof EE_Transaction) {
522 522
             EE_Error::add_error(
523 523
                 __("Cannot save billing info because no transaction was specified", "event_espresso"),
524 524
                 __FILE__,
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
             return false;
529 529
         }
530 530
         $primary_reg = $transaction->primary_registration();
531
-        if (! $primary_reg) {
531
+        if ( ! $primary_reg) {
532 532
             EE_Error::add_error(
533 533
                 __("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
534 534
                 __FILE__,
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
             return false;
539 539
         }
540 540
         $attendee = $primary_reg->attendee();
541
-        if (! $attendee) {
541
+        if ( ! $attendee) {
542 542
             EE_Error::add_error(
543 543
                 __(
544 544
                     "Cannot save billing info because the transaction's primary registration has no attendee!",
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
      */
652 652
     public function payment_occurs()
653 653
     {
654
-        if (! $this->_gateway) {
654
+        if ( ! $this->_gateway) {
655 655
             return EE_PMT_Base::offline;
656 656
         } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
657 657
             return EE_PMT_Base::onsite;
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
     public function payment_overview_content(EE_Payment $payment)
683 683
     {
684 684
         return EEH_Template::display_template(
685
-            EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php',
685
+            EE_LIBRARIES.'payment_methods/templates/payment_details_content.template.php',
686 686
             array('payment_method' => $this->_pm_instance, 'payment' => $payment),
687 687
             true
688 688
         );
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
      */
781 781
     public function get_help_tab_name()
782 782
     {
783
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
783
+        return 'ee_'.strtolower($this->system_name()).'_help_tab';
784 784
     }
785 785
 
786 786
     /**
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
      */
792 792
     public function cap_name()
793 793
     {
794
-        return 'ee_payment_method_' . strtolower($this->system_name());
794
+        return 'ee_payment_method_'.strtolower($this->system_name());
795 795
     }
796 796
 
797 797
     /**
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     public function introductory_html()
826 826
     {
827 827
         return EEH_Template::locate_template(
828
-            $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php',
828
+            $this->file_folder().'templates/'.strtolower($this->system_name()).'_intro.template.php',
829 829
             array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
830 830
         );
831 831
     }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_9_0.dms.php 1 patch
Indentation   +304 added lines, -304 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
16 16
 $class_to_filepath = array();
17 17
 foreach ($stages as $filepath) {
18
-    $matches = array();
19
-    preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-    $class_to_filepath[ $matches[1] ] = $filepath;
18
+	$matches = array();
19
+	preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
+	$class_to_filepath[ $matches[1] ] = $filepath;
21 21
 }
22 22
 // give addons a chance to autoload their stages too
23 23
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
@@ -36,68 +36,68 @@  discard block
 block discarded – undo
36 36
 class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base
37 37
 {
38 38
 
39
-    /**
40
-     * return EE_DMS_Core_4_9_0
41
-     *
42
-     * @param TableManager  $table_manager
43
-     * @param TableAnalysis $table_analysis
44
-     */
45
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
46
-    {
47
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
48
-        $this->_priority = 10;
49
-        $this->_migration_stages = array(
50
-            new EE_DMS_4_9_0_Email_System_Question(),
51
-            new EE_DMS_4_9_0_Answers_With_No_Registration(),
52
-        );
53
-        parent::__construct($table_manager, $table_analysis);
54
-    }
39
+	/**
40
+	 * return EE_DMS_Core_4_9_0
41
+	 *
42
+	 * @param TableManager  $table_manager
43
+	 * @param TableAnalysis $table_analysis
44
+	 */
45
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
46
+	{
47
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
48
+		$this->_priority = 10;
49
+		$this->_migration_stages = array(
50
+			new EE_DMS_4_9_0_Email_System_Question(),
51
+			new EE_DMS_4_9_0_Answers_With_No_Registration(),
52
+		);
53
+		parent::__construct($table_manager, $table_analysis);
54
+	}
55 55
 
56 56
 
57 57
 
58
-    /**
59
-     * Whether to migrate or not.
60
-     *
61
-     * @param array $version_array
62
-     * @return bool
63
-     */
64
-    public function can_migrate_from_version($version_array)
65
-    {
66
-        $version_string = $version_array['Core'];
67
-        if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) {
68
-            //          echo "$version_string can be migrated from";
69
-            return true;
70
-        } elseif (! $version_string) {
71
-            //          echo "no version string provided: $version_string";
72
-            // no version string provided... this must be pre 4.3
73
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
74
-        } else {
75
-            //          echo "$version_string doesnt apply";
76
-            return false;
77
-        }
78
-    }
58
+	/**
59
+	 * Whether to migrate or not.
60
+	 *
61
+	 * @param array $version_array
62
+	 * @return bool
63
+	 */
64
+	public function can_migrate_from_version($version_array)
65
+	{
66
+		$version_string = $version_array['Core'];
67
+		if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) {
68
+			//          echo "$version_string can be migrated from";
69
+			return true;
70
+		} elseif (! $version_string) {
71
+			//          echo "no version string provided: $version_string";
72
+			// no version string provided... this must be pre 4.3
73
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
74
+		} else {
75
+			//          echo "$version_string doesnt apply";
76
+			return false;
77
+		}
78
+	}
79 79
 
80 80
 
81 81
 
82
-    /**
83
-     * @return bool
84
-     */
85
-    public function schema_changes_before_migration()
86
-    {
87
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
88
-        $now_in_mysql = current_time('mysql', true);
89
-        $table_name = 'esp_answer';
90
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
82
+	/**
83
+	 * @return bool
84
+	 */
85
+	public function schema_changes_before_migration()
86
+	{
87
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
88
+		$now_in_mysql = current_time('mysql', true);
89
+		$table_name = 'esp_answer';
90
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
91 91
 					REG_ID int(10) unsigned NOT NULL,
92 92
 					QST_ID int(10) unsigned NOT NULL,
93 93
 					ANS_value text NOT NULL,
94 94
 					PRIMARY KEY  (ANS_ID),
95 95
 					KEY REG_ID (REG_ID),
96 96
 					KEY QST_ID (QST_ID)";
97
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
98
-        $table_name = 'esp_attendee_meta';
99
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
100
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
97
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
98
+		$table_name = 'esp_attendee_meta';
99
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
100
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
101 101
 				ATT_ID bigint(20) unsigned NOT NULL,
102 102
 				ATT_fname varchar(45) NOT NULL,
103 103
 				ATT_lname varchar(45) NOT NULL,
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
 				KEY ATT_email (ATT_email(191)),
115 115
 				KEY ATT_lname (ATT_lname),
116 116
 				KEY ATT_fname (ATT_fname)";
117
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
118
-        $table_name = 'esp_checkin';
119
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
117
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
118
+		$table_name = 'esp_checkin';
119
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
120 120
 				REG_ID int(10) unsigned NOT NULL,
121 121
 				DTT_ID int(10) unsigned NOT NULL,
122 122
 				CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				PRIMARY KEY  (CHK_ID),
125 125
 				KEY REG_ID (REG_ID),
126 126
 				KEY DTT_ID (DTT_ID)";
127
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
128
-        $table_name = 'esp_country';
129
-        $sql = "CNT_ISO varchar(2) NOT NULL,
127
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
128
+		$table_name = 'esp_country';
129
+		$sql = "CNT_ISO varchar(2) NOT NULL,
130 130
 				CNT_ISO3 varchar(3) NOT NULL,
131 131
 				RGN_ID tinyint(3) unsigned DEFAULT NULL,
132 132
 				CNT_name varchar(45) NOT NULL,
@@ -142,29 +142,29 @@  discard block
 block discarded – undo
142 142
 				CNT_is_EU tinyint(1) DEFAULT '0',
143 143
 				CNT_active tinyint(1) DEFAULT '0',
144 144
 				PRIMARY KEY  (CNT_ISO)";
145
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
146
-        $table_name = 'esp_currency';
147
-        $sql = "CUR_code varchar(6) NOT NULL,
145
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
146
+		$table_name = 'esp_currency';
147
+		$sql = "CUR_code varchar(6) NOT NULL,
148 148
 				CUR_single varchar(45) DEFAULT 'dollar',
149 149
 				CUR_plural varchar(45) DEFAULT 'dollars',
150 150
 				CUR_sign varchar(45) DEFAULT '$',
151 151
 				CUR_dec_plc varchar(1) NOT NULL DEFAULT '2',
152 152
 				CUR_active tinyint(1) DEFAULT '0',
153 153
 				PRIMARY KEY  (CUR_code)";
154
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
155
-        // note: although this table is no longer in use,
156
-        // it hasn't been removed because then queries to the model will have errors.
157
-        // but you should expect this table and its corresponding model to be removed in
158
-        // the next few months
159
-        $table_name = 'esp_currency_payment_method';
160
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
154
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
155
+		// note: although this table is no longer in use,
156
+		// it hasn't been removed because then queries to the model will have errors.
157
+		// but you should expect this table and its corresponding model to be removed in
158
+		// the next few months
159
+		$table_name = 'esp_currency_payment_method';
160
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
161 161
 				CUR_code varchar(6) NOT NULL,
162 162
 				PMD_ID int(11) NOT NULL,
163 163
 				PRIMARY KEY  (CPM_ID),
164 164
 				KEY PMD_ID (PMD_ID)";
165
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
166
-        $table_name = 'esp_datetime';
167
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
165
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
166
+		$table_name = 'esp_datetime';
167
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
168 168
 				EVT_ID bigint(20) unsigned NOT NULL,
169 169
 				DTT_name varchar(255) NOT NULL DEFAULT '',
170 170
 				DTT_description text NOT NULL,
@@ -181,25 +181,25 @@  discard block
 block discarded – undo
181 181
 				KEY DTT_EVT_start (DTT_EVT_start),
182 182
 				KEY EVT_ID (EVT_ID),
183 183
 				KEY DTT_is_primary (DTT_is_primary)";
184
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
185
-        $table_name = "esp_datetime_ticket";
186
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
184
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
185
+		$table_name = "esp_datetime_ticket";
186
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
187 187
 				DTT_ID int(10) unsigned NOT NULL,
188 188
 				TKT_ID int(10) unsigned NOT NULL,
189 189
 				PRIMARY KEY  (DTK_ID),
190 190
 				KEY DTT_ID (DTT_ID),
191 191
 				KEY TKT_ID (TKT_ID)";
192
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
193
-        $table_name = 'esp_event_message_template';
194
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
192
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
193
+		$table_name = 'esp_event_message_template';
194
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
195 195
 				EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
196 196
 				GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
197 197
 				PRIMARY KEY  (EMT_ID),
198 198
 				KEY EVT_ID (EVT_ID),
199 199
 				KEY GRP_ID (GRP_ID)";
200
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
201
-        $table_name = 'esp_event_meta';
202
-        $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
200
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
201
+		$table_name = 'esp_event_meta';
202
+		$sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
203 203
 				EVT_ID bigint(20) unsigned NOT NULL,
204 204
 				EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
205 205
 				EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -214,34 +214,34 @@  discard block
 block discarded – undo
214 214
 				EVT_donations tinyint(1) NULL,
215 215
 				PRIMARY KEY  (EVTM_ID),
216 216
 				KEY EVT_ID (EVT_ID)";
217
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
218
-        $table_name = 'esp_event_question_group';
219
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
217
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
218
+		$table_name = 'esp_event_question_group';
219
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
220 220
 				EVT_ID bigint(20) unsigned NOT NULL,
221 221
 				QSG_ID int(10) unsigned NOT NULL,
222 222
 				EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
223 223
 				PRIMARY KEY  (EQG_ID),
224 224
 				KEY EVT_ID (EVT_ID),
225 225
 				KEY QSG_ID (QSG_ID)";
226
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
227
-        $table_name = 'esp_event_venue';
228
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
226
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
227
+		$table_name = 'esp_event_venue';
228
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
229 229
 				EVT_ID bigint(20) unsigned NOT NULL,
230 230
 				VNU_ID bigint(20) unsigned NOT NULL,
231 231
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
232 232
 				PRIMARY KEY  (EVV_ID)";
233
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
234
-        $table_name = 'esp_extra_meta';
235
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
233
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
234
+		$table_name = 'esp_extra_meta';
235
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
236 236
 				OBJ_ID int(11) DEFAULT NULL,
237 237
 				EXM_type varchar(45) DEFAULT NULL,
238 238
 				EXM_key varchar(45) DEFAULT NULL,
239 239
 				EXM_value text,
240 240
 				PRIMARY KEY  (EXM_ID),
241 241
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
242
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
243
-        $table_name = 'esp_extra_join';
244
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
242
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
243
+		$table_name = 'esp_extra_join';
244
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
245 245
 				EXJ_first_model_id varchar(6) NOT NULL,
246 246
 				EXJ_first_model_name varchar(20) NOT NULL,
247 247
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 				PRIMARY KEY  (EXJ_ID),
250 250
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
251 251
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
252
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
253
-        $table_name = 'esp_line_item';
254
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
252
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
253
+		$table_name = 'esp_line_item';
254
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
255 255
 				LIN_code varchar(245) NOT NULL DEFAULT '',
256 256
 				TXN_ID int(11) DEFAULT NULL,
257 257
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 				KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp),
273 273
 				KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type),
274 274
 				KEY obj_id_obj_type (OBJ_ID,OBJ_type)";
275
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
276
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
277
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
278
-        $table_name = 'esp_log';
279
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
275
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
276
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
277
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
278
+		$table_name = 'esp_log';
279
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
280 280
 				LOG_time datetime DEFAULT NULL,
281 281
 				OBJ_ID varchar(45) DEFAULT NULL,
282 282
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -287,12 +287,12 @@  discard block
 block discarded – undo
287 287
 				KEY LOG_time (LOG_time),
288 288
 				KEY OBJ (OBJ_type,OBJ_ID),
289 289
 				KEY LOG_type (LOG_type)";
290
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
-        $table_name = 'esp_message';
292
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
293
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
294
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
295
-        $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
290
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
291
+		$table_name = 'esp_message';
292
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
293
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
294
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
295
+		$sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
296 296
 				GRP_ID int(10) unsigned NULL,
297 297
 				MSG_token varchar(255) NULL,
298 298
 				TXN_ID int(10) unsigned NULL,
@@ -324,18 +324,18 @@  discard block
 block discarded – undo
324 324
 				KEY STS_ID (STS_ID),
325 325
 				KEY MSG_created (MSG_created),
326 326
 				KEY MSG_modified (MSG_modified)";
327
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
328
-        $table_name = 'esp_message_template';
329
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
327
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
328
+		$table_name = 'esp_message_template';
329
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
330 330
 				GRP_ID int(10) unsigned NOT NULL,
331 331
 				MTP_context varchar(50) NOT NULL,
332 332
 				MTP_template_field varchar(30) NOT NULL,
333 333
 				MTP_content text NOT NULL,
334 334
 				PRIMARY KEY  (MTP_ID),
335 335
 				KEY GRP_ID (GRP_ID)";
336
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
337
-        $table_name = 'esp_message_template_group';
338
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
336
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
337
+		$table_name = 'esp_message_template_group';
338
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
339 339
 				MTP_user_id int(10) NOT NULL DEFAULT '1',
340 340
 				MTP_name varchar(245) NOT NULL DEFAULT '',
341 341
 				MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 				MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
348 348
 				PRIMARY KEY  (GRP_ID),
349 349
 				KEY MTP_user_id (MTP_user_id)";
350
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
-        $table_name = 'esp_payment';
352
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
350
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
351
+		$table_name = 'esp_payment';
352
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
353 353
 				TXN_ID int(10) unsigned DEFAULT NULL,
354 354
 				STS_ID varchar(3) DEFAULT NULL,
355 355
 				PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 				PRIMARY KEY  (PAY_ID),
367 367
 				KEY PAY_timestamp (PAY_timestamp),
368 368
 				KEY TXN_ID (TXN_ID)";
369
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
370
-        $table_name = 'esp_payment_method';
371
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
369
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
370
+		$table_name = 'esp_payment_method';
371
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
372 372
 				PMD_type varchar(124) DEFAULT NULL,
373 373
 				PMD_name varchar(255) DEFAULT NULL,
374 374
 				PMD_desc text,
@@ -384,24 +384,24 @@  discard block
 block discarded – undo
384 384
 				PRIMARY KEY  (PMD_ID),
385 385
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
386 386
 				KEY PMD_type (PMD_type)";
387
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
388
-        $table_name = "esp_ticket_price";
389
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
387
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
388
+		$table_name = "esp_ticket_price";
389
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
390 390
 				TKT_ID int(10) unsigned NOT NULL,
391 391
 				PRC_ID int(10) unsigned NOT NULL,
392 392
 				PRIMARY KEY  (TKP_ID),
393 393
 				KEY TKT_ID (TKT_ID),
394 394
 				KEY PRC_ID (PRC_ID)";
395
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
396
-        $table_name = "esp_ticket_template";
397
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
395
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
396
+		$table_name = "esp_ticket_template";
397
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
398 398
 				TTM_name varchar(45) NOT NULL,
399 399
 				TTM_description text,
400 400
 				TTM_file varchar(45),
401 401
 				PRIMARY KEY  (TTM_ID)";
402
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
403
-        $table_name = 'esp_question';
404
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
402
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
403
+		$table_name = 'esp_question';
404
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
405 405
 				QST_display_text text NOT NULL,
406 406
 				QST_admin_label varchar(255) NOT NULL,
407 407
 				QST_system varchar(25) DEFAULT NULL,
@@ -415,18 +415,18 @@  discard block
 block discarded – undo
415 415
 				QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
416 416
 				PRIMARY KEY  (QST_ID),
417 417
 				KEY QST_order (QST_order)';
418
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
419
-        $table_name = 'esp_question_group_question';
420
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
418
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
419
+		$table_name = 'esp_question_group_question';
420
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
421 421
 				QSG_ID int(10) unsigned NOT NULL,
422 422
 				QST_ID int(10) unsigned NOT NULL,
423 423
 				QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
424 424
 				PRIMARY KEY  (QGQ_ID),
425 425
 				KEY QST_ID (QST_ID),
426 426
 				KEY QSG_ID_order (QSG_ID,QGQ_order)";
427
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
428
-        $table_name = 'esp_question_option';
429
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
427
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
428
+		$table_name = 'esp_question_option';
429
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
430 430
 				QSO_value varchar(255) NOT NULL,
431 431
 				QSO_desc text NOT NULL,
432 432
 				QST_ID int(10) unsigned NOT NULL,
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 				PRIMARY KEY  (QSO_ID),
437 437
 				KEY QST_ID (QST_ID),
438 438
 				KEY QSO_order (QSO_order)";
439
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
440
-        $table_name = 'esp_registration';
441
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
439
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
440
+		$table_name = 'esp_registration';
441
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
442 442
 				EVT_ID bigint(20) unsigned NOT NULL,
443 443
 				ATT_ID bigint(20) unsigned NOT NULL,
444 444
 				TXN_ID int(10) unsigned NOT NULL,
@@ -462,18 +462,18 @@  discard block
 block discarded – undo
462 462
 				KEY TKT_ID (TKT_ID),
463 463
 				KEY EVT_ID (EVT_ID),
464 464
 				KEY STS_ID (STS_ID)";
465
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
466
-        $table_name = 'esp_registration_payment';
467
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
465
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
466
+		$table_name = 'esp_registration_payment';
467
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
468 468
 					  REG_ID int(10) unsigned NOT NULL,
469 469
 					  PAY_ID int(10) unsigned NULL,
470 470
 					  RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00',
471 471
 					  PRIMARY KEY  (RPY_ID),
472 472
 					  KEY REG_ID (REG_ID),
473 473
 					  KEY PAY_ID (PAY_ID)";
474
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
475
-        $table_name = 'esp_state';
476
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
474
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
475
+		$table_name = 'esp_state';
476
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
477 477
 				CNT_ISO varchar(2) NOT NULL,
478 478
 				STA_abbrev varchar(24) NOT NULL,
479 479
 				STA_name varchar(100) NOT NULL,
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
 				PRIMARY KEY  (STA_ID),
482 482
 				KEY STA_abbrev (STA_abbrev),
483 483
 				KEY CNT_ISO (CNT_ISO)";
484
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
485
-        $table_name = 'esp_status';
486
-        $sql = "STS_ID varchar(3) NOT NULL,
484
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
485
+		$table_name = 'esp_status';
486
+		$sql = "STS_ID varchar(3) NOT NULL,
487 487
 				STS_code varchar(45) NOT NULL,
488 488
 				STS_type varchar(45) NOT NULL,
489 489
 				STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 				STS_open tinyint(1) NOT NULL DEFAULT 1,
492 492
 				UNIQUE KEY STS_ID_UNIQUE (STS_ID),
493 493
 				KEY STS_type (STS_type)";
494
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
495
-        $table_name = 'esp_transaction';
496
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
494
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
495
+		$table_name = 'esp_transaction';
496
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
497 497
 				TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
498 498
 				TXN_total decimal(12,3) DEFAULT '0.00',
499 499
 				TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00',
@@ -505,9 +505,9 @@  discard block
 block discarded – undo
505 505
 				PRIMARY KEY  (TXN_ID),
506 506
 				KEY TXN_timestamp (TXN_timestamp),
507 507
 				KEY STS_ID (STS_ID)";
508
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
509
-        $table_name = 'esp_venue_meta';
510
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
508
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
509
+		$table_name = 'esp_venue_meta';
510
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
511 511
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
512 512
 			VNU_address varchar(255) DEFAULT NULL,
513 513
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -526,10 +526,10 @@  discard block
 block discarded – undo
526 526
 			KEY VNU_ID (VNU_ID),
527 527
 			KEY STA_ID (STA_ID),
528 528
 			KEY CNT_ISO (CNT_ISO)";
529
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
530
-        // modified tables
531
-        $table_name = "esp_price";
532
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
529
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
530
+		// modified tables
531
+		$table_name = "esp_price";
532
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
533 533
 				PRT_ID tinyint(3) unsigned NOT NULL,
534 534
 				PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00',
535 535
 				PRC_name varchar(245) NOT NULL,
@@ -542,9 +542,9 @@  discard block
 block discarded – undo
542 542
 				PRC_parent int(10) unsigned DEFAULT 0,
543 543
 				PRIMARY KEY  (PRC_ID),
544 544
 				KEY PRT_ID (PRT_ID)";
545
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
546
-        $table_name = "esp_price_type";
547
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
545
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
546
+		$table_name = "esp_price_type";
547
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
548 548
 				PRT_name varchar(45) NOT NULL,
549 549
 				PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
550 550
 				PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -553,9 +553,9 @@  discard block
 block discarded – undo
553 553
 				PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
554 554
 				UNIQUE KEY PRT_name_UNIQUE (PRT_name),
555 555
 				PRIMARY KEY  (PRT_ID)";
556
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
557
-        $table_name = "esp_ticket";
558
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
556
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
557
+		$table_name = "esp_ticket";
558
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
559 559
 				TTM_ID int(10) unsigned NOT NULL,
560 560
 				TKT_name varchar(245) NOT NULL DEFAULT '',
561 561
 				TKT_description text NOT NULL,
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
 				TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
579 579
 				PRIMARY KEY  (TKT_ID),
580 580
 				KEY TKT_start_date (TKT_start_date)";
581
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
582
-        $table_name = 'esp_question_group';
583
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
581
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
582
+		$table_name = 'esp_question_group';
583
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
584 584
 				QSG_name varchar(255) NOT NULL,
585 585
 				QSG_identifier varchar(100) NOT NULL,
586 586
 				QSG_desc text NULL,
@@ -593,159 +593,159 @@  discard block
 block discarded – undo
593 593
 				PRIMARY KEY  (QSG_ID),
594 594
 				UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
595 595
 				KEY QSG_order (QSG_order)';
596
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
597
-        $this->insert_default_data();
598
-        return true;
599
-    }
596
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
597
+		$this->insert_default_data();
598
+		return true;
599
+	}
600 600
 
601
-    /**
602
-     * Inserts default data after parent was called.
603
-     * @since 4.10.0.p
604
-     * @throws EE_Error
605
-     * @throws InvalidArgumentException
606
-     * @throws ReflectionException
607
-     * @throws InvalidDataTypeException
608
-     * @throws InvalidInterfaceException
609
-     */
610
-    public function insert_default_data()
611
-    {
612
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
613
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
614
-        // (because many need to convert old string states to foreign keys into the states table)
615
-        $script_4_1_defaults->insert_default_states();
616
-        $script_4_1_defaults->insert_default_countries();
617
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
618
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
619
-        $script_4_5_defaults->insert_default_price_types();
620
-        $script_4_5_defaults->insert_default_prices();
621
-        $script_4_5_defaults->insert_default_tickets();
622
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
623
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
624
-        $script_4_6_defaults->add_default_admin_only_payments();
625
-        $script_4_6_defaults->insert_default_currencies();
626
-        /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
627
-        $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
628
-        $script_4_8_defaults->verify_new_countries();
629
-        $script_4_8_defaults->verify_new_currencies();
630
-        $this->verify_db_collations();
631
-        $this->verify_db_collations_again();
632
-    }
601
+	/**
602
+	 * Inserts default data after parent was called.
603
+	 * @since 4.10.0.p
604
+	 * @throws EE_Error
605
+	 * @throws InvalidArgumentException
606
+	 * @throws ReflectionException
607
+	 * @throws InvalidDataTypeException
608
+	 * @throws InvalidInterfaceException
609
+	 */
610
+	public function insert_default_data()
611
+	{
612
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
613
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
614
+		// (because many need to convert old string states to foreign keys into the states table)
615
+		$script_4_1_defaults->insert_default_states();
616
+		$script_4_1_defaults->insert_default_countries();
617
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
618
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
619
+		$script_4_5_defaults->insert_default_price_types();
620
+		$script_4_5_defaults->insert_default_prices();
621
+		$script_4_5_defaults->insert_default_tickets();
622
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
623
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
624
+		$script_4_6_defaults->add_default_admin_only_payments();
625
+		$script_4_6_defaults->insert_default_currencies();
626
+		/** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
627
+		$script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
628
+		$script_4_8_defaults->verify_new_countries();
629
+		$script_4_8_defaults->verify_new_currencies();
630
+		$this->verify_db_collations();
631
+		$this->verify_db_collations_again();
632
+	}
633 633
 
634 634
 
635 635
 
636
-    /**
637
-     * @return boolean
638
-     */
639
-    public function schema_changes_after_migration()
640
-    {
641
-        return true;
642
-    }
636
+	/**
637
+	 * @return boolean
638
+	 */
639
+	public function schema_changes_after_migration()
640
+	{
641
+		return true;
642
+	}
643 643
 
644 644
 
645 645
 
646
-    public function migration_page_hooks()
647
-    {
648
-    }
646
+	public function migration_page_hooks()
647
+	{
648
+	}
649 649
 
650 650
 
651 651
 
652
-    /**
653
-     * Verify all EE4 models' tables use utf8mb4 collation
654
-     *
655
-     * @return void
656
-     */
657
-    public function verify_db_collations()
658
-    {
659
-        global $wpdb;
660
-        // double-check we haven't already done it or that that the DB doesn't support utf8mb4
661
-        if ('utf8mb4' !== $wpdb->charset
662
-            || get_option('ee_verified_db_collations', false)) {
663
-            return;
664
-        }
665
-        // grab tables from each model
666
-        $tables_to_check = array();
667
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
668
-            if (method_exists($model_name, 'instance')) {
669
-                $model_obj = call_user_func(array($model_name, 'instance'));
670
-                if ($model_obj instanceof EEM_Base) {
671
-                    foreach ($model_obj->get_tables() as $table) {
672
-                        if (strpos($table->get_table_name(), 'esp_')
673
-                            && (is_main_site()// for main tables, verify global tables
674
-                                || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
675
-                            )
676
-                            && function_exists('maybe_convert_table_to_utf8mb4')
677
-                        ) {
678
-                            $tables_to_check[] = $table->get_table_name();
679
-                        }
680
-                    }
681
-                }
682
-            }
683
-        }
684
-        // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
685
-        // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
686
-        // of hard-coding this
687
-        $addon_tables = array(
688
-            // mailchimp
689
-            'esp_event_mailchimp_list_group',
690
-            'esp_event_question_mailchimp_field',
691
-            // multisite
692
-            'esp_blog_meta',
693
-            // people
694
-            'esp_people_to_post',
695
-            // promotions
696
-            'esp_promotion',
697
-            'esp_promotion_object',
698
-        );
699
-        foreach ($addon_tables as $table_name) {
700
-                $tables_to_check[] = $table_name;
701
-        }
702
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
703
-        // ok and now let's remember this was done (without needing to check the db schemas all over again)
704
-        add_option('ee_verified_db_collations', true, null, 'no');
705
-        // seeing how this ran with the fix from 10435, no need to check again
706
-        add_option('ee_verified_db_collations_again', true, null, 'no');
707
-    }
652
+	/**
653
+	 * Verify all EE4 models' tables use utf8mb4 collation
654
+	 *
655
+	 * @return void
656
+	 */
657
+	public function verify_db_collations()
658
+	{
659
+		global $wpdb;
660
+		// double-check we haven't already done it or that that the DB doesn't support utf8mb4
661
+		if ('utf8mb4' !== $wpdb->charset
662
+			|| get_option('ee_verified_db_collations', false)) {
663
+			return;
664
+		}
665
+		// grab tables from each model
666
+		$tables_to_check = array();
667
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
668
+			if (method_exists($model_name, 'instance')) {
669
+				$model_obj = call_user_func(array($model_name, 'instance'));
670
+				if ($model_obj instanceof EEM_Base) {
671
+					foreach ($model_obj->get_tables() as $table) {
672
+						if (strpos($table->get_table_name(), 'esp_')
673
+							&& (is_main_site()// for main tables, verify global tables
674
+								|| ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
675
+							)
676
+							&& function_exists('maybe_convert_table_to_utf8mb4')
677
+						) {
678
+							$tables_to_check[] = $table->get_table_name();
679
+						}
680
+					}
681
+				}
682
+			}
683
+		}
684
+		// and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
685
+		// when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
686
+		// of hard-coding this
687
+		$addon_tables = array(
688
+			// mailchimp
689
+			'esp_event_mailchimp_list_group',
690
+			'esp_event_question_mailchimp_field',
691
+			// multisite
692
+			'esp_blog_meta',
693
+			// people
694
+			'esp_people_to_post',
695
+			// promotions
696
+			'esp_promotion',
697
+			'esp_promotion_object',
698
+		);
699
+		foreach ($addon_tables as $table_name) {
700
+				$tables_to_check[] = $table_name;
701
+		}
702
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
703
+		// ok and now let's remember this was done (without needing to check the db schemas all over again)
704
+		add_option('ee_verified_db_collations', true, null, 'no');
705
+		// seeing how this ran with the fix from 10435, no need to check again
706
+		add_option('ee_verified_db_collations_again', true, null, 'no');
707
+	}
708 708
 
709 709
 
710 710
 
711
-    /**
712
-     * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
713
-     * which meant some DB collations might not have been updated
714
-     * @return void
715
-     */
716
-    public function verify_db_collations_again()
717
-    {
718
-        global $wpdb;
719
-        // double-check we haven't already done this or that the DB doesn't support it
720
-        // compare to how WordPress' upgrade_430() function does this check
721
-        if ('utf8mb4' !== $wpdb->charset
722
-            || get_option('ee_verified_db_collations_again', false)) {
723
-            return;
724
-        }
725
-        $tables_to_check = array(
726
-            'esp_attendee_meta',
727
-            'esp_message'
728
-        );
729
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
730
-        add_option('ee_verified_db_collations_again', true, null, 'no');
731
-    }
711
+	/**
712
+	 * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
713
+	 * which meant some DB collations might not have been updated
714
+	 * @return void
715
+	 */
716
+	public function verify_db_collations_again()
717
+	{
718
+		global $wpdb;
719
+		// double-check we haven't already done this or that the DB doesn't support it
720
+		// compare to how WordPress' upgrade_430() function does this check
721
+		if ('utf8mb4' !== $wpdb->charset
722
+			|| get_option('ee_verified_db_collations_again', false)) {
723
+			return;
724
+		}
725
+		$tables_to_check = array(
726
+			'esp_attendee_meta',
727
+			'esp_message'
728
+		);
729
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
730
+		add_option('ee_verified_db_collations_again', true, null, 'no');
731
+	}
732 732
 
733 733
 
734 734
 
735
-    /**
736
-     * Runs maybe_convert_table_to_utf8mb4 on the specified tables
737
-     * @param $tables_to_check
738
-     * @return boolean true if logic ran, false if it didn't
739
-     */
740
-    protected function _verify_db_collations_for_tables($tables_to_check)
741
-    {
742
-        foreach ($tables_to_check as $table_name) {
743
-            $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
744
-            if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
745
-                && $this->_get_table_analysis()->tableExists($table_name)
746
-            ) {
747
-                maybe_convert_table_to_utf8mb4($table_name);
748
-            }
749
-        }
750
-    }
735
+	/**
736
+	 * Runs maybe_convert_table_to_utf8mb4 on the specified tables
737
+	 * @param $tables_to_check
738
+	 * @return boolean true if logic ran, false if it didn't
739
+	 */
740
+	protected function _verify_db_collations_for_tables($tables_to_check)
741
+	{
742
+		foreach ($tables_to_check as $table_name) {
743
+			$table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
744
+			if (! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
745
+				&& $this->_get_table_analysis()->tableExists($table_name)
746
+			) {
747
+				maybe_convert_table_to_utf8mb4($table_name);
748
+			}
749
+		}
750
+	}
751 751
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.1.rc.003');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.1.rc.003');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.