PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 6.4.1
WP Popular Posts v6.4.1
4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 5.0.0 5.0.1 5.0.2 5.1.0 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.1.2 6.1.3 6.1.4 6.2.0 6.2.1 6.3.0 6.3.1 6.3.2 6.3.3 6.3.4 6.4.0 6.4.1 6.4.2 7.0.0 7.0.1 7.1.0 7.2.0 7.3.0 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.3.7 7.3.8 7.4.0 trunk 2.3.7 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.2 4.0.3 4.0.5 4.0.6
wordpress-popular-posts / src / Admin / admin-page.php
wordpress-popular-posts / src / Admin Last commit date
Admin.php 2 years ago admin-page.php 2 years ago screen-debug.php 2 years ago screen-stats.php 2 years ago screen-tools.php 2 years ago
admin-page.php
134 lines
1 <?php
2 if ( basename($_SERVER['SCRIPT_NAME']) == basename(__FILE__) ) {
3 exit('Please do not load this page directly');
4 }
5
6 $wpp_tabs = [
7 'stats' => __('Stats', 'wordpress-popular-posts'),
8 'tools' => __('Tools', 'wordpress-popular-posts'),
9 'params' => __('Parameters', 'wordpress-popular-posts'),
10 'debug' => 'Debug'
11 ];
12
13 // Set active tab
14 if ( isset($_GET['tab'] ) && isset($wpp_tabs[$_GET['tab']] ) ) {
15 $current = $_GET['tab']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- $current will be equal to one of the registered tabs
16 } else {
17 $current = 'stats';
18 }
19
20 // Update options on form submission
21 if ( isset($_POST['section']) ) {
22
23 if ( 'stats' == $_POST['section'] ) {
24 $current = 'stats';
25
26 if ( isset($_POST['wpp-update-stats-options-token']) && wp_verify_nonce($_POST['wpp-update-stats-options-token'], 'wpp-update-stats-options') ) {
27 $this->config['stats']['limit'] = ( \WordPressPopularPosts\Helper::is_number($_POST['stats_limit']) && $_POST['stats_limit'] > 0 ) ? (int) $_POST['stats_limit'] : 10;
28 $this->config['stats']['post_type'] = empty($_POST['stats_type']) ? 'post' : sanitize_text_field($_POST['stats_type']);
29 $this->config['stats']['freshness'] = isset($_POST['stats_freshness']);
30
31 update_option('wpp_settings_config', $this->config);
32 echo '<div class="notice notice-success is-dismissible"><p><strong>' . esc_html(__('Settings saved.', 'wordpress-popular-posts')) . '</strong></p></div>';
33 }
34 }
35 elseif ( 'misc' == $_POST['section'] ) {
36 $current = 'tools';
37
38 if ( isset($_POST['wpp-update-misc-options-token'] ) && wp_verify_nonce($_POST['wpp-update-misc-options-token'], 'wpp-update-misc-options') ) {
39 $this->config['tools']['link']['target'] = sanitize_text_field($_POST['link_target']);
40 $this->config['tools']['css'] = (bool) $_POST['css'];
41 $this->config['tools']['experimental'] = isset($_POST['experimental_features']);
42
43 update_option('wpp_settings_config', $this->config);
44 echo '<div class="notice notice-success is-dismissible"><p><strong>' . esc_html(__('Settings saved.', 'wordpress-popular-posts')) . '</strong></p></div>';
45 }
46 }
47 elseif ( 'thumb' == $_POST['section'] ) {
48 $current = 'tools';
49
50 if ( isset($_POST['wpp-update-thumbnail-options-token']) && wp_verify_nonce($_POST['wpp-update-thumbnail-options-token'], 'wpp-update-thumbnail-options') ) {
51 if (
52 $_POST['thumb_source'] == 'custom_field'
53 && ( ! isset($_POST['thumb_field']) || empty($_POST['thumb_field']) )
54 ) {
55 echo '<div class="notice notice-error"><p>' . esc_html(__('Please provide the name of your custom field.', 'wordpress-popular-posts')) . '</p></div>';
56 }
57 else {
58 // thumbnail settings changed, flush transients
59 if ( $this->config['tools']['cache']['active'] ) {
60 $this->flush_transients();
61 }
62
63 $this->config['tools']['thumbnail']['source'] = sanitize_text_field($_POST['thumb_source']);
64 $this->config['tools']['thumbnail']['field'] = ( ! empty($_POST['thumb_field']) ) ? sanitize_text_field($_POST['thumb_field']) : 'wpp_thumbnail';
65 $this->config['tools']['thumbnail']['default'] = ( ! empty($_POST['upload_thumb_src']) ) ? $_POST['upload_thumb_src'] : '';
66 $this->config['tools']['thumbnail']['resize'] = (bool) $_POST['thumb_field_resize'];
67 $this->config['tools']['thumbnail']['lazyload'] = (bool) $_POST['thumb_lazy_load'];
68
69 update_option('wpp_settings_config', $this->config );
70 echo '<div class="notice notice-success is-dismissible"><p><strong>' . esc_html(__('Settings saved.', 'wordpress-popular-posts')) . '</strong></p></div>';
71 }
72 }
73 }
74 elseif ( 'data' == $_POST['section'] && current_user_can('manage_options') ) {
75 $current = 'tools';
76
77 if ( isset($_POST['wpp-update-data-options-token'] ) && wp_verify_nonce($_POST['wpp-update-data-options-token'], 'wpp-update-data-options') ) {
78 $this->config['tools']['log']['level'] = (int) $_POST['log_option'];
79 $this->config['tools']['log']['limit'] = (int) $_POST['log_limit'];
80 $this->config['tools']['log']['expires_after'] = ( \WordPressPopularPosts\Helper::is_number($_POST['log_expire_time']) && $_POST['log_expire_time'] > 0 ) ? (int) $_POST['log_expire_time'] : 180;
81 $this->config['tools']['ajax'] = (bool) $_POST['ajax'];
82
83 // if any of the caching settings was updated, destroy all transients created by the plugin
84 if (
85 $this->config['tools']['cache']['active'] != $_POST['cache']
86 || $this->config['tools']['cache']['interval']['time'] != $_POST['cache_interval_time']
87 || $this->config['tools']['cache']['interval']['value'] != $_POST['cache_interval_value']
88 ) {
89 $this->flush_transients();
90 }
91
92 $this->config['tools']['cache']['active'] = (bool) $_POST['cache'];
93 $this->config['tools']['cache']['interval']['time'] = $_POST['cache_interval_time']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
94 $this->config['tools']['cache']['interval']['value'] = ( isset($_POST['cache_interval_value']) && \WordPressPopularPosts\Helper::is_number($_POST['cache_interval_value']) && $_POST['cache_interval_value'] > 0 ) ? (int) $_POST['cache_interval_value'] : 1;
95
96 $this->config['tools']['sampling']['active'] = (bool) $_POST['sampling'];
97 $this->config['tools']['sampling']['rate'] = ( isset($_POST['sample_rate']) && \WordPressPopularPosts\Helper::is_number($_POST['sample_rate']) && $_POST['sample_rate'] > 0 )
98 ? (int) $_POST['sample_rate']
99 : 100;
100
101 update_option('wpp_settings_config', $this->config);
102 echo '<div class="notice notice-success is-dismissible"><p><strong>' . esc_html(__('Settings saved.', 'wordpress-popular-posts')) . '</strong></p></div>';
103 }
104 }
105
106 }
107 ?>
108
109 <?php if ( current_user_can('edit_others_posts') ) : ?>
110 <nav id="wpp-menu">
111 <ul>
112 <li <?php echo ('stats' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo esc_url(admin_url('options-general.php?page=wordpress-popular-posts&tab=stats')); ?>" title="<?php esc_attr_e('Stats', 'wordpress-popular-posts'); ?>"><span><?php esc_html_e('Stats', 'wordpress-popular-posts'); ?></span></a></li>
113 <li <?php echo ('tools' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo esc_url(admin_url('options-general.php?page=wordpress-popular-posts&tab=tools')); ?>" title="<?php esc_attr_e('Tools', 'wordpress-popular-posts'); ?>"><span><?php esc_html_e('Tools', 'wordpress-popular-posts'); ?></span></a></li>
114 <li <?php echo ('debug' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo esc_url(admin_url('options-general.php?page=wordpress-popular-posts&tab=debug')); ?>" title="Debug"><span>Debug</span></a></li>
115 </ul>
116 </nav>
117 <?php endif; ?>
118
119 <div class="wpp-wrapper wpp-section-<?php echo esc_attr($current); ?>">
120 <div class="wpp-header">
121 <h2>WordPress Popular Posts</h2>
122 <h3><?php echo esc_html($wpp_tabs[$current]); ?></h3>
123 </div>
124
125 <?php
126 // Stats
127 require_once 'screen-stats.php';
128 // Tools
129 require_once 'screen-tools.php';
130 // Debug
131 require_once 'screen-debug.php';
132 ?>
133 </div>
134