PluginProbe ʕ •ᴥ•ʔ
Rich Showcase for Google Reviews / 3.1
Rich Showcase for Google Reviews v3.1
6.9.8 6.9.7 6.9.6 trunk 1.4 1.42 1.43 1.44 1.45 1.46 1.47 1.48 1.49 1.5 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.7 1.6.8 1.6.9 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.4 2.4.1 2.4.2 2.5 2.5.1 2.6 2.6.1 2.6.2 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.6.1 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.8.1 4.8.2 5.0 5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.7.1 5.8 5.9 5.9.1 5.9.2 5.9.3 5.9.7 6.0 6.1 6.2 6.3 6.4 6.4.1 6.5 6.6 6.6.1 6.6.2 6.7 6.8 6.8.1 6.8.2 6.9 6.9.1 6.9.2 6.9.3 6.9.4 6.9.4.1 6.9.4.2 6.9.4.3 6.9.4.4 6.9.5
widget-google-reviews / includes / class-settings-save.php
widget-google-reviews / includes Last commit date
admin 2 years ago core 2 years ago class-activator.php 3 years ago class-assets.php 2 years ago class-builder-page.php 3 years ago class-deactivator.php 3 years ago class-debug-info.php 2 years ago class-feed-ajax.php 2 years ago class-feed-block.php 2 years ago class-feed-deserializer.php 2 years ago class-feed-old.php 4 years ago class-feed-page.php 3 years ago class-feed-serializer.php 3 years ago class-feed-shortcode.php 3 years ago class-feed-widget.php 4 years ago class-plugin-overview-ajax.php 3 years ago class-plugin-overview.php 3 years ago class-plugin-settings.php 2 years ago class-plugin-support.php 3 years ago class-plugin.php 2 years ago class-post-types.php 3 years ago class-reviews-cron.php 2 years ago class-settings-save.php 3 years ago class-view.php 2 years ago index.php 4 years ago page-setting-fig.php 3 years ago page-setting-support.php 4 years ago
class-settings-save.php
157 lines
1 <?php
2
3 namespace WP_Rplg_Google_Reviews\Includes;
4
5 class Settings_Save {
6
7 private $activator;
8 private $reviews_cron;
9
10 public function __construct(Activator $activator, Reviews_Cron $reviews_cron) {
11 $this->activator = $activator;
12 $this->reviews_cron = $reviews_cron;
13 }
14
15 public function register() {
16 add_action('admin_post_grw_settings_save', array($this, 'save_from_post_array'));
17 }
18
19 public function save_from_post_array() {
20 global $wpdb;
21
22 if (!function_exists('wp_nonce_field')) {
23 function wp_nonce_field() {}
24 }
25
26 if (!current_user_can('manage_options')) {
27 die('The account you\'re logged in to doesn\'t have permission to access this page.');
28 }
29
30 if (!empty($_POST)) {
31 $nonce_result_check = $this->check_nonce();
32 if ($nonce_result_check === false) {
33 die('Unable to save changes. Make sure you are accessing this page from the Wordpress dashboard.');
34 }
35 }
36
37 $notice_code = null;
38 update_option('grw_notice_type', 'success');
39
40 if (isset($_POST['active']) && isset($_GET['active'])) {
41 $active = $_GET['active'] == '1' ? '1' : '0';
42 update_option('grw_active', $active);
43 $notice_code = 'settings_active_' . $active;
44 }
45
46 if (isset($_POST['save'])) {
47 $fields = array('grw_demand_assets', 'grw_minified_assets', 'grw_google_api_key');
48 foreach ($fields as $field) {
49
50 if (isset($_POST[$field])) {
51 $value = $_POST[$field];
52 update_option($field, trim(sanitize_text_field(wp_unslash($value))));
53
54 // If save Google API key automatically enable a reviews update cron
55 if ($field == 'grw_google_api_key' && strlen($value) > 0) {
56 update_option('grw_revupd_cron', '1');
57 }
58 }
59 }
60 $notice_code = 'settings_save';
61 }
62
63 if (isset($_POST['create_db'])) {
64 $this->activator->create_db();
65 $notice_code = 'settings_create_db';
66 }
67
68 if (isset($_POST['install'])) {
69 $install_multisite = sanitize_text_field(wp_unslash($_POST['install_multisite']));
70 $this->activator->drop_db($install_multisite);
71 $this->activator->delete_all_options($install_multisite);
72 $this->activator->delete_all_feeds($install_multisite);
73 $this->activator->activate();
74 $this->reviews_cron->deactivate();
75 $notice_code = 'settings_install';
76 }
77
78 if (isset($_POST['reset_all'])) {
79 $reset_all_multisite = sanitize_text_field(wp_unslash($_POST['reset_all_multisite']));
80 $this->activator->drop_db($reset_all_multisite);
81 $this->activator->delete_all_options($reset_all_multisite);
82 $this->activator->delete_all_feeds($reset_all_multisite);
83 $this->reviews_cron->deactivate();
84 $notice_code = 'settings_reset_all';
85 }
86
87 if (isset($_POST['debug_mode'])) {
88 $debug_mode = $_POST['debug_mode'] == 'Enable' ? '1' : '0';
89 update_option('grw_debug_mode', $debug_mode);
90 $notice_code = 'settings_debug_mode_' . $debug_mode;
91 }
92
93 if (isset($_POST['update_db_ver']) && isset($_POST['update_db'])) {
94 $update_db_ver = sanitize_text_field(wp_unslash($_POST['update_db_ver']));
95 if (strlen($update_db_ver) > 0) {
96 $this->activator->update_db($update_db_ver);
97 $notice_code = 'settings_update_db';
98 }
99 }
100
101 if (isset($_POST['revupd_cron'])) {
102 $revupd_cron = $_POST['revupd_cron'] == 'Enable' ? '1' : '0';
103 if ($revupd_cron == '0') {
104 $this->reviews_cron->deactivate();
105 }
106 update_option('grw_revupd_cron', $revupd_cron);
107 $notice_code = 'settings_revupd_cron_' . $revupd_cron;
108
109 /*$api_key = get_option('grw_google_api_key');
110 if ($api_key) {
111 update_option('grw_revupd_cron', $revupd_cron);
112 $notice_code = 'settings_revupd_cron_' . $revupd_cron;
113 } else {
114 update_option('grw_notice_type', 'error');
115 update_option('grw_notice_msg', 'To make the reviews automatically updated, please create your own Google API key. The extrimly detailed instruction how to do it, you can <a href="' . admin_url('admin.php?page=grw-support&grw_tab=fig#fig_api_key') . '" target="_blank">find here</a>.');
116 $notice_code = 'custom_msg';
117 }*/
118 }
119
120 $this->redirect_to_tab($notice_code);
121 }
122
123 public function redirect_to_tab($notice_code = '') {
124 if (empty($_GET['grw_tab'])) {
125 wp_safe_redirect(wp_get_referer());
126 exit;
127 }
128
129 $tab = sanitize_text_field(wp_unslash($_GET['grw_tab']));
130
131 $query_args = array(
132 'grw_tab' => $tab,
133 );
134
135 if (!empty($notice_code)) {
136 $query_args['grw_notice'] = $notice_code;
137 }
138
139 wp_safe_redirect(add_query_arg($query_args, wp_get_referer()));
140 exit;
141 }
142
143 private function check_nonce() {
144 $nonce_actions = array('active', 'save', 'create_db', 'reset', 'reset_all', 'debug_mode', 'update_db');
145 $nonce_form_prefix = 'grw-form_nonce_';
146 $nonce_action_prefix = 'grw-wpnonce_';
147 foreach ($nonce_actions as $key => $value) {
148 if (isset($_POST[$nonce_form_prefix.$value])) {
149 check_admin_referer($nonce_action_prefix.$value, $nonce_form_prefix.$value);
150 return true;
151 }
152 }
153 return false;
154 }
155
156 }
157