PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 All 30 releases
bbp-core / includes / admin / options / options-social-login.php

options-social-login.php in Forumax – AI Powered Advanced Community Forum Plugin 2.5.0, at includes/admin/options/options-social-login.php

176 lines 8.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 $generate_redirect_uri_html = function ( $provider_id, $provider_label, $app_settings_field ) {
4 $url = add_query_arg( array( 'provider' => $provider_id ), wp_login_url() );
5 /* translators: 1: App Settings Field, 2: Provider Label */
6 $instruction = sprintf( __( 'Paste this into the "%1$s" field in %2$s:', 'forumax' ), $app_settings_field, $provider_label );
7
8 return $instruction .
9 '<div style="display: flex; align-items: center; gap: 8px; margin-top: 10px;">' .
10 '<input type="text" id="' . esc_attr( $provider_id ) . '-redirect-uri" value="' . esc_url( $url ) . '" readonly="readonly" style="width: 100%; max-width: 400px; padding: 4px 8px; background: #fff;" />' .
11 '<button type="button" class="button button-secondary" style="display: flex; align-items: center; padding: 0 8px;" onclick="var copyText = document.getElementById(\'' . esc_attr( $provider_id ) . '-redirect-uri\'); copyText.select(); document.execCommand(\'copy\'); var icon = this.querySelector(\'.dashicons\'); icon.className = \'dashicons dashicons-yes\'; icon.style.color = \'green\'; setTimeout(function(){ icon.className = \'dashicons dashicons-clipboard\'; icon.style.color = \'\'; }, 2000);" title="' . esc_attr__( 'Copy', 'forumax' ) . '">' .
12 '<span class="dashicons dashicons-clipboard"></span></button></div>';
13 };
14
15 // Create a section.
16 CSF::createSection(
17 $prefix,
18 [
19 'title' => __( 'Social Login', 'forumax' ),
20 'icon' => 'dashicons dashicons-share-alt',
21 'fields' => [
22 [
23 'id' => 'social_login_enabled',
24 'type' => 'switcher',
25 'title' => esc_html__( 'Enable Social Login', 'forumax' ),
26 'desc' => esc_html__( 'Allow your users to log in instantly using their social media accounts. This removes friction and boosts conversion rates.', 'forumax' ),
27 'default' => false,
28 'class' => 'st-promax-notice'
29 ],
30
31 [
32 'id' => 'social_login_notice',
33 'type' => 'notice',
34 'style' => 'info',
35 'content' => esc_html__( 'Configure your social login providers below using the built-in descriptions and setup notes.', 'forumax' ),
36 'dependency' => [ 'social_login_enabled', '==', 'true' ],
37 ],
38
39 // Google Provider
40 [
41 'id' => 'social_login_google',
42 'type' => 'fieldset',
43 'title' => esc_html__( 'Google One-Tap Sign-in', 'forumax' ),
44 'subtitle' => esc_html__( 'Set up Google One-Tap by entering your Client ID and Client Secret, then copy the redirect URL below into Google Cloud Console exactly as shown.', 'forumax' ),
45 'dependency' => [ 'social_login_enabled', '==', 'true' ],
46 'class' => 'st-promax-notice',
47 'fields' => [
48 [
49 'id' => 'social_login_google_enabled',
50 'type' => 'switcher',
51 'title' => esc_html__( 'Enable Google Login', 'forumax' ),
52 'default' => false,
53 ],
54 [
55 'id' => 'social_login_google_client_id',
56 'type' => 'text',
57 'title' => esc_html__( 'Client ID', 'forumax' ),
58 'subtitle' => esc_html__( 'Copy the Client ID from Google Cloud Console. Use the exact value from your OAuth app.', 'forumax' ),
59 'desc' => sprintf(
60 __( 'Get your Client ID from the <a href="%s" target="_blank">Google Cloud Console</a>.', 'forumax' ),
61 'https://console.cloud.google.com/apis/credentials'
62 ),
63 'dependency' => [ 'social_login_google_enabled', '==', 'true' ],
64 ],
65 [
66 'id' => 'social_login_google_client_secret',
67 'type' => 'text',
68 'title' => esc_html__( 'Client Secret', 'forumax' ),
69 'subtitle' => esc_html__( 'Paste the Client Secret from the same Google OAuth app. Avoid extra spaces before or after the value.', 'forumax' ),
70 'dependency' => [ 'social_login_google_enabled', '==', 'true' ],
71 ],
72 [
73 'id' => 'social_login_google_redirect_uri',
74 'type' => 'notice',
75 'style' => 'info',
76 'title' => esc_html__( 'Authorized Redirect URI', 'forumax' ),
77 'subtitle' => esc_html__( 'Copy this exact URL into Google Cloud Console. A mismatch in protocol, path, or trailing slash will break login.', 'forumax' ),
78 'content' => $generate_redirect_uri_html( 'google', 'Google Console', 'Authorized redirect URIs' ),
79 'dependency' => [ 'social_login_google_enabled', '==', 'true' ],
80 ],
81 ],
82 ],
83
84 // Facebook Provider
85 [
86 'id' => 'social_login_facebook',
87 'type' => 'fieldset',
88 'title' => esc_html__( 'Facebook Login', 'forumax' ),
89 'subtitle' => esc_html__( 'Add your Facebook App ID and App Secret here, then paste the redirect URL into Meta for Developers and switch the app to Live when ready.', 'forumax' ),
90 'dependency' => [ 'social_login_enabled', '==', 'true' ],
91 'class' => 'st-promax-notice',
92 'fields' => [
93 [
94 'id' => 'social_login_facebook_enabled',
95 'type' => 'switcher',
96 'title' => esc_html__( 'Enable Facebook Login', 'forumax' ),
97 'default' => false,
98 ],
99 [
100 'id' => 'social_login_facebook_app_id',
101 'type' => 'text',
102 'title' => esc_html__( 'App ID', 'forumax' ),
103 'subtitle' => esc_html__( 'Copy the App ID from Meta for Developers for the app you want to use for login.', 'forumax' ),
104 'desc' => sprintf(
105 __( 'Get your App ID from <a href="%s" target="_blank">Meta for Developers</a>.', 'forumax' ),
106 'https://developers.facebook.com/apps/'
107 ),
108 'dependency' => [ 'social_login_facebook_enabled', '==', 'true' ],
109 ],
110 [
111 'id' => 'social_login_facebook_app_secret',
112 'type' => 'text',
113 'title' => esc_html__( 'App Secret', 'forumax' ),
114 'subtitle' => esc_html__( 'Paste the App Secret from Meta exactly as provided. Hidden spaces or a wrong app secret will cause login failures.', 'forumax' ),
115 'dependency' => [ 'social_login_facebook_enabled', '==', 'true' ],
116 ],
117 [
118 'id' => 'social_login_facebook_redirect_uri',
119 'type' => 'notice',
120 'style' => 'info',
121 'title' => esc_html__( 'Authorized Redirect URI', 'forumax' ),
122 'subtitle' => esc_html__( 'Copy this exact URL into the Valid OAuth Redirect URIs field in Meta. The app must also be configured correctly in Facebook Login settings.', 'forumax' ),
123 'content' => $generate_redirect_uri_html( 'facebook', 'your Facebook App settings', 'Valid OAuth Redirect URIs' ),
124 'dependency' => [ 'social_login_facebook_enabled', '==', 'true' ],
125 ],
126 ],
127 ],
128
129 // X Provider
130 [
131 'id' => 'social_login_twitter',
132 'type' => 'fieldset',
133 'title' => esc_html__( 'X (Twitter) Login', 'forumax' ),
134 'subtitle' => esc_html__( 'Enter your X app API Key and API Secret, then copy the callback URL below into your X app settings with OAuth enabled.', 'forumax' ),
135 'dependency' => [ 'social_login_enabled', '==', 'true' ],
136 'class' => 'st-promax-notice',
137 'fields' => [
138 [
139 'id' => 'social_login_twitter_enabled',
140 'type' => 'switcher',
141 'title' => esc_html__( 'Enable X (Twitter) Login', 'forumax' ),
142 'default' => false,
143 ],
144 [
145 'id' => 'social_login_twitter_api_key',
146 'type' => 'text',
147 'title' => esc_html__( 'API Key', 'forumax' ),
148 'subtitle' => esc_html__( 'Copy the API Key from your X developer app. Make sure you are using the correct app and environment.', 'forumax' ),
149 'desc' => sprintf(
150 __( 'Get your API Key from the <a href="%s" target="_blank">X Developer Portal</a>.', 'forumax' ),
151 'https://developer.twitter.com/en/portal/projects-and-apps'
152 ),
153 'dependency' => [ 'social_login_twitter_enabled', '==', 'true' ],
154 ],
155 [
156 'id' => 'social_login_twitter_api_secret',
157 'type' => 'text',
158 'title' => esc_html__( 'API Secret', 'forumax' ),
159 'subtitle' => esc_html__( 'Paste the API Secret exactly as provided by X. Confirm OAuth permissions are enabled for the app if login does not work.', 'forumax' ),
160 'dependency' => [ 'social_login_twitter_enabled', '==', 'true' ],
161 ],
162 [
163 'id' => 'social_login_twitter_redirect_uri',
164 'type' => 'notice',
165 'style' => 'info',
166 'title' => esc_html__( 'Authorized Callback URL', 'forumax' ),
167 'subtitle' => esc_html__( 'Copy this exact URL into your X app callback settings. A mismatch here is one of the most common login issues.', 'forumax' ),
168 'content' => $generate_redirect_uri_html( 'twitter', 'your X App settings', 'Callback URI / Redirect URL' ),
169 'dependency' => [ 'social_login_twitter_enabled', '==', 'true' ],
170 ],
171 ],
172 ],
173 ],
174 ]
175 );
176