403Webshell
Server IP : 82.208.35.60  /  Your IP : 216.73.217.33
Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31
System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64
User : studiokobylisy_cz ( 1008)
PHP Version : 7.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/d2m/sofident_cz/wp-content/plugins/sitepress-multilingual-cms/classes/REST/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/d2m/sofident_cz/wp-content/plugins/sitepress-multilingual-cms/classes/REST/RewriteRules.php
<?php

namespace WPML\Core\REST;


class RewriteRules implements \IWPML_REST_Action, \IWPML_DIC_Action  {
	/** @var \SitePress */
	private $sitepress;

	/**
	 * @param \SitePress $sitepress
	 */
	public function __construct( \SitePress $sitepress ) {
		$this->sitepress = $sitepress;
	}

	public function add_hooks() {
		add_action( 'init', [ $this, 'addOptionRewriteRulesHook' ] );
	}

	public function addOptionRewriteRulesHook() {
		if ( $this->isLangInDirectory() && $this->isUseDirectoryForDefaultLanguage() && $this->isInstalledInSubdirectory() ) {
			add_filter( 'option_rewrite_rules', [ $this, 'updateRules' ] );
		}
	}

	public function updateRules( $rewriteRules ) {
		if ( ! is_array( $rewriteRules ) ) {
			return $rewriteRules;
		}

		$subdirectory = $this->getSubdirectory();

		$mapKeys = function ( $value, $key ) use ( $subdirectory ) {
			if ( $key === '^wp-json/?$' ) {
				$key = "^($subdirectory/)?wp-json/?$";
			} elseif ( $key === '^wp-json/(.*)?' ) {
				$key   = "^($subdirectory/)?wp-json/(.*)?";
				$value = str_replace( 'matches[1]', 'matches[2]', $value );
			}

			return [ $key => $value ];
		};

		return \wpml_collect( $rewriteRules )->mapWithKeys( $mapKeys )->toArray();
	}

	/**
	 * @return bool
	 */
	private function isLangInDirectory() {
		return (int) $this->sitepress->get_setting( 'language_negotiation_type' ) === WPML_LANGUAGE_NEGOTIATION_TYPE_DIRECTORY;
	}

	/**
	 * @return bool
	 */
	private function isUseDirectoryForDefaultLanguage() {
		$urlSettings = $this->sitepress->get_setting( 'urls' );

		return isset( $urlSettings['directory_for_default_language'] ) && $urlSettings['directory_for_default_language'];
	}

	/**
	 * @return bool
	 */
	private function isInstalledInSubdirectory() {
		return ! empty( $this->getSubdirectory() );
	}

	/**
	 * @return string
	 */
	private function getSubdirectory() {
		$url       = get_option( 'home' );
		$home_path = trim( parse_url( $url, PHP_URL_PATH ), '/' );

		return $home_path;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit