Skip to content

Commit

Permalink
Expand webcomic_print_form label options.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Sisk committed Sep 4, 2013
1 parent 46458f8 commit 6359de3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions -/php/tags.php
Expand Up @@ -1761,12 +1761,13 @@ public static function webcomic_print_fields( $type, $the_post = false ) {
/** Return a print purchase form. /** Return a print purchase form.
* *
* @param string $type The type of print form, one of 'domestic', 'international', 'original', or 'cart'. * @param string $type The type of print form, one of 'domestic', 'international', 'original', or 'cart'.
* @param string $label The form submit button label. Accepts %dec, %sep, %total, %price, and %shipping tokens. * @param string $label The form submit button label. Accepts %dec, %sep, %total, %price, %shipping, %collection-total, %collection-price, and %collection-shipping tokens.
* @param mixed $the_post The post object or ID to get print adjustments for. * @param mixed $the_post The post object or ID to get print adjustments for.
* @return string * @return string
* @uses Webcomic::$config * @uses Webcomic::$config
* @uses WebcomicTag::webcomic_print_amount() * @uses WebcomicTag::webcomic_print_amount()
* @uses WebcomicTag::webcomic_print_fields() * @uses WebcomicTag::webcomic_print_fields()
* @uses WebcomicTag::webcomic_collection_print_amount()
* @filter string webcomic_print_form Filters the output of `webcomic_print_form`. * @filter string webcomic_print_form Filters the output of `webcomic_print_form`.
*/ */
public static function webcomic_print_form( $type, $label = '', $the_post = false ) { public static function webcomic_print_form( $type, $label = '', $the_post = false ) {
Expand All @@ -1780,8 +1781,9 @@ public static function webcomic_print_form( $type, $label = '', $the_post = fals
} else { } else {
$label = '_cart' === self::$config[ 'collections' ][ $the_post->post_type ][ 'commerce' ][ 'method' ] ? __( 'Add to Cart', 'webcomic' ) : __( 'Buy Now', 'webcomic' ); $label = '_cart' === self::$config[ 'collections' ][ $the_post->post_type ][ 'commerce' ][ 'method' ] ? __( 'Add to Cart', 'webcomic' ) : __( 'Buy Now', 'webcomic' );
} }
} else { } elseif ( false !== strpos( $label, '%' ) ) {
$match = array(); $match = array();
$collection = get_post_type( $the_post );


preg_match( '/%dec(.)/', $label, $match ); preg_match( '/%dec(.)/', $label, $match );


Expand All @@ -1793,9 +1795,12 @@ public static function webcomic_print_form( $type, $label = '', $the_post = fals
$label = preg_replace( '/(%dec.|%sep.)/', '', $label ); $label = preg_replace( '/(%dec.|%sep.)/', '', $label );


$tokens = array( $tokens = array(
'%total' => self::webcomic_print_amount( $type, $dec, $sep, $the_post ), '%total' => self::webcomic_print_amount( $type, $dec, $sep, $the_post ),
'%price' => self::webcomic_print_amount( "{$type}-price", $dec, $sep, $the_post ), '%price' => self::webcomic_print_amount( "{$type}-price", $dec, $sep, $the_post ),
'%shipping' => self::webcomic_print_amount( "{$type}-shipping", $dec, $sep, $the_post ) '%shipping' => self::webcomic_print_amount( "{$type}-shipping", $dec, $sep, $the_post ),
'%collection-total' => self::webcomic_collection_print_amount( $type, $dec, $sep, $collection ),
'%collection-price' => self::webcomic_collection_print_amount( "{$type}-price", $dec, $sep, $collection ),
'%collection-shipping' => self::webcomic_collection_print_amount( "{$type}-shipping", $dec, $sep, $collection )
); );


$label = str_replace( array_keys( $tokens ), $tokens, $label ); $label = str_replace( array_keys( $tokens ), $tokens, $label );
Expand Down

0 comments on commit 6359de3

Please sign in to comment.