Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Expand webcomic_print_form label options.

  • Loading branch information...
commit 6359de3a5a0179d73b150e35933df015e09db62a 1 parent 46458f8
Michael Sisk authored
Showing with 11 additions and 6 deletions.
  1. +11 −6 -/php/tags.php
17 -/php/tags.php
View
@@ -1761,12 +1761,13 @@ public static function webcomic_print_fields( $type, $the_post = false ) {
/** Return a print purchase form.
*
* @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.
* @return string
* @uses Webcomic::$config
* @uses WebcomicTag::webcomic_print_amount()
* @uses WebcomicTag::webcomic_print_fields()
+ * @uses WebcomicTag::webcomic_collection_print_amount()
* @filter string webcomic_print_form Filters the output of `webcomic_print_form`.
*/
public static function webcomic_print_form( $type, $label = '', $the_post = false ) {
@@ -1780,8 +1781,9 @@ public static function webcomic_print_form( $type, $label = '', $the_post = fals
} else {
$label = '_cart' === self::$config[ 'collections' ][ $the_post->post_type ][ 'commerce' ][ 'method' ] ? __( 'Add to Cart', 'webcomic' ) : __( 'Buy Now', 'webcomic' );
}
- } else {
- $match = array();
+ } elseif ( false !== strpos( $label, '%' ) ) {
+ $match = array();
+ $collection = get_post_type( $the_post );
preg_match( '/%dec(.)/', $label, $match );
@@ -1793,9 +1795,12 @@ public static function webcomic_print_form( $type, $label = '', $the_post = fals
$label = preg_replace( '/(%dec.|%sep.)/', '', $label );
$tokens = array(
- '%total' => self::webcomic_print_amount( $type, $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 )
+ '%total' => self::webcomic_print_amount( $type, $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 ),
+ '%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 );
Please sign in to comment.
Something went wrong with that request. Please try again.