• Resolved mtn217

    (@mtn217)


    Hi,

    I’m having an issue where a personal shortcode that I created and have placed in one of my tabs isn’t showing up inside the tab but actually outside and above my tabs. Is it possible to add shortcodes to tabs?

    Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author cubecolour

    (@numeeja)

    This should work and I often use tabs with other shortcodes in their content with no issues.

    Please post a link to the page where I can see the issue and give details of the shortcodes you are using including the code for your shortcode function.

    Thread Starter mtn217

    (@mtn217)

    Here is a page where this is happening: http://ec2-52-89-248-121.us-west-2.compute.amazonaws.com/testing/

    Here is the code I have for the page:
    [tabby title=”Payment Form”]
    [payment]
    [tabbyending]

    So the payment shortcode creates a form where the user is able to make a payment. I add it to the inside of the tab, but it only shows up on the outside of the tab.

    Plugin Author cubecolour

    (@numeeja)

    what PHP code are you using for your shortcode function?

    Thread Starter mtn217

    (@mtn217)

    Here it is:

    
    function pippin_stripe_payment_form() {
     
    	global $stripe_options;
     
    	if(isset($_GET['payment']) && $_GET['payment'] == 'paid') {
    		echo '<p class="success">' . __('Thank you for your payment. Please check your email for your receipt.', 'pippin_stripe') . '</p>';
    	} else { ?>
    		<form action="" method="POST" id="stripe-payment-form">
    			<div class="form-row">
    				<label><?php _e('Amount*', 'pippin_stripe'); ?></label>
    				<input type="text" size="20" autocomplete="off" placeholder="$20" name="user-amount"/>
    			</div>
    
    			<div class="form-row">
    				<label><?php _e('Email*', 'pippin_stripe'); ?></label>
    				<input type="text" size="20" autocomplete="off" name="email"/>
    			</div>
    
    			<div class="form-row">
    				<label><?php _e('Name*', 'pippin_stripe'); ?></label>
    				<input type="text" size="20" autocomplete="off" name="name"/>
    			</div>
    
    			<div class="form-row">
    				<label><?php _e('Street', 'pippin_stripe'); ?></label>
    				<input type="text" size="20" autocomplete="off" name="address"/>
    			</div>
    
    			<div class="form-row">
    				<label><?php _e('City', 'pippin_stripe'); ?></label>
    				<input type="text" size="20" autocomplete="off" name="city"/>
    			</div>
    
    			<div class="form-row">
    				<label><?php _e('Zipcode*', 'pippin_stripe'); ?></label>
    				<input type="text" size="20" autocomplete="off" name="zipcode"/>
    			</div>
    
    			<div class="form-row">
    				<label><?php _e('Card Number*', 'pippin_stripe'); ?></label>
    				<input type="text" size="20" autocomplete="off" class="card-number"/>
    			</div>
    			<div class="form-row">
    				<label><?php _e('CVC*', 'pippin_stripe'); ?></label>
    				<input type="text" size="4" autocomplete="off" class="card-cvc"/>
    			</div>
    			<div class="form-row">
    				<label><?php _e('Expiration (MM/YYYY)*', 'pippin_stripe'); ?></label>
    				<input type="text" size="2" class="card-expiry-month"/>
    				<span> / </span>
    				<input type="text" size="4" class="card-expiry-year"/>
    			</div>
    			<?php if(isset($stripe_options['recurring'])) { ?>
    			<div class="form-row">
    				<label><?php _e('Payment Type:', 'pippin_stripe'); ?></label>
    				<input type="radio" name="recurring" value="no" checked="checked"/><span><?php _e('One time payment', 'pippin_stripe'); ?></span>
    				<input type="radio" name="recurring" value="yes"/><span><?php _e('Recurring monthly payment', 'pippin_stripe'); ?></span>
    			</div>
    			<?php } ?>
    			<input type="hidden" name="action" value="stripe"/>
    			<input type="hidden" name="redirect" value="<?php echo get_permalink(); ?>"/>
    			<input type="hidden" name="amount" value="<?php echo $_POST['user-amount']; ?>"/>
    			<input type="hidden" name="stripe_nonce" value="<?php echo wp_create_nonce('stripe-nonce'); ?>"/>
    			<button type="submit" id="stripe-submit"><?php _e('Submit Payment', 'pippin_stripe'); ?></button>
    		</form>
    		<div class="payment-errors"></div>
    		<?php
    	}
    }
    
    • This reply was modified 8 years, 11 months ago by cubecolour. Reason: Added code backticks
    Plugin Author cubecolour

    (@numeeja)

    The construction used in your function will not work well as as a shortcode function.

    To illustrate this, delete the tab shortcodes to take them out of the equation and paste several paragraphs of Lorem Ipsum filler text to the top of your page. Then no matter where you add your shortcode within the filler text you will see that it will allways be output before that text.

    To fix this, rewrite your code so the form is built as a string assigned as the value of a variable. Then return (not echo) the string at the end of the function.

    Alternatively use an output buffer, eg

    ob_start();

    at the beginning of the function, and

    return ob_get_clean();

    at the end of the function.

    Thread Starter mtn217

    (@mtn217)

    It works again! I used the output buffer at the beginning and end of the function and it works now.

    Thank you sooo much for your help! Love your plugin!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Adding personal shortcode to tab issue’ is closed to new replies.