Saturday, October 19, 2013

How to migrate Wordpress Site from Hostgator to Bluehost manually?

What if the free migrating plugins you are using do not work at all,  or if all else fails, then your last resort would be migrating sites manually. Migrating WordPress site by hand requires a lot of effort and time, but for me this is the safest way to retrieve all your files without experiencing lots of problems. 

I'm not a programmer nor expert in Cpanel, but once you dedicate your time in "learning by doing", all other difficult things become easy. I'll share with you how I migrate WordPress site with less headaches.


Here's how to get started.

From Hostgator:

Step 1: Back up all your WordPress files which is located in the home or root folder of your WordPress installation. Select all files, then click compressed icon. Choose zip archived, then click compressed tab.


Read More

How to Change DNS at GoDaddy?

Step 1: Login to your account with your GoDaddy username and password.

Step 2. Click "My Account Tab". Below you can see domains, web hosting, email, etc, then click Launch Tab found at the right of domain.


Read More

Friday, October 18, 2013

Setting Up Rel="Author" Tag in Blogger

Do you want to appear your photo in Google Search Results like I do?  (see photo below.) If yes, embed now an HTML markup code known as rel="author" to your blog in order to claim your articles as yours.   When set up correctly, a head shot will appear in search results that will make you stand out than the rest. Authorship adds credibility to your blog, thus it will improve readership. Here's an easy tutorial how to link your Google Plus profile to your blog.



Google Plus

Step 1. Create an account in Google Plus. 
Step 2: Fill in necessary information. Be sure to upload the best picture of yours. This will appear in Google search results
Step 3: Go to Google profile >> navigate About menu on top >> then scroll down>> click the Contributor To section on the right.

Read More

Thursday, October 17, 2013

Create, Retrieve, Update, Delate Page

Create Page

	function wpcreatepage(){
		$title = $_REQUEST['title'];
		$content = $_REQUEST['content'];
		$userid = $_REQUEST['userid'];
		$my_post = array(
			  'post_title'    => wp_strip_all_tags($title ),
			  'post_content'  => $content,
			  'post_status'   => 'publish',
			  'post_author'   => $userid,
			  'post_type'     => 'page',
		);
		$pid = wp_insert_post( $my_post );
		echo $pid;
		die();
	}

Retrieve Page

	function wpeditpage(){
		$pageid = $_REQUEST['pageid'];
		$post = get_post( $pageid, ARRAY_A);
		echo json_encode($post);
		die();
	}

Update Page

	function wpupdatepage(){
		$title = $_REQUEST['title'];
		$content = $_REQUEST['content'];
		$pageid = $_REQUEST['pageid'];
	
		$my_post = array();
		$my_post['ID'] = $pageid;
		$my_post['post_title'] = wp_strip_all_tags($title);
		$my_post['post_content'] = $content;
	
		// Update the post into the database
		wp_update_post( $my_post );
		die();
	}

Delete Page

	function wpdeletepage(){
		$pageids = rawurldecode($_REQUEST['pageids']);
		$pageid = rawurldecode($_REQUEST['pageid']);
		
		if(!empty($pageid)){
			echo wp_delete_post($pageid);
		}else if(!empty($pageids)){
			$pageids = explode(",",$pageids);
			foreach($pageids as $id){
				echo wp_delete_post($id);
			}
		}
		
		die(); 
	}

Read More

Create / Retrieve / Update / Delete POST

Create Post

	function wpcreatepost(){
		$title = $_REQUEST['title'];
		$content = $_REQUEST['content'];
		$userid = $_REQUEST['userid'];
		$my_post = array(
			  'post_title'    => wp_strip_all_tags($title ),
			  'post_content'  => $content,
			  'post_status'   => 'publish',
			  'post_author'   => $userid,
			  'post_type'     => 'post',
		);
		$pid = wp_insert_post( $my_post );
		echo $pid;
		die();
	} 
 
 

Retrieve Post

function wpeditpost(){ $postid = $_REQUEST['postid']; $post = get_post( $postid, ARRAY_A); echo json_encode($post); die(); }


Update Post

	function wpupdatepost(){
		$title = $_REQUEST['title'];
		$content = $_REQUEST['content'];
		$postid = $_REQUEST['postid'];
	
		$my_post = array();
		$my_post['ID'] = $postid;
		$my_post['post_title'] = wp_strip_all_tags($title);
		$my_post['post_content'] = $content;
	
		// Update the post into the database
		wp_update_post( $my_post );
		die();
	} 
 

Delete Post

function wpdeletepost(){ $postid = rawurldecode($_REQUEST['postid']); $postids = rawurldecode($_REQUEST['postids']); if(!empty($postid)){ echo wp_delete_post($postid); }else if(!empty($postids)){ $postids = explode(",",$postids); foreach($postids as $id){ echo wp_delete_post($id); } } die(); }
 

 
Read More

Update User Info

                $user_data = array(
		'ID' => $userid,
		'user_login' => $loginName,
		'first_name' => $firstName,
		'last_name' => $lastName,
		'user_email' => $email
	       );
 
	        echo wp_update_user( $user_data ) ;
Read More

Create WP User and send email notification

function wpcreateuser(){

		$loginName = rawurldecode($_REQUEST['login']);
		$firstName = rawurldecode($_REQUEST['firstname']);
		$lastName = rawurldecode($_REQUEST['lastname']);
		$email = rawurldecode($_REQUEST['email']);
		
		$user_data = array(
			'ID' => '',
			'user_pass' => wp_generate_password(),
			'user_login' => $loginName,
			'display_name' => $loginName,
			'first_name' => $firstName,
			'last_name' => $lastName,
			'user_email' => $email,
			'role' => get_option('default_role') // Use default role or another role, e.g. 'editor'
		);
		
		$tempPass = genTempPassword(8);
		$user_id = wp_insert_user( $user_data );
		wp_set_password($tempPass, $user_id);
		
		$headers = "From: Wordpress <".get_bloginfo('admin_email').">\r\n".'X-Mailer: PHP/' . phpversion();
		$subject = "[".get_bloginfo('name')."] Your username and password";
		$siteurl = get_bloginfo('siteurl')."/wp-login.php";
		$msg = wordwrap("Username: ".$loginName." \r\n "."Password: ".$tempPass." \r\n ".$siteurl);
		
		wp_mail($email, $subject, $msg, $headers);
		die();
	}
	
	function genTempPassword ($length = 8)
	{
		// given a string length, returns a random password of that length
		$password = "";
		// define possible characters
		$possible = "0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		$i = 0;
		// add random characters to $password until $length is reached
		while ($i < $length) {
			// pick a random character from the possible ones
			$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
			// we don't want this character if it's already in the password
			if (!strstr($password, $char)) {
				$password .= $char;
				$i++;
			}
		}
		return $password;
	}
Read More

Get WP user and Delete wp user

Get WP user

	$blogusers = get_users('orderby=display_name&order=ASC');
	$users = array();
	foreach($blogusers as $user){
		$users[] = array(
			"ID"=>$user->ID,
			"user_login"=>$user->user_login,
			//"user_pass"=>$user->user_pass,
			"user_nicename"=>$user->user_nicename,
			"user_email"=>$user->user_email,
			"user_registered"=>$user->user_registered,
			"display_name"=>$user->display_name
		);
	}
	echo json_encode($users);
 
 

Delete wp user

echo wp_delete_user($id);

 

 
Read More

Update WP Version

<?php
 function wpupgrade(){
  $reinstall = false;
  global $wp_filesystem;
 
  if ( $reinstall )
   $url = 'update-core.php?action=do-core-reinstall';
  else
   $url = 'update-core.php?action=do-core-upgrade';
  $url = wp_nonce_url($url, 'upgrade-core');
  if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) )
   return;
 
  //$version = isset( $_POST['version'] )? $_POST['version'] : false;
  $version = '3.5.1';
  $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
  $update = find_core_update( $version, $locale );
  if ( !$update )
   return;
 
  if ( ! WP_Filesystem($credentials, ABSPATH) ) {
   request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again
   return;
  }
 ?>
  <div class="wrap">
  <?php screen_icon('tools'); ?>
  <h2> <?php _e('Update WordPress'); ?></h2>
 <?php
  if ( $wp_filesystem->errors->get_error_code() ) {
   foreach ( $wp_filesystem->errors->get_error_messages() as $message )
    show_message($message);
   echo '</div>';
   return;
  }
 
  if ( $reinstall )
   $update->response = 'reinstall';
 
  $result = wp_update_core($update, 'show_message');
 
  if ( is_wp_error($result) ) {
   show_message($result);
   if ('up_to_date' != $result->get_error_code() )
    show_message( __('Installation Failed') );
   echo '</div>';
   return;
  }
 
  show_message( __('WordPress updated successfully') );
  show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a target="_blank" href="%2$s">Learn more</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
  ?>
  </div>
 }
Read More

Get latest wp version

 $request = wp_remote_post( 'http://api.wordpress.org/core/version-check/1.6/', array('body' => array('action' => 'version')));
 
 if (!is_wp_error($request) || wp_remote_retrieve_response_code($request) === 200) {  
  echo json_encode(unserialize($request['body']));  
 }
 
 
 
 

get wordpress version

global $wp_version; echo $wp_version;
 
Read More
Powered By Blogger · Designed By Seo Blogger Templates