Server : Apache System : Linux ls31.server.ly 3.10.0-962.3.2.lve1.5.68.el7.x86_64 #1 SMP Wed Apr 6 11:12:23 UTC 2022 x86_64 User : medchoco ( 2906) PHP Version : 8.3.16 Disable Function : mail Directory : /home/medchoco/www/wp-content/plugins/jetpack-boost-git/app/lib/ |
Upload File : |
<?php namespace Automattic\Jetpack_Boost\Lib; /** * A collection of WordPress options that's stored as a single ar */ class Collection { private $key; /** * Collections imply that they may carry more data than regular options, * This might unnecessarily slow down sites. * Disable autoloading by default. * * @see autoload() to enable autoloading. */ private $autoload = false; /** * @param string $key Collection key. */ public function __construct( $key ) { $this->key = $key; } /* * Allow autoloading collections */ public function autoload() { $this->autoload = true; return $this; } /** * Get the whole collection * * @return array */ public function get() { $result = get_option( $this->key, array() ); if ( is_array( $result ) ) { return $result; } return array(); } /** * Append a single item to the collection * * @param $item * * @return bool */ public function append( $item ) { $items = $this->get(); if ( ! in_array( $item, $items, true ) ) { $items[] = $item; return update_option( $this->key, $items, $this->autoload ); } return false; } /** * Delete the whole collection * * @return bool */ public function delete() { return delete_option( $this->key ); } }