@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @subpackage Yikes_Inc_Easy_Mailchimp_Extender/includes |
| 26 | 26 | * @author YIKES Inc. <[email protected]> |
| 27 | 27 | */ |
| 28 | -class Yikes_Inc_Easy_Mailchimp_Error_Logging {
|
|
| 28 | +class Yikes_Inc_Easy_Mailchimp_Error_Logging { |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Whether we're doing debugging. |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @since 1.0.0 |
| 59 | 59 | */ |
| 60 | - public function __construct() {
|
|
| 60 | + public function __construct() { |
|
| 61 | 61 | $this->is_debugging = WP_DEBUG || (string) get_option( 'yikes-mailchimp-debug-status', '' ) === '1'; |
| 62 | 62 | $this->error_log_file_path = $this->get_error_log_file_path(); |
| 63 | 63 | $this->error_log_folder_path = $this->get_error_log_folder(); |
@@ -78,35 +78,35 @@ discard block |
||
| 78 | 78 | * @param string $error_type The error type. |
| 79 | 79 | * @param string $page The page information. |
| 80 | 80 | */ |
| 81 | - public function maybe_write_to_log( $returned_error, $error_type, $page = '' ) {
|
|
| 82 | - if ( ! $this->is_debugging ) {
|
|
| 81 | + public function maybe_write_to_log( $returned_error, $error_type, $page = '' ) { |
|
| 82 | + if ( ! $this->is_debugging ) { |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $this->yikes_easy_mailchimp_write_to_error_log( $returned_error, $error_type, $page ); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function create_error_log_folder() {
|
|
| 89 | + public function create_error_log_folder() { |
|
| 90 | 90 | |
| 91 | 91 | // If our directory doesn't exist, make it. |
| 92 | - if ( ! file_exists( $this->get_error_log_folder() ) ) {
|
|
| 92 | + if ( ! file_exists( $this->get_error_log_folder() ) ) { |
|
| 93 | 93 | mkdir( $this->get_error_log_folder() ); |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function create_error_log_file() {
|
|
| 97 | + public function create_error_log_file() { |
|
| 98 | 98 | |
| 99 | 99 | // If our error log doesn't exist, make it. |
| 100 | - if ( ! file_exists( $this->error_log_file_path ) ) {
|
|
| 100 | + if ( ! file_exists( $this->error_log_file_path ) ) { |
|
| 101 | 101 | file_put_contents( $this->error_log_file_path, '' ); |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - private function get_error_log_folder() {
|
|
| 105 | + private function get_error_log_folder() { |
|
| 106 | 106 | return WP_CONTENT_DIR . '/uploads/yikes-log/'; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - private function get_error_log_file_path() {
|
|
| 109 | + private function get_error_log_file_path() { |
|
| 110 | 110 | return WP_CONTENT_DIR . '/uploads/yikes-log/yikes-easy-mailchimp-error-log.txt'; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -122,17 +122,17 @@ discard block |
||
| 122 | 122 | * @returned_error |
| 123 | 123 | * @error_type - what was running when the error occured ie (new user subscription, remove user etc) |
| 124 | 124 | */ |
| 125 | - public function yikes_easy_mailchimp_write_to_error_log( $returned_error , $error_type , $page='' ) {
|
|
| 125 | + public function yikes_easy_mailchimp_write_to_error_log( $returned_error , $error_type , $page='' ) { |
|
| 126 | 126 | |
| 127 | 127 | // confirm error logging is toggled on, else lets exit |
| 128 | - if( get_option( 'yikes-mailchimp-debug-status' , '' ) != '1' ) {
|
|
| 128 | + if( get_option( 'yikes-mailchimp-debug-status' , '' ) != '1' ) { |
|
| 129 | 129 | return; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $contents = file_get_contents( $this->error_log_file_path, true ); |
| 133 | 133 | |
| 134 | 134 | // if we pass in a custom page, don't set things up |
| 135 | - if ( empty( $page ) ) {
|
|
| 135 | + if ( empty( $page ) ) { |
|
| 136 | 136 | |
| 137 | 137 | // get the current page, admin or front end? |
| 138 | 138 | $page = is_admin() ? __( 'Admin', 'yikes-inc-easy-mailchimp-extender' ) : __( 'Front End', 'yikes-inc-easy-mailchimp-extender' ); |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @since 5.6 |
| 170 | 170 | */ |
| 171 | - public function yikes_easy_mailchimp_generate_error_log_table() {
|
|
| 171 | + public function yikes_easy_mailchimp_generate_error_log_table() { |
|
| 172 | 172 | |
| 173 | 173 | // ensure file_get_contents exists |
| 174 | - if( function_exists( 'file_get_contents' ) ) {
|
|
| 174 | + if( function_exists( 'file_get_contents' ) ) { |
|
| 175 | 175 | // confirm that our file exists |
| 176 | - if( file_exists( $this->error_log_file_path ) ) {
|
|
| 176 | + if( file_exists( $this->error_log_file_path ) ) { |
|
| 177 | 177 | $error_log_contents = file_get_contents( $this->error_log_file_path, true ); |
| 178 | - if( $error_log_contents === FALSE ) {
|
|
| 178 | + if( $error_log_contents === FALSE ) { |
|
| 179 | 179 | return _e( 'File get contents not available' , 'yikes-inc-easy-mailchimp-extender' ); |
| 180 | 180 | } |
| 181 | - if ( $error_log_contents != '' ) {
|
|
| 181 | + if ( $error_log_contents != '' ) { |
|
| 182 | 182 | // return $error_log_contents; |
| 183 | 183 | print_r( $error_log_contents ); |
| 184 | - } else {
|
|
| 184 | + } else { |
|
| 185 | 185 | ?> |
| 186 | 186 | <!-- table body --> |
| 187 | 187 | <tr class="error-log-tr"> |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | </tr> |
| 196 | 196 | <?php |
| 197 | 197 | } |
| 198 | - } else {
|
|
| 198 | + } else { |
|
| 199 | 199 | ?> |
| 200 | 200 | <!-- table body --> |
| 201 | 201 | <tr class="error-log-tr"> |
@@ -223,7 +223,8 @@ discard block |
||
| 223 | 223 | </tr> |
| 224 | 224 | <?php |
| 225 | 225 | } |
| 226 | - } else { // if file_get_contents is disabled server side
|
|
| 226 | + } else { |
|
| 227 | +// if file_get_contents is disabled server side |
|
| 227 | 228 | ?> |
| 228 | 229 | <!-- table body --> |
| 229 | 230 | <tr> |