Viewing 6 replies - 1 through 6 (of 6 total)
  • codenegar,

    Are you running into an issue where the URL is getting set as a WP_Error object? The functions used here such as get_permalink() and get_post_type_archive_link() return false on error, so is_empty() is generally sufficient here. If you can provide a case where it isn’t, sure, I’ll change it, but I’d like to know if or why this is happening for you.

    Thread Starter codenegar

    (@codenegar)

    I have a plugin that generates pages on the fly, it uses WordPress search and custom taxonomies to create pages with custom posts.
    Some users can’t load pages when your plugin is active, I debugged the code and found that your plugin uses $url variable as string (in fact it’s a wp_error object in those cases).
    I need to edit each your plugin, but it’s more bullet proof for your plugin to avoid using wp_error as string.

    codenegar,

    Can you tell me how $url gets set as a WP_Error() object? Is that happening in the aiosp_mrt_get_url() function or in some other code? I’ll consider adding a check for this, but it’d help to know where or how this is taking place. You should also be able to fix this by using the aioseop_canonical_url filter.

    Thread Starter codenegar

    (@codenegar)

    Thank you.
    I did another debug and found that errors happen in aiosp_mrt_get_url function.
    At line 1821 when it looks for a taxonomy and a term, if the term is empty, get_term_link return an error.
    If you add here a condition to check $term, $taxonomy are not empty, it would be much bullet proof code.

    codenegar,

    Thanks for that; I’ll add some better error checking and handling of this in the next release, which should be out soon.

    Thread Starter codenegar

    (@codenegar)

    Great. Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Avoid using WP_error as string’ is closed to new replies.