Skip to content

Instantly share code, notes, and snippets.

@graphikuz
graphikuz / gist:78eb54f3f57db8ded044
Created August 11, 2014 11:48
Wordpress: MySQL: Change URL in Content
# Change URL in Content
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
@graphikuz
graphikuz / gist:8fae549e7d82b28e0c6f
Created August 11, 2014 11:47
Wordpress: MySQL: Change GUID
# Change GUID
UPDATE wp_posts SET guid = REPLACE (guid, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
@graphikuz
graphikuz / gist:849045ce3919d94c49fa
Created August 11, 2014 11:47
Wordpress: MySQL: Change Siteurl & Homeurl
# Change Siteurl & Homeurl
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';
@graphikuz
graphikuz / gist:20a127576d9a5d5fc612
Created August 11, 2014 11:46
Wordpress: MySQL: Reset Password
# Reset Password
UPDATE wp_users SET user_pass = MD5( 'new_password' ) WHERE user_login = 'your-username';
@graphikuz
graphikuz / gist:f7fb9173b6d01400deb7
Created August 11, 2014 11:45
Wordpress: MySQL: Change Default "Admin" Username
# Change Default "Admin" Username
UPDATE wp_users SET user_login = 'Your New Username' WHERE user_login = 'Admin';
@graphikuz
graphikuz / gist:e721cd64ca829ebd666b
Created August 11, 2014 11:38
Wordpress: Enable debug mode
<?php
/**
* Enable debug mode
*
* Usage:
* http://example.com?debug=debug
*/
if ( isset($_GET['debug']) && $_GET['debug'] == 'debug')
define('WP_DEBUG', true);
?>
@graphikuz
graphikuz / gist:aeeaa854e9bd5862904d
Created August 11, 2014 11:36
Wordpress: Set default editor
<?php
/**
* Set default editor
*/
# This sets the Visual Editor as default #
add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
# This sets the HTML Editor as default #
add_filter( 'wp_default_editor', create_function('', 'return "html";') );
?>
@graphikuz
graphikuz / gist:de05d06008d2dfa2a660
Created August 11, 2014 11:32
Wordpress: Detect Browser
<?php
/**
* Detect Browser
* Add a class to BODY tag
*/
add_filter('body_class','browser_body_class');
function browser_body_class($classes) {
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
if($is_lynx) $classes[] = 'lynx';
elseif($is_gecko) $classes[] = 'gecko';
@graphikuz
graphikuz / gist:2f81688a49a9d7908a2e
Created August 11, 2014 11:29
Wordpress: Register a plugin
<?php
/*
Plugin Name: Plugin Name
Plugin URI: http://example.com/the-plugin
Description: A brief description of the Plugin.
Version: 1.0
Author: Your name
Author URI: http://example.com
License: GPL2?
*/
@graphikuz
graphikuz / gist:c650cea3723fdbbe8b95
Created August 11, 2014 11:28
Wordpress: Check if user is logged in
<?php
/**
* Check if user is logged in
*/
if ( is_user_logged_in() ) {
echo 'Welcome, registered user!';
} else {
echo 'Welcome, visitor!';
};
?>