Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mets.corals.io/wp-content/plugins/query-monitor/collectors/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mets.corals.io/wp-content/plugins/query-monitor/collectors/languages.php
<?php
/**
 * Language and locale collector.
 *
 * @package query-monitor
 */

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

class QM_Collector_Languages extends QM_Collector {

	public $id = 'languages';

	/**
	 * @return void
	 */
	public function set_up() {

		parent::set_up();

		add_filter( 'load_textdomain_mofile', array( $this, 'log_file_load' ), 9999, 2 );
		add_filter( 'load_script_translation_file', array( $this, 'log_script_file_load' ), 9999, 3 );
		add_filter( 'init', array( $this, 'collect_locale_data' ), 9999 );

	}

	/**
	 * @return void
	 */
	public function tear_down() {
		remove_filter( 'load_textdomain_mofile', array( $this, 'log_file_load' ), 9999 );
		remove_filter( 'load_script_translation_file', array( $this, 'log_script_file_load' ), 9999 );
		remove_filter( 'init', array( $this, 'collect_locale_data' ), 9999 );

		parent::tear_down();
	}

	/**
	 * @return void
	 */
	public function collect_locale_data() {
		$this->data['locale'] = get_locale();
		$this->data['user_locale'] = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
		$this->data['determined_locale'] = function_exists( 'determine_locale' ) ? determine_locale() : get_locale();
		$this->data['language_attributes'] = get_language_attributes();

		if ( function_exists( '\Inpsyde\MultilingualPress\siteLanguageTag' ) ) {
			$this->data['mlp_language'] = \Inpsyde\MultilingualPress\siteLanguageTag();
		}

		if ( function_exists( 'pll_current_language' ) ) {
			$this->data['pll_language'] = pll_current_language();
		}
	}

	/**
	 * @return array<int, string>
	 */
	public function get_concerned_actions() {
		return array(
			'load_textdomain',
			'unload_textdomain',
		);
	}

	/**
	 * @return array<int, string>
	 */
	public function get_concerned_filters() {
		return array(
			'determine_locale',
			'gettext',
			'gettext_with_context',
			'language_attributes',
			'load_script_textdomain_relative_path',
			'load_script_translation_file',
			'load_script_translations',
			'load_textdomain_mofile',
			'locale',
			'ngettext',
			'ngettext_with_context',
			'override_load_textdomain',
			'override_unload_textdomain',
			'plugin_locale',
			'pre_determine_locale',
			'pre_load_script_translations',
			'theme_locale',
		);
	}

	/**
	 * @return array<int, string>
	 */
	public function get_concerned_options() {
		return array(
			'WPLANG',
		);
	}

	/**
	 * @return array<int, string>
	 */
	public function get_concerned_constants() {
		return array(
			'WPLANG',
		);
	}

	/**
	 * @return void
	 */
	public function process() {
		if ( empty( $this->data['languages'] ) ) {
			return;
		}

		$this->data['total_size'] = 0;

		ksort( $this->data['languages'] );

		foreach ( $this->data['languages'] as & $mofiles ) {
			foreach ( $mofiles as & $mofile ) {
				if ( $mofile['found'] ) {
					$this->data['total_size'] += $mofile['found'];
				}
			}
		}
	}

	/**
	 * Store log data.
	 *
	 * @param string $mofile Path to the MO file.
	 * @param string $domain Text domain.
	 * @return string
	 */
	public function log_file_load( $mofile, $domain ) {
		if ( 'query-monitor' === $domain && self::hide_qm() ) {
			return $mofile;
		}

		if ( isset( $this->data['languages'][ $domain ][ $mofile ] ) ) {
			return $mofile;
		}

		$trace = new QM_Backtrace( array(
			'ignore_hook' => array(
				current_filter() => true,
			),
			'ignore_func' => array(
				'load_textdomain' => ( 'default' !== $domain ),
				'load_muplugin_textdomain' => true,
				'load_plugin_textdomain' => true,
				'load_theme_textdomain' => true,
				'load_child_theme_textdomain' => true,
				'load_default_textdomain' => true,
			),
		) );

		$found = file_exists( $mofile ) ? filesize( $mofile ) : false;

		$this->data['languages'][ $domain ][ $mofile ] = array(
			'caller' => $trace->get_caller(),
			'domain' => $domain,
			'file' => $mofile,
			'found' => $found,
			'handle' => null,
			'type' => 'gettext',
		);

		return $mofile;

	}

	/**
	 * Filters the file path for loading script translations for the given script handle and textdomain.
	 *
	 * @param string|false $file   Path to the translation file to load. False if there isn't one.
	 * @param string       $handle Name of the script to register a translation domain to.
	 * @param string       $domain The textdomain.
	 *
	 * @return string|false Path to the translation file to load. False if there isn't one.
	 */
	public function log_script_file_load( $file, $handle, $domain ) {
		$trace = new QM_Backtrace( array(
			'ignore_hook' => array(
				current_filter() => true,
			),
		) );

		$found = ( $file && file_exists( $file ) ) ? filesize( $file ) : false;

		$this->data['languages'][ $domain ][] = array(
			'caller' => $trace->get_caller(),
			'domain' => $domain,
			'file' => $file,
			'found' => $found,
			'handle' => $handle,
			'type' => 'jed',
		);

		return $file;
	}

}

# Load early to catch early errors
QM_Collectors::add( new QM_Collector_Languages() );

Spamworldpro Mini