Code improvement
-
Hi,
When installing the plugin it gives me a lot of warnings regarding:
Invalid argument supplied for foreach() in /home/kevin/hoppinger/fc-corporate/web/app/plugins/hreflang-tags-by-dcgws/includes/functions.php on line 463It does this because if assumes the post type settings have been set.
Since I don’t like using SVN and can’t be arsed to see how to create a pull request I’ll add the updated code here that prevents this error:
function hreflang_taxonomy_forms() { $types = get_option('hreflang_post_types'); if(!empty($types)) { foreach($types as $type) { if ( !post_type_exists($type) ) { add_action($type.'_add_form_fields','add_hreflang_to_category_form',99); add_action($type.'_edit_form_fields','add_hreflang_to_category_edit_form',10,1); } } } }I first check if $types is empty before trying to loop over it. This makes sure it only goes into the foreach if the post type settings have actually been set.
Kind regards,
Kevin van Hengst
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Code improvement’ is closed to new replies.