Example #1
0
 /**
  * The constructor.
  *
  * Load a entry type by the file.
  *
  * @param string $file_path
  */
 public function __construct($file_path = '')
 {
     // Try to load the file if the file path is empty.
     if (empty($file_path)) {
         $page_type = papi_get_entry_type_id();
         $file_path = papi_get_file_path($page_type);
     }
     parent::__construct($file_path);
 }
Example #2
0
/**
 * Get taxonomy type id by term id.
 *
 * @param  int $term_id
 *
 * @return string
 */
function papi_get_taxonomy_type_id($term_id = 0)
{
    return papi_get_entry_type_id($term_id, 'term');
}
Example #3
0
		<label class="screen-reader-text" for="add-new-page-search">
			<?php 
echo esc_html($post_type->labels->search_items);
?>
		</label>

		<input placeholder="<?php 
echo esc_html($post_type->labels->search_items);
?>
..." type="search" name="add-new-page-search" id="add-new-page-search" class="papi-search">
	</h1>

	<div class="papi-box-list">
		<?php 
$parent_page_type = papi_get_entry_type_by_id(papi_get_entry_type_id());
$page_types = papi_get_all_page_types($post_type_name);
$show_standard = papi_filter_settings_show_standard_page_type($post_type_name);
if ($parent_page_type instanceof Papi_Page_Type) {
    $child_types = $parent_page_type->get_child_types();
    $page_types = empty($child_types) ? $page_types : $child_types;
    if (!$show_standard) {
        $show_standard = $parent_page_type->standard_type;
    }
}
if ($show_standard) {
    $id = sprintf('papi-standard-%s-type', $post_type_name);
    $page_type = new Papi_Page_Type($id);
    $page_type->id = $id;
    $page_type->name = papi_filter_settings_standard_page_type_name($post_type_name);
    $page_type->description = papi_filter_settings_standard_page_type_description($post_type_name);
Example #4
0
 /**
  * Get Entry Type instance.
  *
  * @return Papi_Entry_Type|false
  */
 private function get_entry_type()
 {
     if ($this->entry_type instanceof Papi_Entry_Type) {
         return $this->entry_type;
     }
     $entry_type_id = papi_get_entry_type_id();
     // If the entry type id is empty try to load
     // the entry type id from `page` query string.
     //
     // Example:
     //   /wp-admin/options-general.php?page=papi/option/site-option-type
     if (empty($entry_type_id)) {
         $entry_type_id = preg_replace('/^papi\\/\\w+\\//', '', papi_get_qs('page'));
     }
     // Use the default entry type id if empty.
     if (empty($entry_type_id)) {
         $entry_type_id = papi_get_entry_type_id();
     }
     // If no entry type id exists Papi can't setup a entry type.
     if (empty($entry_type_id)) {
         return false;
     }
     return $this->entry_type = papi_get_entry_type_by_id($entry_type_id);
 }
Example #5
0
/**
 * Check if given string is a entry type.
 *
 * @param  string $str
 *
 * @return bool
 */
function papi_is_entry_type($str = '')
{
    $id = papi_get_entry_type_id();
    return empty($str) ? !empty($id) : $str === $id;
}
Example #6
0
 /**
  * Get current type class.
  *
  * @return Papi_Entry_Type
  */
 private function get_entry_type()
 {
     if ($entry_type = papi_get_entry_type_by_id(papi_get_entry_type_id())) {
         return $entry_type;
     }
 }
Example #7
0
/**
 * Get page type id by post id.
 *
 * @param  int $post_id
 *
 * @return string
 */
function papi_get_page_type_id($post_id = 0)
{
    return papi_get_entry_type_id($post_id);
}
Example #8
0
 /**
  * Get current type class.
  *
  * @return Papi_Entry_Type
  */
 protected function get_entry_type()
 {
     if ($entry_type = papi_get_entry_type_by_id(papi_get_entry_type_id())) {
         return $entry_type;
     }
 }