Get user in rest API endpoint

Thanks to Jacob Peattie, I was able to solve this issue. You have to include a nonce from the WordPress Javascript API in your REST API requests if you wish to use information about the current user. From the WordPress documentation: If no nonce is provided the API will set the current user to 0, … Read more

Where is the Javascript attribute window._wpCustomHeaderSettings defined?

It’s defined via wp_localize_script() that’s called by the_custom_header_markup(): wp_localize_script( ‘wp-custom-header’, ‘_wpCustomHeaderSettings’, get_header_video_settings() ); So if you want to override the values/settings using JavaScript, then you can hook to wp_print_footer_scripts and add your script like so: add_action( ‘wp_print_footer_scripts’, function(){ if ( wp_script_is( ‘wp-custom-header’ ) ) : ?> <script> if ( window._wpCustomHeaderSettings ) { _wpCustomHeaderSettings.minHeight = 0; … Read more

Adding a class to the active tab [closed]

I have update in codepan js code. please use below js code to active tab. i have tested and it is working fine. let me know if this works for you! class TabList { constructor(buttonsContainer, tabs) { this.buttonsContainer = buttonsContainer; this.tabs = tabs; this.buttonsContainer.addEventListener(“click”, event => { document.querySelector( ‘.woocommerce-tabs__button–active’ ).classList.remove( ‘woocommerce-tabs__button–active’ ); event.target.closest(“.woocommerce-tabs__button”).classList.add(“woocommerce-tabs__button–active”); const index … Read more

WordPress Block.js SVG createElement

Basically, when using wp.element.createElement(), For attribute names having special characters like a hypen/-, the name should be put in single/double quotes: e.g. ‘data-name’ and not simply data-name. createElement( ‘svg’, { ‘data-name’: ‘Layer 1’ // like this data-name: ‘Layer 1’ // not this } ); The same also goes to attribute names like class which is … Read more