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 | |
/** | |
* [Update] This Gist has been integrated into the WordPress Plugin "I don't like Spam!" which supports more WordPress Contact Forms: | |
* https://wordpress.org/plugins/i-dont-like-spam | |
* | |
* Ninja Forms: Server side spam protection making use of the WordPress Comment Blocklist | |
* https://developer.ninjaforms.com/codex/custom-server-side-validation | |
* | |
* Enter your blocklist here: Settings > Discussion > Comment Blocklist | |
* https://developer.wordpress.org/reference/functions/wp_blacklist_check |
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 | |
/** | |
* Include all Gutenberg blocks from content in REST API response | |
* | |
* | |
*/ | |
function my_theme_blocks_to_rest_api( $response, $post, $request ) { | |
if ( ! function_exists( 'parse_blocks' ) ) { | |
return $response; | |
} |
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 | |
/** | |
* Include ACF fields in REST API response | |
* | |
* Post, Page or Custom Posttype | |
*/ | |
function my_theme_acf_to_rest_api( $response, $post, $request ) { | |
if ( ! function_exists( 'get_fields' ) ) { | |
return $response; | |
} |
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 | |
/** | |
* Duplicate specific Theme Customizer values across Multisite network | |
* | |
*/ | |
function my_theme_customize_multisite_duplicate() { | |
if ( is_multisite() ) { | |
// Get existing values from current blog as array |
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 | |
/** | |
* WordPress "Multiblog" | |
* | |
* Combine multiple WP-API feeds sorted by date and cache the output via Transients API | |
*/ | |
// Cache transients in database: https://codex.wordpress.org/Transients_API | |
$transient = 'wp_api_remote_posts_cache; | |
$content = get_transient( $transient ); // Try to get cached data |
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://developer.wordpress.org/reference/hooks/rest_this-post_type_query | |
* | |
* Query language specific posts via "lang" parameter: /wp-json/wp/v2/posts?lang=en | |
*/ | |
function my_theme_filter_rest_post_query( $args, $request ) { | |
$lang_parameter = $request->get_param('lang'); |