Skip to content

Instantly share code, notes, and snippets.

View jonbrockett's full-sized avatar

Jon Brockett jonbrockett

View GitHub Profile
@jonbrockett
jonbrockett / functions.php
Created June 10, 2021 14:10
Disable Searching for an Empty String in WordPress Search
/** Show 'Nothing Found' for an empty search instead of all posts/pages (Helps with Accessibility) */
require_once 'library/search-empty-disable.php';
@jonbrockett
jonbrockett / functions.php
Created June 10, 2021 14:07
Add Custom Meta Data to WordPress Search
/** Make custom meta data searchable */
require_once 'library/search-custom-meta-data.php';
@jonbrockett
jonbrockett / functions.php
Created June 10, 2021 14:05
Remove type= from <script> and <style>
/** Remove type= from <script> and <style> */
require_once 'library/type-remove.php';
@jonbrockett
jonbrockett / functions.php
Created June 10, 2021 14:03
Disable Default Post Type
/** Remove post content type */
require_once 'library/post-disable.php';
@jonbrockett
jonbrockett / author-enumeration-disable.php
Created June 10, 2021 13:58
Disable Enumerating Author Pages
<?php
/**
* Disables enumerating author pages
*
* This helps with security by preventing potential attackers
* from searching for login usernames by simply
* searching ?author=1, ?author=2, etc
*/
@jonbrockett
jonbrockett / author-pages-disable.php
Created June 10, 2021 13:56
Disable Author Pages
<?php
/**
* Disables the author pages
*
* This helps with security by preventing potential attackers
* from searching for login usernames
*/
function disable_author_page() {
global $wp_query;
@jonbrockett
jonbrockett / comments-remove.php
Last active June 10, 2021 13:59
Remove Wordpress Comments
<?php
// Disable support for comments and trackbacks in post types
function disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
@jonbrockett
jonbrockett / functions.php
Last active June 10, 2021 13:42
Remove User Role Editor Plugin's 'Other Roles' Field
<?php
/** Remove User Role Editor's other roles field */
add_filter( 'ure_show_additional_capabilities_section', '__return_false' );
@jonbrockett
jonbrockett / acf-googlemaps-api.php
Last active June 10, 2021 13:53
ACF Google Map API
<?php
/**
* ACF Google Map API Key
*/
function my_acf_init() {
acf_update_setting('google_api_key', '');
}
@jonbrockett
jonbrockett / acf-options.php
Last active June 10, 2021 13:53
ACF Option Pages
<?php
/**
* ACF Option Pages
*/
if( function_exists('acf_add_options_page') ) {
acf_add_options_page(array(
'page_title' => 'Site Settings',
'menu_title' => 'Site Settings',