Skip to content

Instantly share code, notes, and snippets.

@dospuntocero
Last active February 11, 2018 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dospuntocero/261a8df8182e45b962c4130933bae418 to your computer and use it in GitHub Desktop.
Save dospuntocero/261a8df8182e45b962c4130933bae418 to your computer and use it in GitHub Desktop.
wordpress MEGALITE cms. for clients that don't need anything but blog or pages and you don't want them to mess things around. i'm using https://nestedpages.com/ for controlling the page tree. also added a small css for removing the regular editor links. added 2 useful functions: svg capability for uploading and removing thumbnail hardcode dimens…
<?php
/*
Plugin Name: dospuntocero
Plugin URI: -
Description: lite CMS
Author: Francisco Arenas
Version: 1
Author URI: http://dospuntocero.cl
*/
if ( ! function_exists('dospuntocero_cms') ) {
function dospuntocero_cms() {
remove_action( 'welcome_panel' , 'wp_welcome_panel' );
remove_action( 'welcome_panel' , 'wp_welcome_panel' );
//removing hardcoded values on images
function remove_thumbnail_dimensions( $html , $post_id , $post_image_id ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/' , "" , $html );
return $html;
}
add_filter( 'post_thumbnail_html' , 'remove_thumbnail_dimensions' , 10 , 3 );
function my_myme_types( $mime_types ) {
$mime_types[ 'svg' ] = 'image/svg+xml';
return $mime_types;
}
add_filter( 'upload_mimes' , 'my_myme_types' , 1 , 1 );
function annointed_admin_bar_remove() {
global $wp_admin_bar;
/* Remove their stuff */
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('comments');
$wp_admin_bar->remove_menu('new-content');
}
function remove_help_tabs() {
$screen = get_current_screen();
$screen->remove_help_tabs();
}
add_action('admin_head', 'remove_help_tabs');
add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);
function remove_menus(){
// provide a list of usernames who can edit custom field definitions here
$admins = array(
'admin','fran'
);
// get the current user
$current_user = wp_get_current_user();
// match and remove if needed
if( !in_array( $current_user->user_login, $admins ) )
{
define( 'ACF_LITE', true );
remove_menu_page('edit.php?post_type=acf');
remove_menu_page( 'index.php' ); //Dashboard
// remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings
remove_menu_page( 'wpcf7' ); //contact form
remove_menu_page( 'edit.php?post_type=acf-field-group' ); //ACF
$screen = get_current_screen();
if( $screen->base == 'dashboard' ) {
wp_redirect( admin_url( 'admin.php?page=nestedpages' ) );
}
}
}
add_action('admin_menu', 'remove_menus' );
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
function customCSS() {
echo '<style>
#toplevel_page_nestedpages ul li:last-child,.nestedpages-tools ul li:last-child{
display: none;
}
</style>';
}
add_action('admin_head', 'customCSS');
function change_footer_admin () {return '&nbsp;';}
add_filter('admin_footer_text', 'change_footer_admin', 9999);
function change_footer_version() {return ' ';}
//add_filter('update_footer', 'change_footer_version', 9999);
function my_login_logo() { ?>
<style type="text/css">
#login h1 a, .login h1 a {
display: none;
}
#loginform{
border-radius: 12px;
}
</style>
<?php }
add_action( 'login_enqueue_scripts', 'my_login_logo' );
}
dospuntocero_cms();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment