How to find the reason for a risky test in PHPUnit ?

How to find the reason for a risky test in PHPUnit ?

Recently I started phpUnit testing, and I found some of the test are flagging as risky. Most of the time I able figure bout reason but some time it very time consuming and also there isn’t any messages from PHPUnit.

A proper way to prepare IN Query in WordPress

A proper way to prepare IN Query in WordPress

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php global $wpdb; if ( is_array( 

A good article on wp_kses Performance

A good article on wp_kses Performance

https://www.tollmanz.com/wp-kses-performance/

Check if session is started or not in php

Check if session is started or not in php

To avoid Cannot send session cookie – headers already sent warning which is caused by calling the session_start()function without checking if the session is already started or not. You can find following warning in error log file : Warning: session_start() [function.session-start]: Cannot send session cookie 

Get php class file path from class name – ReflectionClass

Get php class file path from class name – ReflectionClass

During development of common library for WordPress plugins and themes ( WordPress development helper library ), I just want to find from which plugin it is called ( I just want to debug the code, but I used in many plugins and i am not 

Generic autoloader for classes named in WordPress coding style

Generic autoloader for classes named in WordPress coding style

if ( ! class_exists( ‘RT_WP_Autoload’ ) ){ /** * Generic autoloader for classes named in WordPress coding style. */ class RT_WP_Autoload { /** * @var string Current directory absolute path */ public $dir; /** * @param string $dir optional, default value is current */ function 

PHP readdir() return false even if permission are right

PHP readdir() return false even if permission are right

Today (So many times ) i face directory read issue using php. If you are trying to read a directory and readdir function is returning false even if php user have right permission (At least read permission) to that directory mainly while your server is 

register_taxonomy reserved terms

register_taxonomy reserved terms

There are some reserved word for register taxonomy. If you are passing the term through the $_GET or $_POST array. Doing so can cause WordPress to respond with a 404 error without any other hint or explanation. Following is the code snippet to check reserved 

PHP CodeSniffer – Coding standards

PHP CodeSniffer – Coding standards

PHP CodeSniffer scan PHP, JavaScript and CSS files and detects violations of a defined set of coding standards. To install phpcs on ubuntu pear install PHP_CodeSniffer To list all installed coding standards phpcs -i I found great article on rtCamp site. you can read it 

PHP profiling using webgrind and Xdebug

PHP profiling using webgrind and Xdebug

Install xdebug sudo apt-get install php5-xdebug Then update config Add following line in /etc/php5/fpm/conf.d/20-xdebug.ini xdebug.profiler_enable = 1 xdebug.profiler_output_dir = /tmp After that please restart php5-fpm sudo service php5-fpm restart Load page you want to optimize It will take time (If its taking too much time