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

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

Calling an API to do authentication / user login

It’s better not to do so. And I’m completely against overriding the default authentication mechanism simply because of WordPress and it’s plugins usually are depended on the website’s database. But if you’re really into this situation WordPress provides a filter called authenticate: add_filter( ‘authenticate’, ‘wpse75679_auth’, 30, 3 ); function wpse75679_auth( $user, $username, $password ) { … Read more

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