Skip to content

Instantly share code, notes, and snippets.

@duogeekdev
duogeekdev / my-mu-plugin.php
Created February 25, 2015 16:11
mu-plugins sample
<?php
function do_something() {
// Here we are doing something
}
function do_another_thing() {
$some_variable = do_something();
// Here we are doing another thing
}
@duogeekdev
duogeekdev / hide-admin-bar-in-wordpress.php
Created February 26, 2015 13:33
Hide admin bar in WordPress
<?php
// Simple way
add_filter( 'show_admin_bar', '__return_false' );
// Standard way
add_filter( 'show_admin_bar', 'show_admin_bar_cb' );
function show_admin_bar_cb() {
return false;
}
@duogeekdev
duogeekdev / code.php
Last active January 23, 2017 19:34
Add featured image in rss feed in a wordpress site
<?php
function add_featured_image_in_rss() {
if ( function_exists( 'get_the_image' ) && ( $featured_image = get_the_image('format=array&echo=0') ) ) {
$featured_image[0] = $featured_image['url'];
} elseif ( function_exists( 'has_post_thumbnail' ) and has_post_thumbnail() ) {
$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'post-thumbnail' );
} elseif ( function_exists( 'get_post_thumbnail_src' ) ) {
$featured_image = get_post_thumbnail_src();
@duogeekdev
duogeekdev / enable-shortcode-in-bbpress-topic-reply-based-on-capability.php
Last active August 29, 2015 14:20
How to enable shortcode in BBPress reply
<?php
add_filter('bbp_get_reply_content', 'bb_sc_render', 99, 2);
add_filter('bbp_get_topic_content', 'bb_sc_render', 99, 2);
function bb_sc_render( $content, $reply_id ) {
$reply_author = bbp_get_reply_author_id( $reply_id );
if( current_user_can( 'manage_options' ) )
<?php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'db_name_here');
/** MySQL database username */
define('DB_USER', 'db_user_name');
/** MySQL database password */
@duogeekdev
duogeekdev / Protect WordPress admin area.php
Created May 9, 2015 20:55
Protect WordPress admin area
<Files wp-login.php>
order deny,allow
Deny from all
Allow from xx.xxx.xxx.xxx
</Files>
<?php
define('AUTH_KEY', 'b],!QlPUie0ycv~R_qU~FL2o2kv7Ve}(oXs+QS$ynckMB[|C5hvCJv?Lt +)&[/4');
define('SECURE_AUTH_KEY', 'vAzf}:6fi2>Y;;euR2(O==|Ja$-$k!Eg)M vYp=-4lxA22SQVP+Rv(#CSN^W79c~');
define('LOGGED_IN_KEY', '!-*@/CC9{cK.q+a+v}bvTgb]:&,`QNx=udW/2Ah y.dJ 0[`XWV&OMc+<&p43~lQ');
define('NONCE_KEY', 'SODE d>js8Tu;^SAEQ6f8Oj|V1iz?[(N{P)II5Cb9|-}2C$-y`E*Kn8L#@O/,e{U');
define('AUTH_SALT', '3m07lkx1!-)97:LjkN~c6Q?|f>2_+=*QpyohH?`i=dY!Y)ksS0yZdp*I_+?nhUKF');
define('SECURE_AUTH_SALT', 'jfrx@D<GkJ+>:#W9q?u{3n)+A|/:`8j@4nA@V}7&-C}-k`N:.|{qq`6-s.:>k5^)');
define('LOGGED_IN_SALT', '.m~&d`Rh1v1_!g#w)]b-:-Hy/-g0ZQ0Ol$`BJ/u9w,cQ)?X TU~/v4kZD&8{;d]#');
define('NONCE_SALT', 'h0HtiN26c+FD;AMAuNn)G)!aDzA=F[m,&w)Rzb/eJ^bh!DV#W)oz[t;%=VjMq] /');
@duogeekdev
duogeekdev / prefix.php
Created May 9, 2015 21:19
Table prefix
<?php
$table_prefix = 'wp_';
@duogeekdev
duogeekdev / change-prefix.sql
Created May 9, 2015 21:23
Replace wordpress table prefix in mysql
// Do this for all existing tables
RENAME table `wp_posts` TO `me_posts`;
// The the following
UPDATE `me_usermeta` SET `meta_key` = REPLACE( `meta_key`, 'wp_', 'me_' );
UPDATE `me_options` SET `option_name` = 'me_user_roles' WHERE `option_name` = 'wp_user_roles';
@duogeekdev
duogeekdev / hide-version.php
Created May 9, 2015 21:29
Hide WP Version
<?php
remove_action('wp_head', 'wp_generator');