Configure the form root element with Symfony Forms 3

While creating the forms with Form component from Symfony you can write your own Type classes which builds the forms. It’s pretty simple to add your own fields and all the required stuff for it.

class SignUpType extends AbstractType {
  public function buildForm(FormBuilderInterface $builder, array $options) {
    ->add('email', Type\EmailType::class, array(
      'label' => __('Email', Plugin::NAME),
      'required' => false,
      'constraints' => array(
         new Constraints\NotBlank(array(
           'groups' => array('personal', 'company'),
         new Constraints\Email(array(
           'groups' => array('personal', 'company'),
     'validation_groups' => array('personal', 'company'),
     'attr' => array(
       'data-form-element-role' => 'conditional-listener',
       'class' => 'regular-text',

But that if you want to configure out the root form element. For example, setup few additional classes and data attributes for your tag? Just add configureOptions() method and fill all the required stuff inside.

class SignUpType extends AbstractType {

  // buidForm here

  public function configureOptions(OptionsResolver $resolver) {
      'attr' => array(
        'data-form-type' => 'conditional-form',
        'id' => 'your-id',

Import and export WordPress database with utf8mb4 charset

Import and export WordPress database with utf8mb4 charset

Here is a short guide how to export and import your WordPress database without data loss. UTF8MB4 charset is tricky and sometimes your database may looks ok but take your time. Double check everything. I lost some data after migrating site between two servers and afterward spend more time to back all the things. Just my experience.

Continue reading

Theme features. Jetpack Infinite Scroll

Themes features. Jetpack Infinite Scroll Cover

Jetpack and almost all it’s modules works fine right from the box. But some of modules requires additional preparation and developer skills. And today I’ll show you which issues may happened with Infinite Scroll module.

This module is great because it cares about Google Analytics page views and enqueue additional CSS and JS files which can appear on the 2nd or 3rd page. In my personal opinion conditional CSS and JS files is not best way how you can solve your problems with site but in some cases it may helpfull.

Continue reading

YARPP Plugin. Technical review

YARPP Plugin. Technical review

Some time ago I wanted do a review YARPP plugin. From the technical side. But after looking at the code I can say that this plugin is typical WordPress plugin with (maybe) already discovered all bad stuff for me. Unpredictable require states and behaviour without ability to change it at least with the settings on the page…

Can I recommend this? I don’t know. It’s ok but hard to customize and not friendly for customizing I suppose. Here is a small shortlist with few things which I would like to highlight.

Continue reading

Coding standards. CamelCase and snak_case

Coding standards

Hi there. I’m working on some plugins for WordPress and I really love WordPress, it’s standards and being a WordPress Developer but sometimes I feel lost while writing code.

I think this idea is not a priority issue of WordPress community. And also this idea can be perceived as negative, but I really hope you would give it a chance.

After a lot of thinking I realized that only one thing stopping me from being happy: snack_case instead of CamelCase.

Why I think that CamelCase is better? There is few reasons for it.

Continue reading

VVV. The local server for WordPress (on Russian)


I wrote a long article about local servers. It may be helpfull for developers. Moreover newbies can easily start testing plugins or themes without crushing your production websites.

There I’m discussing old solutions like Mamp Pro, mini servers such as PHP internal server and Grunt (Gulp) webservers for static content. And acquaint readers with VVV (Varying Vagrant Vagrants).

Article explains in details how to work with VVV:

  1. How VVV works and which apps are used (VirtualBox and Vagrant).
  2. How you can start with VVV with a 5 minutes.
  3. Usage of internal tools (XDebug, PHP My Admin).
  4. Adding new sites in VVV with one simple command without downloading zip archives or manual configuring Nginx, MySQL (vv utility).
  5. The folder mounting (great for developers who use repositories for own projects).
  6. How to save your own configuration of VVV (and update it).

Read the full article on Russian →

Why you should never use wp-admin named folders in your plugin or theme

Why you should never use wp-admin named folders in your plugin or theme

Working on each plugin I always want to create a simpler and clean folders and files structure which everyone can understand in just one glance. It’s a main goal for all developers — creating simply and reusable code which doing some amazing work inside your products. Isn’t it?

I’ve been going a long way in attempts to create a solid files structure which perfect fits for every product I’m working on. It’s a good idea to write just a simply fancy code in single project. Even better to write a code using certain standards.

Unfortunately now WordPress doesn’t have established recommendations for plugins structure. The themes have a better equipment. Usually the themes shouldn’t have any hardcoded logic. I think that themes should be just a templates which defines a views, not a business logic or something. Or maybe not. Every single product have different purposes and environment. I don’t think that this world have just a one single solution which is right.

Now we have many plugins with absolutely different files structure. And understanding the logic of that plugin is like the conquest of Everest. 🙂

Jetpack plugin files

Jetpack plugin files

In my projects I have come to the conclusion that a folder called wp-admin is the best name for the folder with files which relates to WordPress wp-admin pages (admin screens). But it’s not the best name for this type of folder.

After running a wp core verify-checksums I was surpised with output in console.

wp core verify-checksums
Warning: File should not exist: wp-content/plugins/setka-editor/twig-templates/wp-admin/settings/auth/token.html.twig
Warning: File should not exist: wp-content/plugins/setka-editor/twig-templates/wp-admin/settings/common/checkboxes-in-fieldset.html.twig
Warning: File should not exist: wp-content/plugins/setka-editor/twig-templates/wp-admin/settings/common/template.html.twig
Success: WordPress install verifies against checksums.

Ow! It looked not as I expected. In trying to understand and explain this behaviour I’m stuck in WP-CLI source code. And the answer in Core_Command->get_wp_core_files(). So I’ve just renamed my folder from wp-admin to admin.

Also be avoid name your folders as wp-includes or any other WordPress “reserved” names. Other products may confused with this names.

P. S. It seems that I need more to write about plugin structure in next posts.