format( 'M d, Y H.i.s' ) . ': '; $string = "\r\n" . $curTime . $string; fwrite( $file, $string ); fclose( $file ); return true; } } } if ( ! function_exists( 'xlplugins_force_log' ) ) { function xlplugins_force_log( $string, $filename = 'force.txt', $mode = 'a' ) { if ( empty( $string ) ) { return false; } $current_date_obj = new DateTime( 'now', new DateTimeZone( 'UTC' ) ); $upload_dir = wp_upload_dir(); $base_path = $upload_dir['basedir'] . '/xlplugins'; if ( ! file_exists( $base_path ) ) { mkdir( $base_path, 0777, true ); } $filename = str_replace( '.txt', '-' . date( 'Y-m' ) . '.txt', $filename ); $file_path = $base_path . '/' . $filename; $file = fopen( $file_path, $mode ); $curTime = $current_date_obj->format( 'M d, Y H.i.s' ) . ': '; $string = "\r\n" . $curTime . $string; fwrite( $file, $string ); fclose( $file ); return true; } }