PluginProbe
Enter Addons – Ultimate Template Builder for Elementor / 2.2.8
Enter Addons – Ultimate Template Builder for Elementor v2.2.8
trunk 2.2.10 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4
enteraddons / classes / Post_Type_Base.php

Post_Type_Base.php in Enter Addons – Ultimate Template Builder for Elementor 2.2.8, at classes/Post_Type_Base.php

81 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Enteraddons\Classes;
3
4 /**
5 * Enteraddons Post Type Base class
6 *
7 * @package Enteraddons
8 * @author ThemeLooks
9 * @copyright 2022 ThemeLooks
10 * @license GPL-2.0-or-later
11 *
12 *
13 */
14
15 abstract class Post_Type_Base {
16
17 abstract public function getPostTypeName();
18
19 public function getArgs() {
20 return [];
21 }
22
23 public function getLabels() {
24 return [];
25 }
26 public function addTaxonomy() {
27 return [];
28 }
29 public function regPostType() {
30
31 $labels = $this->getLabels();
32
33 $default = array(
34 'labels' => $labels,
35 'public' => true,
36 'rewrite' => false,
37 'show_ui' => true,
38 'show_in_menu' => false,
39 'show_in_nav_menus' => false,
40 'exclude_from_search' => true,
41 'capability_type' => 'post',
42 'hierarchical' => false,
43 'supports' => array( 'title', 'editor' ),
44 );
45
46 $args = wp_parse_args( $this->getArgs(), $default );
47
48 register_post_type( $this->getPostTypeName(), $args );
49
50 // Remove post type support
51 if( !empty( $this->getremoveSupport() ) ) {
52 foreach( $this->getremoveSupport() as $name ) {
53 if( !empty( $name ) ) {
54 $this->removePostTypeSupport($name);
55 }
56 }
57 }
58
59 }
60
61 public function removePostTypeSupport( $name ) {
62 remove_post_type_support( $this->getPostTypeName(), $name );
63 }
64
65 public function registeTaxonomy() {
66
67 if( $this->addTaxonomy() ) {
68 foreach( $this->addTaxonomy() as $taxonomyinfo ) {
69 if( !empty( $taxonomyinfo['taxonomy_name'] ) ) {
70 register_taxonomy( $taxonomyinfo['taxonomy_name'], $this->getPostTypeName(), $taxonomyinfo['args'] );
71 }
72 }
73 }
74 }
75
76 function __construct() {
77 $this->regPostType();
78 $this->registeTaxonomy();
79 }
80
81 }