-
-
Save michaeluno/1f876f725b546ecd9b9409a40c9f1605 to your computer and use it in GitHub Desktop.
A WordPress plugin that tests Admin Page Framework to see how to add a custom post type sub-menu item to another custom post type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class APFTest_CPTGroup_Admin extends AdminPageFramework { | |
public function setUp() { | |
$this->setRootMenuPageBySlug( 'edit.php?post_type=cpt_a' ); | |
$this->addSubMenuItems( | |
array( | |
'title' => 'Settings', | |
'page_slug' => 'apf_test_multiple_cpt_group', | |
'order' => 30, | |
) | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class APFTest_CPTGroup_PostType_A extends AdminPageFramework_PostType { | |
public function setUp() { | |
$this->setArguments( | |
array( | |
'labels' => array( | |
'name' => 'CPT A', | |
'menu_name' => 'CPT A', | |
), | |
'show_ui' => true, | |
'menu_position' => 200, | |
'show_submenu_add_new' => false, // an admin page will be placed instead | |
'submenu_order_manage' => 10, | |
) | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class APFTest_CPTGroup_PostType_B extends AdminPageFramework_PostType { | |
public function setUp() { | |
$this->setArguments( | |
array( | |
'labels' => array( | |
'name' => 'CPT B', | |
'menu_name' => 'CPT B', | |
), | |
'show_ui' => true, | |
'show_in_menu' => 'edit.php?post_type=cpt_a', | |
'submenu_order_manage' => 20, | |
) | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Admin Page Framework - Test CPT Group | |
* Plugin URI: http://admin-page-framework.michaeluno.jp/ | |
* Description: Demonstrates how to add a custom post type sub-menu item to another custom post type. | |
* Author: Michael Uno | |
* Author URI: http://en.michaeluno.jp/ | |
* Version: 0.0.1 | |
*/ | |
class APFTest_CPTGroup { | |
public function __construct() { | |
add_action( 'plugins_loaded', array( $this, 'load' ) ); | |
} | |
public function load() { | |
if ( ! class_exists( 'AdminPageFramework' ) ) { | |
return; | |
} | |
include( dirname( __FILE__ ) . '/APFTest_CPTGroup_Admin.php' ); | |
include( dirname( __FILE__ ) . '/APFTest_CPTGroup_PostType_A.php' ); | |
include( dirname( __FILE__ ) . '/APFTest_CPTGroup_PostType_B.php' ); | |
new APFTest_CPTGroup_PostType_A( 'cpt_a', null, __FILE__ ); | |
new APFTest_CPTGroup_PostType_B( 'cpt_b', null, __FILE__ ); | |
new APFTest_CPTGroup_Admin; | |
} | |
} | |
new APFTest_CPTGroup; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment