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
**/*.min.js | |
**/*.build.js | |
**/node_modules/** | |
**/vendor/** | |
build | |
coverage | |
cypress | |
node_modules | |
vendor |
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('rest_api_init', function() { | |
// Surface all Gutenberg blocks in the WordPress REST API | |
$post_types = get_post_types_by_support( [ 'editor' ] ); | |
foreach ( $post_types as $post_type ) { | |
if ( gutenberg_can_edit_post_type( $post_type ) ) { |
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 wpscholar_rest_get_request( $route, array $params = [] ) { | |
$request = new WP_REST_Request( 'GET', $route ); | |
$request->set_query_params( $params ); | |
$response = rest_do_request( $request ); | |
return rest_get_server()->response_to_data( $response, false ); | |
} |
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 | |
echo esc_html( size_format( wp_max_upload_size() ) ); |
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 | |
/** | |
* Fix plugin URLs for plugins inside the theme | |
*/ | |
add_filter( 'plugins_url', function ( $url, $path, $plugin ) { | |
$theme_path = trailingslashit( wp_normalize_path( get_theme_file_path() ) ); | |
if ( 0 === strpos( $plugin, $theme_path ) ) { | |
$basename = trim( dirname( str_replace( $theme_path, '', $plugin ) ), '/' ); | |
$url = get_theme_file_uri( "$basename/$path" ); |
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 Loader(el) { | |
el.loader = this; | |
this.el = el; | |
this.style = document.getElementById('js-loader-styles'); | |
this.init(); | |
if (!document.body.animate) { | |
if (!this.style) { | |
this.style = document.createElement('style'); |
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 print(selector) { | |
var w = window.open('', '', 'left=0,top=0,width=' + window.width + ',height=' + window.height + ',toolbar=0,scrollbars=0,status=0'); | |
w.document.write('<link rel="stylesheet" type="text/css" href="/path/to.css" />'); | |
w.document.write(document.querySelector(selector).innerHTML); | |
w.document.close(); | |
w.addEventListener('load', function () { | |
w.focus(); | |
w.print(); | |
w.close(); | |
}, true); |
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 | |
/** | |
* Check if value is a callable, if so, covert the callable to a value. | |
* Accepts any number of additional arguments, all of which will be passed to the callable. | |
* | |
* @param callable|mixed $value | |
* | |
* @return mixed | |
*/ |
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 (win, doc) { | |
doc.addEventListener('DOMContentLoaded', () => { | |
// Prevent empty links from doing anything | |
[].forEach.call(doc.querySelectorAll('a[href="#"]'), function (el) { | |
el.addEventListener('click', function (e) { | |
e.preventDefault(); | |
}); | |
}); |
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 | |
define( 'SITE_LIVE_DOMAIN', SITE_LIVE_DOMAIN ); | |
define( 'WP_ENV', isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ? $_ENV['PANTHEON_ENVIRONMENT'] : 'local' ); | |
define( 'SCHEME', isset( $_SERVER['HTTP_USER_AGENT_HTTPS'] ) && $_SERVER['HTTP_USER_AGENT_HTTPS'] == 'ON' ? 'https' : 'http' ); | |
// Redirect all traffic on live site to the correct domain | |
if ( 'live' === WP_ENV && php_sapi_name() !== 'cli' ) { | |
if ( $_SERVER['HTTP_HOST'] !== SITE_LIVE_DOMAIN ) { |