Skip to content

Commit 3c05a48

Browse files
committed
Improved settings handler
1 parent 02e362b commit 3c05a48

File tree

9 files changed

+724
-456
lines changed

9 files changed

+724
-456
lines changed

ChangeLog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Changelog
22

3-
### 1.5.5 (unreleased)
3+
### 1.6.0 (unreleased)
44
* Misc: Add plugin admin action links
5+
* Misc: Improved settings handler
56

67
### 1.5.4 (30 May 2019)
78
* Fix: Temporarily suppress PHP warnings while connecting with PHP Console to avoid headers already sent warnings, then restore all errors reporting

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "unfulvio/wp-php-console",
33
"description": "A WordPress implementation of PHP Console.",
44
"type": "wordpress-plugin",
5-
"version": "1.5.5",
5+
"version": "1.6.0",
66
"keywords": ["wordpress", "debug", "debugging", "development", "php-console", "console", "terminal", "command-line", "cli" ],
77
"homepage": "https://github.com/unfulvio/wp-php-console",
88
"license": "GPLv3.0+",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "wp-php-console",
33
"title": "WP PHP Console",
44
"description": "An implementation of PHP Console as a WordPress plugin. Use Chrome Dev Tools to debug your WordPress installation!",
5-
"version": "1.5.5",
5+
"version": "1.6.0",
66
"homepage": "https://wordpress.org/plugins/wp-php-console/",
77
"repository": {
88
"type": "git",

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ None.
130130

131131
= 1.5.5 =
132132
* Misc: Add plugin admin action links
133+
* Misc: Improved settings handler
133134

134135
= 1.5.4 =
135136
* Fix: Temporarily suppress PHP warnings while connecting with PhpConsole to avoid headers already sent warnings, then restore all errors reporting

src/Admin.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* WP PHP Console
4+
*
5+
* This source file is subject to the GNU General Public License v3.0
6+
* that is bundled with this package in the file license.txt.
7+
* It is also available through the world-wide-web at this URL:
8+
* http://www.gnu.org/licenses/gpl-3.0.html
9+
*
10+
* @author Fulvio Notarstefano <[email protected]>
11+
* @copyright Copyright (c) 2014-2019 Fulvio Notarstefano
12+
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
13+
*/
14+
15+
namespace WP_PHP_Console;
16+
17+
defined( 'ABSPATH' ) or exit;
18+
19+
/**
20+
* WP PHP Console admin handler.
21+
*
22+
* @since 1.6.0
23+
*/
24+
class Admin {
25+
26+
27+
/**
28+
* Initializes the plugin admin.
29+
*
30+
* @since 1.6.0
31+
*/
32+
public function __construct() {
33+
34+
// add plugin page row action links
35+
add_filter( 'plugin_action_links_wp-php-console/wp-php-console.php', static function( $actions ) {
36+
return array_merge( [
37+
'<a href="' . esc_url( admin_url() ) . '">' . esc_html__( 'Settings', 'wp-php-console' ) . '</a>',
38+
'<a href="' . esc_url( Plugin::get_project_page_url() ) . '">' . esc_html__( 'GitHub', 'wp-php-console' ) . '</a>',
39+
'<a href="' . esc_url( Plugin::get_support_page_url() ) . '">' . esc_html__( 'Support', 'wp-php-console' ) . '</a>',
40+
'<a href="' . esc_url( Plugin::get_reviews_page_url() ) . '">' . esc_html__( 'Review', 'wp-php-console' ) . '</a>',
41+
], $actions );
42+
} );
43+
44+
// init settings page
45+
if ( ! defined( 'DOING_AJAX' ) ) {
46+
new Admin\SettingsPage();
47+
}
48+
}
49+
50+
51+
/**
52+
* Displays notices in admin.
53+
*
54+
* @since 1.6.0
55+
*/
56+
private static function output_admin_notices() {
57+
58+
// display admin notice and abort if no password has been set
59+
add_action( 'admin_notices', static function() {
60+
if ( ! Settings::has_eval_terminal_password() ) :
61+
?>
62+
<div class="update-nag">
63+
<p><?php printf(
64+
/* translators: Placeholders: %1$s - WP PHP Console name, %2$s - opening HTML <a> link tag; %3$s closing HTML </a> link tag */
65+
__( '%1$s: Please remember to %2$sset a password%3$s if you want to enable the terminal.', 'wp-php-console' ),
66+
'<strong>' . Plugin::NAME . '</strong>',
67+
'<a href="' . esc_url( admin_url( 'options-general.php?page=wp-php-console' ) ) .'">',
68+
'</a>'
69+
); ?></p>
70+
</div>
71+
<?php
72+
endif;
73+
}, -1000 );
74+
}
75+
76+
77+
}

0 commit comments

Comments
 (0)