PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 3.3.2
Strong Testimonials v3.3.2
3.3.2 3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / includes / class-strong-log.php
strong-testimonials / includes Last commit date
elementor 1 year ago logs 1 month ago strong-testimonials-beaver-block 1 year ago submodules 8 months ago class-strong-gutemberg.php 1 year ago class-strong-log.php 1 year ago class-strong-mail.php 1 year ago class-strong-testimonials-average-shortcode.php 1 year ago class-strong-testimonials-count-shortcode.php 1 year ago class-strong-testimonials-defaults.php 1 month ago class-strong-testimonials-form.php 1 month ago class-strong-testimonials-order.php 1 year ago class-strong-testimonials-privacy.php 1 year ago class-strong-testimonials-render.php 1 month ago class-strong-testimonials-templates.php 1 year ago class-strong-testimonials-view-shortcode.php 1 week ago class-strong-testimonials-view-widget.php 1 year ago class-strong-view-display.php 1 day ago class-strong-view-form.php 1 day ago class-strong-view-slideshow.php 1 day ago class-strong-view.php 1 day ago class-walker-strong-category-checklist-front.php 1 year ago deprecated.php 1 year ago filters.php 1 month ago functions-activation.php 1 month ago functions-content.php 11 months ago functions-image.php 5 months ago functions-rating.php 1 year ago functions-template-form.php 1 week ago functions-template.php 4 months ago functions-views.php 1 year ago functions.php 1 month ago l10n-polylang.php 1 year ago l10n-wpml.php 1 year ago post-types.php 1 week ago retro.php 1 year ago scripts.php 1 month ago
class-strong-log.php
144 lines
1 <?php
2 /**
3 * Debug Logger
4 */
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 if ( ! class_exists( 'Strong_Log' ) ) :
11
12 class Strong_Log {
13
14 public $name;
15
16 public $filename;
17
18 public $action;
19
20 public function __construct( $name ) {
21 $this->set_name( $name );
22 $this->set_filename();
23 $this->set_log_action();
24 $this->add_actions();
25 }
26
27 private function set_name( $name = 'main' ) {
28 $this->name = $name;
29 }
30
31 private function set_filename() {
32 $this->filename = apply_filters(
33 "strong_log_{$this->name}_filename",
34 str_replace( '_', '-', "strong-{$this->name}-debug.log" )
35 );
36 }
37
38 private function set_log_action() {
39 $this->action = "strong_log_{$this->name}";
40 }
41
42 public function add_actions() {
43 add_action( 'init', array( $this, 'init' ), 20 );
44 add_action( 'shutdown', array( $this, 'on_shutdown' ), 20 );
45 }
46
47 public function init() {
48 // TODO Make admin check optional.
49 if ( $this->is_enabled() && current_user_can( 'administrator' ) ) {
50 add_action( $this->action, array( $this, 'debug_log' ), 10, 3 );
51 }
52 }
53
54 private function is_enabled() {
55 $options = get_option( "wpmtst_{$this->name}_debug" );
56 $is_enabled = ( isset( $options['log'] ) && $options['log'] );
57
58 return apply_filters( $this->action, $is_enabled );
59 }
60
61 public function get_log_file_path() {
62 return $this->get_log_file_base( 'basedir' ) . $this->filename;
63 }
64
65 public function get_log_file_url() {
66 return $this->get_log_file_base( 'baseurl' ) . $this->filename;
67 }
68
69 public function get_log_file_base( $base = 'basedir' ) {
70 $upload_dir = wp_upload_dir();
71
72 if ( isset( $upload_dir[ $base ] ) ) {
73 $log_file_base = $upload_dir[ $base ];
74 } else {
75 $log_file_base = $upload_dir['basedir'];
76 }
77
78 return trailingslashit( $log_file_base );
79 }
80
81 /**
82 * Debug log entries.
83 *
84 * @param $entry
85 * @param string $label
86 * @param string $function_name
87 */
88 public function debug_log( $entry, $label = '', $function_name = '' ) {
89 $this->log( $entry, $label, $function_name );
90 }
91
92 /**
93 * Disable debug logging on shutdown.
94 */
95 public function on_shutdown() {
96 if ( get_transient( $this->action ) ) {
97 do_action( $this->action, str_repeat( '-', 50 ), '', current_filter() );
98 delete_transient( $this->action );
99 }
100 }
101
102 /**
103 * Generic logging function.
104 *
105 * @param array|string $data
106 * @param string $label
107 * @param string $function_name
108 */
109 public function log( $data, $label = '', $function_name = '' ) {
110
111 $entry = '[' . gmdate( 'Y-m-d H:i:s' ) . ']';
112
113 if ( wp_doing_ajax() ) {
114 $entry .= ' | DOING_AJAX';
115 }
116
117 if ( $function_name ) {
118 $entry .= ' | FN: ' . $function_name;
119 }
120
121 $entry .= ' | ';
122
123 if ( $label ) {
124 $entry .= $label . ' = ';
125 }
126
127 if ( is_array( $data ) || is_object( $data ) ) {
128 $entry .= print_r( $data, true );
129 } elseif ( is_bool( $data ) ) {
130 $entry .= ( $entry ? 'true' : 'false' ) . PHP_EOL;
131 } else {
132 $entry .= $data . PHP_EOL;
133 }
134
135 //$entry .= PHP_EOL;
136
137 error_log( $entry, 3, $this->get_log_file_path() );
138
139 set_transient( $this->action, true );
140 }
141 }
142
143 endif;
144