Permalink
Browse files

Shortcode should return, not echo

  • Loading branch information...
1 parent 7731fd5 commit ff7895e9f916114f47c21aa62aeb791fc3c5dc4b @rinatkhaziev rinatkhaziev committed Jun 18, 2013
Showing with 8 additions and 4 deletions.
  1. +8 −4 ad-code-manager.php
View
@@ -834,8 +834,9 @@ function register_ad_codes( $ad_codes = array() ) {
* @uses do_action( 'acm_tag, 'your_tag_id' )
*
* @param string $tag_id Unique ID for the ad tag
+ * @param bool $echo whether to echo or return ( defaults to echo )
*/
- function action_acm_tag( $tag_id ) {
+ function action_acm_tag( $tag_id, $echo = true ) {
/**
* See http://adcodemanager.wordpress.com/2013/04/10/hi-all-on-a-dotcom-site-that-uses/
*
@@ -876,8 +877,11 @@ function action_acm_tag( $tag_id ) {
*/
$output_html = apply_filters( 'acm_output_html_after_tokens_processed', $output_html, $tag_id );
- // Print the ad code
- echo $output_html;
+ if ( $echo )
+ // Print the ad code
+ echo $output_html;
+ else
+ return $output_html;
}
/**
@@ -1067,7 +1071,7 @@ function shortcode( $atts ) {
if ( empty( $id ) )
return;
- $this->action_acm_tag( $id );
+ return $this->action_acm_tag( $id, false );
}
}

0 comments on commit ff7895e

Please sign in to comment.