14
14
* Version: 1.0
15
15
*/
16
16
17
- function shoestrap_edd_purchase_variable_pricing( $download_id ) {
18
- $variable_pricing = edd_has_variable_prices( $download_id );
19
-
20
- if ( ! $variable_pricing )
21
- return;
22
-
23
- $prices = apply_filters( 'edd_purchase_variable_prices', edd_get_variable_prices( $download_id ), $download_id );
24
-
25
- $type = edd_single_price_option_mode( $download_id ) ? 'checkbox' : 'radio';
26
-
27
- do_action( 'edd_before_price_options', $download_id );
28
-
29
- echo '< div class ="edd_price_options "> ';
30
- if ( $prices ) {
31
- echo '< select name ="edd_options[price_id][] "> ';
32
- foreach ( $prices as $key => $price ) {
33
- printf(
34
- '< option for ="%3$s " name ="edd_options[price_id][] " id ="%3$s " class ="%4$s " value ="%5$s " %7$s > %6$s</ option > ',
35
- checked( 0, $key, false ),
36
- $type,
37
- esc_attr( 'edd_price_option_' . $download_id . '_' . $key ),
38
- esc_attr( 'edd_price_option_' . $download_id ),
39
- esc_attr( $key ),
40
- esc_html( $price['name'] . ' - ' . edd_currency_filter( edd_format_amount( $price[ 'amount' ] ) ) ),
41
- selected( isset( $_GET['price_option'] ), $key, false )
42
- );
43
- do_action( 'edd_after_price_option', $key, $price, $download_id );
17
+ function edd_library_variable_price_dropdown() {
18
+ function shoestrap_edd_purchase_variable_pricing( $download_id ) {
19
+ $variable_pricing = edd_has_variable_prices( $download_id );
20
+
21
+ if ( ! $variable_pricing )
22
+ return;
23
+
24
+ $prices = apply_filters( 'edd_purchase_variable_prices', edd_get_variable_prices( $download_id ), $download_id );
25
+
26
+ $type = edd_single_price_option_mode( $download_id ) ? 'checkbox' : 'radio';
27
+
28
+ do_action( 'edd_before_price_options', $download_id );
29
+
30
+ echo '< div class ="edd_price_options "> ';
31
+ if ( $prices ) {
32
+ echo '< select name ="edd_options[price_id][] "> ';
33
+ foreach ( $prices as $key => $price ) {
34
+ printf(
35
+ '< option for ="%3$s " name ="edd_options[price_id][] " id ="%3$s " class ="%4$s " value ="%5$s " %7$s > %6$s</ option > ',
36
+ checked( 0, $key, false ),
37
+ $type,
38
+ esc_attr( 'edd_price_option_' . $download_id . '_' . $key ),
39
+ esc_attr( 'edd_price_option_' . $download_id ),
40
+ esc_attr( $key ),
41
+ esc_html( $price['name'] . ' - ' . edd_currency_filter( edd_format_amount( $price[ 'amount' ] ) ) ),
42
+ selected( isset( $_GET['price_option'] ), $key, false )
43
+ );
44
+ do_action( 'edd_after_price_option', $key, $price, $download_id );
45
+ }
46
+ echo '</ select > ';
44
47
}
45
- echo '</ select > ';
46
- }
47
- do_action( 'edd_after_price_options_list', $download_id, $prices, $type );
48
+ do_action( 'edd_after_price_options_list', $download_id, $prices, $type );
48
49
49
- echo '</ div > <!--end .edd_price_options--> ';
50
- do_action( 'edd_after_price_options', $download_id );
50
+ echo '</ div > <!--end .edd_price_options--> ';
51
+ do_action( 'edd_after_price_options', $download_id );
52
+ }
53
+ add_action( 'edd_purchase_link_top', 'shoestrap_edd_purchase_variable_pricing', 10, 1 );
54
+ remove_action( 'edd_purchase_link_top', 'edd_purchase_variable_pricing', 10, 2 );
51
55
}
52
- add_action( 'edd_purchase_link_top', 'shoestrap_edd_purchase_variable_pricing', 10, 1 );
53
- remove_action( 'edd_purchase_link_top', 'edd_purchase_variable_pricing', 10, 1 );
56
+ add_action( 'plugins_loaded', 'edd_library_variable_price_dropdown', 20 );
0 commit comments