Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Created October 7, 2013 06:33
Show Gist options
  • Select an option

  • Save ctrl-freak/6863361 to your computer and use it in GitHub Desktop.

Select an option

Save ctrl-freak/6863361 to your computer and use it in GitHub Desktop.
Wordpress Theme-based Camouflage
<?
/**
* 'Fix' Stylesheet URLs
*/
function intranet_short_css($args = '') {
$parts = explode('/', $args);
return '/css/'.$parts[count($parts)-1];
// return '/css/'.$args[0];
}
add_action('stylesheet_uri', 'intranet_short_css');
/**
* 'Fix' attachment links
*/
function intranet_attachment_link($url, $id) {
return str_replace('/wp-content/', '/content/', wp_get_attachment_url($id));
}
add_filter('attachment_link', 'intranet_attachment_link');
function intranet_upload_url()
{
return '/content/uploads';
}
add_filter( 'pre_option_upload_url_path', 'intranet_upload_url' );
/**
* Get rid of the Wordpress Footer
*/
function intranet_dashboard_footer () {
}
add_filter('admin_footer_text', 'intranet_dashboard_footer ');
/**
* Add custom .htaccess rules
*/
function intranet_add_rewrites($content) {
$theme_name = next(explode('/themes/', get_stylesheet_directory()));
global $wp_rewrite;
$intranet_new_non_wp_rules = array(
'css/(.*)' => 'wp-content/themes/'. $theme_name . '/css/$1',
'js/(.*)' => 'wp-content/themes/'. $theme_name . '/js/$1',
'images/(.*)' => 'wp-content/themes/'. $theme_name . '/images/$1',
'admin/(.*)' => 'wp-admin/$1',
);
$wp_rewrite->non_wp_rules += $intranet_new_non_wp_rules;
}
add_action('generate_rewrite_rules', 'intranet_add_rewrites');
/**
* Remove unnecessary actions
*/
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
// remove_action('wp_head', 'feed_links');
remove_action('wp_head', 'feed_links_extra');
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('wp_head', 'rel_canonical');
remove_action('wp_head', 'wp_generator');
/**
* Disable Wordpress Core update notification
*/
function hide_wp_update_nag() {
remove_action( 'admin_notices', 'update_nag', 3 ); //update notice at the top of the screen
remove_filter( 'update_footer', 'core_update_footer' ); //update notice in the footer
}
add_action('admin_menu','hide_wp_update_nag');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment