query( 'START TRANSACTION;' ); self::$_transaction_started = true; } /** * Rollback a sql transaction */ public static function rollbackTransaction() { global $wpdb; if ( ! self::$_transaction_started ) { return; } $wpdb->query( 'ROLLBACK;' ); self::$_transaction_started = false; } /** * Show value of variable * * @param mixed $variable * @param string $file_path * @param string $line */ public static function var_dump( $variable, string $file_path = '', string $line = '' ) { echo wp_kses( '
' . print_r( $variable, true ) . '
', true ); echo 'FILE:' . esc_html( $file_path ) . '
LINE:' . esc_html( $line ); } /** * Check enable debug mode * * @return bool * @since 3.2.8 * @editor tungnx */ public static function is_debug(): bool { return LP_Settings::get_option( 'debug', 'no' ) === 'yes'; } /** * Set error log * * @param Throwable $e * * @return void * @version 1.0.1 * @since 3.0.0 */ public static function error_log( Throwable $e ) { error_log( sprintf( 'MESSAGE: %s FILE: %s LINE: %s', $e->getMessage(), $e->getFile(), $e->getLine() ) ); } public static function log_to_comment( $comment_content ) { wp_insert_comment( [ 'comment_content' => $comment_content, 'comment_type' => 'lp_debug_log', ] ); } /** * @return LP_Debug|null */ public static function instance() { if ( ! self::$_instance ) { self::$_instance = new self(); } return self::$_instance; } } return LP_Debug::instance();