/** * Load property from page type. * * @param string $slug * @param string $child_slug * * @return null|Papi_Core_Property */ public function get_property($slug, $child_slug = '') { $page_type_id = papi_get_page_type_id($this->id); $page_type = papi_get_entry_type_by_id($page_type_id); if ($page_type instanceof Papi_Page_Type === false) { return; } if ($property = $page_type->get_property($slug, $child_slug)) { return $this->prepare_property($property); } }
/** * The constructor. * * Load a page 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_page_type_id(); $file_path = papi_get_file_path($page_type); } if (is_file($file_path)) { $this->setup_file($file_path); $this->setup_meta_data(); } }
/** * Get page type id. * * @param int $post_id * * @deprecated deprecated since version 2.0.0. * * @return string */ function papi_get_page_type_meta_value($post_id = 0) { _deprecated_function(__FUNCTION__, '2.0.0', 'papi_get_page_type_id'); return papi_get_page_type_id($post_id); }
/** * Get the Page type name. * * @param int $post_id * * @return string */ function papi_get_page_type_name($post_id = 0) { $post_id = papi_get_post_id($post_id); if (empty($post_id)) { return ''; } $page_type_id = papi_get_page_type_id($post_id); if (empty($page_type_id)) { return ''; } $page_type = papi_get_page_type_by_id($page_type_id); if (empty($page_type)) { return ''; } return $page_type->name; }
static function is_papi_page() { return !!\papi_get_page_type_id(); }
/** * Render metabox. */ public function metabox() { $post_type = papi_get_post_type(); $page_type = papi_get_entry_type_by_id(papi_get_page_type_id()); $page_type_key = papi_get_page_type_key('switch'); $page_types = papi_get_all_page_types($post_type); // Don't do anything without any page types. if (empty($page_type) || empty($page_types)) { return; } ?> <div class="misc-pub-section misc-pub-section-last papi-page-type-switcher"> <label for="<?php echo esc_attr($page_type_key); ?> "><?php esc_html_e('Page Type:', 'papi'); ?> </label> <span><?php echo esc_html($page_type->name); ?> </span> <?php if (papi_current_user_is_allowed($page_type->capabilities) && $page_type->switcher) { ?> <a href="#" id="papi-page-type-switcher-edit" class="hide-if-no-js"><?php esc_html_e('Edit', 'papi'); ?> </a> <div> <select name="<?php echo esc_attr($page_type_key); ?> " id="<?php echo esc_attr($page_type_key); ?> "> <?php foreach ($page_types as $pt) { if (!papi_current_user_is_allowed($pt->capabilities)) { continue; } papi_render_html_tag('option', ['selected' => $page_type->match_id($pt->get_id()), 'value' => esc_attr($pt->get_id()), esc_html($pt->name)]); } ?> </select> <a href="#" id="papi-page-type-switcher-save" class="hide-if-no-js button"><?php esc_html_e('OK', 'papi'); ?> </a> <a href="#" id="papi-page-type-switcher-cancel" class="hide-if-no-js"><?php esc_html_e('Cancel', 'papi'); ?> </a> </div> <?php } ?> </div> <?php }
/** * Output Papi page type hidden field. * * This will only output on a post type page. */ public function edit_form_after_title() { wp_nonce_field('papi_save_data', 'papi_meta_nonce'); papi_render_html_tag('input', ['data-papi-page-type-key' => true, 'name' => esc_attr(papi_get_page_type_key()), 'type' => 'hidden', 'value' => esc_attr(papi_get_page_type_id())]); }
/** * Get current page type. * * @return Papi_Page_Type */ private function get_page_type() { if ($page_type = papi_get_page_type_by_id(papi_get_page_type_id())) { return $page_type; } }
/** * Load right Papi file if it exists. * * @return bool */ public function setup_papi() { // If the post type isn't in the post types array we can't proceed. if (in_array($this->post_type, ['revision', 'nav_menu_item'])) { return false; } if (empty($this->page_type_id)) { // If only page type is used, override the page type value. $this->page_type_id = papi_filter_settings_only_page_type($this->post_type); if (empty($this->page_type_id)) { // Load page types that don't have any real post type. $this->page_type_id = str_replace('papi/', '', papi_get_qs('page')); } if (empty($this->page_type_id)) { $this->page_type_id = papi_get_page_type_id(); } } if (empty($this->page_type_id)) { return false; } $this->page_type = papi_get_page_type_by_id($this->page_type_id); // Do a last check so we can be sure that we have a page type instance. return $this->page_type instanceof Papi_Page_Type; }
/** * Get page type. * * @param array $data * @param string $field_name * @param WP_REST_Request $request * * @return array */ public function get_page_type(array $data, $field_name, $request) { return papi_get_page_type_id($data['ID']) ?: ''; }
public static function is_papi_page() { return (bool) \papi_get_page_type_id(); }
<label class="screen-reader-text" for="add-new-page-search"> <?php echo $post_type->labels->search_items; ?> </label> <input placeholder="<?php echo $post_type->labels->search_items; ?> ..." type="search" name="add-new-page-search" id="add-new-page-search" class="papi-search"> </h2> <div class="papi-box-list"> <?php $parent_page_type = papi_get_page_type_by_id(papi_get_page_type_id()); $page_types = papi_get_all_page_types(); $show_standard = papi_filter_settings_show_standard_page_type($post_type_name); if (papi_is_page_type($parent_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_name($post_type_name); $page_type->description = papi_filter_settings_standard_page_description($post_type_name);