Nasrul Hazim Bin Mohamad

Migrate from WordPress to Laravel – Part 1

Dec
22

Assalamualaikum / Hi,

I’ve been using WordPress, since 2012 – 5 years, of service. I think it’s time to migrate to another platform – Laravel. I’ve been reading how murze.be did.

Basically, I got the idea how he did. But, as my sense of explorer, want to learn something new, I read few more articles, packages available out there for migrate from WordPress to Laravel.

I ended up with my own solution.

The idea – use the WordPress REST API.

Of course, I need to prepare my database schema, but I left that part later. What’s important is to grab all the contents from my blog – posts, pages, comments, media, tags, categories and users(since i’m the only author, I don’t have to fetch the user).

Here what I did:

Create the service to call WordPress REST API.

Create an artisan command to fetch all contents.

Do register the artisan command in `Kernel.php`

Then create a `wp` directory in `storage` directory.

So, what I need to do, just call php artisan import:wp http://blog.nasrulhazim.com and I will get as following, store in storage/wp in JSON Pretty Format.

And that’s it for Part 1.

Next, I need to grab all the media, download it to my storage directory.

See you guys on next post.

Training: WordPress Theme Development

Mar
17

Training by Cleanique Coders Resources (002507773-X)

WordPress Theme Development is a course for an eye opener, how easy is to develop WordPress theme. Cleanique Coders will provide every essentials aspect for WordPress Theme Development.

In this course, we are going to LEARN how to develop WordPress theme using a WordPress skeleton and HTML theme.

And we are NOT going to customize WordPress ready-made theme

Our Trainer

Fauzan Rani

We have Fauzan Rani in the house, who has experience in WordPress theme development. He is well verse in following programming languages.

HTML/CSS/Bootstrap
jQuery/AJAX
PHP/MySQL
Wordpress, Magento
Joomla, Drupal, CodeIgniter, Laravel, AngularJS

He has involved in numbers of WordPress training:

SkillsMalaysia Invite
– Facilitator in training how to manage content for SkillsMalaysia website.
– Platform : WordPress
-Venue : CIAST, Shah Alam, Selangor

AgrobIS Mini Portal
-Trainer during AgrobIS website user training.
-Venue : MARDI, Serdang, Selangor

WordPress User Training
– 2 day training for Basic Web Development Using WordPress.As a sole trainer.Volunteer for Community.
-Time : July 21-22, 2014
-Venue : KKLW, Putrajaya, Selangor

WordPress For Non-Techies
– 1 day training for Basic Web Development Using WordPress.As a co-trainer.
– Community event organized by JomWeb and MaGIC
-Time : Nov 22, 2014
-Venue : MaGIC, Cyberjaya, Selangor

** He may show best of the best of this artworks during the class!

Course Details

Date: 26 & 27 March 2016

Venue: Hour Loft Cafe, Seksyen 7, Shah Alam – http://bit.ly/hour-loft-cafe

Fee: RM 300

Syllabus Details

1) Starting the WordPress theme
– Training Overview
– Template Hierarchy/Structure
– Setup a WordPress Folder
– Activating a WordPress Theme

2) CSS and JS Integration
– Adding a CSS,JS to header and footer
– Working with CSS and JS in WordPress themes

3) Header and Footers

4) Homepage
– Sliders
– Feature post

5) Page Templates
– single post
– list page
– wordpress loop
– custom page template
– shortcodes

6) Navigation
– Adding new Menu
– Reposition and update menu
– Remove menu

7) Custom Post Type
– add new CPT
– list page
– WP_Query function
– custom field
– single page
– permalink

8) Blog
– list/index page
– adding comments

9) Gallery
– using plugin
– add, update, delete album
– add, update, delete, import photos

10) Contact Form
– Add Form using plugin
– Add Maps
– Address

11) Search
– Search Form
– Search Result Page

12) Finishing a WP theme
– add widget areas
– adding shortcodes
– Option Page
– Adding Analytics to Your Website

13) Migrate WordPress Website to Live Server
– Configure the database
– Folder permission
– Security options

 

REGISTER NOW AT http://goo.gl/forms/CUljXIeEPy

Training: WordPress for Beginners

Dec
31

Location: Medina Arabic, Seksyen 9, Bangi (Above Melaka Kitchen Restaurant)

Date: 10th January 2016

Available Seats: 28 seats

Brochure:

Training-WordPress-Basic-NHM-20151231

 

Registration closed!

InsyAllah before end of January 2016 will be another free training for ‘WordPress For Beginners’! Stay tuned!

WordPress: Using Bootstrap In WordPress Admin

Dec
31

First of all – you need LESS compiler – for Windows, I use winless – please download & install it.

Next, grab the Bootstrap ( I use version 3.3.4, newer version broken when compiling the LESS ).

Extract the Bootstrap to a folder and then create a LESS file called bootstrap.less and paste in the following code:

.bs-wrapper {
   @import (less) url('bootstrap.css');
}

Now open up winless, and add folder where your Bootstrap CSS directory, and then on file bootstrap.less output file, you may name it as wp-admin-bootstrap.css.

Winless - Choosing the output

Winless – Choosing the output

Next, you just need to use wp_enqueue_style() to include the generated CSS – wp-admin-bootstrap.css

Y2016

Dec
18

Year 2016, InsyaAllah, next year to be a year of sharing knowledge of what I’ve learnt so far. Following are the trainings I would like to conduct:

1. Mobile Apps Development with jQuery Mobile
2. Mobile Apps Development with Intel XDK (incoming)
3. API Development with Slim Framework (incoming)
4. PHP Basic / Advanced
5. Web Development with CakePHP 3 (incoming)
6. Web Development with Laravel 5 (incoming)
7. Web Development with Yii Framework 2 (incoming)
8. WordPress for Developers – Beginner Level
9. WordPress Theme Development
10. WordPress Plugin Development

Those status incoming, it’s the one I’m preparing the syllabus & materials, summarizing the process, and so on. Hope more things can be share other than mentioned above such as the tools I’ve used along the process of the development – Sublime Text 3, SQLYog, Putty, Git and so on

WordPress: Theme Development

Dec
17

I’ve been learning WordPress Development recently – both plugins & themes. Until today got a chance to summarize the WordPress Theme Development.

You have two options when developing WordPress Theme – either from scratch or extend(using child theme) the existing theme. Below is the illustration that I have on choosing the theme development method.

WordPress Theme Development Options

WordPress Theme Development Options

I’ve added some other requirement during the development process including how you want to design your layout, icons, colors. These are essentials things that you need to know / have.

Hope these two options could speed up your development process and of course these options for developers and not for non-developers (which I suggest to buy a 3rd Party Plugin for drag-and-drop theme development).

And of course the text editor – my favourite is Sublime Text 3.

WordPress: Migration / Deployment

Dec
15

During my first time using WordPress, migrate from one domain to another, it’s a headache for me. Too many steps need to take care off.

Until recently, working in a new company (Rocket Web Sdn Bhd), learning new things using WordPress – hardening, migration, tips & tricks, paid & free plugins.

You may read the summary of deployment(to few servers) from my previous.

The point of this post to highlight the plugins required for deployment/migration.

Duplicator

Duplicator

Create a backup of your WordPress files and database. Duplicate and move an entire site from one location to another in a few steps.

Using Duplicator helps a lot with setting up dumping database and renaming the domain name. Save a lot of your time. You just need to create MySQL user, password and database manually. That’s all you need. I bet there’s much better plugin, but this one work fine for my current tasks.

Better Search and Replace

Better Search and Replace

A small plugin for running a search/replace on your WordPress database.

I use this plugin after the deployment – where I need to rename all the old domain name or any keyword I want to updates. You can select which tables you want to search the keyword and making update. This plugin provide `Run as Dry` – no changes being made unless you un-check this option.

So, these two plugins are useful and easy to use. Hopes will help others doing migration from one server to another.

 

 

WordPress: Custom Post Type Slider

Nov
29

Getting Light Slider

Download Light Slider here.

Then extract the content, copy the img, js and css in src directory into your WordPress Plugin folder.

Include Light Slider JavaScript & CSS

wp_enqueue_style( 'light-slider-css', plugin_dir_url( __FILE__ ) . 'css/lightslider.css', array(), $this->version, 'all' );
wp_enqueue_script( 'light-slider-js', plugin_dir_url( __FILE__ ) . 'js/lightslider.js', array( 'jquery' ), $this->version, false );

Add Some Padding to the item and set link to white

<style type="text/css">
  .lslide {
    min-height: 250px !important;
    padding-left: 50px !important;
    padding-right: 50px !important;
    padding-top: 25px !important;
    padding-bottom: 25px !important;
  }
  .lSSlideOuter .lSPager.lSpg > li a {
    background-color: white !important;
  }
</style>

Getting posts

$posts = wp_get_recent_posts( ['numberposts' => 5,'category_name' => 'Announcement'], OBJECT );

The View Part

<?php $index = 0; ?>

<ul id="light-slider">
  <?php foreach ($posts as $key => $value): ?>
    <li>
      <h4 style="color:white !important;font-style: bold !important;"><?= $value->post_title; ?></h4>
      <p style="color:white !important;"><?= strip_tags($value->post_content, ['p','span']); ?></p>
      <a href="<?= $value->guid; ?>" style="color:white !important;text-decoration: underline;float: right;"><?php echo (get_locale() != 'ms_MY') ? 'Read More':'Baca Lagi'; ?></a>
    </li>
    <?php $index++; ?>
  <?php endforeach ?>
</ul>

Final Part: initialize the Light Slider

jQuery(document).ready(function($) {
    jQuery("#light-slider").lightSlider({auto:true,item:1,speed:1000});
});

Result

lkim-slider

lkim-slider

WordPress Post Slider available here

WPML: Custom Language Switcher

Oct
06

Quick reference on how to add custom language switcher in WPML


if(!function_exists('icl_post_languages')) {
	function icl_post_languages(){
	  $languages = icl_get_languages('skip_missing=1');
          echo '<pre>';
          var_dump($languages);
          echo '</pre>';
	  if(1 < count($languages)){
              // iterate through the list to create your custom language switcher
	  }
	}
}
/*
array(2) 
{ 
	["ms"]=> array(12) 
	{ 
		["code"]=> string(2) "ms" 
		["id"]=> string(2) "64" 
		["native_name"]=> string(6) "Melayu" 
		["major"]=> string(1) "0" 
		["active"]=> string(1) "1" 
		["default_locale"]=> string(5) "ms_MY" 
		["encode_url"]=> string(1) "0" 
		["tag"]=> string(5) "ms-MY" 
		["translated_name"]=> string(6) "Melayu" 
		["url"]=> string(26) "http://localhost/" 
		["country_flag_url"]=> string(88) "http://localhost/wp-content/plugins/sitepress-multilingual-cms/res/flags/ms.png" 
		["language_code"]=> string(2) "ms" 
	} 
	["en"]=> array(12) 
	{ 
		["code"]=> string(2) "en" 
		["id"]=> string(1) "1" 
		["native_name"]=> string(7) "English" 
		["major"]=> string(1) "1" 
		["active"]=> int(0) 
		["default_locale"]=> string(5) "en_US" 
		["encode_url"]=> string(1) "0" 
		["tag"]=> string(5) "en-US" 
		["translated_name"]=> string(7) "English" 
		["url"]=> string(29) "http://localhost/en/" 
		["country_flag_url"]=> string(88) "http://localhost/wp-content/plugins/sitepress-multilingual-cms/res/flags/en.png" 
		["language_code"]=> string(2) "en" 
	} 
}
*/

Reference: Custom Language Switcher

WordPress: Message Class

Sep
20

A simple class for displaying admin messages – error, notice and successful.


class Message {
	public static function error($message) {
		return '<div class="error"><p>'.$message.'</p></div>';
	}

	public static function success($message) {
		return '<div class="updated"><p>'.$message.'</p></div>';
	}

	public static function notice($message) {
		return '<div class="update-nag">'.$message.'</div>';
	}
}

/** 
 * Usage
 **/
Message::error('Hutang 2.6Bil! Bayar!');
Message::notice('Kacing! (PM: eh..cam bunyi duit masuk je');
Message::success('PM: Hasil derma orang bagi. Syukur lahhhh..boleh byr hutang');
wp-admin-message-error

wp-admin-message-error

wp-admin-message-notice

wp-admin-message-notice

wp-admin-message-success

wp-admin-message-success