Last active
January 16, 2019 16:18
-
-
Save ideadude/4e1d17e590ed5e80a5aa7e7ea0e959db to your computer and use it in GitHub Desktop.
Turn Discount Code dropdown on the PMPro orders list to a select2 field.
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
/** | |
* Turn Discount Code dropdown on orders list to a select2 field. | |
* Add this code to a custom plugin. https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_add_select2_to_discount_code_filter_on_orders_page() { | |
if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'pmpro-orders' ) { | |
wp_enqueue_style( 'select2', plugins_url( 'css/select2.css', __FILE__ ), '', '4.0.6', 'screen' ); | |
wp_enqueue_script( 'select2', plugins_url( 'js/select2.js', __FILE__ ), array( 'jquery' ), '4.0.6' ); | |
function my_add_select2_inline_script() { | |
?> | |
<script> | |
jQuery(document).ready(function() { | |
jQuery('#discount_code').select2(); | |
}); | |
</script> | |
<?php | |
} | |
add_action( 'admin_footer', 'my_add_select2_inline_script' ); | |
} | |
} | |
add_action( 'admin_enqueue_scripts', 'my_add_select2_to_discount_code_filter_on_orders_page' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment