• Resolved Soela

    (@soela)


    Hi Giovambattista,

    thanks for the great plugin(!), one question though:
    Is it possible to store the output of the wp_bannerize_pro() function in a variable for later use in the script, rather than outputting the returned HTML immediately? Much like many of the WP functions starting with “get_”, see e.g. the_title() vs. get_the_title().

    Thanks again,
    Chris

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author gfazioli

    (@gfazioli)

    @soela great suggestion! In the meanwhile, you may use an easy workaround for that, the first one is:

    
    ob_start();
    wp_bannerize_pro($atts); // your attrs
    $content = ob_get_contents();
    ob_end_clean();
    

    in $content you’ll get the HTML

    Or you could create a simple global function with the above code, something like

    
    if (!function_exists('get_wp_bannerize_pro')) {
     function get_wp_bannerize_pro($atts) {
      ob_start();
      wp_bannerize_pro($atts); // your attrs
      $content = ob_get_contents();
      ob_end_clean();
      return $content;
     }
    }
    

    Anyway, I’ll try to add this feature soon

    • This reply was modified 4 years, 11 months ago by gfazioli.
    Thread Starter Soela

    (@soela)

    Just wanted to say a big Thank You for this amazing example of plugin support. Before I even could try out your workaround (which no doubt would have worked perfectly) I found an update with the feature implemented in the core! And the new function get_wp_bannerize_pro() of course works perfectly, too, and does exactly what I wanted.
    Keep up the good work!

    All the best,
    Chris

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Caching output of wp_bannerize_pro() in variable’ is closed to new replies.