cedaro / cpt-archives

A WordPress plugin to manage post type archive titles, descriptions, and permalink slugs from the dashboard.
44 stars 7 forks source link

Resolve Php Notices in debug mode as well #4

Closed klihelp closed 9 years ago

klihelp commented 9 years ago

Some admin pages show php notices, followed by php error .. out of the box the plugin on backend should work without any php notices.

Notice: Trying to get property of non-object in /wp/content/plugins/cpt-archives/php/PostType/ArchiveHookProvider.php on line 445

> $parent_slug = 'edit.php?post_type=' . $archive->get_post()->archive_for_post_type;

Warning: Cannot modify header information - headers already sent by

Make an extra check:

if (  !$archive->get_post_id()  ){
  continue;
}

Registering archive page to a non-existent custom post type will trigger a php notice. Should be silent about it.

   $GLOBALS['cptarchives']->register_archive( 'courses', array(
        'customize_rewrites' => true,
        'show_in_menu'       => true
    ) );
bradyvercher commented 9 years ago

The plugin shouldn't have any debug notices out of the box. If I'm understanding you correctly, you're seeing debug notices when registering an archive for a post type that doesn't exist. Is that right?

I figured the developer implementing this plugin would know whether or not a post type exists when registering an archive and would provide the necessary checks, but things could probably be a little more friendly for that scenario.