How to Solve WordPress asked for FTP credentials

I know it is very annoying when you are going to install a PLUGIN in WordPress. I like the way, one click and install for PLUGINS and THEMES in WordPress. Here is the way that I’m using:

Edit your wp-config.php and add the line into it.


How to disable AutoSave in WordPress ?

Sometimes we do not need the auto save function in the editor in WordPress, it will increase your database or slow down you editing experience while you are in slow internet connection.

Here is the solution to disable it, if you need to re-enable it just comment them away.

define( 'AUTOSAVE_INTERVAL', 60*60*60*24*365 ); // Set autosave interval to a year
define( 'EMPTY_TRASH_DAYS',  0 ); // Empty trash now: Zero days
define( 'WP_POST_REVISIONS', false ); // Do not save any revisions

Publishing Failed in WordPress

When you post in WordPress with over 5MB text post, you may receive this error with red color.

Publishing Failed

or you found in your php error log

PHP Fatal error:  Maximum execution time of 60 seconds exceeded in /home/nginx/domains/ on line 2295

This is because WordPress need more time to execute and process and formatting your post over the maximum execution time.

You may use the way below to solve this.

Edit the file wp-config.php and add in the line

@ini_set('max_execution_time', 1800);

But, use this with caution, because if many of your script in WordPress over this time, this way maybe kill your server.

Create WordPress widget template from scratch

I’ve save down the most basic widget code for WordPress, you can copy this to your plugin and modify it to start your first widget. You can save time on this tutorial to help you create wordpress widget from scratch.


class example_widget extends WP_Widget {
    function __construct() {
        parent::__construct(false, $name = 'Example Widget');	
 	/** @see WP_Widget::widget -- do not rename this */
    function widget($args, $instance) {	
        extract( $args );
        $title 		= apply_filters('widget_title', $instance['title']);
        $message 	= $instance['message'];
		<?php echo $before_widget; ?>
			<?php if ( $title )
			echo $before_title . $title . $after_title; ?>
				<li><?php echo $message; ?></li>
			<?php echo $after_widget; ?>
    /** @see WP_Widget::update -- do not rename this */
    function update($new_instance, $old_instance) {		
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['message'] = strip_tags($new_instance['message']);
        return $instance;
    /** @see WP_Widget::form -- do not rename this */
    function form($instance) {	
        $title 		= esc_attr($instance['title']);
        $message	= esc_attr($instance['message']);
          <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> 
          <input class="" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" />
          <label for="<?php echo $this->get_field_id('message'); ?>"><?php _e('Simple Message'); ?></label> 
          <input class="" id="<?php echo $this->get_field_id('message'); ?>" name="<?php echo $this->get_field_name('message'); ?>" type="text" value="<?php echo $message; ?>" />
} // end class example_widget
add_action('widgets_init', create_function('', 'return register_widget("example_widget");'));

lazy-result.js ReferenceError: Promise is not defined

        this.processing = new Promise(function (resolve, reject) {
ReferenceError: Promise is not defined

When I install the FoundationPress, after I run gulp build I saw this message,
this is because the node version problem.

the have mention in this post


vim node_modules/postcss/lib/lazy-result.js

Put this to the first line of the file lazy-result.js



Then install

npm install es6-promise

Then build again

[[email protected]]# gulp build
[18:14:07] Starting 'clean'...
[18:14:07] Starting 'clean:javascript'...
[18:14:07] Starting 'clean:css'...
[18:14:07] Finished 'clean:javascript' after 4.56 ms
[18:14:07] Finished 'clean:css' after 2.98 ms
[18:14:07] Finished 'clean' after 6.38 ms
[18:14:07] Starting 'build'...
[18:14:07] Starting 'copy'...
[18:14:07] Finished 'copy' after 103 ms
[18:14:07] Starting 'sass'...
[18:14:08] Starting 'javascript'...
[18:14:08] Starting 'lint'...
[18:14:10] Finished 'lint' after 1.53 s
[18:14:10] Finished 'sass' after 2.58 s
[18:14:14] Finished 'javascript' after 6.12 s
[18:14:14] Finished 'build' after 6.78 s

Success !

Connect to Jetpack using behind varnish and nginx

Normally if you use varnish or other reverse proxy, you may use other port in wordpress. So you are not able to connect to Jetpack, because to connect Jetpack, you must have port 80 to authorize.

It may display the error like this from your Jetpack debugger

    [headers] => Array
            [server] => nginx
            [date] => Sat, 23 Aug 2014 00:57:12 GMT
            [content-type] => text/plain;charset=utf-8
            [connection] => close
            [x-pingback] =>
            [expires] => Wed, 11 Jan 1984 05:00:00 GMT
            [cache-control] => no-cache, must-revalidate, max-age=60
            [pragma] => no-cache
            [x-hacker] => Jetpack Test

    [body] => {"error":"Communication error","error_description":"We were unable to make an XML-RPC request to your website. Please make sure that XML-RPC is turned on and that Jetpack is installed, activated and connected with your account. If the error persists, try disconnecting and connecting Jetpack again."}
    [response] => Array
             => 400
            [message] => Bad Request

    [cookies] => Array

    [filename] => 

because of the $_SERVER['SERVER_PORT'] is not equal to value 80;
But we can cheat the Jetpack by add this to wp-config.php


Delete expired _transient in wordpress to optimize the database

If you separate your database to another server, and if the wp_options table is going bigger to 2MB, then it will slow down your query time, because WordPress like to query all the data from the table wp_options always.

You have to make the table smaller size to speed up the query.

I always clean up those useless _transient from the database, it could save you mostly 1MB

DELETE FROM `wp_options` WHERE `option_name` LIKE ('%\_transient\_%')

How to Setup Temporary WordPress Staging Site

I’m going to Setup Temporary WordPress Staging Site using same MySQL database. It is very useful for you to develop themes or plugin without affect to your current running sites, and you need to use real data to test it out.

Prepare your contents

Copy all your current contents from




Set a domain and Point your Apache or Nginx to

Modify WordPress file

After that edit the file in wordpress


Inside the function get_option

Put this code, save it.

Put the codes

if ($option == "siteurl" || $option == "home") {
  return "";

How to remove ver from js and css in WordPress ?

Remove the ver=date behind the JS and CSS in wordpress.

// Load in any own plugin
function juz_remove_wp_ver_css_js( $src ) {
    if ( strpos( $src, 'ver=' ) )
        $src = remove_query_arg( 'ver', $src );
    return $src;
add_filter( 'style_loader_src', 'juz_remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'juz_remove_wp_ver_css_js', 9999 );