Skip to content

Instantly share code, notes, and snippets.

View dana-ross's full-sized avatar

Dana Ross dana-ross

View GitHub Profile
@dana-ross
dana-ross / disable-rest-endpoints.php
Created February 27, 2018 16:58 — forked from chuckreynolds/disable-rest-endpoints.php
WordPress: Disable WP REST API JSON endpoints if user not logged in
<?php
/*
* Disable WP REST API JSON endpoints if user not logged in
*/
function chuck_disable_rest_endpoints( $access ) {
if( ! is_user_logged_in() ) {
return new WP_Error( 'rest_cannot_access', __( 'Only authenticated users can access the REST API.', 'disable-json-api' ), array( 'status' => rest_authorization_required_code() ) );
}
return $access;
}
((function ($) {
$.scrollWindowTo = function (pos, duration, cb) {
if (duration == null) {
duration = 0;
}
if (pos === $(window).scrollTop()) {
$(window).trigger('scroll');
if (typeof cb === "function") {
cb();
}