-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqycli.php
More file actions
111 lines (96 loc) · 3.39 KB
/
qycli.php
File metadata and controls
111 lines (96 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* @package qycli-utilities
* @version 1.0.3
*/
/*
Plugin Name: qycli Utilities
Description: qycli Utilities
Author: Micha Cassola
Author URI: https://github.com/michacassola
Version: 1.0.3
License: MIT http://opensource.org/licenses/MIT
*/
add_filter( 'auto_update_plugin', '__return_true' );
add_filter( 'auto_update_theme', '__return_true' );
add_action("admin_menu", "qyc_submenu");
function qyc_submenu() {
add_submenu_page(
'tools.php',
'qycli Utilities',
'qycli Utilities',
'administrator',
'qycli-utilities',
'qyc_admin_page',
-1 );
}
function qyc_admin_page() {
//Get the active tab from the $_GET param
$default_tab = null;
$tab = isset($_GET['tab']) ? $_GET['tab'] : $default_tab;
?>
<div class="wrap">
<h2 style="margin-bottom: 15px;">qycli Utilities</h2>
<!-- Here are our tabs -->
<nav class="nav-tab-wrapper">
<a href="?page=qycli-utilities" class="nav-tab <?php if($tab===null):?>nav-tab-active<?php endif; ?>">Logins</a>
<a href="?page=qycli-utilities&tab=object-stats" class="nav-tab <?php if($tab==='object-stats'):?>nav-tab-active<?php endif; ?>">Object Cache Stats</a>
</nav>
<div class="tab-content">
<?php switch($tab) :
case 'object-stats':
qyc_object_stats_tab();
break;
default:
qyc_default_tab();
break;
endswitch; ?>
</div>
</div>
<?php
}
function qyc_default_tab() {
?>
<br><p>Login to phpMyAdmin and File Browser with:</p>
<p>User: <?php echo DB_USER ?> <br>
Password: <?php echo DB_PASSWORD ?></p>
<div style="display: flex;">
<a href="https://<?php echo $_SERVER['HTTP_HOST'] ?>/qyc/pma/" target="_blank" style="margin: 5px;"><div class="submit button button-primary">
phpMyAdmin <div class="dashicons dashicons-external" style="position: relative; bottom: 2px; vertical-align: middle;"></div></div></a>
<a href="https://<?php echo $_SERVER['HTTP_HOST'] ?>/qyc/fb/" target="_blank" style="margin: 5px;"><div class="submit button button-primary">
File Browser <div class="dashicons dashicons-external" style="position: relative; bottom: 2px; vertical-align: middle;"></div></div></a>
</div>
<?php
}
function qyc_object_stats_tab() {
?>
<h3 style="margin: 30px 0 15px 0;">WP redis Object Caching Statistics</h3>
<?php $GLOBALS['wp_object_cache']->stats(); ?>
<?php
}
if ( function_exists( 'wp_cache_flush' ) ) {
add_action( 'admin_bar_menu', 'o1_flush_cache_button', 100 );
}
/* WP Redis Object Cache Flush Admin Bar Button*/
function o1_flush_cache_button( $wp_admin_bar ) {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
if ( isset( $_GET['flush-cache-button'] )
&& 'flush' === $_GET['flush-cache-button']
&& wp_verify_nonce( $_GET['_wpnonce'], 'flush-cache-button' )
) {
wp_cache_flush();
add_action( 'admin_notices', function () {
echo '<div class="notice notice-success is-dismissible"><p>Object Cache flushed.</p></div>';
} );
}
$dashboard_url = admin_url( add_query_arg( 'flush-cache-button', 'flush', 'index.php' ) );
$args = array(
'id' => 'flush_cache_button',
'title' => 'Flush Object Cache',
'href' => wp_nonce_url( $dashboard_url, 'flush-cache-button' ),
'meta' => array( 'class' => 'flush-cache-button' )
);
$wp_admin_bar->add_node( $args );
}