Last active
January 5, 2017 23:38
-
-
Save gabelloyd/b71492c58ed8f962dc1dd142215931f2 to your computer and use it in GitHub Desktop.
Filter the price input field for Name Your Price WooCommerce Extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Replace title and type input on the price input field for Name Your Price | |
* Ref: https://gist.github.com/helgatheviking/e1326e2047ed621158f86c1d4747e9bc | |
* | |
* @param string $input - the <input> tag | |
* @param string $product_id | |
* @param string $prefix - needed for composites and bundles | |
* @return string | |
*/ | |
function ltc_change_title_input( $input, $product_id, $prefix ) { | |
$title = esc_attr( 'Enter Your Donation', 'wtrwd'); | |
$replace = sprintf( 'title="%s"', $title ); | |
$input = str_replace( 'title="nyp"', $replace, $input ); | |
return $input; | |
} | |
add_filter ('woocommerce_get_price_input', 'ltc_change_title_input', 10, 3); | |
function ltc_change_type_input( $input, $product_id, $prefix ) { | |
$type = esc_attr( 'tel', 'your_text_domain'); //change to telephone type so number pad displays on mobile | |
$replace = sprintf( 'type="%s"', $type ); | |
$input = str_replace( 'type="text"', $replace, $input ); | |
return $input; | |
} | |
add_filter ('woocommerce_get_price_input', 'ltc_change_type_input', 10, 3); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment