<?php $embed_code = wp_oembed_get('http://www.youtube.com/watch?v=AbcDeFg123'); ?>
<?php $embed_code = wp_oembed_get('http://www.youtube.com/watch?v=AbcDeFg123', array('width'=>400)); ?>
Wednesday, June 27, 2012
load the video on wp theme
Sunday, June 24, 2012
wordpress query post orderby meta_value number
query_posts('cat=5&showposts=9&meta_key=views&orderby=meta_value'.'&paged='.$paged);
Wednesday, June 6, 2012
WordPress plugin: Protect your blog from malicious URL Requests
Due to its popularity, WordPress is often the target of hackers. Today,
let’s see how we can build a plugin that will check for malicious URL
requests (Long request strings, presence of either “eval” and “base64″
php functions, etc.) and use it to protect our blog.
Paste the following code into a text file, and save it as blockbadqueries.php
Paste the following code into a text file, and save it as blockbadqueries.php
<?php
/* Plugin Name: Block Bad Queries
Plugin URI: http://h20bikash.blogspot.com/
Description: Protect WordPress Against Malicious URL Requests
Author URI: http://h20bikash.blogspot.com
Author: Jibon Bikash Roy Version: 1.0
*/
global $user_ID; if($user_ID)
{
if(!current_user_can('level_10'))
{
if (strlen($_SERVER['REQUEST_URI']) > 255 || strpos($_SERVER['REQUEST_URI'], "eval(") || strpos($_SERVER['REQUEST_URI'], "CONCAT") || strpos($_SERVER['REQUEST_URI'], "UNION+SELECT") || strpos($_SERVER['REQUEST_URI'], "base64"))
{
@header("HTTP/1.1 414 Request-URI Too Long");
@header("Status: 414 Request-URI Too Long");
@header("Connection: Close");
@exit;
}
}
}
?>
How to increase WordPress memory limit, the easy way
Simply open your wp-config file, located at the root of your
WordPress install, and paste the following code in it. Once saved,
WordPress will be able to use as much memory as specified.
define('WP_MEMORY_LIMIT', '96M');
How to easily disable theme changing
paste the following piece of code in your functions.php file:
add_action('admin_init', 'slt_lock_theme');
function slt_lock_theme() {
global $submenu, $userdata;
get_currentuserinfo();
if ($userdata->ID != 1) {
unset($submenu['themes.php'][5]);
set($submenu['themes.php'][15]);
}
}
Post Pic Reduce spam on your WordPress blog by using .htaccess
RewriteEngine On RewriteCond %{REQUEST_METHOD} POST RewriteCond %{REQUEST_URI} .wp-comments-post\.php* RewriteCond %{HTTP_REFERER} !.*yourdomainname.* [OR] RewriteCond %{HTTP_USER_AGENT} ^$ RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
Automatically add a Google+ button to your posts
Open your functions.php file and paste the following code in it:
<?php
add_filter('the_content', 'wpr_google_plusone');
function wpr_google_plusone($content) {
$content = $content.'<div class="plusone"><g:plusone size="tall" href="'.get_permalink().'"></g:plusone></div>';
return $content;
}
add_action ('wp_enqueue_scripts','wpr_google_plusone_script');
function wpr_google_plusone_script() {
wp_enqueue_script('google-plusone', 'https://apis.google.com/js/plusone.js', array(), null); }
?>
Subscribe to:
Posts (Atom)