PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 2.38
Strong Testimonials v2.38
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
integrations 7 years ago class-strong-form.php 7 years ago class-strong-log.php 7 years ago class-strong-mail.php 7 years ago class-strong-templates.php 7 years ago class-strong-testimonials-order.php 7 years ago class-strong-testimonials-privacy.php 7 years ago class-strong-testimonials-render.php 7 years ago class-strong-testimonials-shortcode-average.php 7 years ago class-strong-testimonials-shortcode-count.php 7 years ago class-strong-testimonials-shortcode.php 7 years ago class-strong-view-display.php 7 years ago class-strong-view-form.php 7 years ago class-strong-view-slideshow.php 7 years ago class-strong-view.php 7 years ago class-walker-strong-category-checklist-front.php 7 years ago deprecated.php 7 years ago filters.php 7 years ago functions-activation.php 7 years ago functions-content.php 7 years ago functions-image.php 7 years ago functions-rating.php 7 years ago functions-template-form.php 7 years ago functions-template.php 7 years ago functions-views.php 7 years ago functions.php 7 years ago l10n-polylang.php 7 years ago l10n-wpml.php 7 years ago post-types.php 7 years ago retro.php 7 years ago scripts.php 7 years ago widget2.php 7 years ago
class-strong-log.php
142 lines
1 <?php
2 /**
3 * Debug Logger
4 */
5
6 if ( ! defined( 'ABSPATH' ) ) exit;
7
8 if ( ! class_exists( 'Strong_Log' ) ) :
9
10 class Strong_Log {
11
12 public $name;
13
14 public $filename;
15
16 public $action;
17
18 public function __construct( $name ) {
19 $this->set_name( $name );
20 $this->set_filename();
21 $this->set_log_action();
22 $this->add_actions();
23 }
24
25 private function set_name( $name = 'main' ) {
26 $this->name = $name;
27 }
28
29 private function set_filename() {
30 $this->filename = apply_filters( "strong_log_{$this->name}_filename",
31 str_replace( '_', '-', "strong-{$this->name}-debug.log" ) );
32 }
33
34 private function set_log_action() {
35 $this->action = "strong_log_{$this->name}";
36 }
37
38 public function add_actions() {
39 add_action( 'init', array( $this, 'init' ), 20 );
40 add_action( 'shutdown', array( $this, 'on_shutdown' ), 20 );
41 }
42
43 public function init() {
44 // TODO Make admin check optional.
45 if ( $this->is_enabled() && current_user_can( 'administrator' ) ) {
46 add_action( $this->action, array( $this, 'debug_log' ), 10, 3 );
47 }
48 }
49
50 private function is_enabled() {
51 $options = get_option( "wpmtst_{$this->name}_debug" );
52 $is_enabled = ( isset( $options['log'] ) && $options['log'] );
53
54 return apply_filters( $this->action, $is_enabled );
55 }
56
57 public function get_log_file_path() {
58 return $this->get_log_file_base( 'basedir' ) . $this->filename;
59 }
60
61 public function get_log_file_url() {
62 return $this->get_log_file_base( 'baseurl' ) . $this->filename;
63 }
64
65 public function get_log_file_base( $base = 'basedir' ) {
66 $upload_dir = wp_upload_dir();
67
68 if ( isset( $upload_dir[ $base ] ) ) {
69 $log_file_base = $upload_dir[ $base ];
70 } else {
71 $log_file_base = $upload_dir['basedir'];
72 }
73
74 return trailingslashit( $log_file_base );
75 }
76
77 /**
78 * Debug log entries.
79 *
80 * @param $entry
81 * @param string $label
82 * @param string $function
83 */
84 public function debug_log( $entry, $label = '', $function = '' ) {
85 $this->log( $entry, $label, $function );
86 }
87
88 /**
89 * Disable debug logging on shutdown.
90 */
91 public function on_shutdown() {
92 if ( get_transient( $this->action ) ) {
93 do_action( $this->action, str_repeat( '-', 50 ), '', current_filter() );
94 delete_transient( $this->action );
95 }
96 }
97
98 /**
99 * Generic logging function.
100 *
101 * @param array|string $data
102 * @param string $label
103 * @param string $function
104 */
105 public function log( $data, $label = '', $function = '' ) {
106
107 $entry = '[' . date('Y-m-d H:i:s') . ']';
108
109 if ( wp_doing_ajax() ) {
110 $entry .= ' | DOING_AJAX';
111 }
112
113 if ( $function ) {
114 $entry .= ' | FN: ' . $function;
115 }
116
117 $entry .= ' | ';
118
119 if ( $label ) {
120 $entry .= $label . ' = ';
121 }
122
123 if ( is_array( $data ) || is_object( $data ) ) {
124 $entry .= print_r( $data, true );
125 } elseif ( is_bool( $data ) ) {
126 $entry .= ( $entry ? 'true' : 'false' ) . PHP_EOL;
127 } else {
128 $entry .= $data . PHP_EOL;
129 }
130
131 //$entry .= PHP_EOL;
132
133 error_log( $entry, 3, $this->get_log_file_path() );
134
135 set_transient( $this->action, true );
136
137 }
138
139 }
140
141 endif;
142