• Resolved Dave2084

    (@dave2084)


    I have some custom shortcodes that add tables of information with a summary of posts from the last week.

    These are filtered by a taxonomy that each user can set so they see posts that a relevant to them in the newsletter.

    This all worked perfectly in RC 1.0.4, however upon upgrading to RC 2.0.1 today it is now broken and if I filter by taxonomy no posts are found when using the web browser, however the posts show up fine in the emails themselves. This is a problem however as the newsletter archive is also empty except for the header, preamble and footer.

    Just to be sure I reverted to RC 1.0.4 and it worked again, and was broken on going back to 2.0.1.

    I realise that you do not support custom shortcodes but this is something more fundamental. If I do a simple var_dump(get_term( 3609, ‘subject’ )) in the custom shortcode I get a result of WP_Error – invalid_taxonomy, despite the taxonomy and term being OK.

    The odd thing is as I mentioned above that it works when sending the mail but not when rendering a webpage.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter Dave2084

    (@dave2084)

    I have just done some additional testing and when sending a mail out to a list then shortcodes are not rendered, it appears to only work when sending a preview email.

    Thread Starter Dave2084

    (@dave2084)

    I’ve installed RC 2.0.0 and the issue is not present, so it was introduced in RC 2.0.1.

    @dave2084 We’ve done some modifications to the plugin in the latest release because Multisite activation broke besides other conflicts with plugins using wp_mail. I’m afraid we can guarantee or support that your custom shortcodes will work. Sorry for the inconvenience.

    Thread Starter Dave2084

    (@dave2084)

    I don’t need support with my custom shortcode, but not being able to access a taxonomy in the shortcodes is something fundamental to WP which I would expect to work.

    Re,

    We’ve just tried the following code:

    add_filter('mailpoet_newsletter_shortcode', 'mailpoet_custom_shortcode', 10, 5);
    function mailpoet_custom_shortcode($shortcode, $newsletter, $subscriber, $queue, $newsletter_body) {
      if ($shortcode !== '[custom:taxonomy]') return $shortcode; 
      var_dump(get_term(1));
    }
    

    Here is the result when previewing a newsletter with [custom:taxonomy] shortcode:

    object(WP_Term)[437]
      public 'term_id' => int 1
      public 'name' => string 'Uncategorized' (length=13)
      public 'slug' => string 'uncategorized' (length=13)
      public 'term_group' => int 0
      public 'term_taxonomy_id' => int 1
      public 'taxonomy' => string 'category' (length=8)
      public 'description' => string '' (length=0)
      public 'parent' => int 0
      public 'count' => int 3
      public 'filter' => string 'raw' (length=3)
    

    Are we missing something?

    Thread Starter Dave2084

    (@dave2084)

    Getting term 1 (taxonomy ‘category’) is OK

    The problem is with custom taxonomies.

    If I use either of the following then I get WP_Error->invalid_taxonomy returned:

    var_dump(get_term( 3 ));
    var_dump(get_terms( 'subject' ))

    Term 3 is part of the custom ‘subject’ taxonomy.

    Again this was OK in RC 2.0.0 but not in RC 2.0.1.

    Of 16 taxonomies in the DB for this site only ‘category’, ‘link_category’ and ‘nav_menu’ will return terms.

    Dave,

    Are you using a plugin that creates those custom taxonomies? Please provide steps to reproduce. Feel free to use the question mark icon on any of the plugin pages to get in touch with us directly.

    Thread Starter Dave2084

    (@dave2084)

    Sorry for the delay, I’ll take a look today and post how the custom taxonomies are set up.

    Thread Starter Dave2084

    (@dave2084)

    Currently using this:
    https://github.com/johnbillion/extended-taxos/tree/2.0.5

    It is also being used in conjunction with his extended-cpts plugin.

    I see that in v4.0 (released 8 days ago) he has merged the two plugins into a single one. I’ll try and find time today to add the v4.0 code but the cpt plugin arguments will need some minor changes.

    Thread Starter Dave2084

    (@dave2084)

    Marking some headway now.

    I updated both plugins to the latest 2.x and the fault was still present, initially I held off going to the new combined 4.x version as it is no longer a plugin but a library AND it requires PHP 7 but in dev and production we are currently running 5.5.

    After changing quite a bit of legacy code to make it PHP 7 compatible I now have the taxonomies working with the v4.x library of extended-cpts, but there are a lot of changes I will need to do to the site before I can launch it on PHP 7.

    Dave,

    Thank you for looking into this and please keep us posted. We’ve noticed that extended-taxos initializes using the init hook with priority of 9. Our plugin was recently updated to use priority 0. Could that be an issue? Feel free to edit line lib/Config/Initializer.php:65 and remove the priority, then test if it works.

    John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Author of Extended CPTs / Taxos here.

    I removed the special init handling from Extended CPTs for just this reason. The hook priority of 9 did mean it didn’t always work with other plugins.

    In Extended CPTs 4+, you need to register post types and taxonomies within your own callback function that’s hooked onto the init action. You can then use whichever priority causes the least problems on your own particular site, although 9 does work in most cases.

    Thread Starter Dave2084

    (@dave2084)

    Hi, sorry for the silence regarding this issue. Now I’ve come back to this so I can get the mail-poet version installed to be the latest (v3.0 congratulations!) although I can fix this by changing the hook priorities I have noticed that it is not necessary as v3.0 works with out existing code.

    Putting that aside as time allows we will have a project to move the site to PHP7 and update some of the legacy code like the Extended CPTs / Taxos.

    I think this issue can be closed now.

    Thanks for all the support!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Custom Shortcodes cannot access taxonomy’ is closed to new replies.