Wednesday, August 12, 2015

PHPStorm: mark a single file as excluded

PHPStorm allows to mark a folder as "Excluded" (Go to Project view, right-click on a folder and choose "Mark Directory as... Excluded". Then, all the files in that folder will be ignored by the PHPStorm when it looks for functions, constants, etc. So, for example, if you have an older versions of a library, in "archive" folder, you can exclude it, and Code Inspection will not refer to those older method definitions, constants, etc.

But what if you need to exclude just a single file? The only way I found was to mark it as a plain text:

It's particularly useful for WordPress projects: those two files


have tons of "dummy" methods:

* @ignore
function add_filter() {}

- with no parameters or bodies. PHPStorm finds them, considers no params and a void return and issues useless inspection errors.

There is an alternative solution, suggested by Slava Abakumov: add the file(s) to the Settings->Editor->File Types->Ignore...
The drawback is that the file disappears completely from the Project view, and even by typing its name, you won't be able to find it. Ignored completely. This can be quite inconvenient if you want to ignore a file, but still be able to edit it.

A Pro-tip from the creators of WPGlobus Multilingual Plugin for WordPress

Thursday, August 6, 2015

makepot.php for single textdomain only

Here is a patch to the entry.php file that allows to ignore all strings that are not from a single textdomain.
Ugly. Hard-coded. Enjoy :)

Thursday, February 19, 2015

Codeception: XPath `...` is malformed!


Codeception PHP Testing Framework v2.0.11
Powered by PHPUnit 4.4.5 by Sebastian Bergmann.


* I am on page "/"
* I click "Terms of Use"

  XPath `Terms of Use` is malformed!


$I->click( "Terms of Use" );


$I->click(['link' => "Terms of Use"]);

From the documentation:

// using strict locator
$I->click(['link' => 'Login']);

Tuesday, August 19, 2014

WooCommerce: SQL to fix sorting by date

In one of the projects, I needed to import a product data from a non-WP website to WooCommerce.

After importing, the "Sort by newness" did not work correctly, because the post dates were all the same.

A simple SQL solved my problem:

Wednesday, May 28, 2014

WordPress Tip: Export WooCommerce category list (SQL, CSV, Excel)

Run this SQL in phpMyAdmin, and then click Export link at the bottom to save as CSV for Excel or other format.

Note: tested only on one level of subcategories.

Gist revisions are welcome:

Thursday, March 20, 2014

SourceTree does not show submodules

(SourceTree is a nice Git client by Atlassian)

The Problem:

SourceTree loses track of Git submodules. The entire "submodules" sidebar section is invisible.

A "clue":

Click the "Terminal" toolbar icon and type
$ git submodule

You should see something like:
dbd34bd2657ef70f001c1d135e2e14adef7dcdb9 dbdump (heads/master)
No submodule mapping found in .gitmodules for path 'wp'

The first line is good. The second one is a "clue".
It says: "Git knows about a submodule that you defined earlier. However, it cannot find the path to it in your .gitmodules file!"

Apparently, the path to submodule is wrong, or absent.
Restore it.

...or if you do not need that submodule, issue the following command in the terminal window:
$ git rm --cached {your submodule path} 




Wednesday, March 19, 2014

Making a plugin: SVN, GitHub, PHPUnit and Travis-CI [Part 1]

This is my first experiment to publish an open-source code. It was quite a "challenge", after years of working exclusively for corporate clients and myself, to write something that can go to "the wild" :-))

WordPress version:
GitHub version:

Here is a shortened list of what's involved in making a public plugin and publish it on site:
  • Write a bullet-proof PHP code (mission impossible, but approach as close as you can)
  • Organize the code in a special way: names of the files, folders, special headers, screenshots, readme.txt and so on.
  • Place your plugin somewhere so that WordPress staff can check it out and approve. (Hint: GitHub is a good place for that)
  • Apply here: Note: the name of your plugin will become it's "slug" in the URL, so choose carefully!
  • Wait for the approval, and if you never used SVN before, take this time to learn the basics.
  • SVN-Commit your code once approved.
  • Wait for reviews and support request.............. :-)
  • Folders structure and on GitHub are not exactly the same as on
  • You can setup Travis-CI calling PHPUnit to test your code automatically. It's not an easy thing to setup - but highly recommended.
To Read:

I'll try to find time and write more details [Part 2,3,...] soon.