body_class REST field in WP-API

get_body_class() relies on $wp_query to do its thing, which is apparently a no-go for the JSON API. I considered creating a global object to hold the body class, and just using that to keep the body_class up to date…but that wouldn’t work without page reloads, and there would be no assurance that the object was … Read more

Set Title from Custom Template

Use global variables to pass values from the template to the header. // in the template file global $my_page_title; $my_page_title=”field value”; global $my_meta_description; $my_meta_description = ‘field value’; get_header(); // in the header file global $my_page_title; global $my_meta_description; echo $my_page_title; echo $my_meta_description;

How to disable search as you type plugin suggestions?

Dirty fix will be to remove/change $pluginInstallSearch.on to trigger only on submit. The changed function looks like this. Remember this is not recommended. $pluginInstallSearchOnlyonSubmit = $(“.plugin-install-php .search-form.search-plugins”); $pluginInstallSearchOnlyonSubmit.on( ‘submit’, _.debounce( function( event, eventtype ) { var $searchTab = $( ‘.plugin-install-search’ ), data, searchLocation; data = { _ajax_nonce: wp.updates.ajaxNonce, s: $pluginInstallSearchOnlyonSubmit.find(‘.wp-filter-search’).val(),//Set the search input value tab: … Read more

Get a default value of the Customizer setting using wp.customize API (JS)

It would make sense for the default value to be available via: wp.customize.instance( ‘slug_awesome_title’ ).default Or equivalently: wp.customize( ‘slug_awesome_title’ ).default However, I can see the default is simply not getting exported from PHP to JS. I can see that this is going to be needed in core also when client-side templating replaces server-side rendering of … Read more

Store regex expression in WordPress DB using Options API

WordPress by default “escapes” all slashes and quotes in all input (historical reason, relic of the time PHP could have been configured to do it by default, or not). If you are handling forms by yourself instead of using the APIs you will need to strip the slashes, probably best to be done when saving … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)