The DemoProtector is a PHP Class which allows you to protect certain parts of the administration panel of your WordPress websites.

The class is a must have for each Envato user which sells WordPress plugins or any other stuff which have to grand access to the administrator panel of the system for demo or any other purposes.

Have you ever received comments from clients telling you that your demo is not working or they cannot log in to the admin panel? Especially if you provided admin access to the panel you did have headache blocking rights and hard-coding fixes to block the users which make fun with your demo WordPress installation. Also there are a lot of people installing plugins which edit other plugins and template files just to steal your code. Most of the people do not respect our licenses and they have to be stopped.

The class that I present you is going to help you stop those people. Forget about worrying for your demo installation. Just include the class and with 2-3 lines of code you can be ready for going live without any doubts and fully protected.



In order to make the script work you have to upload the folder demo-protector to the folder of your active WordPress theme (<>/wp-content/themes/<mytheme>/).
Once uploaded you should open file functions.php and include the file DemoProtectorInit.php from the demo-protector folder like this:


Once loaded the file open file DemoProtectorInit.php in demo-protector folder and in method _setup() you can setup the class options. You can also see some commented examples there.

By default the class blocks certain areas of the admininstartion panel. You can take a look at the reference table below to see the default settings or just call the method getInitialOptions


These settings are enough for you to be sure you are protected.

You can also use several class methods to setup the class to do exactly what you need. You can change the default settings on the fly and also add your own custom protection conditions.

Class methods

getInitialOptions()Prints on the screen table with initial setup
getAvailableOptions()Prints on the screen table with all possible page protections
getOptionsStatus()Prints on the screen table with all protection statuses
protect(array $options)Adds options for protection. Example: array('update', 'pages_add', 'links_delete'). These options will be added to the list with pages to protect.
protectAll()Sets all pages for protection
unprotect(array $options)Removes options from protection list. Example: array('update', 'pages_add', 'links_delete'). These options will be removed from the list with pages to protect.
unprotectAll()Removes all options from protection list
customProtection($regex)Accepts regular expression which is matched against the script file and all $_GET values*

* Example: If you want to block the access to a page with URL: you should make a regular expression which matches post-new.php?post_type=page


You can also enable / disable protection for each option by calling the methods like this:



This will enable protection for plugins_deactivate and disable protection for themes_add option.

Protection options

Here is a table with possible protection options which you can pass to the class.

Note: Value true means the page is protected and the users do not have access to it.

OptionTypeDefault value
updateBoolean (true / false)true
postsBoolean (true / false)false
posts_addBoolean (true / false)false
posts_editBoolean (true / false)false
pagesBoolean (true / false)false
pages_addBoolean (true / false)false
pages_editBoolean (true / false)false
mediaBoolean (true / false)false
media_uploadBoolean (true / false)false
media_editBoolean (true / false)false
linksBoolean (true / false)false
links_addBoolean (true / false)false
links_editBoolean (true / false)false
links_deleteBoolean (true / false)false
links_categoriesBoolean (true / false)false
commentsBoolean (true / false)false
themesBoolean (true / false)false
themes_addBoolean (true / false)false
themes_editBoolean (true / false)false
themes_deleteBoolean (true / false)false
theme_optionsBoolean (true / false)false
theme_backgroundBoolean (true / false)false
theme_headerBoolean (true / false)false
theme_editorBoolean (true / false)true
widgetsBoolean (true / false)false
menusBoolean (true / false)false
pluginsBoolean (true / false)false
plugins_installBoolean (true / false)false
plugins_activateBoolean (true / false)false
plugins_deactivateBoolean (true / false)false
plugins_deleteBoolean (true / false)false
plugins_editorBoolean (true / false)false
usersBoolean (true / false)true
users_addBoolean (true / false)true
users_editBoolean (true / false)true
users_deleteBoolean (true / false)true
users_edit_selfBoolean (true / false)true
toolsBoolean (true / false)true
importBoolean (true / false)true
exportBoolean (true / false)true
optionsBoolean (true / false)true
options_generalBoolean (true / false)true
options_writingBoolean (true / false)true
options_readingBoolean (true / false)true
options_discussionBoolean (true / false)true
options_mediaBoolean (true / false)true
options_privacyBoolean (true / false)true
options_permalinkBoolean (true / false)true
lost_passwordBoolean (true / false)true

Options groups

Most of the options are sorted in groups like the links groups from the administration panel menu. If the main group option is blocked all inner options are also blocked.

Groups reference


You can contact me by sending an email from my CodeCanyon profile