Skip to content

Instantly share code, notes, and snippets.

View iagdotme's full-sized avatar

Ian Anderson Gray iagdotme

View GitHub Profile
@iagdotme
iagdotme / titlechanger.html
Created May 19, 2017 09:51
Fun Title Changer
<script>
var title = document.title;
var blurMessage = [
"Please come back! :-( ",
"Don't you love me anymore? :-(",
"Fancy a cookie? ",
"I'm feeling lonely :-( ",
"I need a hug... ",
"Just checking my email...",
"Let's have a pizza party!",
@iagdotme
iagdotme / strip.php
Created September 24, 2015 16:28
Strips out junk HTML from WP posts once imported from Blogger
$args = array( 'numberposts' => '150' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
$post = get_post($recent["ID"]);
$content = apply_filters('the_content', $post->post_content);
$content = strip_tags($content,"<p><br><a><img><ul><li>");
$content = str_replace('style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"',"",$content);
$content = str_replace('style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"',"",$content);
$content = str_replace('border="0"',"",$content);
@iagdotme
iagdotme / fix-custom-post-type-active-menu.js
Created September 4, 2013 07:47
When you use a custom post type in WordPress the menu incorrectly chooses the "posts" menu as being active. This little jQuery script fixes that. The example below works for the Events custom post type for the Event Organiser plugin, but you can change it two whatever you like...
if ($("body").hasClass("single-event") || $("body").hasClass("tax-event-venue") || $("body").hasClass("tax-event-venue") || $("body").hasClass("tax-event-category"))
{
$("li.menu-news").removeClass("active");
$("li.menu-whats-on").addClass("active");
}
@iagdotme
iagdotme / convert-images-site-relative.php
Last active December 22, 2015 05:09
Convert absolute URLs in blog and page content to site relative ones. The conversion happens when you save or publish content. For example <img src="http://www.yoursite.com/image.gif" /> will be converted to <img src="/image.gif" />
<?php
/* ---------------------------------------------------------------------------------- */
/* Convert absolute URLs in content to site relative ones
Inspired by http://thisismyurl.com/6166/replace-wordpress-static-urls-dynamic-urls/
*/
function sp_clean_static_url($content) {
$thisURL = get_bloginfo('url');
$stuff = str_replace(' src=\"'.$thisURL, ' src=\"', $content );
$stuff = str_replace(' href=\"'.$thisURL, ' href=\"', $stuff );
return $stuff;
@iagdotme
iagdotme / change-login-link.php
Created September 3, 2013 09:06
Change Login link in WordPress
@iagdotme
iagdotme / change-wp-login-image.php
Created September 3, 2013 09:06
Change WP Login Image
<?php
/* ------------------------------------------------------------------ */
// Custom Login Image
// http://wp.tutsplus.com/tutorials/customizing-wordpress-for-your-clients/
function my_custom_login_logo()
{
echo '<style type="text/css"> h1 a { background-image:url(/assets/img/spLogo.png) !important; } </style>';
}
add_action('login_head', 'my_custom_login_logo');
@iagdotme
iagdotme / remove-mandrill-widget.php
Created September 3, 2013 09:05
Remove Mandrill Dashboard Widget
<?php
/* ------------------------------------------------------------------ */
// Remove Mandrill Dashboard Widget
// http://wordpress.org/support/topic/dashboard-widget?replies=3
function sp_remove_wpmandrill_dashboard() {
if ( class_exists( 'wpMandrill' ) ) {
remove_action( 'wp_dashboard_setup', array( 'wpMandrill' , 'addDashboardWidgets' ) );
}
}
add_action( 'admin_init', 'sp_remove_wpmandrill_dashboard' );
@iagdotme
iagdotme / change-howdy.php
Created September 3, 2013 09:05
Change WP Howdy Text
<?php
/* ------------------------------------------------------------------ */
// Change Howdy
// http://www.wpbeginner.com/wp-tutorials/how-to-change-the-howdy-text-in-wordpress-3-3-admin-bar/
add_action( 'admin_bar_menu', 'wp_admin_bar_my_custom_account_menu', 11 );
function wp_admin_bar_my_custom_account_menu( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );
@iagdotme
iagdotme / remove-help-screen-options.php
Created September 3, 2013 09:03
Remove help and screen context and options
<?php
// Remove help and screen context:
// Remove Help and Screen Options
// http://wordpress.stackexchange.com/questions/73561/how-to-remove-all-widgets-from-dashboard
add_filter( 'contextual_help', 'wpse_25034_remove_dashboard_help_tab', 999, 3 );
add_filter( 'screen_options_show_screen', 'wpse_25034_remove_help_tab' );
function wpse_25034_remove_dashboard_help_tab( $old_help, $screen_id, $screen )
{
if( 'dashboard' != $screen->base )
@iagdotme
iagdotme / remove-dashboard-widgets.php
Last active December 22, 2015 05:08
Remove WP Dashboard Widgets
<?php
// Remove Dashboard Widgets
// http://digwp.com/2010/10/customize-wordpress-dashboard/
function disable_default_dashboard_widgets() {
// disable default dashboard widgets
remove_meta_box('dashboard_right_now', 'dashboard', 'core');
remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');