PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / 2.2.4
Wp Social Login and Register Social Counter v2.2.4
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 3 years ago classes 3 years ago controls 3 years ago views 3 years ago attr.php 4 years ago onboard.php 3 years ago
onboard.php
217 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($_POST['settings']['newsletter_email']),
78 'environment_id' => Onboard::ENVIRONMENT_ID,
79 'contact_list_id' => Onboard::CONTACT_LIST_ID,
80 ];
81
82 $response = Plugin_Data_Sender::instance()->sendAutomizyData( 'email-subscribe', $data);
83 exit;
84 }
85 }
86
87 private function get_onboard_url() {
88 return add_query_arg(
89 array(
90 'page' => 'wslu_global_setting',
91 'wp-social-met-onboard-steps' => 'loaded',
92 ),
93 admin_url('admin.php')
94 );
95 }
96
97 public function redirect_onboard() {
98 if (is_null(get_option($this->optionKey))) {
99 wp_redirect($this->get_onboard_url());
100 exit;
101 }
102 }
103
104 private static function get_plugin_url() {
105 return add_query_arg(
106 array(
107 'page' => 'wslu_global_setting',
108 ),
109 admin_url('admin.php')
110 );
111 }
112
113 public function finish_onboard() {
114
115 if(class_exists('\WP_Social_Pro')) {
116
117 $activated_module = [];
118 $modules = \WP_Social_Pro\Modules\Manifesto::modules_list();
119
120 foreach ($modules as $key => $value) {
121 if (isset($_POST['module_list']) && in_array($key, map_deep( wp_unslash( $_POST['module_list'] ) , 'sanitize_text_field' ))) {
122 $activated_module[$key] = 'yes';
123 } else {
124 $activated_module[$key] = 'no';
125 }
126 }
127
128 update_option(\WP_Social_Pro\Modules\Manifesto::OPTION_KEY_ACTIVE_MODULE_CONF, $activated_module);
129 }
130
131 $login_global_settings = get_option(Login_Settings::OK_GLOBAL, []);
132
133 foreach (self::settings()['login'] as $key => $value) {
134 if (isset($_POST['login']) && array_key_exists($key, map_deep( wp_unslash( $_POST['login'] ) , 'sanitize_text_field' ))) {
135
136 $login_global_settings[$key]['enable'] = 1;
137
138 if ($value != 1 && empty($login_global_settings[$key]['data'])) {
139 $login_global_settings[$key]['data'] = $value;
140 }
141 } else {
142 $login_global_settings[$key]['enable'] = 0;
143 }
144 }
145
146 update_option(Login_Settings::OK_GLOBAL, $login_global_settings);
147
148 foreach (self::settings()['share'] as $key => $value) {
149 switch ($key) {
150 case 'show_font_from_theme':
151
152 if (isset($_POST['share']) && array_key_exists($key, map_deep( wp_unslash( $_POST['share'] ) , 'sanitize_text_field' ))) {
153 update_option('xs_share_global_setting_data', ['show_font_from_theme' => 1]);
154 } else {
155 update_option('xs_share_global_setting_data', ['show_font_from_theme' => 0]);
156 }
157
158 break;
159 case 'show_social_count_share':
160
161 $style_setting_data_share = get_option('xs_style_setting_data_share', []);
162
163 if (isset($_POST['share']) && array_key_exists($key, map_deep( wp_unslash( $_POST['share'] ) , 'sanitize_text_field' ))) {
164 $style_setting_data_share['main_content']['show_social_count_share'] = 1;
165 $style_setting_data_share['fixed_display']['show_social_count_share'] = 1;
166 } else {
167 $style_setting_data_share['main_content']['show_social_count_share'] = 0;
168 $style_setting_data_share['fixed_display']['show_social_count_share'] = 0;
169 }
170
171 update_option('xs_style_setting_data_share', $style_setting_data_share);
172 break;
173 }
174 }
175
176 if (isset($_POST['counter']['show_font_from_theme'])) {
177 update_option('xs_counter_global_setting_data', ['show_font_from_theme' => 1]);
178 } else {
179 update_option('xs_counter_global_setting_data', ['show_font_from_theme' => 0]);
180 }
181
182 if (!get_option($this->optionKey)) {
183 add_option($this->optionKey, $this->optionValue);
184 }
185 }
186
187 public static function settings() {
188 return [
189 'login' => [
190 'wp_login_page' => [
191 'title' => __('Show button to wp-login page', 'wp-social'),
192 'value' => 'login_form',
193 ],
194 'email_new_registered_user' => [
195 'title' => __('Email login credentials to a newly-registered user', 'wp-social'),
196 'value' => 1,
197 ],
198 ],
199 'share' => [
200 'show_font_from_theme' => [
201 'title' => __('Use theme default font family', 'wp-social'),
202 'value' => 1,
203 ],
204 'show_social_count_share' => [
205 'title' => __('Show total count', 'wp-social'),
206 'value' => 1,
207 ],
208 ],
209 'counter' => [
210 'show_font_from_theme' => [
211 'title' => __('Use theme default font family', 'wp-social'),
212 'value' => 1,
213 ],
214 ],
215 ];
216 }
217 }