Completed
Branch update-venue-ui (4b9c7e)
by
unknown
02:27
created
admin_pages/events/Events_Admin_Page_Init.core.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -14,42 +14,42 @@
 block discarded – undo
14 14
 class Events_Admin_Page_Init extends EE_Admin_Page_CPT_Init
15 15
 {
16 16
 
17
-    public function __construct()
18
-    {
19
-        /**
20
-         * define some events related constants but only if not defined (need to check because unit tests
21
-         *  may load)
22
-         */
23
-        if (! defined('EVENTS_PG_SLUG')) {
24
-            define('EVENTS_PG_SLUG', 'espresso_events');
25
-            define('EVENTS_LABEL', __('Events', 'event_espresso'));
26
-            define('EVENTS_ADMIN', EE_ADMIN_PAGES . 'events/');
27
-            define('EVENTS_ADMIN_URL', admin_url('admin.php?page=' . EVENTS_PG_SLUG));
28
-            define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN . 'templates/');
29
-            define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'events/assets/');
30
-        }
31
-        parent::__construct();
32
-    }
17
+	public function __construct()
18
+	{
19
+		/**
20
+		 * define some events related constants but only if not defined (need to check because unit tests
21
+		 *  may load)
22
+		 */
23
+		if (! defined('EVENTS_PG_SLUG')) {
24
+			define('EVENTS_PG_SLUG', 'espresso_events');
25
+			define('EVENTS_LABEL', __('Events', 'event_espresso'));
26
+			define('EVENTS_ADMIN', EE_ADMIN_PAGES . 'events/');
27
+			define('EVENTS_ADMIN_URL', admin_url('admin.php?page=' . EVENTS_PG_SLUG));
28
+			define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN . 'templates/');
29
+			define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'events/assets/');
30
+		}
31
+		parent::__construct();
32
+	}
33 33
 
34
-    protected function _set_init_properties()
35
-    {
36
-        $this->label = __('Event Espresso - Event Details', 'event_espresso');
37
-    }
34
+	protected function _set_init_properties()
35
+	{
36
+		$this->label = __('Event Espresso - Event Details', 'event_espresso');
37
+	}
38 38
 
39
-    protected function _set_menu_map()
40
-    {
41
-        $this->_menu_map = new EE_Admin_Page_Main_Menu(
42
-            array(
43
-                'menu_group'      => 'main',
44
-                'menu_order'      => 10,
45
-                'subtitle'        => __('Events', 'event_espresso'),
46
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
47
-                'parent_slug'     => 'espresso_events',
48
-                'menu_slug'       => 'espresso_events',
49
-                'menu_label'      => __('Event Espresso', 'event_espresso'),
50
-                'capability'      => 'ee_read_events',
51
-                'admin_init_page' => $this,
52
-            )
53
-        );
54
-    }
39
+	protected function _set_menu_map()
40
+	{
41
+		$this->_menu_map = new EE_Admin_Page_Main_Menu(
42
+			array(
43
+				'menu_group'      => 'main',
44
+				'menu_order'      => 10,
45
+				'subtitle'        => __('Events', 'event_espresso'),
46
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
47
+				'parent_slug'     => 'espresso_events',
48
+				'menu_slug'       => 'espresso_events',
49
+				'menu_label'      => __('Event Espresso', 'event_espresso'),
50
+				'capability'      => 'ee_read_events',
51
+				'admin_init_page' => $this,
52
+			)
53
+		);
54
+	}
55 55
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
          * define some events related constants but only if not defined (need to check because unit tests
21 21
          *  may load)
22 22
          */
23
-        if (! defined('EVENTS_PG_SLUG')) {
23
+        if ( ! defined('EVENTS_PG_SLUG')) {
24 24
             define('EVENTS_PG_SLUG', 'espresso_events');
25 25
             define('EVENTS_LABEL', __('Events', 'event_espresso'));
26
-            define('EVENTS_ADMIN', EE_ADMIN_PAGES . 'events/');
27
-            define('EVENTS_ADMIN_URL', admin_url('admin.php?page=' . EVENTS_PG_SLUG));
28
-            define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN . 'templates/');
29
-            define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'events/assets/');
26
+            define('EVENTS_ADMIN', EE_ADMIN_PAGES.'events/');
27
+            define('EVENTS_ADMIN_URL', admin_url('admin.php?page='.EVENTS_PG_SLUG));
28
+            define('EVENTS_TEMPLATE_PATH', EVENTS_ADMIN.'templates/');
29
+            define('EVENTS_ASSETS_URL', EE_ADMIN_PAGES_URL.'events/assets/');
30 30
         }
31 31
         parent::__construct();
32 32
     }
Please login to merge, or discard this patch.
admin_pages/venues/Venues_Admin_Page_Init.core.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -17,39 +17,39 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    public function __construct()
21
-    {
22
-        // define some event categories related constants
23
-        define('EE_VENUES_PG_SLUG', 'espresso_venues');
24
-        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
25
-        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
26
-        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
20
+	public function __construct()
21
+	{
22
+		// define some event categories related constants
23
+		define('EE_VENUES_PG_SLUG', 'espresso_venues');
24
+		define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
25
+		define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
26
+		define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
27 27
 
28
-        parent::__construct();
29
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
30
-    }
28
+		parent::__construct();
29
+		$this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
30
+	}
31 31
 
32
-    protected function _set_init_properties()
33
-    {
34
-        $this->label = __('Event Venues', 'event_espresso');
35
-        $this->menu_label = __('Venues', 'event_espresso');
36
-        $this->menu_slug = EE_VENUES_PG_SLUG;
37
-    }
32
+	protected function _set_init_properties()
33
+	{
34
+		$this->label = __('Event Venues', 'event_espresso');
35
+		$this->menu_label = __('Venues', 'event_espresso');
36
+		$this->menu_slug = EE_VENUES_PG_SLUG;
37
+	}
38 38
 
39 39
 
40
-    protected function _set_menu_map()
41
-    {
42
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
43
-            array(
44
-                'menu_group'      => 'management',
45
-                'menu_order'      => 40,
46
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
47
-                'parent_slug'     => 'espresso_events',
48
-                'menu_slug'       => EE_VENUES_PG_SLUG,
49
-                'menu_label'      => __('Venues', 'event_espresso'),
50
-                'capability'      => 'ee_read_venues',
51
-                'admin_init_page' => $this,
52
-            )
53
-        );
54
-    }
40
+	protected function _set_menu_map()
41
+	{
42
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
43
+			array(
44
+				'menu_group'      => 'management',
45
+				'menu_order'      => 40,
46
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
47
+				'parent_slug'     => 'espresso_events',
48
+				'menu_slug'       => EE_VENUES_PG_SLUG,
49
+				'menu_label'      => __('Venues', 'event_espresso'),
50
+				'capability'      => 'ee_read_venues',
51
+				'admin_init_page' => $this,
52
+			)
53
+		);
54
+	}
55 55
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
     {
22 22
         // define some event categories related constants
23 23
         define('EE_VENUES_PG_SLUG', 'espresso_venues');
24
-        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page=' . EE_VENUES_PG_SLUG));
25
-        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL . 'venues/assets/');
26
-        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES . 'venues/templates/');
24
+        define('EE_VENUES_ADMIN_URL', admin_url('admin.php?page='.EE_VENUES_PG_SLUG));
25
+        define('EE_VENUES_ASSETS_URL', EE_ADMIN_PAGES_URL.'venues/assets/');
26
+        define('EE_VENUES_TEMPLATE_PATH', EE_ADMIN_PAGES.'venues/templates/');
27 27
 
28 28
         parent::__construct();
29
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
29
+        $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.'/';
30 30
     }
31 31
 
32 32
     protected function _set_init_properties()
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page_Init.core.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,52 +12,52 @@
 block discarded – undo
12 12
  */
13 13
 class Messages_Admin_Page_Init extends EE_Admin_Page_Init
14 14
 {
15
-    /**
16
-     *constructor
17
-     *
18
-     * @Constructor
19
-     * @access public
20
-     * @return void
21
-     */
22
-    public function __construct()
23
-    {
15
+	/**
16
+	 *constructor
17
+	 *
18
+	 * @Constructor
19
+	 * @access public
20
+	 * @return void
21
+	 */
22
+	public function __construct()
23
+	{
24 24
 
25
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
25
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26 26
 
27
-        if (! defined('EE_MSG_PG_SLUG')) {
28
-            define('EE_MSG_PG_SLUG', 'espresso_messages');
29
-            define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
30
-            define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
31
-            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
32
-            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
33
-            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
34
-            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
35
-            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
36
-        }
27
+		if (! defined('EE_MSG_PG_SLUG')) {
28
+			define('EE_MSG_PG_SLUG', 'espresso_messages');
29
+			define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
30
+			define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
31
+			define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
32
+			define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
33
+			define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
34
+			define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
35
+			define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
36
+		}
37 37
 
38
-        parent::__construct();
39
-    }
38
+		parent::__construct();
39
+	}
40 40
 
41 41
 
42
-    protected function _set_init_properties()
43
-    {
44
-        $this->label = __('Messages System', 'event_espresso');
45
-    }
42
+	protected function _set_init_properties()
43
+	{
44
+		$this->label = __('Messages System', 'event_espresso');
45
+	}
46 46
 
47 47
 
48
-    protected function _set_menu_map()
49
-    {
50
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
51
-            array(
52
-                'menu_group'      => 'management',
53
-                'menu_order'      => 10,
54
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
55
-                'parent_slug'     => 'espresso_events',
56
-                'menu_slug'       => EE_MSG_PG_SLUG,
57
-                'menu_label'      => __('Messages', 'event_espresso'),
58
-                'capability'      => 'ee_read_global_messages',
59
-                'admin_init_page' => $this,
60
-            )
61
-        );
62
-    }
48
+	protected function _set_menu_map()
49
+	{
50
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
51
+			array(
52
+				'menu_group'      => 'management',
53
+				'menu_order'      => 10,
54
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
55
+				'parent_slug'     => 'espresso_events',
56
+				'menu_slug'       => EE_MSG_PG_SLUG,
57
+				'menu_label'      => __('Messages', 'event_espresso'),
58
+				'capability'      => 'ee_read_global_messages',
59
+				'admin_init_page' => $this,
60
+			)
61
+		);
62
+	}
63 63
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 
25 25
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26 26
 
27
-        if (! defined('EE_MSG_PG_SLUG')) {
27
+        if ( ! defined('EE_MSG_PG_SLUG')) {
28 28
             define('EE_MSG_PG_SLUG', 'espresso_messages');
29 29
             define('EE_MSG_PG_NAME', ucwords(str_replace('_', '', EE_MSG_PG_SLUG)));
30
-            define('EE_MSG_ADMIN', EE_ADMIN_PAGES . 'messages/');
31
-            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page=' . EE_MSG_PG_SLUG));
32
-            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN . 'assets/');
33
-            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'messages/assets/');
34
-            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN . 'templates/');
35
-            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'messages/templates/');
30
+            define('EE_MSG_ADMIN', EE_ADMIN_PAGES.'messages/');
31
+            define('EE_MSG_ADMIN_URL', admin_url('admin.php?page='.EE_MSG_PG_SLUG));
32
+            define('EE_MSG_ASSETS_PATH', EE_MSG_ADMIN.'assets/');
33
+            define('EE_MSG_ASSETS_URL', EE_ADMIN_PAGES_URL.'messages/assets/');
34
+            define('EE_MSG_TEMPLATE_PATH', EE_MSG_ADMIN.'templates/');
35
+            define('EE_MSG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'messages/templates/');
36 36
         }
37 37
 
38 38
         parent::__construct();
Please login to merge, or discard this patch.
admin_pages/registration_form/Registration_Form_Admin_Page_Init.core.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -18,41 +18,41 @@
 block discarded – undo
18 18
 class Registration_Form_Admin_Page_Init extends EE_Admin_Page_Init
19 19
 {
20 20
 
21
-    public function __construct()
22
-    {
23
-        // define some constants
24
-        define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25
-        define('REGISTRATION_FORM_LABEL', __('Registration Form', 'event_espresso'));
26
-        define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
-        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/');
28
-        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
-        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
-        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/');
31
-        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
-        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/');
33
-        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
34
-        parent::__construct();
35
-    }
21
+	public function __construct()
22
+	{
23
+		// define some constants
24
+		define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25
+		define('REGISTRATION_FORM_LABEL', __('Registration Form', 'event_espresso'));
26
+		define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
+		define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/');
28
+		define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
+		define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
+		define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/');
31
+		define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
+		define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/');
33
+		define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
34
+		parent::__construct();
35
+	}
36 36
 
37
-    protected function _set_init_properties()
38
-    {
39
-        $this->label = __('Registration Form Overview', 'event_espresso');
40
-    }
37
+	protected function _set_init_properties()
38
+	{
39
+		$this->label = __('Registration Form Overview', 'event_espresso');
40
+	}
41 41
 
42 42
 
43
-    protected function _set_menu_map()
44
-    {
45
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
46
-            array(
47
-                'menu_group'      => 'management',
48
-                'menu_order'      => 30,
49
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
50
-                'parent_slug'     => 'espresso_events',
51
-                'menu_slug'       => REGISTRATION_FORM_PG_SLUG,
52
-                'menu_label'      => __('Registration Form', 'event_espresso'),
53
-                'capability'      => 'ee_read_questions',
54
-                'admin_init_page' => $this,
55
-            )
56
-        );
57
-    }
43
+	protected function _set_menu_map()
44
+	{
45
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
46
+			array(
47
+				'menu_group'      => 'management',
48
+				'menu_order'      => 30,
49
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
50
+				'parent_slug'     => 'espresso_events',
51
+				'menu_slug'       => REGISTRATION_FORM_PG_SLUG,
52
+				'menu_label'      => __('Registration Form', 'event_espresso'),
53
+				'capability'      => 'ee_read_questions',
54
+				'admin_init_page' => $this,
55
+			)
56
+		);
57
+	}
58 58
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@
 block discarded – undo
24 24
         define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25 25
         define('REGISTRATION_FORM_LABEL', __('Registration Form', 'event_espresso'));
26 26
         define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
-        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form/');
28
-        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
-        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
-        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets/');
31
-        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
-        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates/');
33
-        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
27
+        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES.'registration_form/');
28
+        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG));
29
+        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG));
30
+        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN.'assets/');
31
+        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL.'registration_form/assets/');
32
+        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN.'templates/');
33
+        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registration_form/templates/');
34 34
         parent::__construct();
35 35
     }
36 36
 
Please login to merge, or discard this patch.
admin_pages/about/About_Admin_Page_Init.core.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -14,37 +14,37 @@
 block discarded – undo
14 14
 class About_Admin_Page_Init extends EE_Admin_Page_Init
15 15
 {
16 16
 
17
-    public function __construct()
18
-    {
19
-        // define some events related constants
20
-        define('EE_ABOUT_PG_SLUG', 'espresso_about');
21
-        define('EE_ABOUT_LABEL', __('About', 'event_espresso'));
22
-        define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
23
-        define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
24
-        define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
25
-        define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
26
-        parent::__construct();
27
-    }
17
+	public function __construct()
18
+	{
19
+		// define some events related constants
20
+		define('EE_ABOUT_PG_SLUG', 'espresso_about');
21
+		define('EE_ABOUT_LABEL', __('About', 'event_espresso'));
22
+		define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
23
+		define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
24
+		define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
25
+		define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
26
+		parent::__construct();
27
+	}
28 28
 
29
-    protected function _set_init_properties()
30
-    {
31
-        $this->label = __('About Event Espresso', 'event_espresso');
32
-    }
29
+	protected function _set_init_properties()
30
+	{
31
+		$this->label = __('About Event Espresso', 'event_espresso');
32
+	}
33 33
 
34
-    protected function _set_menu_map()
35
-    {
36
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
37
-            array(
38
-                'menu_group'              => 'extras',
39
-                'menu_order'              => 40,
40
-                'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
41
-                'parent_slug'             => 'espresso_events',
42
-                'menu_slug'               => 'espresso_about',
43
-                'menu_label'              => EE_ABOUT_LABEL,
44
-                'capability'              => 'manage_options',
45
-                'maintenance_mode_parent' => 'espresso_maintenance_settings',
46
-                'admin_init_page'         => $this,
47
-            )
48
-        );
49
-    }
34
+	protected function _set_menu_map()
35
+	{
36
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
37
+			array(
38
+				'menu_group'              => 'extras',
39
+				'menu_order'              => 40,
40
+				'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
41
+				'parent_slug'             => 'espresso_events',
42
+				'menu_slug'               => 'espresso_about',
43
+				'menu_label'              => EE_ABOUT_LABEL,
44
+				'capability'              => 'manage_options',
45
+				'maintenance_mode_parent' => 'espresso_maintenance_settings',
46
+				'admin_init_page'         => $this,
47
+			)
48
+		);
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
         // define some events related constants
20 20
         define('EE_ABOUT_PG_SLUG', 'espresso_about');
21 21
         define('EE_ABOUT_LABEL', __('About', 'event_espresso'));
22
-        define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES . 'about/');
23
-        define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page=' . EE_ABOUT_PG_SLUG));
24
-        define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN . 'templates/');
25
-        define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL . 'about/assets/');
22
+        define('EE_ABOUT_ADMIN', EE_ADMIN_PAGES.'about/');
23
+        define('EE_ABOUT_ADMIN_URL', admin_url('admin.php?page='.EE_ABOUT_PG_SLUG));
24
+        define('EE_ABOUT_TEMPLATE_PATH', EE_ABOUT_ADMIN.'templates/');
25
+        define('EE_ABOUT_ASSETS_URL', EE_ADMIN_PAGES_URL.'about/assets/');
26 26
         parent::__construct();
27 27
     }
28 28
 
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page_Init.core.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,50 +13,50 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     *        constructor
18
-     *
19
-     * @Constructor
20
-     * @access public
21
-     * @return void
22
-     */
23
-    public function __construct()
24
-    {
25
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
-        if (! defined('REG_PG_SLUG')) {
27
-            define('REG_PG_SLUG', 'espresso_registrations');
28
-            define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
29
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
30
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
31
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
32
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
33
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
34
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
35
-        }
36
-
37
-        parent::__construct();
38
-    }
39
-
40
-
41
-    protected function _set_init_properties()
42
-    {
43
-        $this->label = __('Registrations Overview', 'event_espresso');
44
-    }
45
-
46
-
47
-    protected function _set_menu_map()
48
-    {
49
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
50
-            array(
51
-                'menu_group'      => 'main',
52
-                'menu_order'      => 40,
53
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
54
-                'parent_slug'     => 'espresso_events',
55
-                'menu_slug'       => REG_PG_SLUG,
56
-                'menu_label'      => __('Registrations', 'event_espresso'),
57
-                'capability'      => 'ee_read_registrations',
58
-                'admin_init_page' => $this,
59
-            )
60
-        );
61
-    }
16
+	/**
17
+	 *        constructor
18
+	 *
19
+	 * @Constructor
20
+	 * @access public
21
+	 * @return void
22
+	 */
23
+	public function __construct()
24
+	{
25
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
+		if (! defined('REG_PG_SLUG')) {
27
+			define('REG_PG_SLUG', 'espresso_registrations');
28
+			define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
29
+			define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
30
+			define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
31
+			define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
32
+			define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
33
+			define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
34
+			define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
35
+		}
36
+
37
+		parent::__construct();
38
+	}
39
+
40
+
41
+	protected function _set_init_properties()
42
+	{
43
+		$this->label = __('Registrations Overview', 'event_espresso');
44
+	}
45
+
46
+
47
+	protected function _set_menu_map()
48
+	{
49
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
50
+			array(
51
+				'menu_group'      => 'main',
52
+				'menu_order'      => 40,
53
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
54
+				'parent_slug'     => 'espresso_events',
55
+				'menu_slug'       => REG_PG_SLUG,
56
+				'menu_label'      => __('Registrations', 'event_espresso'),
57
+				'capability'      => 'ee_read_registrations',
58
+				'admin_init_page' => $this,
59
+			)
60
+		);
61
+	}
62 62
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@
 block discarded – undo
23 23
     public function __construct()
24 24
     {
25 25
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
26
-        if (! defined('REG_PG_SLUG')) {
26
+        if ( ! defined('REG_PG_SLUG')) {
27 27
             define('REG_PG_SLUG', 'espresso_registrations');
28 28
             define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG)));
29
-            define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/');
30
-            define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG));
31
-            define('REG_ASSETS_PATH', REG_ADMIN . 'assets/');
32
-            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/');
33
-            define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/');
34
-            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/');
29
+            define('REG_ADMIN', EE_ADMIN_PAGES.'registrations/');
30
+            define('REG_ADMIN_URL', admin_url('admin.php?page='.REG_PG_SLUG));
31
+            define('REG_ASSETS_PATH', REG_ADMIN.'assets/');
32
+            define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL.'registrations/assets/');
33
+            define('REG_TEMPLATE_PATH', REG_ADMIN.'templates/');
34
+            define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registrations/templates/');
35 35
         }
36 36
 
37 37
         parent::__construct();
Please login to merge, or discard this patch.
payment_methods/Paypal_Express/EE_PMT_Paypal_Express.pm.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -15,89 +15,89 @@
 block discarded – undo
15 15
 class EE_PMT_Paypal_Express extends EE_PMT_Base
16 16
 {
17 17
 
18
-    /**
19
-     * EE_PMT_Paypal_Express constructor.
20
-     */
21
-    public function __construct($pm_instance = null)
22
-    {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
24
-        $this->_gateway = new EEG_Paypal_Express();
18
+	/**
19
+	 * EE_PMT_Paypal_Express constructor.
20
+	 */
21
+	public function __construct($pm_instance = null)
22
+	{
23
+		require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
24
+		$this->_gateway = new EEG_Paypal_Express();
25 25
 
26
-        $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
28
-        $this->_default_description = esc_html__(
29
-            // @codingStandardsIgnoreStart
30
-            'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31
-            // @codingStandardsIgnoreEnd
32
-            'event_espresso'
33
-        );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
26
+		$this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
+		$this->_template_path = $this->file_folder() . 'templates/';
28
+		$this->_default_description = esc_html__(
29
+			// @codingStandardsIgnoreStart
30
+			'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31
+			// @codingStandardsIgnoreEnd
32
+			'event_espresso'
33
+		);
34
+		$this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36
-        parent::__construct($pm_instance);
37
-    }
36
+		parent::__construct($pm_instance);
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * Adds the help tab.
42
-     *
43
-     * @see EE_PMT_Base::help_tabs_config()
44
-     * @return array
45
-     */
46
-    public function help_tabs_config()
47
-    {
48
-        return array(
49
-            $this->get_help_tab_name() => array(
50
-                'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
51
-                'filename' => 'payment_methods_overview_paypal_express'
52
-            )
53
-        );
54
-    }
40
+	/**
41
+	 * Adds the help tab.
42
+	 *
43
+	 * @see EE_PMT_Base::help_tabs_config()
44
+	 * @return array
45
+	 */
46
+	public function help_tabs_config()
47
+	{
48
+		return array(
49
+			$this->get_help_tab_name() => array(
50
+				'title'    => esc_html__('PayPal Express Settings', 'event_espresso'),
51
+				'filename' => 'payment_methods_overview_paypal_express'
52
+			)
53
+		);
54
+	}
55 55
 
56 56
 
57
-    /**
58
-     * Gets the form for all the settings related to this payment method type.
59
-     *
60
-     * @return EE_Payment_Method_Form
61
-     */
62
-    public function generate_new_settings_form()
63
-    {
64
-        return new SettingsForm(array(), $this->get_help_tab_link());
65
-    }
57
+	/**
58
+	 * Gets the form for all the settings related to this payment method type.
59
+	 *
60
+	 * @return EE_Payment_Method_Form
61
+	 */
62
+	public function generate_new_settings_form()
63
+	{
64
+		return new SettingsForm(array(), $this->get_help_tab_link());
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * Creates a billing form for this payment method type.
70
-     *
71
-     * @param \EE_Transaction $transaction
72
-     * @return \EE_Billing_Info_Form
73
-     */
74
-    public function generate_new_billing_form(EE_Transaction $transaction = null)
75
-    {
76
-        if ($this->_pm_instance->debug_mode()) {
77
-            $form = new EE_Billing_Info_Form(
78
-                $this->_pm_instance,
79
-                array(
80
-                    'name' => 'paypal_express_Info_Form',
81
-                    'subsections' => array(
82
-                        'paypal_express_debug_info' => new EE_Form_Section_Proper(
83
-                            array(
84
-                                'layout_strategy' => new EE_Template_Layout(
85
-                                    array(
86
-                                        'layout_template_file' => $this->_template_path
87
-                                                                    . 'paypal_express_debug_info.template.php',
88
-                                        'template_args'        => array(
89
-                                            'debug_mode' => $this->_pm_instance->debug_mode()
90
-                                        )
91
-                                    )
92
-                                )
93
-                            )
94
-                        )
95
-                    )
96
-                )
97
-            );
98
-            return $form;
99
-        }
68
+	/**
69
+	 * Creates a billing form for this payment method type.
70
+	 *
71
+	 * @param \EE_Transaction $transaction
72
+	 * @return \EE_Billing_Info_Form
73
+	 */
74
+	public function generate_new_billing_form(EE_Transaction $transaction = null)
75
+	{
76
+		if ($this->_pm_instance->debug_mode()) {
77
+			$form = new EE_Billing_Info_Form(
78
+				$this->_pm_instance,
79
+				array(
80
+					'name' => 'paypal_express_Info_Form',
81
+					'subsections' => array(
82
+						'paypal_express_debug_info' => new EE_Form_Section_Proper(
83
+							array(
84
+								'layout_strategy' => new EE_Template_Layout(
85
+									array(
86
+										'layout_template_file' => $this->_template_path
87
+																	. 'paypal_express_debug_info.template.php',
88
+										'template_args'        => array(
89
+											'debug_mode' => $this->_pm_instance->debug_mode()
90
+										)
91
+									)
92
+								)
93
+							)
94
+						)
95
+					)
96
+				)
97
+			);
98
+			return $form;
99
+		}
100 100
 
101
-        return false;
102
-    }
101
+		return false;
102
+	}
103 103
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,18 +20,18 @@
 block discarded – undo
20 20
      */
21 21
     public function __construct($pm_instance = null)
22 22
     {
23
-        require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php');
23
+        require_once($this->file_folder().'EEG_Paypal_Express.gateway.php');
24 24
         $this->_gateway = new EEG_Paypal_Express();
25 25
 
26 26
         $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso');
27
-        $this->_template_path = $this->file_folder() . 'templates/';
27
+        $this->_template_path = $this->file_folder().'templates/';
28 28
         $this->_default_description = esc_html__(
29 29
             // @codingStandardsIgnoreStart
30 30
             'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.',
31 31
             // @codingStandardsIgnoreEnd
32 32
             'event_espresso'
33 33
         );
34
-        $this->_default_button_url = $this->file_url() . 'lib/paypal-express-checkout-logo-gold-160.png';
34
+        $this->_default_button_url = $this->file_url().'lib/paypal-express-checkout-logo-gold-160.png';
35 35
 
36 36
         parent::__construct($pm_instance);
37 37
     }
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha_invisible/EED_Recaptcha_Invisible.module.php 2 patches
Indentation   +328 added lines, -328 removed lines patch added patch discarded remove patch
@@ -18,332 +18,332 @@
 block discarded – undo
18 18
 class EED_Recaptcha_Invisible extends EED_Module
19 19
 {
20 20
 
21
-    /**
22
-     * @var EE_Registration_Config $config
23
-     */
24
-    private static $config;
25
-
26
-
27
-    /**
28
-     * @return EED_Module|EED_Recaptcha
29
-     */
30
-    public static function instance()
31
-    {
32
-        return parent::get_instance(__CLASS__);
33
-    }
34
-
35
-
36
-    /**
37
-     * @return void
38
-     * @throws InvalidInterfaceException
39
-     * @throws InvalidDataTypeException
40
-     * @throws InvalidArgumentException
41
-     */
42
-    public static function set_hooks()
43
-    {
44
-        EED_Recaptcha_Invisible::setProperties();
45
-        if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) {
46
-            if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
47
-                // ticket selection
48
-                add_filter(
49
-                    'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
50
-                    array('EED_Recaptcha_Invisible', 'ticketSelectorForm'),
51
-                    10,
52
-                    3
53
-                );
54
-                add_action(
55
-                    'EED_Ticket_Selector__process_ticket_selections__before',
56
-                    array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
57
-                );
58
-            }
59
-            if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
60
-                // checkout
61
-                add_action(
62
-                    'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form',
63
-                    array('EED_Recaptcha_Invisible', 'spcoRegStepForm')
64
-                );
65
-                add_filter(
66
-                    'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
67
-                    array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
68
-                    10,
69
-                    2
70
-                );
71
-            }
72
-            add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars'));
73
-        }
74
-    }
75
-
76
-
77
-    /**
78
-     * @return void
79
-     * @throws InvalidInterfaceException
80
-     * @throws InvalidDataTypeException
81
-     * @throws InvalidArgumentException
82
-     */
83
-    public static function set_hooks_admin()
84
-    {
85
-        EED_Recaptcha_Invisible::setProperties();
86
-        if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
87
-            add_action(
88
-                'EED_Ticket_Selector__process_ticket_selections__before',
89
-                array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
90
-            );
91
-        }
92
-        if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
93
-            add_filter(
94
-                'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
95
-                array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
96
-                10,
97
-                2
98
-            );
99
-        }
100
-        // admin settings
101
-        add_action(
102
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
103
-            array('EED_Recaptcha_Invisible', 'adminSettings')
104
-        );
105
-        add_filter(
106
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
107
-            array('EED_Recaptcha_Invisible', 'updateAdminSettings')
108
-        );
109
-    }
110
-
111
-
112
-    /**
113
-     * @return void
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidDataTypeException
116
-     * @throws InvalidArgumentException
117
-     */
118
-    public static function setProperties()
119
-    {
120
-
121
-        EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration;
122
-    }
123
-
124
-
125
-    /**
126
-     * @return boolean
127
-     */
128
-    public static function useInvisibleRecaptcha()
129
-    {
130
-        return EED_Recaptcha_Invisible::$config->use_captcha
131
-               && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible';
132
-    }
133
-
134
-
135
-    /**
136
-     * @param string $form
137
-     * @return boolean
138
-     */
139
-    public static function protectForm($form)
140
-    {
141
-        return is_array(EED_Recaptcha_Invisible::$config->recaptcha_protected_forms)
142
-               && in_array($form, EED_Recaptcha_Invisible::$config->recaptcha_protected_forms, true);
143
-    }
144
-
145
-
146
-    /**
147
-     * @return void
148
-     * @throws InvalidInterfaceException
149
-     * @throws InvalidDataTypeException
150
-     * @throws InvalidArgumentException
151
-     */
152
-    public static function localizeScriptVars()
153
-    {
154
-        /** @var \EventEspresso\core\services\request\Request $request */
155
-        $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
156
-        // Invisible Recaptcha is ONLY ever required for the frontend and admin
157
-        // so we don't need to load any JS assets for other types of requests (like AJAX or API).
158
-        if (! ($request->isAdmin() || $request->isFrontend())) {
159
-            return;
160
-        }
161
-        wp_localize_script(
162
-            EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
163
-            'eeRecaptcha',
164
-            RecaptchaFactory::create()->getLocalizedVars()
165
-        );
166
-    }
167
-
168
-
169
-    /**
170
-     * @return string
171
-     */
172
-    public static function assetsUrl()
173
-    {
174
-        return plugin_dir_url(__FILE__) . 'assets/';
175
-    }
176
-
177
-
178
-    /**
179
-     * @param \WP $WP
180
-     */
181
-    public function run($WP)
182
-    {
183
-    }
184
-
185
-
186
-    /**
187
-     * @param RequestInterface $request
188
-     * @return bool
189
-     * @throws InvalidArgumentException
190
-     * @throws InvalidDataTypeException
191
-     * @throws InvalidInterfaceException
192
-     * @throws RuntimeException
193
-     */
194
-    public static function verifyToken(RequestInterface $request)
195
-    {
196
-        return RecaptchaFactory::create()->verifyToken($request);
197
-    }
198
-
199
-
200
-    /**
201
-     * @param EE_Form_Section_Proper $reg_form
202
-     * @return void
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws InvalidDataTypeException
206
-     * @throws InvalidInterfaceException
207
-     * @throws DomainException
208
-     */
209
-    public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form)
210
-    {
211
-        // do nothing if form isn't for a reg step or test has already been passed
212
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
213
-            return;
214
-        }
215
-        $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs');
216
-        if ($default_hidden_inputs instanceof EE_Form_Section_Proper) {
217
-            $invisible_recaptcha = RecaptchaFactory::create();
218
-            $invisible_recaptcha->addToFormSection($default_hidden_inputs);
219
-        }
220
-    }
221
-
222
-
223
-    /**
224
-     * @param EE_Form_Section_Proper $reg_form
225
-     * @return bool
226
-     * @throws InvalidDataTypeException
227
-     * @throws InvalidInterfaceException
228
-     * @throws EE_Error
229
-     * @throws InvalidArgumentException
230
-     */
231
-    public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form)
232
-    {
233
-        return strpos($reg_form->name(), 'reg-step-form') !== false
234
-               && ! RecaptchaFactory::create()->recaptchaPassed();
235
-    }
236
-
237
-
238
-    /**
239
-     * @param array|null             $req_data
240
-     * @param EE_Form_Section_Proper $reg_form
241
-     * @return array
242
-     * @throws EE_Error
243
-     * @throws InvalidArgumentException
244
-     * @throws InvalidDataTypeException
245
-     * @throws InvalidInterfaceException
246
-     * @throws RuntimeException
247
-     */
248
-    public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form)
249
-    {
250
-        // do nothing if form isn't for a reg step or test has already been passed
251
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
252
-            return $req_data;
253
-        }
254
-        /** @var RequestInterface $request */
255
-        $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
256
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
257
-            if ($request->isAjax()) {
258
-                $json_response = new EE_SPCO_JSON_Response();
259
-                $json_response->echoAndExit();
260
-            }
261
-            EEH_URL::safeRedirectAndExit(
262
-                EE_Registry::instance()->CFG->core->reg_page_url()
263
-            );
264
-        }
265
-        return $req_data;
266
-    }
267
-
268
-
269
-    /**
270
-     * @param string   $html
271
-     * @param EE_Event $event
272
-     * @param bool     $iframe
273
-     * @return string
274
-     * @throws EE_Error
275
-     * @throws InvalidArgumentException
276
-     * @throws InvalidDataTypeException
277
-     * @throws InvalidInterfaceException
278
-     * @throws ReflectionException
279
-     * @throws DomainException
280
-     */
281
-    public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false)
282
-    {
283
-        $recaptcha = RecaptchaFactory::create();
284
-        // do nothing if test has  already  been passed
285
-        if ($recaptcha->recaptchaPassed()) {
286
-            return $html;
287
-        }
288
-        $html .= $recaptcha->getInputHtml(
289
-            array(
290
-                'recaptcha_id'   => $event->ID(),
291
-                'iframe'         => $iframe,
292
-                'localized_vars' => $recaptcha->getLocalizedVars(),
293
-            )
294
-        );
295
-        return $html;
296
-    }
297
-
298
-
299
-    /**
300
-     * @return void
301
-     * @throws InvalidArgumentException
302
-     * @throws InvalidInterfaceException
303
-     * @throws InvalidDataTypeException
304
-     * @throws RuntimeException
305
-     */
306
-    public static function processTicketSelectorForm()
307
-    {
308
-        // do nothing if test has  already  been passed
309
-        if (RecaptchaFactory::create()->recaptchaPassed()) {
310
-            return;
311
-        }
312
-        /** @var RequestInterface $request */
313
-        $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
314
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
315
-            $event_id = $request->getRequestParam('tkt-slctr-event-id');
316
-            $return_url = $request->requestParamIsSet("tkt-slctr-return-url-{$event_id}")
317
-                ? $request->getRequestParam("tkt-slctr-return-url-{$event_id}")
318
-                : get_permalink($event_id);
319
-            EEH_URL::safeRedirectAndExit($return_url);
320
-        }
321
-    }
322
-
323
-
324
-    /**
325
-     * @throws EE_Error
326
-     * @throws InvalidArgumentException
327
-     * @throws InvalidDataTypeException
328
-     * @throws InvalidInterfaceException
329
-     */
330
-    public static function adminSettings()
331
-    {
332
-        RecaptchaFactory::getAdminModule()->adminSettings();
333
-    }
334
-
335
-
336
-    /**
337
-     * @param EE_Registration_Config $EE_Registration_Config
338
-     * @return EE_Registration_Config
339
-     * @throws EE_Error
340
-     * @throws InvalidArgumentException
341
-     * @throws InvalidDataTypeException
342
-     * @throws InvalidInterfaceException
343
-     * @throws ReflectionException
344
-     */
345
-    public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
346
-    {
347
-        return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config);
348
-    }
21
+	/**
22
+	 * @var EE_Registration_Config $config
23
+	 */
24
+	private static $config;
25
+
26
+
27
+	/**
28
+	 * @return EED_Module|EED_Recaptcha
29
+	 */
30
+	public static function instance()
31
+	{
32
+		return parent::get_instance(__CLASS__);
33
+	}
34
+
35
+
36
+	/**
37
+	 * @return void
38
+	 * @throws InvalidInterfaceException
39
+	 * @throws InvalidDataTypeException
40
+	 * @throws InvalidArgumentException
41
+	 */
42
+	public static function set_hooks()
43
+	{
44
+		EED_Recaptcha_Invisible::setProperties();
45
+		if (EED_Recaptcha_Invisible::useInvisibleRecaptcha()) {
46
+			if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
47
+				// ticket selection
48
+				add_filter(
49
+					'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
50
+					array('EED_Recaptcha_Invisible', 'ticketSelectorForm'),
51
+					10,
52
+					3
53
+				);
54
+				add_action(
55
+					'EED_Ticket_Selector__process_ticket_selections__before',
56
+					array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
57
+				);
58
+			}
59
+			if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
60
+				// checkout
61
+				add_action(
62
+					'AHEE__EE_SPCO_Reg_Step__display_reg_form__reg_form',
63
+					array('EED_Recaptcha_Invisible', 'spcoRegStepForm')
64
+				);
65
+				add_filter(
66
+					'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
67
+					array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
68
+					10,
69
+					2
70
+				);
71
+			}
72
+			add_action('loop_end', array('EED_Recaptcha_Invisible', 'localizeScriptVars'));
73
+		}
74
+	}
75
+
76
+
77
+	/**
78
+	 * @return void
79
+	 * @throws InvalidInterfaceException
80
+	 * @throws InvalidDataTypeException
81
+	 * @throws InvalidArgumentException
82
+	 */
83
+	public static function set_hooks_admin()
84
+	{
85
+		EED_Recaptcha_Invisible::setProperties();
86
+		if (EED_Recaptcha_Invisible::protectForm('ticket_selector')) {
87
+			add_action(
88
+				'EED_Ticket_Selector__process_ticket_selections__before',
89
+				array('EED_Recaptcha_Invisible', 'processTicketSelectorForm')
90
+			);
91
+		}
92
+		if (EED_Recaptcha_Invisible::protectForm('registration_form')) {
93
+			add_filter(
94
+				'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data',
95
+				array('EED_Recaptcha_Invisible', 'receiveSpcoRegStepForm'),
96
+				10,
97
+				2
98
+			);
99
+		}
100
+		// admin settings
101
+		add_action(
102
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
103
+			array('EED_Recaptcha_Invisible', 'adminSettings')
104
+		);
105
+		add_filter(
106
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
107
+			array('EED_Recaptcha_Invisible', 'updateAdminSettings')
108
+		);
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return void
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws InvalidArgumentException
117
+	 */
118
+	public static function setProperties()
119
+	{
120
+
121
+		EED_Recaptcha_Invisible::$config = EE_Registry::instance()->CFG->registration;
122
+	}
123
+
124
+
125
+	/**
126
+	 * @return boolean
127
+	 */
128
+	public static function useInvisibleRecaptcha()
129
+	{
130
+		return EED_Recaptcha_Invisible::$config->use_captcha
131
+			   && EED_Recaptcha_Invisible::$config->recaptcha_theme === 'invisible';
132
+	}
133
+
134
+
135
+	/**
136
+	 * @param string $form
137
+	 * @return boolean
138
+	 */
139
+	public static function protectForm($form)
140
+	{
141
+		return is_array(EED_Recaptcha_Invisible::$config->recaptcha_protected_forms)
142
+			   && in_array($form, EED_Recaptcha_Invisible::$config->recaptcha_protected_forms, true);
143
+	}
144
+
145
+
146
+	/**
147
+	 * @return void
148
+	 * @throws InvalidInterfaceException
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws InvalidArgumentException
151
+	 */
152
+	public static function localizeScriptVars()
153
+	{
154
+		/** @var \EventEspresso\core\services\request\Request $request */
155
+		$request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
156
+		// Invisible Recaptcha is ONLY ever required for the frontend and admin
157
+		// so we don't need to load any JS assets for other types of requests (like AJAX or API).
158
+		if (! ($request->isAdmin() || $request->isFrontend())) {
159
+			return;
160
+		}
161
+		wp_localize_script(
162
+			EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA,
163
+			'eeRecaptcha',
164
+			RecaptchaFactory::create()->getLocalizedVars()
165
+		);
166
+	}
167
+
168
+
169
+	/**
170
+	 * @return string
171
+	 */
172
+	public static function assetsUrl()
173
+	{
174
+		return plugin_dir_url(__FILE__) . 'assets/';
175
+	}
176
+
177
+
178
+	/**
179
+	 * @param \WP $WP
180
+	 */
181
+	public function run($WP)
182
+	{
183
+	}
184
+
185
+
186
+	/**
187
+	 * @param RequestInterface $request
188
+	 * @return bool
189
+	 * @throws InvalidArgumentException
190
+	 * @throws InvalidDataTypeException
191
+	 * @throws InvalidInterfaceException
192
+	 * @throws RuntimeException
193
+	 */
194
+	public static function verifyToken(RequestInterface $request)
195
+	{
196
+		return RecaptchaFactory::create()->verifyToken($request);
197
+	}
198
+
199
+
200
+	/**
201
+	 * @param EE_Form_Section_Proper $reg_form
202
+	 * @return void
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws InvalidDataTypeException
206
+	 * @throws InvalidInterfaceException
207
+	 * @throws DomainException
208
+	 */
209
+	public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form)
210
+	{
211
+		// do nothing if form isn't for a reg step or test has already been passed
212
+		if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
213
+			return;
214
+		}
215
+		$default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs');
216
+		if ($default_hidden_inputs instanceof EE_Form_Section_Proper) {
217
+			$invisible_recaptcha = RecaptchaFactory::create();
218
+			$invisible_recaptcha->addToFormSection($default_hidden_inputs);
219
+		}
220
+	}
221
+
222
+
223
+	/**
224
+	 * @param EE_Form_Section_Proper $reg_form
225
+	 * @return bool
226
+	 * @throws InvalidDataTypeException
227
+	 * @throws InvalidInterfaceException
228
+	 * @throws EE_Error
229
+	 * @throws InvalidArgumentException
230
+	 */
231
+	public static function processSpcoRegStepForm(EE_Form_Section_Proper $reg_form)
232
+	{
233
+		return strpos($reg_form->name(), 'reg-step-form') !== false
234
+			   && ! RecaptchaFactory::create()->recaptchaPassed();
235
+	}
236
+
237
+
238
+	/**
239
+	 * @param array|null             $req_data
240
+	 * @param EE_Form_Section_Proper $reg_form
241
+	 * @return array
242
+	 * @throws EE_Error
243
+	 * @throws InvalidArgumentException
244
+	 * @throws InvalidDataTypeException
245
+	 * @throws InvalidInterfaceException
246
+	 * @throws RuntimeException
247
+	 */
248
+	public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form)
249
+	{
250
+		// do nothing if form isn't for a reg step or test has already been passed
251
+		if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
252
+			return $req_data;
253
+		}
254
+		/** @var RequestInterface $request */
255
+		$request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
256
+		if (! EED_Recaptcha_Invisible::verifyToken($request)) {
257
+			if ($request->isAjax()) {
258
+				$json_response = new EE_SPCO_JSON_Response();
259
+				$json_response->echoAndExit();
260
+			}
261
+			EEH_URL::safeRedirectAndExit(
262
+				EE_Registry::instance()->CFG->core->reg_page_url()
263
+			);
264
+		}
265
+		return $req_data;
266
+	}
267
+
268
+
269
+	/**
270
+	 * @param string   $html
271
+	 * @param EE_Event $event
272
+	 * @param bool     $iframe
273
+	 * @return string
274
+	 * @throws EE_Error
275
+	 * @throws InvalidArgumentException
276
+	 * @throws InvalidDataTypeException
277
+	 * @throws InvalidInterfaceException
278
+	 * @throws ReflectionException
279
+	 * @throws DomainException
280
+	 */
281
+	public static function ticketSelectorForm($html = '', EE_Event $event, $iframe = false)
282
+	{
283
+		$recaptcha = RecaptchaFactory::create();
284
+		// do nothing if test has  already  been passed
285
+		if ($recaptcha->recaptchaPassed()) {
286
+			return $html;
287
+		}
288
+		$html .= $recaptcha->getInputHtml(
289
+			array(
290
+				'recaptcha_id'   => $event->ID(),
291
+				'iframe'         => $iframe,
292
+				'localized_vars' => $recaptcha->getLocalizedVars(),
293
+			)
294
+		);
295
+		return $html;
296
+	}
297
+
298
+
299
+	/**
300
+	 * @return void
301
+	 * @throws InvalidArgumentException
302
+	 * @throws InvalidInterfaceException
303
+	 * @throws InvalidDataTypeException
304
+	 * @throws RuntimeException
305
+	 */
306
+	public static function processTicketSelectorForm()
307
+	{
308
+		// do nothing if test has  already  been passed
309
+		if (RecaptchaFactory::create()->recaptchaPassed()) {
310
+			return;
311
+		}
312
+		/** @var RequestInterface $request */
313
+		$request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
314
+		if (! EED_Recaptcha_Invisible::verifyToken($request)) {
315
+			$event_id = $request->getRequestParam('tkt-slctr-event-id');
316
+			$return_url = $request->requestParamIsSet("tkt-slctr-return-url-{$event_id}")
317
+				? $request->getRequestParam("tkt-slctr-return-url-{$event_id}")
318
+				: get_permalink($event_id);
319
+			EEH_URL::safeRedirectAndExit($return_url);
320
+		}
321
+	}
322
+
323
+
324
+	/**
325
+	 * @throws EE_Error
326
+	 * @throws InvalidArgumentException
327
+	 * @throws InvalidDataTypeException
328
+	 * @throws InvalidInterfaceException
329
+	 */
330
+	public static function adminSettings()
331
+	{
332
+		RecaptchaFactory::getAdminModule()->adminSettings();
333
+	}
334
+
335
+
336
+	/**
337
+	 * @param EE_Registration_Config $EE_Registration_Config
338
+	 * @return EE_Registration_Config
339
+	 * @throws EE_Error
340
+	 * @throws InvalidArgumentException
341
+	 * @throws InvalidDataTypeException
342
+	 * @throws InvalidInterfaceException
343
+	 * @throws ReflectionException
344
+	 */
345
+	public static function updateAdminSettings(EE_Registration_Config $EE_Registration_Config)
346
+	{
347
+		return RecaptchaFactory::getAdminModule()->updateAdminSettings($EE_Registration_Config);
348
+	}
349 349
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\Request');
156 156
         // Invisible Recaptcha is ONLY ever required for the frontend and admin
157 157
         // so we don't need to load any JS assets for other types of requests (like AJAX or API).
158
-        if (! ($request->isAdmin() || $request->isFrontend())) {
158
+        if ( ! ($request->isAdmin() || $request->isFrontend())) {
159 159
             return;
160 160
         }
161 161
         wp_localize_script(
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public static function assetsUrl()
173 173
     {
174
-        return plugin_dir_url(__FILE__) . 'assets/';
174
+        return plugin_dir_url(__FILE__).'assets/';
175 175
     }
176 176
 
177 177
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
     public static function spcoRegStepForm(EE_Form_Section_Proper $reg_form)
210 210
     {
211 211
         // do nothing if form isn't for a reg step or test has already been passed
212
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
212
+        if ( ! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
213 213
             return;
214 214
         }
215 215
         $default_hidden_inputs = $reg_form->get_subsection('default_hidden_inputs');
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
     public static function receiveSpcoRegStepForm($req_data = array(), EE_Form_Section_Proper $reg_form)
249 249
     {
250 250
         // do nothing if form isn't for a reg step or test has already been passed
251
-        if (! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
251
+        if ( ! EED_Recaptcha_Invisible::processSpcoRegStepForm($reg_form)) {
252 252
             return $req_data;
253 253
         }
254 254
         /** @var RequestInterface $request */
255 255
         $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
256
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
256
+        if ( ! EED_Recaptcha_Invisible::verifyToken($request)) {
257 257
             if ($request->isAjax()) {
258 258
                 $json_response = new EE_SPCO_JSON_Response();
259 259
                 $json_response->echoAndExit();
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
         }
312 312
         /** @var RequestInterface $request */
313 313
         $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface');
314
-        if (! EED_Recaptcha_Invisible::verifyToken($request)) {
314
+        if ( ! EED_Recaptcha_Invisible::verifyToken($request)) {
315 315
             $event_id = $request->getRequestParam('tkt-slctr-event-id');
316 316
             $return_url = $request->requestParamIsSet("tkt-slctr-return-url-{$event_id}")
317 317
                 ? $request->getRequestParam("tkt-slctr-return-url-{$event_id}")
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha/EED_Recaptcha.module.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         }
132 132
         define(
133 133
             'RECAPTCHA_BASE_PATH',
134
-            rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/'
134
+            rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/').'/'
135 135
         );
136 136
         define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__));
137 137
     }
@@ -184,14 +184,14 @@  discard block
 block discarded – undo
184 184
     {
185 185
         wp_register_script(
186 186
             'espresso_recaptcha',
187
-            RECAPTCHA_BASE_URL . 'scripts/espresso_recaptcha.js',
187
+            RECAPTCHA_BASE_URL.'scripts/espresso_recaptcha.js',
188 188
             array('single_page_checkout'),
189 189
             EVENT_ESPRESSO_VERSION,
190 190
             true
191 191
         );
192 192
         wp_register_script(
193 193
             'google_recaptcha',
194
-            'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language,
194
+            'https://www.google.com/recaptcha/api.js?hl='.EED_Recaptcha::$config->recaptcha_language,
195 195
             array('espresso_recaptcha'),
196 196
             EVENT_ESPRESSO_VERSION,
197 197
             true
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) {
252 252
             // only display if they have NOT passed the test yet
253 253
             EEH_Template::display_template(
254
-                RECAPTCHA_BASE_PATH . '/templates/recaptcha.template.php',
254
+                RECAPTCHA_BASE_PATH.'/templates/recaptcha.template.php',
255 255
                 array(
256 256
                     'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey,
257 257
                     'recaptcha_theme'     => EED_Recaptcha::$config->recaptcha_theme,
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
         $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN);
297 297
         // verify recaptcha
298 298
         EED_Recaptcha::_get_recaptcha_response();
299
-        if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) {
299
+        if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) {
300 300
             $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response();
301 301
             EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed));
302 302
         }
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         foreach ($bypass_request_params_array as $key => $value) {
342 342
             // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE,
343 343
             // otherwise carry over it's value. This way, one missed setting results in no bypass
344
-            $bypass_recaptcha = isset($_REQUEST[ $key ]) && $_REQUEST[ $key ] === $value
344
+            $bypass_recaptcha = isset($_REQUEST[$key]) && $_REQUEST[$key] === $value
345 345
                 ? $bypass_recaptcha
346 346
                 : false;
347 347
         }
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
     private static function _process_recaptcha_response()
374 374
     {
375 375
         // verify library is loaded
376
-        if (! class_exists('\ReCaptcha\ReCaptcha')) {
377
-            require_once RECAPTCHA_BASE_PATH . '/autoload.php';
376
+        if ( ! class_exists('\ReCaptcha\ReCaptcha')) {
377
+            require_once RECAPTCHA_BASE_PATH.'/autoload.php';
378 378
         }
379 379
         // The response from reCAPTCHA
380 380
         EED_Recaptcha::_get_recaptcha_response();
Please login to merge, or discard this patch.
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -18,382 +18,382 @@
 block discarded – undo
18 18
 class EED_Recaptcha extends EED_Module
19 19
 {
20 20
 
21
-    /**
22
-     * @var EE_Registration_Config $config
23
-     */
24
-    private static $config;
25
-
26
-    /**
27
-     * @type bool $_not_a_robot
28
-     */
29
-    private static $_not_a_robot;
30
-
31
-    /**
32
-     * @type string $_recaptcha_response
33
-     */
34
-    private static $_recaptcha_response;
35
-
36
-
37
-    /**
38
-     * @return EED_Module|EED_Recaptcha
39
-     */
40
-    public static function instance()
41
-    {
42
-        return parent::get_instance(__CLASS__);
43
-    }
44
-
45
-
46
-    /**
47
-     * set_hooks - for hooking into EE Core, other modules, etc
48
-     *
49
-     * @return void
50
-     * @throws InvalidArgumentException
51
-     * @throws InvalidInterfaceException
52
-     * @throws InvalidDataTypeException
53
-     */
54
-    public static function set_hooks()
55
-    {
56
-        EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration;
57
-        // use_captcha ?
58
-        if (
59
-            EED_Recaptcha::useRecaptcha()
60
-            && EED_Recaptcha::notPaymentOptionsRevisit()
61
-        ) {
62
-            EED_Recaptcha::set_definitions();
63
-            EED_Recaptcha::enqueue_styles_and_scripts();
64
-            add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0);
65
-            add_action(
66
-                'AHEE__before_spco_whats_next_buttons',
67
-                array('EED_Recaptcha', 'display_recaptcha'),
68
-                10,
69
-                0
70
-            );
71
-            add_filter(
72
-                'FHEE__EED_Single_Page_Checkout__init___continue_reg',
73
-                array('EED_Recaptcha', 'not_a_robot')
74
-            );
75
-            add_filter(
76
-                'FHEE__EE_SPCO_Reg_Step__set_completed___completed',
77
-                array('EED_Recaptcha', 'not_a_robot')
78
-            );
79
-            add_filter(
80
-                'FHEE__EE_SPCO_JSON_Response___toString__JSON_response',
81
-                array('EED_Recaptcha', 'recaptcha_response')
82
-            );
83
-            add_filter(
84
-                'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
85
-                array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method')
86
-            );
87
-        }
88
-    }
89
-
90
-
91
-    /**
92
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
93
-     *
94
-     * @return void
95
-     * @throws InvalidArgumentException
96
-     * @throws InvalidInterfaceException
97
-     * @throws InvalidDataTypeException
98
-     */
99
-    public static function set_hooks_admin()
100
-    {
101
-        EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration;
102
-        EED_Recaptcha::set_definitions();
103
-        // use_captcha ?
104
-        if (
105
-            EED_Recaptcha::useRecaptcha()
106
-            && EED_Recaptcha::notPaymentOptionsRevisit()
107
-            && EE_Registry::instance()->REQ->get('step', '') !== ''
108
-        ) {
109
-            EED_Recaptcha::enqueue_styles_and_scripts();
110
-            add_filter(
111
-                'FHEE__EED_Single_Page_Checkout__init___continue_reg',
112
-                array('EED_Recaptcha', 'not_a_robot')
113
-            );
114
-            add_filter(
115
-                'FHEE__EE_SPCO_Reg_Step__set_completed___completed',
116
-                array('EED_Recaptcha', 'not_a_robot')
117
-            );
118
-            add_filter(
119
-                'FHEE__EE_SPCO_JSON_Response___toString__JSON_response',
120
-                array('EED_Recaptcha', 'recaptcha_response')
121
-            );
122
-        }
123
-    }
124
-
125
-
126
-    /**
127
-     * @return void
128
-     */
129
-    public static function set_definitions()
130
-    {
131
-        if (is_user_logged_in()) {
132
-            EED_Recaptcha::$_not_a_robot = true;
133
-        }
134
-        define(
135
-            'RECAPTCHA_BASE_PATH',
136
-            rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/'
137
-        );
138
-        define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__));
139
-    }
140
-
141
-
142
-    /**
143
-     * @return void
144
-     */
145
-    public static function set_late_hooks()
146
-    {
147
-        add_filter(
148
-            'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
149
-            array('EED_Recaptcha', 'not_a_robot')
150
-        );
151
-    }
152
-
153
-
154
-    /**
155
-     * @return boolean
156
-     */
157
-    public static function useRecaptcha()
158
-    {
159
-        return EED_Recaptcha::$config->use_captcha
160
-               && EED_Recaptcha::$config->recaptcha_theme !== 'invisible';
161
-    }
162
-
163
-
164
-    /**
165
-     * @return boolean
166
-     * @throws InvalidArgumentException
167
-     * @throws InvalidInterfaceException
168
-     * @throws InvalidDataTypeException
169
-     */
170
-    public static function notPaymentOptionsRevisit()
171
-    {
172
-        return ! (
173
-            EE_Registry::instance()->REQ->get('step', '') === 'payment_options'
174
-            && (bool) EE_Registry::instance()->REQ->get('revisit', false) === true
175
-        );
176
-    }
177
-
178
-
179
-    /**
180
-     * @return void
181
-     * @throws InvalidArgumentException
182
-     * @throws InvalidInterfaceException
183
-     * @throws InvalidDataTypeException
184
-     */
185
-    public static function enqueue_styles_and_scripts()
186
-    {
187
-        wp_register_script(
188
-            'espresso_recaptcha',
189
-            RECAPTCHA_BASE_URL . 'scripts/espresso_recaptcha.js',
190
-            array('single_page_checkout'),
191
-            EVENT_ESPRESSO_VERSION,
192
-            true
193
-        );
194
-        wp_register_script(
195
-            'google_recaptcha',
196
-            'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language,
197
-            array('espresso_recaptcha'),
198
-            EVENT_ESPRESSO_VERSION,
199
-            true
200
-        );
201
-        EE_Registry::$i18n_js_strings['no_SPCO_error'] = __(
202
-            'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.',
203
-            'event_espresso'
204
-        );
205
-        EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __(
206
-            'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.',
207
-            'event_espresso'
208
-        );
209
-        EE_Registry::$i18n_js_strings['recaptcha_fail'] = __(
210
-            'Please complete the anti-spam test before proceeding.',
211
-            'event_espresso'
212
-        );
213
-    }
214
-
215
-
216
-    /**
217
-     * @param \WP $WP
218
-     */
219
-    public function run($WP)
220
-    {
221
-    }
222
-
223
-
224
-    /**
225
-     * @return boolean
226
-     * @throws InvalidArgumentException
227
-     * @throws InvalidInterfaceException
228
-     * @throws InvalidDataTypeException
229
-     */
230
-    public static function not_a_robot()
231
-    {
232
-        $not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot)
233
-            ? EED_Recaptcha::$_not_a_robot
234
-            : EED_Recaptcha::recaptcha_passed();
235
-        return $not_a_robot;
236
-    }
237
-
238
-
239
-    /**
240
-     * @return void
241
-     * @throws DomainException
242
-     * @throws InvalidArgumentException
243
-     * @throws InvalidInterfaceException
244
-     * @throws InvalidDataTypeException
245
-     */
246
-    public static function display_recaptcha()
247
-    {
248
-        // logged in means you have already passed a turing test of sorts
249
-        if (is_user_logged_in()) {
250
-            return;
251
-        }
252
-        // don't display if not using recaptcha or user is logged in
253
-        if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) {
254
-            // only display if they have NOT passed the test yet
255
-            EEH_Template::display_template(
256
-                RECAPTCHA_BASE_PATH . '/templates/recaptcha.template.php',
257
-                array(
258
-                    'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey,
259
-                    'recaptcha_theme'     => EED_Recaptcha::$config->recaptcha_theme,
260
-                    'recaptcha_type'      => EED_Recaptcha::$config->recaptcha_type,
261
-                )
262
-            );
263
-            wp_enqueue_script('google_recaptcha');
264
-        }
265
-    }
266
-
267
-
268
-    /**
269
-     * @return array
270
-     * @throws InvalidArgumentException
271
-     * @throws InvalidInterfaceException
272
-     * @throws InvalidDataTypeException
273
-     */
274
-    public static function bypass_recaptcha_for_spco_load_payment_method()
275
-    {
276
-        return array(
277
-            'EESID'  => EE_Registry::instance()->SSN->id(),
278
-            'step'   => 'payment_options',
279
-            'action' => 'switch_spco_billing_form',
280
-        );
281
-    }
282
-
283
-
284
-    /**
285
-     * @return boolean
286
-     * @throws InvalidArgumentException
287
-     * @throws InvalidInterfaceException
288
-     * @throws InvalidDataTypeException
289
-     */
290
-    public static function recaptcha_passed()
291
-    {
292
-        // logged in means you have already passed a turing test of sorts
293
-        if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) {
294
-            return true;
295
-        }
296
-        // was test already passed?
297
-        $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed');
298
-        $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN);
299
-        // verify recaptcha
300
-        EED_Recaptcha::_get_recaptcha_response();
301
-        if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) {
302
-            $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response();
303
-            EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed));
304
-        }
305
-        EED_Recaptcha::$_not_a_robot = $recaptcha_passed;
306
-        return $recaptcha_passed;
307
-    }
308
-
309
-
310
-    /**
311
-     * @param array $recaptcha_response
312
-     * @return array
313
-     */
314
-    public static function recaptcha_response($recaptcha_response = array())
315
-    {
316
-        if (EED_Recaptcha::_bypass_recaptcha()) {
317
-            $recaptcha_response['bypass_recaptcha'] = true;
318
-            $recaptcha_response['recaptcha_passed'] = true;
319
-        } else {
320
-            $recaptcha_response['recaptcha_passed'] = EED_Recaptcha::$_not_a_robot;
321
-        }
322
-        return $recaptcha_response;
323
-    }
324
-
325
-
326
-    /**
327
-     * @return boolean
328
-     */
329
-    private static function _bypass_recaptcha()
330
-    {
331
-        // an array of key value pairs that must match exactly with the incoming request,
332
-        // in order to bypass recaptcha for the current request ONLY
333
-        $bypass_request_params_array = (array) apply_filters(
334
-            'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
335
-            array()
336
-        );
337
-        // does $bypass_request_params_array have any values ?
338
-        if (empty($bypass_request_params_array)) {
339
-            return false;
340
-        }
341
-        // initially set bypass to TRUE
342
-        $bypass_recaptcha = true;
343
-        foreach ($bypass_request_params_array as $key => $value) {
344
-            // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE,
345
-            // otherwise carry over it's value. This way, one missed setting results in no bypass
346
-            $bypass_recaptcha = isset($_REQUEST[ $key ]) && $_REQUEST[ $key ] === $value
347
-                ? $bypass_recaptcha
348
-                : false;
349
-        }
350
-        return $bypass_recaptcha;
351
-    }
352
-
353
-
354
-    /**
355
-     * @return void
356
-     * @throws InvalidArgumentException
357
-     * @throws InvalidInterfaceException
358
-     * @throws InvalidDataTypeException
359
-     */
360
-    private static function _get_recaptcha_response()
361
-    {
362
-        EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get(
363
-            'g-recaptcha-response',
364
-            false
365
-        );
366
-    }
367
-
368
-
369
-    /**
370
-     * @return boolean
371
-     * @throws InvalidArgumentException
372
-     * @throws InvalidInterfaceException
373
-     * @throws InvalidDataTypeException
374
-     */
375
-    private static function _process_recaptcha_response()
376
-    {
377
-        // verify library is loaded
378
-        if (! class_exists('\ReCaptcha\ReCaptcha')) {
379
-            require_once RECAPTCHA_BASE_PATH . '/autoload.php';
380
-        }
381
-        // The response from reCAPTCHA
382
-        EED_Recaptcha::_get_recaptcha_response();
383
-        $recaptcha_response = EED_Recaptcha::$_recaptcha_response;
384
-        // Was there a reCAPTCHA response?
385
-        if ($recaptcha_response) {
386
-            // if allow_url_fopen is Off, then set a different request method
387
-            $request_method = ! ini_get('allow_url_fopen') ? new SocketPost() : null;
388
-            $recaptcha = new ReCaptcha(
389
-                EED_Recaptcha::$config->recaptcha_privatekey,
390
-                $request_method
391
-            );
392
-            $recaptcha_response = $recaptcha->verify(
393
-                EED_Recaptcha::$_recaptcha_response,
394
-                $_SERVER['REMOTE_ADDR']
395
-            );
396
-        }
397
-        return $recaptcha_response instanceof Response && $recaptcha_response->isSuccess();
398
-    }
21
+	/**
22
+	 * @var EE_Registration_Config $config
23
+	 */
24
+	private static $config;
25
+
26
+	/**
27
+	 * @type bool $_not_a_robot
28
+	 */
29
+	private static $_not_a_robot;
30
+
31
+	/**
32
+	 * @type string $_recaptcha_response
33
+	 */
34
+	private static $_recaptcha_response;
35
+
36
+
37
+	/**
38
+	 * @return EED_Module|EED_Recaptcha
39
+	 */
40
+	public static function instance()
41
+	{
42
+		return parent::get_instance(__CLASS__);
43
+	}
44
+
45
+
46
+	/**
47
+	 * set_hooks - for hooking into EE Core, other modules, etc
48
+	 *
49
+	 * @return void
50
+	 * @throws InvalidArgumentException
51
+	 * @throws InvalidInterfaceException
52
+	 * @throws InvalidDataTypeException
53
+	 */
54
+	public static function set_hooks()
55
+	{
56
+		EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration;
57
+		// use_captcha ?
58
+		if (
59
+			EED_Recaptcha::useRecaptcha()
60
+			&& EED_Recaptcha::notPaymentOptionsRevisit()
61
+		) {
62
+			EED_Recaptcha::set_definitions();
63
+			EED_Recaptcha::enqueue_styles_and_scripts();
64
+			add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0);
65
+			add_action(
66
+				'AHEE__before_spco_whats_next_buttons',
67
+				array('EED_Recaptcha', 'display_recaptcha'),
68
+				10,
69
+				0
70
+			);
71
+			add_filter(
72
+				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
73
+				array('EED_Recaptcha', 'not_a_robot')
74
+			);
75
+			add_filter(
76
+				'FHEE__EE_SPCO_Reg_Step__set_completed___completed',
77
+				array('EED_Recaptcha', 'not_a_robot')
78
+			);
79
+			add_filter(
80
+				'FHEE__EE_SPCO_JSON_Response___toString__JSON_response',
81
+				array('EED_Recaptcha', 'recaptcha_response')
82
+			);
83
+			add_filter(
84
+				'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
85
+				array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method')
86
+			);
87
+		}
88
+	}
89
+
90
+
91
+	/**
92
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
93
+	 *
94
+	 * @return void
95
+	 * @throws InvalidArgumentException
96
+	 * @throws InvalidInterfaceException
97
+	 * @throws InvalidDataTypeException
98
+	 */
99
+	public static function set_hooks_admin()
100
+	{
101
+		EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration;
102
+		EED_Recaptcha::set_definitions();
103
+		// use_captcha ?
104
+		if (
105
+			EED_Recaptcha::useRecaptcha()
106
+			&& EED_Recaptcha::notPaymentOptionsRevisit()
107
+			&& EE_Registry::instance()->REQ->get('step', '') !== ''
108
+		) {
109
+			EED_Recaptcha::enqueue_styles_and_scripts();
110
+			add_filter(
111
+				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
112
+				array('EED_Recaptcha', 'not_a_robot')
113
+			);
114
+			add_filter(
115
+				'FHEE__EE_SPCO_Reg_Step__set_completed___completed',
116
+				array('EED_Recaptcha', 'not_a_robot')
117
+			);
118
+			add_filter(
119
+				'FHEE__EE_SPCO_JSON_Response___toString__JSON_response',
120
+				array('EED_Recaptcha', 'recaptcha_response')
121
+			);
122
+		}
123
+	}
124
+
125
+
126
+	/**
127
+	 * @return void
128
+	 */
129
+	public static function set_definitions()
130
+	{
131
+		if (is_user_logged_in()) {
132
+			EED_Recaptcha::$_not_a_robot = true;
133
+		}
134
+		define(
135
+			'RECAPTCHA_BASE_PATH',
136
+			rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/'
137
+		);
138
+		define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__));
139
+	}
140
+
141
+
142
+	/**
143
+	 * @return void
144
+	 */
145
+	public static function set_late_hooks()
146
+	{
147
+		add_filter(
148
+			'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
149
+			array('EED_Recaptcha', 'not_a_robot')
150
+		);
151
+	}
152
+
153
+
154
+	/**
155
+	 * @return boolean
156
+	 */
157
+	public static function useRecaptcha()
158
+	{
159
+		return EED_Recaptcha::$config->use_captcha
160
+			   && EED_Recaptcha::$config->recaptcha_theme !== 'invisible';
161
+	}
162
+
163
+
164
+	/**
165
+	 * @return boolean
166
+	 * @throws InvalidArgumentException
167
+	 * @throws InvalidInterfaceException
168
+	 * @throws InvalidDataTypeException
169
+	 */
170
+	public static function notPaymentOptionsRevisit()
171
+	{
172
+		return ! (
173
+			EE_Registry::instance()->REQ->get('step', '') === 'payment_options'
174
+			&& (bool) EE_Registry::instance()->REQ->get('revisit', false) === true
175
+		);
176
+	}
177
+
178
+
179
+	/**
180
+	 * @return void
181
+	 * @throws InvalidArgumentException
182
+	 * @throws InvalidInterfaceException
183
+	 * @throws InvalidDataTypeException
184
+	 */
185
+	public static function enqueue_styles_and_scripts()
186
+	{
187
+		wp_register_script(
188
+			'espresso_recaptcha',
189
+			RECAPTCHA_BASE_URL . 'scripts/espresso_recaptcha.js',
190
+			array('single_page_checkout'),
191
+			EVENT_ESPRESSO_VERSION,
192
+			true
193
+		);
194
+		wp_register_script(
195
+			'google_recaptcha',
196
+			'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language,
197
+			array('espresso_recaptcha'),
198
+			EVENT_ESPRESSO_VERSION,
199
+			true
200
+		);
201
+		EE_Registry::$i18n_js_strings['no_SPCO_error'] = __(
202
+			'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.',
203
+			'event_espresso'
204
+		);
205
+		EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __(
206
+			'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.',
207
+			'event_espresso'
208
+		);
209
+		EE_Registry::$i18n_js_strings['recaptcha_fail'] = __(
210
+			'Please complete the anti-spam test before proceeding.',
211
+			'event_espresso'
212
+		);
213
+	}
214
+
215
+
216
+	/**
217
+	 * @param \WP $WP
218
+	 */
219
+	public function run($WP)
220
+	{
221
+	}
222
+
223
+
224
+	/**
225
+	 * @return boolean
226
+	 * @throws InvalidArgumentException
227
+	 * @throws InvalidInterfaceException
228
+	 * @throws InvalidDataTypeException
229
+	 */
230
+	public static function not_a_robot()
231
+	{
232
+		$not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot)
233
+			? EED_Recaptcha::$_not_a_robot
234
+			: EED_Recaptcha::recaptcha_passed();
235
+		return $not_a_robot;
236
+	}
237
+
238
+
239
+	/**
240
+	 * @return void
241
+	 * @throws DomainException
242
+	 * @throws InvalidArgumentException
243
+	 * @throws InvalidInterfaceException
244
+	 * @throws InvalidDataTypeException
245
+	 */
246
+	public static function display_recaptcha()
247
+	{
248
+		// logged in means you have already passed a turing test of sorts
249
+		if (is_user_logged_in()) {
250
+			return;
251
+		}
252
+		// don't display if not using recaptcha or user is logged in
253
+		if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) {
254
+			// only display if they have NOT passed the test yet
255
+			EEH_Template::display_template(
256
+				RECAPTCHA_BASE_PATH . '/templates/recaptcha.template.php',
257
+				array(
258
+					'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey,
259
+					'recaptcha_theme'     => EED_Recaptcha::$config->recaptcha_theme,
260
+					'recaptcha_type'      => EED_Recaptcha::$config->recaptcha_type,
261
+				)
262
+			);
263
+			wp_enqueue_script('google_recaptcha');
264
+		}
265
+	}
266
+
267
+
268
+	/**
269
+	 * @return array
270
+	 * @throws InvalidArgumentException
271
+	 * @throws InvalidInterfaceException
272
+	 * @throws InvalidDataTypeException
273
+	 */
274
+	public static function bypass_recaptcha_for_spco_load_payment_method()
275
+	{
276
+		return array(
277
+			'EESID'  => EE_Registry::instance()->SSN->id(),
278
+			'step'   => 'payment_options',
279
+			'action' => 'switch_spco_billing_form',
280
+		);
281
+	}
282
+
283
+
284
+	/**
285
+	 * @return boolean
286
+	 * @throws InvalidArgumentException
287
+	 * @throws InvalidInterfaceException
288
+	 * @throws InvalidDataTypeException
289
+	 */
290
+	public static function recaptcha_passed()
291
+	{
292
+		// logged in means you have already passed a turing test of sorts
293
+		if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) {
294
+			return true;
295
+		}
296
+		// was test already passed?
297
+		$recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed');
298
+		$recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN);
299
+		// verify recaptcha
300
+		EED_Recaptcha::_get_recaptcha_response();
301
+		if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) {
302
+			$recaptcha_passed = EED_Recaptcha::_process_recaptcha_response();
303
+			EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed));
304
+		}
305
+		EED_Recaptcha::$_not_a_robot = $recaptcha_passed;
306
+		return $recaptcha_passed;
307
+	}
308
+
309
+
310
+	/**
311
+	 * @param array $recaptcha_response
312
+	 * @return array
313
+	 */
314
+	public static function recaptcha_response($recaptcha_response = array())
315
+	{
316
+		if (EED_Recaptcha::_bypass_recaptcha()) {
317
+			$recaptcha_response['bypass_recaptcha'] = true;
318
+			$recaptcha_response['recaptcha_passed'] = true;
319
+		} else {
320
+			$recaptcha_response['recaptcha_passed'] = EED_Recaptcha::$_not_a_robot;
321
+		}
322
+		return $recaptcha_response;
323
+	}
324
+
325
+
326
+	/**
327
+	 * @return boolean
328
+	 */
329
+	private static function _bypass_recaptcha()
330
+	{
331
+		// an array of key value pairs that must match exactly with the incoming request,
332
+		// in order to bypass recaptcha for the current request ONLY
333
+		$bypass_request_params_array = (array) apply_filters(
334
+			'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
335
+			array()
336
+		);
337
+		// does $bypass_request_params_array have any values ?
338
+		if (empty($bypass_request_params_array)) {
339
+			return false;
340
+		}
341
+		// initially set bypass to TRUE
342
+		$bypass_recaptcha = true;
343
+		foreach ($bypass_request_params_array as $key => $value) {
344
+			// if $key is not found or value doesn't match exactly, then toggle bypass to FALSE,
345
+			// otherwise carry over it's value. This way, one missed setting results in no bypass
346
+			$bypass_recaptcha = isset($_REQUEST[ $key ]) && $_REQUEST[ $key ] === $value
347
+				? $bypass_recaptcha
348
+				: false;
349
+		}
350
+		return $bypass_recaptcha;
351
+	}
352
+
353
+
354
+	/**
355
+	 * @return void
356
+	 * @throws InvalidArgumentException
357
+	 * @throws InvalidInterfaceException
358
+	 * @throws InvalidDataTypeException
359
+	 */
360
+	private static function _get_recaptcha_response()
361
+	{
362
+		EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get(
363
+			'g-recaptcha-response',
364
+			false
365
+		);
366
+	}
367
+
368
+
369
+	/**
370
+	 * @return boolean
371
+	 * @throws InvalidArgumentException
372
+	 * @throws InvalidInterfaceException
373
+	 * @throws InvalidDataTypeException
374
+	 */
375
+	private static function _process_recaptcha_response()
376
+	{
377
+		// verify library is loaded
378
+		if (! class_exists('\ReCaptcha\ReCaptcha')) {
379
+			require_once RECAPTCHA_BASE_PATH . '/autoload.php';
380
+		}
381
+		// The response from reCAPTCHA
382
+		EED_Recaptcha::_get_recaptcha_response();
383
+		$recaptcha_response = EED_Recaptcha::$_recaptcha_response;
384
+		// Was there a reCAPTCHA response?
385
+		if ($recaptcha_response) {
386
+			// if allow_url_fopen is Off, then set a different request method
387
+			$request_method = ! ini_get('allow_url_fopen') ? new SocketPost() : null;
388
+			$recaptcha = new ReCaptcha(
389
+				EED_Recaptcha::$config->recaptcha_privatekey,
390
+				$request_method
391
+			);
392
+			$recaptcha_response = $recaptcha->verify(
393
+				EED_Recaptcha::$_recaptcha_response,
394
+				$_SERVER['REMOTE_ADDR']
395
+			);
396
+		}
397
+		return $recaptcha_response instanceof Response && $recaptcha_response->isSuccess();
398
+	}
399 399
 }
Please login to merge, or discard this patch.