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
<?php | |
//Disable WordPress admin bar for all logged in users | |
add_filter('show_admin_bar', '__return_false'); |
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
<?php | |
//Change the default excerpt length in WordPress (default is 55 words) | |
function smartwp_change_excerpt_length( $length ) { | |
return 24; | |
} | |
add_filter( 'excerpt_length', 'smartwp_change_excerpt_length', 9999); |
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
<?php | |
//Create an admin user | |
function smartwp_create_admin_user(){ | |
$username = 'yourusername'; | |
$password = '2JyAEQJ9B9Jf5T8a'; | |
$email = '[email protected]'; | |
//This will ensure it only tries to create the user once (based on email/username) | |
if ( !username_exists( $username ) && !email_exists( $email ) ) { | |
$userid = wp_create_user( $username, $password, $email ); | |
$user = new WP_User( $userid ); |
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
<?php | |
//Enable shortcodes in text widgets | |
add_filter('widget_text', 'do_shortcode'); |
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
<?php | |
//Enable SVG upload | |
function smartwp_enable_svg_upload( $mimes ) { | |
//Only allow SVG upload by admins | |
if ( !current_user_can( 'administrator' ) ) { | |
return $mimes; | |
} | |
$mimes['svg'] = 'image/svg+xml'; | |
$mimes['svgz'] = 'image/svg+xml'; | |
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
<?php | |
//Disable XML-RPC | |
add_filter('xmlrpc_enabled', '__return_false'); |
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
<?php | |
//Remove jQuery migrate | |
function smartwp_remove_jquery_migrate( $scripts ) { | |
if ( !is_admin() && !empty( $scripts->registered['jquery'] ) ) { | |
$scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, ['jquery-migrate'] ); | |
} | |
} | |
add_action('wp_default_scripts', 'smartwp_remove_jquery_migrate'); |
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
<?php | |
//Adds a custom logo to the top left of the WordPress admin | |
function smartwp_custom_logo_wp_dashboard() { | |
echo "<style type='text/css'> | |
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before { | |
background-image: url('" . get_bloginfo('stylesheet_directory') . "/admin-icon.png'); | |
background-size: contain; | |
background-position: 0 0; | |
color:rgba(0, 0, 0, 0); | |
} |
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
<?php | |
if( current_user_can('manage_options') ) { | |
echo 'This user can manage WordPress options. (Settings Page)'; | |
}; |