Skip to content

Instantly share code, notes, and snippets.

View mavisland's full-sized avatar
🤯
overthinking kills your happiness

Tanju Yıldız mavisland

🤯
overthinking kills your happiness
View GitHub Profile
@mavisland
mavisland / custom_login_title.php
Last active August 29, 2015 13:56
This little snippet will change the title attribute text when you hover over the wordpress logo on the login page.
<?php
function custom_login_title() {
return get_option('blogname');
}
add_filter('login_headertitle', 'custom_login_title');
?>
@mavisland
mavisland / change_author_base.php
Created February 21, 2014 13:23
Adding this to the functions.php of your wordpress theme will change the default mysite.com/author/name to mysite.com/profile/name, however you can change this to user or anything that you would like.
<?php
add_action('init', 'change_author_base');
function change_author_base() {
global $wp_rewrite;
$author_slug = 'profile'; // change slug name
$wp_rewrite->author_base = $author_slug;
}
?>
@mavisland
mavisland / custom_login_title.php
Created February 27, 2014 16:47
This little snippet will change the title attribute text when you hover over the wordpress logo on the login page. If you want to replace the logo take a look at this snippet it will remove the wordpress logo.
<?php
function custom_login_title() {
return get_option('blogname');
}
add_filter('login_headertitle', 'custom_login_title');
?>
@mavisland
mavisland / replace_login_logo.php
Created February 27, 2014 17:00
Adding this PHP code to the functions.php of your wordpress theme will allow you to replace the default wordpress login logo.
<?php
function loginLogo() {
echo '<style type="text/css">
h1 a { background-image:url('.get_bloginfo('template_directory').'path/to/logo.gif) !important; }
</style>';
}
add_action('login_head', 'loginLogo');
?>
@mavisland
mavisland / panokml.php
Created March 1, 2014 01:46
pano.kml
<?php
function WriteHeader() {
header('Content-Type: application/vnd.google-earth.kml+xml');
header('Content-Disposition: attachment;filename="pano.kml"');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<kml xmlns=\"http://earth.google.com/kml/2.1\">\n";
echo "<Folder>\n";
echo "\t<name>pano</name>\n";
echo "\t<open>1</open>\n";
@mavisland
mavisland / wp_dont_update.php
Created March 2, 2014 02:22
How to: Disable the “please update now” message in WP dashboard. When a new version of WordPress is available, a message asking you to update your WP installation is displayed on your dashboard. Even if you better update, sometimes you may want to hide this message. Here is how to do it. To get rid of the “Please update now” message in your Word…
<?php
if ( !current_user_can( 'edit_users' ) ) {
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function( '$a', "return null;" ) );
}
?>
@mavisland
mavisland / hide_wp_version.php
Created March 6, 2014 05:17
Hiding the WP version info is a small step to prevent bots from crawling your site, it does not prevent fingerprinting, but every little bit helps. In your theme’s functions.php add the following:
<?php
// remove version info from head and feeds
function complete_version_removal() {
return '';
}
add_filter('the_generator', 'complete_version_removal');
?>
@mavisland
mavisland / disable_theme_edit.php
Created March 6, 2014 05:18
Prevent users from being able to edit or update sensitive files via the admin.
<?php
define('DISALLOW_FILE_EDIT',true); //edits
define('DISALLOW_FILE_MODS',true); //updates
?>
@mavisland
mavisland / remove_header_output.php
Created March 6, 2014 05:19
WordPress can add a lot of stuff in your header for various services, this will remove everything, but take care, it also removes some functionality ( for instance if someone is looking for your RSS feed). If you want to keep some just comment the line out.
<?php
// remove junk from head
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
@mavisland
mavisland / rewrite_theme_dir.php
Created March 6, 2014 05:23
Rewrite static theme assets and plugins directory (WordPress)
<?php
// rewrite /wp-content/themes/theme-name/css/ to /css/
// rewrite /wp-content/themes/theme-name/js/ to /js/
// rewrite /wp-content/themes/theme-name/img/ to /img/
// rewrite /wp-content/plugins/ to /plugins/
function roots_flush_rewrites() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}