Add Shortcodes Actions And Filters


Add PHP Code to create your own Shortcodes, Actions and Filters.

Can import your shortcodes from Shortcode Exec PHP plugin (which is no longer supported).

Provides a place to add your code that is more convenient than putting it in your theme’s functions.php file.

Add your code in the Dashboard -> Tools -> Shortcodes, Actions and Filters
but this is only available to users with Administrator role.

Why this plugin?
Existing WordPress documentation suggests adding your own shortcodes, action and filters in the theme’s functions.php file.
This is not a good idea because:

  • If you upgrade your theme, this file can be overwritten and
  • if you change your theme then you need to add the same code to that theme as well.

Your code additions should not have to be artificially tied to your theme. This plugin frees you from that constraint.


  • Dashboard page for code listings
  • Dashboard page for editing a shortcode
  • Dashboard page for editing a filter
  • Dashboard page for editing an action
  • Dashboard page for import/export to/from file and import from Shortcode Exec PHP


  1. From the Dashboard:
  2. Дополнения
  3. Добавить новую
  4. Search «Add Shortcodes, Actions And Filters»
  5. Установить сейчас
  6. Активно
  7. Go to Tools -> Shortcodes, Actions And Filters

Часто задаваемые вопросы

What happens when there is a syntax or other fatal error in one of my code items?

Typically you will see an error message on the page that is trying to execute the code.
The error will contain a link to edit the problem code item. It will look like this:

Shortcodes, Actions and Filters Plugin: Error in user-provided code item named «My Action». Fix the code here

There are two cases where this plugin will not execute code.

  1. On this plugin’s own dashboard pages for displaying and editing code. This is so that you can always get back to the
    page to edit code despite any error in your code.
  2. On login/logout page (which is the same page) except when the «Allow Execution of Actions and Filters on Login/Logout pages»
    option is set to «true».

You will not see any errors on this plugin’s dashboard pages for editing and listing the code. Therefore, you should
open a different page on your site where you can see the results (or errors) of your code execution.

By default, no code that you put in this plugin will run on login/logout pages.
This is to prevent the situation where your code causes a fatal error
that prevents you from being able to login to fix the problem. Consequently, any action or filters that you want run on
login/logout pages will not be run. However you can override this setting on the plugin’s Options page by setting
«Allow Execution of Actions and Filters on Login/Logout pages» to «true». Do so at your own risk! Any code that you want
executed on login/logout pages should have «Execute also on Dashboard Pages» checked.

In certain cases, an error may cause you to be unable to access any pages your site, including dashboard pages.
However, you will be able to access this plugin’s dashboard pages so that you can edit or delete the problem code.
Enter the URL to the plugin’s dashboard page directly into your browser:


Only administrator users (manage_options role) can access that page and edit code.

Worst-case scenario: if somehow your site is completely inaccessible, you can disable your code in via the database.
This can happen if you enabled the setting to run code on the login page and that code creates a fatal error. To recover,
find the wp_addactionsandfilters_plugin_usercode table. If you know the code item that is causing the problem, then set
its «enabled» value to 0.

Alternately, disable the problem code using the following query if you know the code’s ID number.
If the ID is 5, then you would execute:
UPDATE wp_addactionsandfilters_plugin_usercode SET enabled = 0 WHERE id = 5

Alternately, disable all code using the following query:
UPDATE wp_addactionsandfilters_plugin_usercode SET enabled = 0

What order are the code elements executed in?

They are executed in order by ID number, lowest to highest. Shortcode are registered but not executed until the
shortcode appears on a page.

Action and filter code can depend on code from a code item with a lower ID number. For example, if code item with
ID=1 defines a function, then all code items with ID>1 have the function defined. But if you deactivate
the code with ID=1, then active code items that depend on it will fail.

Why doesn’t my action code execute on login/logout pages?

The plugin will not execute code on these pages because an error in your code could cause you to be unable to log into
your site to fix the error. However, as stated above, you can override this setting (do so at your own risk!)

Я получаю ошибку 403, когда сохраняю код

You are probably using WordFence plugin and you must add this plugin to the whitelist.


I have been using this plugin and it has been working great so far. Helped me add a necessary code tweak and maintain it even with my limited php knowledge. Thanks to the developers for making this available and keeping it up to date!
But when I do, it's because it deserves 5-stars. Hat's off to the gentleman that originally wrote this plugin and had so many ignorant people discourage his continuation of supporting it... GLASS UP to the gentleman that took it over and made it even better. I love this so much. Nothing like a quick dirty way to write your own micro-plugins for, like... anything. It's really great. Thanks.
Посмотреть все 19 отзывов

Участники и разработчики

«Add Shortcodes Actions And Filters» — проект с открытым исходным кодом. В развитие плагина внесли свой вклад следующие участники:


«Add Shortcodes Actions And Filters» переведён на 1 язык. Благодарим переводчиков за их работу.

Перевести «Add Shortcodes Actions And Filters» на ваш язык.

Заинтересованы в разработке?

Посмотрите код, проверьте SVN репозиторий, или подпишитесь на журнал разработки по RSS.

Журнал изменений


  • Security fix.


  • Bug Fix: Was incorrectly stripping slashes from Short Code Exec PHP code on import.


  • Bug Fix: Code Editor now usable on RTL language sites. Forced code section to be LTR.


  • Bug Fix: Displaying code editor that had textarea tag in the code element it failed to display properly


  • Bug Fix: Import file operation was stripping out backslashes out of code


  • Minor performance improvement to options handling


  • Improved error handling/reporting for PHP 7+


  • Introduced option to permit code execution on login/logout pages
  • Minor improvement to error messages
  • Fix for minor issue on edit page when using PHP 7.0.


  • Fix for scenario where bad code is executing on admin pages that could cause the user to be unable to login to fix it.


  • Significant upgrade!
  • Re-designed administration panel allows you to separate out your code, and activate/deactivate them individually
  • Now can create shortcodes similar to (the no longer supported) PHP Shortcode Exec plugin
  • Can import your shortcodes from PHP Shortcode Exec plugin
  • Supports multisite


  • More graceful handling of PHP FATAL Errors introduced by user’s code


  • Fixed debug error message on admin page


  • Limiting access to only Administrators to avoid possible security exploit


  • Initial Revision