HEX
Server: Apache/2.4.29 (Ubuntu)
System: Linux bareserver 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64
User: root (0)
PHP: 7.2.24-0ubuntu0.18.04.17
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/site/newsite/wp-content/plugins/wp-job-manager/includes/3rd-party/polylang.php
<?php
/**
 * Only load these if Polylang plugin is installed and active.
 *
 * @package wp-job-manager
 */

/**
 * Load routines only if Polylang is loaded.
 *
 * @since 1.26.0
 */
function polylang_wpjm_init() {
	add_filter( 'wpjm_lang', 'polylang_wpjm_get_job_listings_lang' );
	add_filter( 'wpjm_page_id', 'polylang_wpjm_page_id' );
	add_action( 'get_job_listings_query_args', 'polylang_wpjm_query_language' );
}
add_action( 'pll_init', 'polylang_wpjm_init' );


/**
 * Sets the current language when running job listings query.
 *
 * @since 1.29.1
 *
 * @param array $query_args
 * @return array
 */
function polylang_wpjm_query_language( $query_args ) {
	// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Input is used safely.
	$input_lang = isset( $_POST['lang'] ) ? sanitize_text_field( wp_unslash( $_POST['lang'] ) ) : false;

	if ( $input_lang ) {
		$query_args['lang'] = $input_lang;
	}
	return $query_args;
}

/**
 * Returns Polylang's current language.
 *
 * @since 1.26.0
 *
 * @param string $lang
 * @return string
 */
function polylang_wpjm_get_job_listings_lang( $lang ) {
	if (
		function_exists( 'pll_current_language' )
		&& function_exists( 'pll_is_translated_post_type' )
		&& pll_is_translated_post_type( 'job_listing' )
	) {
		return pll_current_language();
	}
	return $lang;
}

/**
 * Returns the page ID for the current language.
 *
 * @since 1.26.0
 *
 * @param int $page_id
 * @return int
 */
function polylang_wpjm_page_id( $page_id ) {
	if ( function_exists( 'pll_get_post' ) ) {
		$page_id = pll_get_post( $page_id );
	}
	return absint( $page_id );
}

/**
 * Tells Polylang about ajax requests
 * The filter is applied *before* the action 'pll_init'
 *
 * @since 1.32.0
 *
 * @param bool $is_ajax
 * @return bool
 */
function polylang_wpjm_doing_ajax( $is_ajax ) {
	return isset( $_SERVER['REQUEST_URI'] ) && false === strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/jm-ajax/' ) ? $is_ajax : true;
}
add_filter( 'pll_is_ajax_on_front', 'polylang_wpjm_doing_ajax' );