Assignments in WordPress plugin

By selecting the specific assignments, you can manage where and how WordPress plugin scripts should or shouldn’t be published. To have it published on all pages, do not specify any assignments. Every assignment group has 3 states:

  • Ignore (Default)
  • Include
  • Exclude

By default, the assignments set to Ignore, meaning the plugin is not limited by assignments. To use an assignment, set the option to Include or Exclude.

Assignments option

If you select Include, the plugin code will be applied to all objects selected in the current assignment group. If you select Exclude, the plugin will ignore all objects selected in the current assignment group.

Another important point is the Matching method. Matching method setting determines how many of the assignment groups will be used. The matching method has only two states:

  • All
  • Any (Default)

Any is selected by default, and this means that any assignment group will be enough to bind the plugin. And if All is selected, then this means that all assignment conditions must match.

Matching method selector

Different plugins have different assignment groups. Let’s take a closer look at the full list of assignments groups:

WordPress content

This group of settings enables/disables the plugin on any WordPress Page, Post, or Category. You can choose any quantity and combination from the dropdown list.

Home page

This group of settings enables/disables the plugin code on the Home page

This group of settings enables/disables the plugin according to any WordPress menu. Userful if you want to disable the plugin on the contact page, for example.

Date & Time

This group of settings enables/disables the plugin code on a specific time period. For example, if you want to disable the plugin during the Christmas week.

Assignments in WordPress plugin - Date and Time Picker
Date and Time Picker

User roles

This group of settings enables/disables the plugin for any WordPress user group. For example, disable the plugin for the administrator to simplify the debugging of the site.

URL

This group of settings enables/disables the plugin code for some specific URL. For example, you can disable the plugin for some languages.

Devices

This group of settings enables/disables the plugin code for mobiles, tablets, and desktops/laptops.

Custom PHP

In this settings group, you can use any PHP code to set the plugin enable/disable rules. The code written in this field must return true or false. For example, you can turn off the plugin every Friday of every even week of the year.

$dayofweek = date('w');
if( '5' == $dayofweek ) { // Only on Fridays.
    $result = true;
} else {
    $result = false;
}
return $result;

Save Changes

Do not forget to click Save Changes after changing assignments in WordPress plugin settings. After clicking this button, the settings will be saved and applied to all pages of the website.

Take a look at all WordPress plugins using the assignment interface.

Was this article helpful to you?