Thursday, October 30, 2014

How to create an databse in wordpress plugin?

register_activation_hook( __FILE__, 'jal_install' );
register_activation_hook( __FILE__, 'jal_install_data' );


function jal_install() {
    global $wpdb;
    global $jal_db_version;

    $table_name = $wpdb->prefix . 'liveshoutbox';
   
    /*
     * We'll set the default character set and collation for this table.
     * If we don't do this, some characters could end up being converted
     * to just ?'s when saved in our table.
     */
    $charset_collate = '';

    if ( ! empty( $wpdb->charset ) ) {
      $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
    }

    if ( ! empty( $wpdb->collate ) ) {
      $charset_collate .= " COLLATE {$wpdb->collate}";
    }

    $sql = "CREATE TABLE name (
        id mediumint(9) NOT NULL AUTO_INCREMENT,
        time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
        name tinytext NOT NULL,
        text text NOT NULL,
        url varchar(55) DEFAULT '' NOT NULL,
        UNIQUE KEY id (id)
    ) $charset_collate;";

    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta( $sql );

    add_option( 'jal_db_version', $jal_db_version );
}

Wednesday, October 29, 2014

How to include your css in wordpress plugin?

// register jquery and style on initialization


add_action('init', 'register_script');
function register_script() {
    wp_register_script( 'custom_jquery', plugins_url('plug/js/jquery.js'));

    wp_register_style( 'new_style', plugins_url('plug/css/style.css'));
}

// use the registered jquery and style above
add_action('wp_enqueue_scripts', 'enqueue_style');

function enqueue_style(){
   wp_enqueue_script('custom_jquery');

   wp_enqueue_style( 'new_style' );
}





//Link your CSS

<style type="text/css">
<?php include('css/style.css'); ?>
</style>

Tuesday, October 21, 2014

Autorefresh and redirect in html

<META http-equiv="refresh" content="5;URL=www.facebook.com/crazy.snamit"

Here the content means the timesolt in seconds i.e. the time after the page will refresh and move to the url you have set.

Feel Free to comment!!!

Saturday, October 11, 2014

How to get the facebbok page badges in blogger?

To add profile badge to your blogger website you can follow these steps

1) create your profile badge on the link :-
                                       
                                        www.facebook.com/badges

2) Right click on the badge image and click "open image in new tab "

3) Copy the URL of the image

4) Go blogger, choose layout and the "add a widget"

5) Choose "image" widget

6) Write the title like "about us or facebook".

7) Paste badge image which you have copied.

8) Click save.

9) And after watching preview click "save arrangement"