@@ -27,7 +27,7 @@ class Plugin {
2727
2828
2929 /** @var string plugin version */
30- CONST VERSION = '1.5.4 ' ;
30+ CONST VERSION = '1.5.5 ' ;
3131
3232 /** @var string plugin name */
3333 CONST NAME = 'WP PHP Console ' ;
@@ -85,6 +85,8 @@ private function set_options() {
8585 /**
8686 * Sets plugin text domain.
8787 *
88+ * @internal action hook callback
89+ *
8890 * @since 1.0.0
8991 */
9092 public function set_locale () {
@@ -104,17 +106,20 @@ public function set_locale() {
104106 */
105107 private function set_admin () {
106108
107- if ( ! defined ( ' DOING_AJAX ' ) && is_admin () ) {
109+ if ( is_admin () ) {
108110
109- // add a settings link to the plugins admin screen
110- $ plugin_name = str_replace ( 'includes/class- ' , '' , plugin_basename ( __FILE__ ) );
111- add_filter ( "plugin_action_links_ {$ plugin_name }" , static function ( $ actions ) {
111+ add_filter ( 'plugin_action_links_wp-php-console/wp-php-console.php ' , static function ( $ actions ) {
112112 return array_merge ( [
113- '<a href=" ' . esc_url ( admin_url ( 'options-general.php?page=wp-php-console ' ) ) . '"> ' . __ ( 'Settings ' , 'wp-php-console ' ) . '</a> ' ,
113+ '<a href=" ' . esc_url ( self ::get_settings_page_url () ) . '"> ' . esc_html__ ( 'Settings ' , 'wp-php-console ' ) . '</a> ' ,
114+ '<a href=" ' . esc_url ( self ::get_project_page_url () ) . '"> ' . esc_html__ ( 'GitHub ' , 'wp-php-console ' ) . '</a> ' ,
115+ '<a href=" ' . esc_url ( self ::get_support_page_url () ) . '"> ' . esc_html__ ( 'Support ' , 'wp-php-console ' ) . '</a> ' ,
116+ '<a href=" ' . esc_url ( self ::get_reviews_page_url () ) . '"> ' . esc_html__ ( 'Review ' , 'wp-php-console ' ) . '</a> ' ,
114117 ], $ actions );
115118 } );
116119
117- new Settings ( $ this ->options );
120+ if ( ! defined ( 'DOING_AJAX ' ) ) {
121+ new Settings ( $ this ->options );
122+ }
118123 }
119124 }
120125
@@ -145,6 +150,7 @@ private function set_hooks() {
145150 *
146151 * PHP Console needs to hook in session, in WordPress we need to be in 'init':
147152 * @link http://silvermapleweb.com/using-the-php-session-in-wordpress/
153+ *
148154 * @internal action hook callback
149155 *
150156 * @since 1.4.0
@@ -185,7 +191,7 @@ public function connect() {
185191 *
186192 * @return array
187193 */
188- protected function get_options () {
194+ private function get_options () {
189195
190196 $ options = get_option ( 'wp_php_console ' , [] );
191197
@@ -367,7 +373,6 @@ public function print_notice_exception( \Exception $e ) {
367373 }
368374
369375
370-
371376 /**
372377 * Admin password notice.
373378 *
@@ -393,4 +398,106 @@ public function password_notice() {
393398 }
394399
395400
401+ /**
402+ * Gets the plugin path.
403+ *
404+ * @since 1.5.5
405+ *
406+ * @return string
407+ */
408+ public static function get_plugin_path () {
409+
410+ return untrailingslashit ( dirname ( __DIR__ ) );
411+ }
412+
413+
414+ /**
415+ * Gets the plugin vendor path.
416+ *
417+ * @since 1.5.5
418+ */
419+ public static function get_plugin_vendor_path () {
420+
421+ return self ::get_plugin_path () . '/vendor ' ;
422+ }
423+
424+
425+ /**
426+ * Gets the plugin page URL.
427+ *
428+ * @since 1.5.5
429+ *
430+ * @return string
431+ */
432+ public static function get_plugin_page_url () {
433+
434+ return 'https://wordpress.org/support/plugin/wp-php-console/ ' ;
435+ }
436+
437+
438+ /**
439+ * Gets the GitHub repository page URL.
440+ *
441+ * @since 1.5.5
442+ *
443+ * @return string
444+ */
445+ public static function get_project_page_url () {
446+
447+ return 'https://github.com/unfulvio/wp-php-console ' ;
448+ }
449+
450+
451+ /**
452+ * Gets the plugin reviews page URL.
453+ *
454+ * @since 1.5.5
455+ *
456+ * @return string
457+ */
458+ public static function get_reviews_page_url () {
459+
460+ return 'https://wordpress.org/support/plugin/wp-php-console/reviews/ ' ;
461+ }
462+
463+
464+ /**
465+ * Gets the plugin support page URL.
466+ *
467+ * @since 1.5.5
468+ *
469+ * @return string
470+ */
471+ public static function get_support_page_url () {
472+
473+ return 'https://wordpress.org/support/plugin/wp-php-console/ ' ;
474+ }
475+
476+
477+ /**
478+ * Gets the admin settings page URL.
479+ *
480+ * @since 1.5.5
481+ *
482+ * @return string
483+ */
484+ public static function get_settings_page_url () {
485+
486+ return admin_url ( 'options-general.php?page=wp-php-console ' );
487+ }
488+
489+
490+ /**
491+ * Determines if the current page is the settings page.
492+ *
493+ * @since 1.5.5
494+ *
495+ * @return bool
496+ */
497+ public static function is_settings_page () {
498+
499+ return is_admin () && isset ( $ _GET ['page ' ] ) && 'page ' === 'wp-php-console ' ;
500+ }
501+
502+
396503}
0 commit comments