PluginProbe
Knowledge Base documentation & wiki plugin – BasePress Docs / trunk
Knowledge Base documentation & wiki plugin – BasePress Docs vtrunk
basepress / includes / class-basepress-debug-output.php

class-basepress-debug-output.php in Knowledge Base documentation & wiki plugin – BasePress Docs trunk, at includes/class-basepress-debug-output.php

89 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * This is the class that handles debugging functionalities
4 */
5
6 // Exit if called directly
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 if ( ! class_exists( 'Basepress_Debug_Output' ) ){
12
13 class Basepress_Debug_Output{
14
15 private $is_debug = false;
16
17 public function __construct(){
18 add_action( 'init', array( $this, 'toggle_debugging' ) );
19 }
20
21
22 public function toggle_debugging(){
23
24 if( isset( $_REQUEST['basepress_debug'] ) && ! (bool)$_REQUEST['basepress_debug'] && isset( $_COOKIE['basepress_debug'] ) ){
25 $this->is_debug = false;
26 setcookie( 'basepress_debug', true, time() - 3600, '/' );
27 }
28 elseif( isset( $_REQUEST['basepress_debug'] ) && (bool)$_REQUEST['basepress_debug']
29 || isset( $_COOKIE['basepress_debug'] ) ){
30 $this->is_debug = true;
31 setcookie( 'basepress_debug', true, 0, '/' );
32 add_action( 'wp_footer', array( $this, 'run_debug' ) );
33 }
34
35 }
36
37 public function run_debug(){
38 global $basepress_utils;
39
40 $options = $basepress_utils->get_options();
41 ?>
42 <!-- BasePress KB Debugging info
43
44 VERSION: <?php echo esc_html( BASEPRESS_VER ); ?>
45
46 DB VERSION: <?php echo esc_html( BASEPRESS_DB_VER ); ?>
47
48 PLAN: <?php echo esc_html( ucfirst( BASEPRESS_PLAN ) ); ?>
49
50
51 VARIABLES:
52 <?php
53 global $basepress_utils;
54 echo 'is_knowledgebase: ' . var_export( $basepress_utils->is_knowledgebase, true ) . "\n"; // phpcs:ignore
55 echo 'is_products_page: ' . var_export( $basepress_utils->is_products_page, true ) . "\n"; // phpcs:ignore
56 echo 'is_product: ' . var_export( $basepress_utils->is_product, true ) . "\n"; // phpcs:ignore
57 echo 'is_section: ' . var_export( $basepress_utils->is_section, true ) . "\n"; // phpcs:ignore
58 echo 'is_tag: ' . var_export( $basepress_utils->is_tag, true ) . "\n"; // phpcs:ignore
59 echo 'is_article: ' . var_export( $basepress_utils->is_article, true ) . "\n"; // phpcs:ignore
60 echo 'is_search: ' . var_export( $basepress_utils->is_search, true ) . "\n"; // phpcs:ignore
61 echo 'is_global_search: ' . var_export( $basepress_utils->is_global_search, true ) . "\n"; // phpcs:ignore
62
63 //Exclude this options from output
64 $excluded_options = array(
65 'post_count_ip_exclude',
66 'feedback_recaptcha_site_key',
67 'feedback_recaptcha_secrete_key',
68 'feedback_notify_admin',
69 'feedback_notice_email_from'
70 );
71
72 foreach( $excluded_options as $excluded_option ){
73 if( isset( $options[$excluded_option] ) ){
74 unset( $options[$excluded_option] );
75 }
76 }
77 ?>
78
79 OPTIONS:
80 <?php echo var_export( $options ); // phpcs:ignore ?>
81
82 -->
83 <?php
84 }
85 }
86
87 new Basepress_Debug_Output();
88 }
89