This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php#L64 | |
register_rest_route( | |
$this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', | |
array( | |
'methods' => WP_REST_Server::READABLE, | |
'callback' => array( $this, 'get_item' ), | |
'permission_callback' => array( $this, 'get_item_permissions_check' ), | |
'args' => array( | |
'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function cached_get_item_permissions_check( $request ) { | |
$error = new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) ); | |
if ( (int) $request['id'] <= 0 ) { | |
return $error; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Cached version of count_user_posts, which is uncached but doesn't always need to hit the db | |
* | |
* Count_user_posts is generally fast, but it can be easy to end up with many redundant queries. | |
* if it's called several times per request. This allows bypassing the db queries in favor of | |
* the cache | |
* | |
* @param int $user_id user id to get count. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Rest endpoint filter to change permission callback of item_permission_check. | |
* | |
* @param type $endpoints return endpoints. | |
*/ | |
public function replace_rest_endpoints_permission_callback( $endpoints ) { | |
if ( isset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(*), post_type FROM `wp_posts` WHERE post_type IN( SELECT DISTINCT post_type wp_posts ) GROUP BY post_type ORDER BY `count(*)` DESC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
window.addEventListener('load', () => { | |
const download_button = document.querySelectorAll( '.download-rt-whitepaper a' ); | |
download_button[0].click(); | |
}); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Local Storage Demo | |
* | |
* @requires AMP WordPress Plugin. | |
*/ | |
add_action( | |
'wp_head', | |
function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* AMP Local Storage. | |
* | |
* @package AMP_Local_Storage_Test | |
* @author Milind, rtCamp | |
* @license GPL-2.0-or-later | |
* @copyright 2020 rtCamp pvt. ltd. | |
* | |
* @wordpress-plugin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( | |
'wp', | |
function() { | |
add_action( 'amp_mobile_client_side_redirection', '__return_false' ); | |
if ( ! isset( $_GET['noamp'] ) && wp_is_mobile() && function_exists( 'is_amp_endpoint' ) && ! is_amp_endpoint() && function_exists( 'amp_is_available' ) && amp_is_available() ) { | |
wp_safe_redirect( esc_url( add_query_arg( 'amp', '1', get_permalink() ) ), 302 ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Web Stories amp-onerror Workaround plugin bootstrap. | |
* | |
* @package Google\Web_Stories_AMP_OnError_Workaround | |
* @author Pascal Birchler, Google | |
* @license GPL-2.0-or-later | |
* @copyright 2021 Google Inc. | |
* | |
* @wordpress-plugin |
OlderNewer