phprockers-logo

Simple way to create a widget in wordpress

1 comments
First Step: Goto this directory-localhost/yourwordpressname/wp-content/plugins.
Second Step: Create a folder for creating a widget in above directory.

Third Step: Inside the folder, Create a .php file and copy below codes.
Fourth Step: Goto wordpress administrator, see left sidebar, click plugins and activate your plugin.
Fifth Step: Finally Goto wordpress widget  and find the your widget name here. Then you have to use, where you want in widgetized area in wordpress.

Guides for creating a complete widgets in WordPress 3.3

0 comments
The first thing we have to do is load our widget when necessary. WordPress provides the widgets_init action hook that will allow us to do this. In WordPress 3.1, this action hook is fired right after the default WordPress widgets have been registered.

Note: This can be used to all wordpress versions


<?php

/**
* Plugin Name: Example Widget
* Plugin URI: http://phprockers.blogspot.com/p/wordpress.html
* Description: A widget that serves as an example for developing more advanced widgets.
* Version: 1.0
* Author: Ramakrishnan V.
* Author URI: http://phprockers.blogspot.com

*
*/

Uploading Files with PHP

1 comments
This script will allow you to upload files from your browser to your hosting, using PHP. The first thing we need to do is create an HTML form that allows people to choose the file they want to upload. 

<form enctype="multipart/form-data" action="upload.php" method="POST"> 
<lable> Please choose a file: </lable>
<input name="uploaded" type="file" /><br /> 
<input type="submit" value="Upload" /> 
</form> 
 
This form sends data to the file "upload.php". Then we can easily get the uploaded information using file function in upload.php.

How To Optimize Your Site With GZIP Compression

0 comments
Compression is a simple, the effective way to save bandwidth and speed up your sites. I hesitated when recommending gzip compression when speeding up your javascript because of problems in older browsers.

Most of my traffic comes from the modern browsers, and quite frankly, most of my users are fairly technology-savvy. I don't want to slow everyone else down because somebody is the chugging along on IE on Windows Operating Systems. Google and Yahoo browsers are using gzip compression.

Before we start, I should explain what content encoding is. When you request a file like http://www.gmail.com/index.html, your browser talks to a web server. 


How to get URL of first image in a post

1 comments

We can easily grab the first image from the post, and display it. 


// Get URL of first image in a post
function get_first_image() {
         global $post;
         $first_img = ''; 
         ob_start();
         ob_end_clean();
         $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
         $first_img = $matches [1] [0];
         if(empty($first_img)){
                  $first_image = "/images/default.jpg";
        }
        return $first_image;
}


<?php echo catch_that_image() ?>

How to write a WordPress Plugin?

0 comments
Before we move on coding a plugin, please make sure you remember the following coding practices.

1. Always you chose a unique name to your plugin so that it doesnt collide with names used in other plugins.

2. Make sure you comment wherever and whenever necessary in the code.

3. You will to test the plugin in your localhost (using xampp) along with latest version of wordpress.
Plugin Files & Names

What is mean by Wordpress?

0 comments
WordPress is not just a blogging platform and it is such a powerful CMS with unlimited capabilities, besides having a huge user base. Almost anything can be scripted with wordpress.