AdminAjaxController.php
4 years ago
MetaController.php
4 years ago
NoticeController.php
4 years ago
PostTypeController.php
4 years ago
SettingsController.php
4 years ago
UpgradeController.php
4 years ago
PostTypeController.php
95 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace RT\ThePostGrid\Controllers\Admin; |
| 5 | |
| 6 | class PostTypeController { |
| 7 | |
| 8 | public function __construct() { |
| 9 | add_action( 'init', [ &$this, 'register_post_types' ], 1 ); |
| 10 | add_action( 'admin_init', [ &$this, 'the_post_grid_remove_all_meta_box' ], 9999 ); |
| 11 | } |
| 12 | |
| 13 | public function the_post_grid_remove_all_meta_box() { |
| 14 | if ( is_admin() && apply_filters( 'rttpg_remove_all_extra_metabox_from_shordcode', true ) ) { |
| 15 | add_filter( "get_user_option_meta-box-order_" . rtTPG()->post_type, |
| 16 | [ |
| 17 | &$this, |
| 18 | 'remove_all_meta_boxes_tgp_sc', |
| 19 | ] ); |
| 20 | } |
| 21 | |
| 22 | if ( get_option( 'rttpg_activation_redirect', false ) ) { |
| 23 | delete_option( 'rttpg_activation_redirect' ); |
| 24 | wp_redirect( admin_url( 'edit.php?post_type=rttpg&page=rttpg_settings§ion=common-settings' ) ); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | public function register_post_types() { |
| 29 | |
| 30 | // Create the post grid post type |
| 31 | $labels = [ |
| 32 | 'name' => __( 'The Post Grid', 'the-post-grid' ), |
| 33 | 'singular_name' => __( 'The Post Grid', 'the-post-grid' ), |
| 34 | 'add_new' => __( 'Add New Grid', 'the-post-grid' ), |
| 35 | 'all_items' => __( 'All Grids', 'the-post-grid' ), |
| 36 | 'add_new_item' => __( 'Add New Post Grid', 'the-post-grid' ), |
| 37 | 'edit_item' => __( 'Edit Post Grid', 'the-post-grid' ), |
| 38 | 'new_item' => __( 'New Post Grid', 'the-post-grid' ), |
| 39 | 'view_item' => __( 'View Post Grid', 'the-post-grid' ), |
| 40 | 'search_items' => __( 'Search Post Grids', 'the-post-grid' ), |
| 41 | 'not_found' => __( 'No Post Grids found', 'the-post-grid' ), |
| 42 | 'not_found_in_trash' => __( 'No Post Grids found in Trash', 'the-post-grid' ), |
| 43 | ]; |
| 44 | |
| 45 | register_post_type( rtTPG()->post_type, |
| 46 | [ |
| 47 | 'labels' => $labels, |
| 48 | 'public' => false, |
| 49 | 'show_ui' => true, |
| 50 | '_builtin' => false, |
| 51 | 'capability_type' => 'page', |
| 52 | 'hierarchical' => true, |
| 53 | 'menu_icon' => rtTPG()->get_assets_uri( 'images/icon-16x16.png' ), |
| 54 | 'rewrite' => false, |
| 55 | 'query_var' => rtTPG()->post_type, |
| 56 | 'supports' => [ |
| 57 | 'title', |
| 58 | ], |
| 59 | 'show_in_menu' => true, |
| 60 | 'menu_position' => 20, |
| 61 | ] ); |
| 62 | |
| 63 | |
| 64 | } |
| 65 | |
| 66 | |
| 67 | /** |
| 68 | * @return void|array |
| 69 | */ |
| 70 | public function remove_all_meta_boxes_tgp_sc() { |
| 71 | global $wp_meta_boxes; |
| 72 | if ( isset( $wp_meta_boxes[ rtTPG()->post_type ]['normal']['high']['rttpg_meta'] ) && $wp_meta_boxes[ rtTPG()->post_type ]['normal']['high']['rttpg_sc_preview_meta'] |
| 73 | && $wp_meta_boxes[ rtTPG()->post_type ]['side']['low']['rt_plugin_sc_pro_information'] |
| 74 | ) { |
| 75 | $publishBox = $wp_meta_boxes[ rtTPG()->post_type ]['side']['core']['submitdiv']; |
| 76 | $scBox = $wp_meta_boxes[ rtTPG()->post_type ]['normal']['high']['rttpg_meta']; |
| 77 | $scBoxPreview = $wp_meta_boxes[ rtTPG()->post_type ]['normal']['high']['rttpg_sc_preview_meta']; |
| 78 | $docBox = $wp_meta_boxes[ rtTPG()->post_type ]['side']['low']['rt_plugin_sc_pro_information']; |
| 79 | |
| 80 | $wp_meta_boxes[ rtTPG()->post_type ] = [ |
| 81 | 'side' => [ |
| 82 | 'core' => [ 'submitdiv' => $publishBox ], |
| 83 | 'default' => [ |
| 84 | 'rt_plugin_sc_pro_information' => $docBox, |
| 85 | ], |
| 86 | ], |
| 87 | 'normal' => [ 'high' => [ 'submitdiv' => $scBox ] ], |
| 88 | 'advanced' => [ 'high' => [ 'postexcerpt' => $scBoxPreview ] ], |
| 89 | ]; |
| 90 | |
| 91 | return []; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | } |