Site Functions
get_all_sites()
/**
* Retrieves all sites.
*
* @file App/Shared/Helpers/site.php
* @throws ReflectionException
* @throws UnresolvableQueryHandlerException
*/
function get_all_sites(): mixed;
get_site_by()
/**
* Retrieves site data given a site ID or site object.
*
* @file App/Shared/Helpers/site.php
* @param string $field The field to retrieve the site with (id, key or slug).
* @param string $value A value for $field.
* @return object|bool
* @throws CommandPropertyNotFoundException
* @throws ReflectionException
* @throws TypeException
* @throws UnresolvableQueryHandlerException
*/
function get_site_by(string $field, string $value): object|bool;
if_site_domain_exists()
/**
* Checks whether the given site domain exists.
*
* @file App/Shared/Helpers/site.php
* @param string $sitedomain Site domain to check against.
* @return bool If site domain exists, return true otherwise return false.
* @throws ContainerExceptionInterface
* @throws Exception
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
function if_site_domain_exists(string $sitedomain): bool;
if_site_exists()
/**
* Checks whether the given site exists.
*
* @file App/Shared/Helpers/site.php
* @param string $siteDomain Site domain to check against.
* @param string $sitePath Site path to check against.
* @return bool If site exists, return true otherwise return false.
* @throws ContainerExceptionInterface
* @throws Exception
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
function if_site_exists(string $siteDomain, string $sitePath): bool;
/**
* System function: Adds user meta data for specified site.
*
* @access private
*
* @file App/Shared/Helpers/site.php
* @param string $siteKey Site key.
* @param array $params Parameters to set (assign_id or role).
* @return bool True if usermete and role is added.
* @throws CommandPropertyNotFoundException
* @throws ContainerExceptionInterface
* @throws Exception
* @throws NotFoundExceptionInterface
* @throws ReflectionException
* @throws TypeException
* @throws UnresolvableQueryHandlerException
*/
function add_site_usermeta(string $siteKey, array $params = []): bool;
create_site_directories()
/**
* System function: Create the needed directories when a new site is created.
*
* @access private
*
* @file App/Shared/Helpers/site.php
* @param string $siteId Site ID.
* @param Site $site Site object.
* @param bool $update Whether the site is being created or updated.
* @return bool True on success or false on failure.
* @throws CommandPropertyNotFoundException
* @throws ReflectionException
* @throws UnresolvableQueryHandlerException|TypeException
*/
function create_site_directories(string $siteId, Site $site, bool $update = false): bool;
/**
* System function: Deletes user meta data when site/user is deleted.
*
* @access private
*
* @file App/Shared/Helpers/site.php
* @param string $siteId Site Id.
* @param Site $oldSite Site object.
* @return bool True on success or false on failure.
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
* @throws \Exception
*/
function delete_site_usermeta(string $siteId, Site $oldSite): bool;
delete_site_tables()
/**
* System function: Deletes site tables when site is deleted.
*
* @access private
*
* @file App/Shared/Helpers/site.php
* @param string $siteId Site ID.
* @param Site $oldSite Site object.
* @return bool True on success or false on failure.
* @throws ContainerExceptionInterface
* @throws Exception
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
function delete_site_tables(string $siteId, Site $oldSite): bool;
delete_site_directories()
/**
* System function: Deletes the site directory when the site is deleted.
*
* @access private
*
* @file App/Shared/Helpers/site.php
* @param string $siteId Site ID.
* @return bool True on success or false on failure.
*/
function delete_site_directories(string $siteId, Site $oldSite): bool;
get_current_site_key()
/**
* Retrieve the current site key.
*
* @file App/Shared/Helpers/site.php
* @return mixed Site key.
* @throws ReflectionException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
function get_current_site_key(): mixed;
get_multisite_users()
/**
* Retrieve a list of users based on site.
*
* @file App/Shared/Helpers/site.php
* @return array Users data.
* @throws ReflectionException
* @throws UnresolvableQueryHandlerException
*/
function get_multisite_users(): array;
add_user_to_site()
/**
* Add user to a site.
*
* @file App/Shared/Helpers/site.php
* @param string|User $user User to add to a site.
* @param string|Site $site Site to add user to.
* @param string $role Role to assign to user for this site.
* @return false|string User id on success or false on failure.
* @throws CommandPropertyNotFoundException
* @throws ContainerExceptionInterface
* @throws Exception
* @throws InvalidArgumentException
* @throws NotFoundExceptionInterface
* @throws ReflectionException
* @throws TypeException
* @throws UnresolvableQueryHandlerException
*/
function add_user_to_site(User|string $user, Site|string $site, string $role): false|string;
cms_insert_site()
/**
* Insert a site into the database.
*
* Some of the `$sitedata` array fields have filters associated with the values. Exceptions are
* 'site_owner', 'site_registered' and 'site_modified' The filters have the prefix 'pre_'
* followed by the field name. An example using 'site_name' would have the filter called,
* 'pre_site_name' that can be hooked into.
*
* @file App/Shared/Helpers/site.php
* @param array|Site|ServerRequestInterface $sitedata {
* An array or Site array of user data arguments.
*
* @type string $id Sites's ID. If supplied, the site will be updated.
* @type string $domain The site's domain.
* @type string $mapping Mapped domain to use for the site.
* @type string $name The site's name/title.
* @type string $path The site's path.
* @type string $owner The site's owner.
* @type string $status The site's status.
* @type string $registered Date the site registered. Format is 'Y-m-d H:i:s'.
* @type string $modified Date the site's record was updated. Format is 'Y-m-d H:i:s'.
* }
*
* @return string|Error The newly created site's id or Error if the site could not
* be created.
* @throws CommandCouldNotBeHandledException
* @throws CommandPropertyNotFoundException
* @throws ContainerExceptionInterface
* @throws Exception
* @throws InvalidArgumentException
* @throws NotFoundExceptionInterface
* @throws ReflectionException
* @throws TypeException
* @throws UnresolvableCommandHandlerException
* @throws UnresolvableQueryHandlerException
* @throws DateInvalidTimeZoneException
*/
function cms_insert_site(array|ServerRequestInterface|Site $sitedata): Error|string;
cms_update_site()
/**
* Update a site in the database.
*
* See cms_insert_site() For what fields can be set in $sitedata.
*
* @file App/Shared/Helpers/site.php
* @param array|ServerRequestInterface|Site $sitedata An array of site data or a site object.
* @return Error|string The updated site's id or Error if update failed.
* @throws CommandCouldNotBeHandledException
* @throws CommandPropertyNotFoundException
* @throws ContainerExceptionInterface
* @throws DateInvalidTimeZoneException
* @throws Exception
* @throws InvalidArgumentException
* @throws NotFoundExceptionInterface
* @throws ReflectionException
* @throws TypeException
* @throws UnresolvableCommandHandlerException
* @throws UnresolvableQueryHandlerException
*/
function cms_update_site(array|ServerRequestInterface|Site $sitedata): Error|string;
cms_delete_site()
/**
* Deletes a site.
*
* @file App/Shared/Helpers/site.php
* @param string $siteId ID of site to delete.
* @return string|Error Returns id of deleted site or Error.
* @throws CommandCouldNotBeHandledException
* @throws CommandPropertyNotFoundException
* @throws Exception
* @throws ReflectionException
* @throws UnresolvableCommandHandlerException
* @throws UnresolvableQueryHandlerException
*/
function cms_delete_site(string $siteId): Error|string;
cms_delete_site_user()
/**
* Delete site user.
*
* @file App/Shared/Helpers/site.php
* @param string $userId The id of user to be deleted.
* @param array $params User parameters (assign_id and role).
* @return bool|Error Returns true if successful or returns error otherwise.
* @throws CommandPropertyNotFoundException
* @throws ContainerExceptionInterface
* @throws Exception
* @throws InvalidArgumentException
* @throws NotFoundExceptionInterface
* @throws ReflectionException
* @throws SessionException
* @throws TypeException
* @throws UnresolvableQueryHandlerException
*/
function cms_delete_site_user(string $userId, array $params = []): Error|bool;
new_site_schema()
/**
* System function: Creates new tables and user meta for site admin after new site
* is created.
*
* @access private Used when the action hook `save_site` is called.
*
* @file App/Shared/Helpers/site.php
* @param string $siteId Site id of the newly created site.
* @param Site $site Site object of newly created site.
* @param bool $update Whether the site is being created or updated.
* @return string|bool Returns the site id if successful or false on failure.
* @throws CommandPropertyNotFoundException
* @throws ContainerExceptionInterface
* @throws Exception
* @throws InvalidArgumentException
* @throws NotFoundExceptionInterface
* @throws ReflectionException
* @throws TypeException
* @throws UnresolvableQueryHandlerException
*/
function new_site_schema(string $siteId, Site $site, bool $update): bool|string;
does_site_exist()
/**
* System function: Checks if site exists or is archived.
*
* @access private
*
* @file App/Shared/Helpers/site.php
* @return ResponseInterface
* @throws ContainerExceptionInterface
* @throws Exception
* @throws NotFoundExceptionInterface
* @throws ReflectionException
* @throws \Exception
*/
function does_site_exist(): \Psr\Http\Message\ResponseInterface;
get_site_name()
/**
* A function which retrieves cms site name.
*
* Purpose of this function is for the `site_name`
* filter.
*
* @file App/Shared/Helpers/site.php
* @param string $siteId
* @return string Site's name on success or '' on failure.
* @throws CommandPropertyNotFoundException
* @throws ReflectionException
* @throws UnresolvableQueryHandlerException|Exception
*/
function get_site_name(string $siteId): string;
get_site_domain()
/**
* A function which retrieves cms site domain.
*
* Purpose of this function is for the `site_domain`
* filter.
*
* @file App/Shared/Helpers/site.php
* @param string $siteId The unique id of a site.
* @return string Site's domain on success or '' on failure.
* @throws CommandPropertyNotFoundException
* @throws Exception
* @throws ReflectionException
* @throws UnresolvableQueryHandlerException
*/
function get_site_domain(string $siteId): string;
get_site_path()
/**
* A function which retrieves cms site path.
*
* Purpose of this function is for the `site_path`
* filter.
*
* @file App/Shared/Helpers/site.php
* @param string $siteId The unique id of a site.
* @return string Site's path on success or false on failure.
* @throws CommandPropertyNotFoundException
* @throws Exception
* @throws ReflectionException
* @throws UnresolvableQueryHandlerException
*/
function get_site_path(string $siteId): string;
get_site_owner()
/**
* A function which retrieves cms site owner.
*
* Purpose of this function is for the `site_owner`
* filter.
*
* @file App/Shared/Helpers/site.php
* @param string $siteId The unique id of a site.
* @return string Site's owner on success or false on failure.
* @throws CommandPropertyNotFoundException
* @throws Exception
* @throws ReflectionException
* @throws UnresolvableQueryHandlerException
*/
function get_site_owner(string $siteId): string;
get_site_status()
/**
* A function which retrieves cms site status.
*
* Purpose of this function is for the `site_status`
* filter.
*
* @file App/Shared/Helpers/site.php
* @param string $siteId The unique id of a site.
* @return string Site's status on success or false on failure.
* @throws CommandPropertyNotFoundException
* @throws Exception
* @throws ReflectionException
* @throws UnresolvableQueryHandlerException
*/
function get_site_status(string $siteId): string;
cms_unique_site_slug()
/**
* Creates a unique site slug.
*
* @file App/Shared/Helpers/site.php
* @param string $originalSlug Original slug of site.
* @param string $originalTitle Original title of site.
* @param string $siteId Unique site id.
* @return string Unique site slug.
* @throws ContainerExceptionInterface
* @throws Exception
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
function cms_unique_site_slug(string $originalSlug, string $originalTitle, string $siteId): string;
get_siteinfo()
/**
* Retrieves info about current site.
*
* @file App/Shared/Helpers/site.php
* @param string $show
* @param string $filter
* @return string
* @throws ContainerExceptionInterface
* @throws Exception
* @throws InvalidArgumentException
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
function get_siteinfo(string $show = '', string $filter = 'raw'): string;
siteinfo()
/**
* Retrieves filtered info about current site.
*
* @file App/Shared/Helpers/site.php
* @param string $show
* @return string
* @throws ContainerExceptionInterface
* @throws Exception
* @throws InvalidArgumentException
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
function siteinfo(string $show = ''): string;