I'm moving functionality from a theme's functions.php to a "functionality plugin". For some reason, when in functions.php, everything works perfectly fine. But when I move it into plugin, I get error 500 for the entire wp-admin area.
I was able to pinpoint problem to taxonomy registration block of code by excluding functionality blocks piece by piece.
Here is the whole custom post type registration code:
function create_post_type() {
register_post_type( 'Ads',
array(
'labels' => array(
'name' => 'Ads',
'singular_name' => 'Ad',
'menu_name' => 'Ads',
'name_admin_bar' => 'Ad',
'add_new' => 'Add New',
'add_new_item' => 'Add New Ad',
'new_item' => 'New Ad',
'edit_item' => 'Edit Ad',
'view_item' => 'View Ad',
'all_items' => 'All Ads',
'search_items' => 'Search Ads',
'parent_item_colon' => 'Parent Ads:',
'not_found' => 'No ads found.',
'not_found_in_trash' => 'No ads found in Trash.'
),
'public' => true,
'has_archive' => true,
'rewrite' => true,
'hierarchical' => true,
'supports' => array(
'title',
'revisions'
),
)
);
}
/* This piece bellow is causing trouble*/
register_taxonomy("Placements", array("ads"), array(
"hierarchical" => true,
"label" => "Placements",
"singular_label" => "Placement",
"rewrite" => true
));
/* End of trouble making code */
add_action( 'init', 'create_post_type' );
and here is the error log
[Tue May 01 23:11:04.268105 2018] [:error] [pid 24511] [client 174.214.1.78:15113] PHP Fatal error: Uncaught Error: Call to a member function add_rewrite_tag() on null in /nas/content/live/adsplugintest/wp-includes/rewrite.php:172 Stack trace: #0 /nas/content/live/adsplugintest/wp-includes/class-wp-taxonomy.php(379): add_rewrite_tag('%Placements%', '([^/]+)', 'placements=') #1 /nas/content/live/adsplugintest/wp-includes/taxonomy.php(386): WP_Taxonomy->add_rewrite_rules() #2 /nas/content/live/adsplugintest/wp-content/plugins/custom-ads-plugin/custom-ads.php(45): register_taxonomy('Placements', Array, Array) #3 /nas/content/live/adsplugintest/wp-settings.php(305): include_once('/nas/content/li...') #4 /nas/content/live/adsplugintest/wp-config.php(121): require_once('/nas/content/li...') #5 /nas/content/live/adsplugintest/wp-load.php(37): require_once('/nas/content/li...') #6 /nas/content/live/adsplugintest/wp-admin/admin.php(31): require_once('/nas/content/li...') #7 /nas/content/live/adsplugintest/wp-admin/index.php(10): require_once('/nas/content/li...') #8 {main} thrown in /nas/content/live/adsplugintest/wp-includes/rewrite.php on line 172