Nasrul Hazim Bin Mohamad

WordPress: Requirement for Deployment to Production


WordPress Plugins

  1. DuplicatorCreate a backup of your WordPress files and database. Duplicate and move an entire site from one location to another in a few steps. Create a full snapshot of your site at any point in time.
  2. Better Search and Replace A small plugin for running a search/replace on your WordPress database.

Linux Commands

# Find something in a file
# This will be useful when you need to find hardcoded IP/domain in files
grep -rnw '/path/to/somewhere/' -e "pattern"

Recommended requirement for WordPress is PHP 5.6, MySQL 5.5 and make sure to enable Apache mod_rewrite module.

Apache: Required Modules

  • mod_authz_host
  • log_config_module
  • expires_module
  • deflate_module
  • headers_module
  • setenvif_module
  • mime_module
  • autoindex_module
  • dir_module
  • alias_module
  • rewrite_module
  • negotiation_module
  • ssl_module
  • php5_module

PHP: Required Modules

  • cURL
  • Date/Time
  • DOM
  • POSIX Regex
  • Filter
  • FTP
  • GD
  • Hash
  • Iconv
  • JSON
  • libxml
  • Multibyte String
  • MySQL
  • OpenSSL
  • PCRE
  • SimpleXML
  • Sockets
  • SPL
  • Tokenizer
  • XML Parser
  • XMLReader
  • Zlib
  • Mcrypt

Increase Upload Limit & Post Limit in .htaccess

# Set Upload Limit
php_value post_max_size 25M
php_value memory_limit 128M
php_value upload_max_filesize 25M

# Suhosin - if Suhosin installed
php_value 20000
php_value suhosin.request.max_vars 20000


# Changing directory permissions recursively
find /var/www/html -type d -exec chmod 755 {} \;

# Changing file permissions recursively
find /var/www/html -type f -exec chmod 644 {} \;


# Prevent direct access to wp-login.php
<Files wp-login.php>
order deny,allow
Deny from all

# Prevent people from browsing the content of directories
Options All -Indexes

# Protect the .htaccess file itself
<Files .htaccess>
order allow,deny
deny from all

# Securing wp-includes
# Block the include-only files. Place this outside of WordPress block to prevent overwrite
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]

# Securing wp-config.php
<files wp-config.php>
order allow,deny
deny from all


# wp-config.php
define('DISALLOW_FILE_EDIT', true);

# Turn Off PHP Error Reporting
@ini_set(‘display_errors’, 0);

WordPress Plugin – All In One WP Security & Firewall


  1. WordPress Requirement
  2. WordPress Hardening
  3. Keeping WordPress Secure the Ultimate Guide
  4. What are PHP Extensions and Libraries WordPress Needs
  5. PHP Security Best Practice

WordPress: Custom Post Type Slider


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;

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): ?>
      <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>
    <?php $index++; ?>
  <?php endforeach ?>

Final Part: initialize the Light Slider

jQuery(document).ready(function($) {




WordPress Post Slider available here

CSS: Custom Scrollbar



/* Let's get this party started */
::-webkit-scrollbar {
    width: 9px;
/* Track */
::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); 
    -webkit-border-radius: 10px;
    border-radius: 10px;
/* Handle */
::-webkit-scrollbar-thumb {
    -webkit-border-radius: 7px;
    border-radius: 7px;
    background: rgba(242,242,242,0.3); 
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
    cursor: pointer !important;
::-webkit-scrollbar-thumb:window-inactive {
  background: rgba(242,242,242,0.3); 
::-webkit-scrollbar-thumb:hover {
  background: rgba(242,242,242,0.5); 

Reference: Custom Scrollbar

JavaScript: JSON


JSON, number of references for beginners, shared by one of my student during training in INTIM, Kemaman.



PHP: Detect If It’s IE


IE 11

IE 11

if  (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false)) {

Learn New Programming Language

Learn Programming Language

Learn Programming Language

When someone asking about .NET, and it’s difficulty to learn..below are my comments..

start to learn new programming language, usually what i did:

1) Get right tools – usually this one no problem, and i’m using Sublime Text 3, for any codings.

2) Environment – based on your development machine (in this case is Windows), setup what’s the essential to run the .NET, identify first, then install it. Usually it’s a straight forward process

3) Programming Level 1 – Learn the syntax – conditional statement, loop, etc; variables – how to define a variable, variables scope, functions – built-in or user-defined. Some extra part if the programming language has the interaction with files & form, etc.

4) Programming Level 2 – This level you will start to keep your codes as simple as possible and reusable. You will learn how to deal with Object-Oriented programming if any(usually any programming language have the OOP). Keep in mind – Don’t Repeat Yourself in this stage – which means, you don’t need to write the same Uploading codes for photo gallery and user profile photo, just create one class, the pass respective arguments to identify what kind of Upload you’re handling.

5) Programming Level 3 – Now you’re familiar with Level 1 & 2. Should be easy enough to work with framework. Framework provide many features that ready for your system development. Some terms you might need to remember – MVC(model, view, controller), route, class, object. Framework also provide numbers of utilities. For .NET, most of the components are ready if i’m not mistaken.

Above are my comments based on my experience. I’m might be wrong, so feel free to correct me if i’m wrong.
p/s: For PHP, it’s quite easy to learn from Level 1 to Level 3. For .NET, left it quite some forgot already. tongue emoticon