/** * Display settings page with some additional JS for hiding conditional fields. * * @since 2.4.0 * @see SV_WC_Payment_Gateway::admin_options() */ public function admin_options() { parent::admin_options(); // add inline javascript ob_start(); ?> $( '.accept-js-toggle' ).change( function() { if ( $( this ).is( ':checked' ) ) { $( this ).closest( 'tr' ).next().show(); } else { $( this ).closest( 'tr' ).next().hide(); } } ).change(); $( '#woocommerce_<?php echo $this->get_id(); ?> _environment' ).change( function() { if ( 'production' === $( this ).val() ) { var accept_js_setting = $( '#woocommerce_<?php echo $this->get_id(); ?> _accept_js_enabled' ); } else { var accept_js_setting = $( '#woocommerce_<?php echo $this->get_id(); ?> _test_accept_js_enabled' ); } $( accept_js_setting ).change(); } ).change(); <?php wc_enqueue_js(ob_get_clean()); }
/** * Adds some inline JS to show/hide the authorization message settings fields. * * @since 2.4.0 * @see WC_Settings_API::admin_options() */ public function admin_options() { parent::admin_options(); // add inline javascript to show/hide any shared settings fields as needed ob_start(); ?> $( '#woocommerce_<?php echo sanitize_html_class($this->get_id()); ?> _authorization_message_enabled' ).change( function() { var enabled = $( this ).is( ':checked' ); if ( enabled ) { $( '.authorization-message-field' ).closest( 'tr' ).show(); } else { // show the fields $( '.authorization-message-field' ).closest( 'tr' ).hide(); $( '#woocommerce_<?php echo sanitize_html_class($this->get_id()); ?> _authorization_message_enabled' ).change(); } } ).change(); <?php wc_enqueue_js(ob_get_clean()); }