PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 6.1.0
WP Popular Posts v6.1.0
7.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 3 years ago admin-page.php 3 years ago screen-debug.php 3 years ago screen-stats.php 3 years ago screen-tools.php 3 years ago
admin-page.php
132 lines
1 <?php
2 if ( basename($_SERVER['SCRIPT_NAME']) == basename(__FILE__) )
3 exit('Please do not load this page directly');
4
5 $tabs = [
6 'stats' => __('Stats', 'wordpress-popular-posts'),
7 'tools' => __('Tools', 'wordpress-popular-posts'),
8 'params' => __('Parameters', 'wordpress-popular-posts'),
9 'debug' => 'Debug'
10 ];
11
12 // Set active tab
13 if ( isset($_GET['tab'] ) && isset($tabs[$_GET['tab']] ) )
14 $current = $_GET['tab'];
15 else
16 $current = 'stats';
17
18 // Update options on form submission
19 if ( isset($_POST['section']) ) {
20
21 if ( "stats" == $_POST['section'] ) {
22 $current = 'stats';
23
24 if ( isset($_POST['wpp-update-stats-options-token']) && wp_verify_nonce($_POST['wpp-update-stats-options-token'], 'wpp-update-stats-options') ) {
25 $this->config['stats']['limit'] = ( \WordPressPopularPosts\Helper::is_number($_POST['stats_limit']) && $_POST['stats_limit'] > 0 ) ? (int) $_POST['stats_limit'] : 10;
26 $this->config['stats']['post_type'] = empty($_POST['stats_type']) ? "post" : sanitize_text_field($_POST['stats_type']);
27 $this->config['stats']['freshness'] = isset($_POST['stats_freshness']);
28
29 update_option('wpp_settings_config', $this->config);
30 echo "<div class=\"notice notice-success is-dismissible\"><p><strong>" . __('Settings saved.', 'wordpress-popular-posts') . "</strong></p></div>";
31 }
32 }
33 elseif ( "misc" == $_POST['section'] ) {
34 $current = 'tools';
35
36 if ( isset($_POST['wpp-update-misc-options-token'] ) && wp_verify_nonce($_POST['wpp-update-misc-options-token'], 'wpp-update-misc-options') ) {
37 $this->config['tools']['link']['target'] = sanitize_text_field($_POST['link_target']);
38 $this->config['tools']['css'] = (bool) $_POST['css'];
39 $this->config['tools']['experimental'] = isset($_POST['experimental_features']);
40
41 update_option('wpp_settings_config', $this->config);
42 echo "<div class=\"notice notice-success is-dismissible\"><p><strong>" . __('Settings saved.', 'wordpress-popular-posts') . "</strong></p></div>";
43 }
44 }
45 elseif ( "thumb" == $_POST['section'] ) {
46 $current = 'tools';
47
48 if ( isset($_POST['wpp-update-thumbnail-options-token']) && wp_verify_nonce($_POST['wpp-update-thumbnail-options-token'], 'wpp-update-thumbnail-options') ) {
49 if (
50 $_POST['thumb_source'] == "custom_field"
51 && ( ! isset($_POST['thumb_field']) || empty($_POST['thumb_field']) )
52 ) {
53 echo '<div id="wpp-message" class="error fade"><p>' . __('Please provide the name of your custom field.', 'wordpress-popular-posts') . '</p></div>';
54 }
55 else {
56 // thumbnail settings changed, flush transients
57 if ( $this->config['tools']['cache']['active'] ) {
58 $this->flush_transients();
59 }
60
61 $this->config['tools']['thumbnail']['source'] = sanitize_text_field($_POST['thumb_source']);
62 $this->config['tools']['thumbnail']['field'] = ( ! empty($_POST['thumb_field']) ) ? sanitize_text_field($_POST['thumb_field']) : "wpp_thumbnail";
63 $this->config['tools']['thumbnail']['default'] = ( ! empty($_POST['upload_thumb_src']) ) ? $_POST['upload_thumb_src'] : "";
64 $this->config['tools']['thumbnail']['resize'] = (bool) $_POST['thumb_field_resize'];
65 $this->config['tools']['thumbnail']['lazyload'] = (bool) $_POST['thumb_lazy_load'];
66
67 update_option('wpp_settings_config', $this->config );
68 echo "<div class=\"notice notice-success is-dismissible\"><p><strong>" . __('Settings saved.', 'wordpress-popular-posts') . "</strong></p></div>";
69 }
70 }
71 }
72 elseif ( "data" == $_POST['section'] && current_user_can('manage_options') ) {
73 $current = 'tools';
74
75 if ( isset($_POST['wpp-update-data-options-token'] ) && wp_verify_nonce($_POST['wpp-update-data-options-token'], 'wpp-update-data-options') ) {
76 $this->config['tools']['log']['level'] = (int) $_POST['log_option'];
77 $this->config['tools']['log']['limit'] = (int) $_POST['log_limit'];
78 $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;
79 $this->config['tools']['ajax'] = (bool) $_POST['ajax'];
80
81 // if any of the caching settings was updated, destroy all transients created by the plugin
82 if (
83 $this->config['tools']['cache']['active'] != $_POST['cache']
84 || $this->config['tools']['cache']['interval']['time'] != $_POST['cache_interval_time']
85 || $this->config['tools']['cache']['interval']['value'] != $_POST['cache_interval_value']
86 ) {
87 $this->flush_transients();
88 }
89
90 $this->config['tools']['cache']['active'] = (bool) $_POST['cache'];
91 $this->config['tools']['cache']['interval']['time'] = $_POST['cache_interval_time']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
92 $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;
93
94 $this->config['tools']['sampling']['active'] = (bool) $_POST['sampling'];
95 $this->config['tools']['sampling']['rate'] = ( isset($_POST['sample_rate']) && \WordPressPopularPosts\Helper::is_number($_POST['sample_rate']) && $_POST['sample_rate'] > 0 )
96 ? (int) $_POST['sample_rate']
97 : 100;
98
99 update_option('wpp_settings_config', $this->config);
100 echo "<div class=\"notice notice-success is-dismissible\"><p><strong>" . __('Settings saved.', 'wordpress-popular-posts') . "</strong></p></div>";
101 }
102 }
103
104 }
105 ?>
106
107 <?php if ( current_user_can('edit_others_posts') ) : ?>
108 <nav id="wpp-menu">
109 <ul>
110 <li <?php echo ('stats' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo admin_url('options-general.php?page=wordpress-popular-posts&tab=stats'); ?>" title="<?php esc_attr_e('Stats', 'wordpress-popular-posts'); ?>"><span><?php _e('Stats', 'wordpress-popular-posts'); ?></span></a></li>
111 <li <?php echo ('tools' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo admin_url('options-general.php?page=wordpress-popular-posts&tab=tools'); ?>" title="<?php esc_attr_e('Tools', 'wordpress-popular-posts'); ?>"><span><?php _e('Tools', 'wordpress-popular-posts'); ?></span></a></li>
112 <li <?php echo ('debug' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo admin_url('options-general.php?page=wordpress-popular-posts&tab=debug'); ?>" title="Debug"><span>Debug</span></a></li>
113 </ul>
114 </nav>
115 <?php endif; ?>
116
117 <div class="wpp-wrapper wpp-section-<?php echo esc_attr($current); ?>">
118 <div class="wpp-header">
119 <h2>WordPress Popular Posts</h2>
120 <h3><?php echo esc_html($tabs[$current]); ?></h3>
121 </div>
122
123 <?php
124 // Stats
125 require_once 'screen-stats.php';
126 // Tools
127 require_once 'screen-tools.php';
128 // Debug
129 require_once 'screen-debug.php';
130 ?>
131 </div>
132