API
1 week ago
DefaultOptions
2 years ago
PagesFields
4 months ago
SettingsFields
4 months ago
Announcement.php
1 week ago
Assets.php
1 week ago
Main.php
1 year ago
Page.php
1 week ago
PostType.php
2 years ago
PostType.php
150 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Post Type. |
| 4 | * |
| 5 | * @package ShopPress |
| 6 | */ |
| 7 | |
| 8 | namespace ShopPress\Admin; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | class PostType { |
| 13 | /** |
| 14 | * Init. |
| 15 | * |
| 16 | * @since 1.2.0 |
| 17 | */ |
| 18 | public static function init() { |
| 19 | add_action( 'init', array( __CLASS__, 'woocommerce_pages' ) ); |
| 20 | add_action( 'init', array( __CLASS__, 'woocommerce_my_account_pages' ) ); |
| 21 | add_action( 'init', array( __CLASS__, 'woocommerce_products_loop' ) ); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * WooCommerce pages. |
| 26 | * |
| 27 | * @since 1.0.0 |
| 28 | */ |
| 29 | public static function woocommerce_pages() { |
| 30 | register_post_type( |
| 31 | 'shoppress_pages', |
| 32 | array( |
| 33 | 'labels' => array( |
| 34 | 'name' => __( 'WooCommerce pages', 'shop-press' ), |
| 35 | 'singular_name' => __( 'WooCommerce pages', 'shop-press' ), |
| 36 | ), |
| 37 | 'public' => true, |
| 38 | 'has_archive' => true, |
| 39 | 'show_in_menu' => false, |
| 40 | 'can_export' => true, |
| 41 | 'rewrite' => false, |
| 42 | 'show_in_nav_menus' => false, |
| 43 | 'exclude_from_search' => true, |
| 44 | 'show_in_rest' => true, |
| 45 | 'supports' => array( 'editor', 'title', 'custom-fields' ), |
| 46 | ) |
| 47 | ); |
| 48 | |
| 49 | $args = array( |
| 50 | 'type' => 'array', |
| 51 | 'single' => true, |
| 52 | 'object_subtype' => 'shoppress_pages', |
| 53 | 'show_in_rest' => array( |
| 54 | 'schema' => array( |
| 55 | 'type' => 'array', |
| 56 | 'items' => array( |
| 57 | 'type' => 'array', |
| 58 | ), |
| 59 | ), |
| 60 | ), |
| 61 | ); |
| 62 | |
| 63 | register_meta( 'post', 'custom_type', $args ); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * WooCommerce my account pages. |
| 68 | * |
| 69 | * @since 1.0.0 |
| 70 | */ |
| 71 | public static function woocommerce_my_account_pages() { |
| 72 | register_post_type( |
| 73 | 'shoppress_myaccount', |
| 74 | array( |
| 75 | 'labels' => array( |
| 76 | 'name' => __( 'WooCommerce my account pages', 'shop-press' ), |
| 77 | 'singular_name' => __( 'WooCommerce my account pages', 'shop-press' ), |
| 78 | ), |
| 79 | 'public' => true, |
| 80 | 'has_archive' => true, |
| 81 | 'show_in_menu' => false, |
| 82 | 'can_export' => true, |
| 83 | 'rewrite' => false, |
| 84 | 'show_in_nav_menus' => false, |
| 85 | 'exclude_from_search' => true, |
| 86 | 'show_in_rest' => true, |
| 87 | 'supports' => array( 'editor', 'title', 'custom-fields' ), |
| 88 | ) |
| 89 | ); |
| 90 | |
| 91 | $args = array( |
| 92 | 'type' => 'array', |
| 93 | 'single' => true, |
| 94 | 'object_subtype' => 'shoppress_myaccount', |
| 95 | 'show_in_rest' => array( |
| 96 | 'schema' => array( |
| 97 | 'type' => 'array', |
| 98 | 'items' => array( |
| 99 | 'type' => 'array', |
| 100 | ), |
| 101 | ), |
| 102 | ), |
| 103 | ); |
| 104 | |
| 105 | register_meta( 'post', 'custom_type', $args ); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * WooCommerce products loop. |
| 110 | * |
| 111 | * @since 1.0.0 |
| 112 | */ |
| 113 | public static function woocommerce_products_loop() { |
| 114 | register_post_type( |
| 115 | 'shoppress_loop', |
| 116 | array( |
| 117 | 'labels' => array( |
| 118 | 'name' => __( 'WooCommerce products loop', 'shop-press' ), |
| 119 | 'singular_name' => __( 'WooCommerce products loop', 'shop-press' ), |
| 120 | ), |
| 121 | 'public' => true, |
| 122 | 'has_archive' => true, |
| 123 | 'show_in_menu' => false, |
| 124 | 'can_export' => true, |
| 125 | 'rewrite' => false, |
| 126 | 'show_in_nav_menus' => false, |
| 127 | 'exclude_from_search' => true, |
| 128 | 'show_in_rest' => true, |
| 129 | 'supports' => array( 'editor', 'title', 'custom-fields' ), |
| 130 | ) |
| 131 | ); |
| 132 | |
| 133 | $args = array( |
| 134 | 'type' => 'array', |
| 135 | 'single' => true, |
| 136 | 'object_subtype' => 'shoppress_loop', |
| 137 | 'show_in_rest' => array( |
| 138 | 'schema' => array( |
| 139 | 'type' => 'array', |
| 140 | 'items' => array( |
| 141 | 'type' => 'array', |
| 142 | ), |
| 143 | ), |
| 144 | ), |
| 145 | ); |
| 146 | |
| 147 | register_meta( 'post', 'custom_type', $args ); |
| 148 | } |
| 149 | } |
| 150 |