This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Display comments in admin to authors own posts only | |
function wps_get_comment_list_by_user($clauses) { | |
if (is_admin()) { | |
global $user_ID, $wpdb; | |
$clauses['join'] = ", wp_posts"; | |
$clauses['where'] .= " AND wp_posts.post_author = ". $user_ID ." AND wp_comments.comment_post_ID = wp_posts.ID"; | |
}; | |
return $clauses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Adjust default sizes for embedded content | |
function wps_embed_size($embed_size){ | |
if(is_single()){ | |
$embed_size['height'] = 240; | |
$embed_size['width'] = 380; | |
} | |
return $embed_size; | |
} | |
add_filter('embed_defaults', 'wps_embed_size'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Host: smtpout.secureserver.net | |
Port: 465 | |
Username: your email address | |
Password: your_secretPassword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
WordPress customize upload foleder path | |
Create a Directory within Uploads folder | |
*/ | |
function mw_activate() { | |
$upload = wp_upload_dir(); | |
$upload_dir = $upload['basedir']; | |
$upload_dir = $upload_dir . '/my_plugin_files'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Both theme and plugin developers might need to check if their code is going to be run in the Loop or not. As the name suggests, the in_the_loop() function provides the answer easily. | |
Usage | |
<?php | |
if( in_the_loop() ) { | |
// do something loop-related | |
} else { | |
// don't do anything or display some kind of error/warning | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ever needed to include a variable, inline style for your plugin or theme? Of course you did! Enqueueing external CSS files with WordPress' wp_enqueue_style() function (and its companions) is pretty slick but it lacks the funcionality to include inline CSS styles. | |
Well, at least that's what I thought before coming across the wp_add_inline_style() function. | |
Usage | |
<?php | |
$custom_style_file = get_template_directory_uri() . '/css/custom_style.css'; | |
function custom_styles() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Like strip_shortcodes(), wp_is_mobile() is also easy to explain: It allows you to detect users that are using mobile devices to connect to your website. | |
Usage | |
<?php | |
if( wp_is_mobile() ) { | |
// echo the "HAVE YOU TRIED OUR AWESOME MOBILE APP?" banner | |
} else { | |
// don't echo the banner | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There might be some cases that you need the shortcodes of the text to be omitted: You may use part of the content for a "Next Post" preview, you may have switched to a new theme and don't want to display texts of shortcodes that are not run anymore, and so on. | |
When that time comes, strip_shortcodes() is your friend. | |
Usage | |
There's a very good example in the Codex. Let's say that you need to strip shortcodes in the homepage but let them run in other content pages. | |
Here's how you should use the strip_shortcodes() function: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Have you ever needed to share an email address in your WordPress blog or website? | |
You most likely have, and if you ever cared about not getting caught by spam robots which crawl the web for email addresses, telephone numbers and things like that, you've searched for a solution to hide the email addresses from those tiny evil robots. | |
I know I have, and little did I know, there was already a core WordPress function for it: antispambot(). | |
Usage | |
The usage of the function is pretty simple: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<li><a href="http://www.acunetix.com/websitesecurity/wordpress-security-plugin/" target="_blank">Acunetix Wordpress Security Plugin</a>. Check <a href="http://wordpress.org/support/plugin/wp-security-scan" target="_blank">support forum</a> for any issues.</li> | |
<li><a href="http://wordpress.org/plugins/sucuri-scanner/" target="_blank">Sucuri Security Malware Scanner</a>. Check <a href="http://wordpress.org/support/plugin/sucuri-scanner" target="_blank">support forum</a> for any issues.</li> | |
<li><a href="http://wordpress.org/plugins/akismet/" target="_blank">Akismet</a>. Check <a href="http://wordpress.org/support/plugin/akismet" target="_blank">support forum</a> for any issues.</li> | |
<li><a href="http://www.seoegghead.com/software/wordpress-firewall.seo" target="_blank">Wordpress Firewall</a></li> | |
<li><a href="http://wordpress.org/plugins/crayon-syntax-highlighter/" target="_blank">Crayon Syntax Highlighter</a>. Check <a href="http://wordpress.org/support/plugin/crayon-syntax-highlighter" target= |