Starting with version 2.1.12 of WPCode you can execute PHP snippets on demand.
This is especially useful when you want to run pieces of code that you need to be sure are only executed once or that you need to control when they are executed.
In order to run snippets on demand, you need to follow a few simple steps:
1. Choose the PHP Code Type for your snippet, in order to do that please click the Code Type dropdown as shown below and select PHP Snippet.
2. Choose the “On Demand” location in the Insertion settings:
First, click the Location picker:
And from the menu select “On Demand” under the “PHP Snippets Only” locations list:
3. Finally, with that selected you will see that the status toggle next to the Save button has been replaced with a button “Execut Snippet Now”. Clicking this button will save the snippet with its code and settings and immediately execute the snippet. If you wish to save the snippet without executing it you can always use the “Save Snippet” or “Update” button as usual.