Last active
October 30, 2023 06:00
-
-
Save david-rahrer/5e8fb64687cdfd62b12f5f2fc015fbc3 to your computer and use it in GitHub Desktop.
Misc WordPress Functions
This file contains 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
/* Hide contrast checker warning in admin */ | |
function custom_admin_styles() { | |
?> | |
<style type="text/css"> | |
.block-editor-contrast-checker>.components-notice { | |
margin: 0; | |
display: none; | |
} | |
</style> | |
<?php | |
} | |
add_action('admin_head', 'custom_admin_styles'); | |
/* Remove subtitle displayed in excerpt */ | |
function remove_headings_from_content($content) { | |
global $wp_current_filter; | |
// If this is the front page and the content is an excerpt, remove the headings | |
if (is_front_page() && in_array('get_the_excerpt', $wp_current_filter)) { | |
$content = preg_replace('/<h[1-6].*?>.*?<\/h[1-6]>/', '', $content); | |
} | |
return $content; | |
} | |
add_filter('the_content', 'remove_headings_from_content', 999); // High priority | |
add_filter('get_the_excerpt', 'remove_headings_from_content', 999); // High priority | |
/* Custom default avatar */ | |
add_filter("avatar_defaults", "addNewAvatar"); | |
function addNewAvatar($avatar_defaults) | |
{ | |
$myavatar = | |
"https://domain.com/wp-content/uploads/2023/07/my-default-avatar.png"; | |
$avatar_defaults[$myavatar] = "My Avatar"; | |
return $avatar_defaults; | |
} | |
/* Make admin notices removeable */ | |
add_action("admin_enqueue_scripts", "ds_admin_theme_style"); | |
add_action("login_enqueue_scripts", "ds_admin_theme_style"); | |
function ds_admin_theme_style() | |
{ | |
if (!current_user_can("manage_options")) { | |
echo "<style>.update-nag, .updated, .error, .is-dismissible { display: none; }</style>"; | |
} | |
} | |
/* Custom admin css styles */ | |
function custom_admin_styles() { | |
?> | |
<style type="text/css"> | |
/* Hide Limit Login upgrade notice */ | |
#llar-header-upgrade-message { | |
display: none; | |
} | |
/* Hide contrast checker warning in admin */ | |
.block-editor-contrast-checker>.components-notice { | |
margin: 0; | |
display: none; | |
} | |
/* Fix list display in post edit screen */ | |
.editor-styles-wrapper .block-editor-block-list__layout ul, .editor-styles-wrapper .block-editor-block-list__layout ul li, .editor-styles-wrapper .editor-block-list__layout ul, .editor-styles-wrapper .editor-block-list__layout ul li, .editor-styles-wrapper div.text ul, .editor-styles-wrapper div.text ul li { | |
list-style-position: outside !important; | |
} | |
</style> | |
<?php | |
} | |
add_action('admin_head', 'custom_admin_styles'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment