Source of file MslsContentTypes.php

Size: 1,387 Bytes - Last Modified: 2018-02-05T14:23:18+00:00

/home/dennisploetner/Projects/Multisite-Language-Switcher/includes/MslsContentTypes.php

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
<?php
/**
 * MslsContentTypes
 * @author Dennis Ploetner <re@lloc.de>
 * @since 0.9.8
 */

namespace lloc\Msls;

/**
 * Supported content types
 * @package Msls
 */
class MslsContentTypes extends MslsRegistryInstance {

	/**
	 * Request
	 * @var string
	 */
	protected $request;

	/**
	 * Types
	 * @var array
	 */
	protected $types = array();

	/**
	 * Factory method
	 * @return MslsContentTypes
	 */
	public static function create() {
		$_request = MslsPlugin::get_superglobals( [ 'taxonomy' ] );
		if ( '' != $_request['taxonomy'] ) {
			return MslsTaxonomy::instance();
		}

		return MslsPostType::instance();
	}

	/**
	 * Check for post_type
	 * @return bool
	 */
	public function is_post_type() {
		return false;
	}

	/**
	 * Check for taxonomy
	 * @return bool
	 */
	public function is_taxonomy() {
		return false;
	}

	/**
	 * Check if the current user can manage this content type
	 *
	 * Returns name of the content type if the user has access or an empty
	 * string if the user can not access
	 * @return string
	 */
	public function acl_request() {
		return '';
	}

	/**
	 * Getter
	 * @return array
	 */
	public function get() {
		return (array) $this->types;
	}

	/**
	 * Gets the request if it is an allowed content type
	 * @return string
	 */
	public function get_request() {
		return(
			in_array( $this->request, $this->types ) ?
			$this->request :
			''
		);
	}

}