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/gg.corals.io/wp-content/plugins/essential-grid/admin/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/gg.corals.io/wp-content/plugins/essential-grid/admin/includes/favorite.class.php
<?php
/**
 * @author    ThemePunch <[email protected]>
 * @link      https://www.themepunch.com/
 * @copyright 2023 ThemePunch
 */

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

class Essential_Grid_Favorite {
	/**
	 * option to keep favorite list
	 */
	CONST OPTION = 'tp_eg-favorite';

	/**
	 * @param mixed $default
	 * @return false|mixed|void
	 */
	public function get_favorites($default = array())
	{
		return get_option(self::OPTION, $default);
	}

	/**
	 * @param array $data
	 * @return void
	 */
	public function set_favorites($data)
	{
		update_option(self::OPTION, $data);
	}

	/**
	 * get a certain favorite type
	 * 
	 * @param string $type
	 * @return array
	 **/
	public function get_favorite_type($type){
		$fav = $this->get_favorites();
		return Essential_Grid_Base::getVar($fav, $type, array());
	}

	/**
	 * check if certain element is in favorites
	 * 
	 * @param string $type
	 * @param mixed $id
	 * @return bool
	 **/
	public function is_favorite($type, $id){
		$favs = $this->get_favorite_type($type);
		return array_search($id, $favs) !== false;
	}
	
	/**
	 * change the setting of a favorization
	 * 
	 * @param string $action
	 * @param string $type
	 * @param mixed $id
	 * @return array
	 **/
	public function update_favorites($action, $type, $id){
		$fav = $this->get_favorites();
		$id	 = esc_attr($id);

		if (!isset($fav[$type])) $fav[$type] = array();
		$key = array_search($id, $fav[$type]);
		
		switch ($action) {
			case 'add':
				if ($key === false) $fav[$type][] = $id;
				break;
			case 'remove':
				unset($fav[$type][$key]);
				break;
			case 'replace':
				$fav[$type] = $id;
				break;
			default:
		}
		
		$this->set_favorites($fav);

		return $fav;
	}
}

Spamworldpro Mini