PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / 3.2.1
Wp Social Login and Register Social Counter v3.2.1
3.2.1 trunk 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.11 1.3.2 1.3.3 1.3.4 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.4 1.4.5 1.4.6 1.4.8 1.4.9 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.8 2.2.9 3.0.0 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0
wp-social / lib / onboard / onboard.php
wp-social / lib / onboard Last commit date
assets 1 week ago classes 1 week ago controls 3 years ago views 1 week ago attr.php 4 years ago onboard.php 10 months ago
onboard.php
216 lines
1 <?php
2
3 namespace WP_Social\Lib\Onboard;
4
5 use WP_Social\App\Login_Settings;
6 use WP_Social\Lib\Onboard\Classes\Plugin_Data_Sender;
7 use WP_Social\Plugin;
8 use WP_Social\Traits\Singleton;
9
10 defined('ABSPATH') || exit;
11
12 class Onboard {
13
14 use Singleton;
15 protected $optionKey = 'wp_social_onboard_status';
16 protected $optionValue = 'onboarded';
17
18 const CONTACT_LIST_ID = 4;
19 const ENVIRONMENT_ID = 4;
20
21 public function views() {
22 ?>
23 <div class="metform-onboard-dashboard">
24 <div class="metform_container">
25 <form action="" method="POST" id="wslu-admin-settings-form">
26 <?php include self::get_dir() . 'views/layout-onboard.php';?>
27 </form>
28 </div>
29 </div>
30 <?php
31 }
32
33 public static function get_dir() {
34 return Plugin::instance()->lib_dir() . 'onboard/';
35 }
36
37 public static function get_url() {
38 return Plugin::instance()->lib_url() . 'onboard/';
39 }
40
41 public function init() {
42
43 new Classes\Ajax;
44
45 if (get_option($this->optionKey)) {
46 if (isset($_GET['wp-social-met-onboard-steps'])) {
47 wp_redirect($this->get_plugin_url());
48 }
49 return true;
50 }
51
52 add_action('wpsocial/admin/after_save', [$this, 'ajax_action']);
53
54 $param = isset($_GET['wp-social-met-onboard-steps']) ? sanitize_text_field($_GET['wp-social-met-onboard-steps']) : null;
55 $requestUri = (isset($_GET['post_type']) ? sanitize_text_field($_GET['post_type']) : '') . (isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '');
56
57 if (strpos($requestUri, 'wslu') !== false && is_admin()) {
58 if ($param !== 'loaded' && !get_option($this->optionKey)) {
59 wp_redirect($this->get_onboard_url());
60 exit;
61 }
62 }
63
64 return true;
65 }
66
67 public function ajax_action() {
68
69 $this->finish_onboard();
70
71 if ( isset( $_POST['settings']['tut_term'] ) && sanitize_text_field($_POST['settings']['tut_term']) == 'user_agreed' ) {
72 Plugin_Data_Sender::instance()->send( 'diagnostic-data' ); // send non-sensitive diagnostic data and details about plugin usage.
73 }
74
75 if ( isset( $_POST['settings']['newsletter_email'] ) && !empty($_POST['settings']['newsletter_email'])) {
76 $data = [
77 'email' => sanitize_email( wp_unslash( $_POST['settings']['newsletter_email'] ) ),
78 'slug' => 'wp-social',
79 ];
80
81 $response = Plugin_Data_Sender::instance()->sendEmailSubscribeData( 'plugin-subscribe', $data);
82 exit;
83 }
84 }
85
86 private function get_onboard_url() {
87 return add_query_arg(
88 array(
89 'page' => 'wslu_global_setting',
90 'wp-social-met-onboard-steps' => 'loaded',
91 ),
92 admin_url('admin.php')
93 );
94 }
95
96 public function redirect_onboard() {
97 if (is_null(get_option($this->optionKey))) {
98 wp_redirect($this->get_onboard_url());
99 exit;
100 }
101 }
102
103 private static function get_plugin_url() {
104 return add_query_arg(
105 array(
106 'page' => 'wslu_global_setting',
107 ),
108 admin_url('admin.php')
109 );
110 }
111
112 public function finish_onboard() {
113
114 if(class_exists('\WP_Social_Pro')) {
115
116 $activated_module = [];
117 $modules = \WP_Social_Pro\Modules\Manifesto::modules_list();
118
119 foreach ($modules as $key => $value) {
120 if (isset($_POST['module_list']) && in_array($key, map_deep( wp_unslash( $_POST['module_list'] ) , 'sanitize_text_field' ))) {
121 $activated_module[$key] = 'yes';
122 } else {
123 $activated_module[$key] = 'no';
124 }
125 }
126
127 update_option(\WP_Social_Pro\Modules\Manifesto::OPTION_KEY_ACTIVE_MODULE_CONF, $activated_module);
128 }
129
130 $login_global_settings = get_option(Login_Settings::OK_GLOBAL, []);
131
132 foreach (self::settings()['login'] as $key => $value) {
133 if (isset($_POST['login']) && array_key_exists($key, map_deep( wp_unslash( $_POST['login'] ) , 'sanitize_text_field' ))) {
134
135 $login_global_settings[$key]['enable'] = 1;
136
137 if ($value != 1 && empty($login_global_settings[$key]['data'])) {
138 $login_global_settings[$key]['data'] = $value;
139 }
140 } else {
141 $login_global_settings[$key]['enable'] = 0;
142 }
143 }
144
145 update_option(Login_Settings::OK_GLOBAL, $login_global_settings);
146
147 foreach (self::settings()['share'] as $key => $value) {
148 switch ($key) {
149 case 'show_font_from_theme':
150
151 if (isset($_POST['share']) && array_key_exists($key, map_deep( wp_unslash( $_POST['share'] ) , 'sanitize_text_field' ))) {
152 update_option('xs_share_global_setting_data', ['show_font_from_theme' => 1]);
153 } else {
154 update_option('xs_share_global_setting_data', ['show_font_from_theme' => 0]);
155 }
156
157 break;
158 case 'show_social_count_share':
159
160 $style_setting_data_share = get_option('xs_style_setting_data_share', []);
161
162 if (isset($_POST['share']) && array_key_exists($key, map_deep( wp_unslash( $_POST['share'] ) , 'sanitize_text_field' ))) {
163 $style_setting_data_share['main_content']['show_social_count_share'] = 1;
164 $style_setting_data_share['fixed_display']['show_social_count_share'] = 1;
165 } else {
166 $style_setting_data_share['main_content']['show_social_count_share'] = 0;
167 $style_setting_data_share['fixed_display']['show_social_count_share'] = 0;
168 }
169
170 update_option('xs_style_setting_data_share', $style_setting_data_share);
171 break;
172 }
173 }
174
175 if (isset($_POST['counter']['show_font_from_theme'])) {
176 update_option('xs_counter_global_setting_data', ['show_font_from_theme' => 1]);
177 } else {
178 update_option('xs_counter_global_setting_data', ['show_font_from_theme' => 0]);
179 }
180
181 if (!get_option($this->optionKey)) {
182 add_option($this->optionKey, $this->optionValue);
183 }
184 }
185
186 public static function settings() {
187 return [
188 'login' => [
189 'wp_login_page' => [
190 'title' => __('Show button to wp-login page', 'wp-social'),
191 'value' => 'login_form',
192 ],
193 'email_new_registered_user' => [
194 'title' => __('Email login credentials to a newly-registered user', 'wp-social'),
195 'value' => 1,
196 ],
197 ],
198 'share' => [
199 'show_font_from_theme' => [
200 'title' => __('Use theme default font family', 'wp-social'),
201 'value' => 1,
202 ],
203 'show_social_count_share' => [
204 'title' => __('Show total count', 'wp-social'),
205 'value' => 1,
206 ],
207 ],
208 'counter' => [
209 'show_font_from_theme' => [
210 'title' => __('Use theme default font family', 'wp-social'),
211 'value' => 1,
212 ],
213 ],
214 ];
215 }
216 }