HEX
Server: LiteSpeed
System: Linux dune179.sitesanctuary.org 5.14.0-427.40.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 16 07:08:17 EDT 2024 x86_64
User: h278792 (1197)
PHP: 8.1.29
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/h278792/public_html/wp-content/plugins/learnpress/inc/class-lp-debug.php
<?php
/**
 * Class LP_Debug
 *
 * @editor tungnx
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class LP_Debug {

	/**
	 * @var array Stores open file _handles.
	 * @access private
	 */
	private $_handles;

	/**
	 * @var null
	 */
	private static $_instance = null;

	/**
	 * @var array
	 */
	private static $_time = array();

	/**
	 * Constructor for the logger.
	 */
	protected function __construct() {

	}

	/**
	 * @var bool
	 */
	protected static $_transaction_started = false;

	public function output() {

	}

	/**
	 * Set time start
	 *
	 * @param string $name
	 */
	public static function time_start( string $name = '' ) {
		if ( ! self::is_debug() ) {
			return;
		}

		if ( empty( $name ) ) {
			echo 'Please set unique name';
		}

		self::$_time[ $name ] = microtime( true );
	}

	/**
	 * Get total time execute
	 *
	 * @param string $name
	 */
	public static function time_end( string $name = '' ) {
		if ( ! self::is_debug() ) {
			return;
		}
		if ( empty( $name ) ) {
			echo 'Please set unique name';
		}

		$time = microtime( true ) - self::$_time[ $name ];
		echo "{$name} execution time = " . $time . "\n";
		unset( self::$_time[ $name ] );
	}

	/**
	 * Start a new sql transaction
	 *
	 * Remove this function on add-on Frontend Editor and update
	 */
	public static function startTransaction() {
		global $wpdb;

		if ( self::$_transaction_started ) {
			return;
		}

		$wpdb->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 $variable
	 * @param $file_path
	 * @param $line
	 */
	public static function var_dump( $variable, $file_path, $line ) {
		echo '<pre>' . print_r( $variable, true ) . '</pre>';
		echo 'FILE:' . esc_html( $file_path ) . '<br> 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 string $message
	 *
	 * @return void
	 */
	public static function error_log( string $message ) {
		if ( LP_Debug::is_debug() ) {
			error_log( $message );
		}
	}

	/**
	 * @return LP_Debug|null
	 */
	public static function instance() {
		if ( ! self::$_instance ) {
			self::$_instance = new self();
		}

		return self::$_instance;
	}
}

return LP_Debug::instance();