Support » Plugin: HREFLANG Tags Lite » 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 463

    It 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)
  • Plugin Author David Davis

    (@dcgws)

    Hi Kevin

    Sorry, I’ve just seen this. I’ve been very busy with other projects/life outside of plugin development.

    First of all, please try and edit your post. Please use x’s in place of your name and account details in your file path. 1) it doesn’t help me address the issue and 2) it could be a serious security breach for you.

    I’ll try to issue an update in the next couple of weeks.

    Best
    David

Viewing 1 replies (of 1 total)
  • The topic ‘Code improvement’ is closed to new replies.