Open ipokkel opened 3 years ago
A temporary workaround to load the required files would be to load a customization recipe in a customization plugin that also checks if the user is on the checkout page or whether a level for checkout exists.
function my_pmprorh_enqueue_select2( $hook ) {
if ( ! defined( 'PMPRORH_URL' ) || ! function_exists( 'pmpro_getLevelAtCheckout' ) ) {
return;
}
global $pmpro_pages;
$level = pmpro_getLevelAtCheckout();
// only include on front end and user profiles
if (
( ! is_admin() &&
( ! empty( $_REQUEST['level'] ) ||
! empty( $pmpro_level ) ||
class_exists( 'Theme_My_Login' ) && method_exists( 'Theme_My_Login', 'is_tml_page' ) && Theme_My_Login::is_tml_page( 'profile' )
) ||
( isset( $pmpro_pages['member_profile_edit'] ) && is_page( $pmpro_pages['member_profile_edit'] ) ) ||
( isset( $pmpro_pages['checkout'] ) && is_page( $pmpro_pages['checkout'] ) ) ||
( isset( $level->id ) )
) ||
$hook == 'profile.php' ||
$hook == 'user-edit.php'
) {
wp_enqueue_style( 'select2', PMPRORH_URL . '/css/select2.min.css', '', '4.0.3', 'screen' );
wp_enqueue_script( 'select2', PMPRORH_URL . '/js/select2.min.js', array( 'jquery' ), '4.0.3' );
}
}
add_action( 'wp_enqueue_scripts', 'my_pmprorh_enqueue_select2' );
Describe the bug A select2 Register Helper field type is rendered as a multi-select field and the console has a javascript error notification of select2 not being a valid function when there is no
level
URL parameter.We should consider additional conditional checks if the user is on the checkout page to load the required CSS & JS here:
https://github.com/strangerstudios/pmpro-register-helper/blob/2780df68cde584b5087ad7b508aa68a84494046c/pmpro-register-helper.php#L1338-L1352
To Reproduce Steps to reproduce the behavior:
level=1
, and load pageScreenshots If applicable, please attach a screenshot to make your issue clearer.
Expected behavior A clear and concise description of what you expected to happen.
Isolating the problem (mark completed items with an [x]):