Download the PHP package publishpress/publishpress-instance-protection without Composer

On this page you can find all versions of the php package publishpress/publishpress-instance-protection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package publishpress-instance-protection

PublishPress Instance Protection

This is a library for protecting WordPress plugins to run twice instances at the same time.

Installation

This library should be added as a composer requirement running the command:

How to use it

Making sure the plugin do not break with more running instances

The first step, before even requiring this library, is making sure your plugin do not break if it has two or more instances running at the same time on the site.

This is easy to accomplish using constants defined after the plugin is loaded, and checking it before loading the plugin. If the constant is defined, we do not load the plugin again (and not even require its libraries).

This verification has to be out of any hook.

Make sure to rename the variables and constant according to your plugin. This example copy the PublishPress Authors code:

Free plugin example

Pro plugin example

Please note that the Pro plugin checks two constants: its own constant, and the one defined in the free plugin. This way the Pro won't run if the free is already running as a stand alone plugin.

Functions

Before defining functions on the global escope always add it inside a conditional using function_exists. If they are defined on a speicifc includes.php file for example, you can use only one conditional before including it, instead of adding the conditional to every function.

Classes

Before declaring classes, follow the same approach on the previous topic, but using class_exists.

Adding the admin notices library

This library do not use composer's autoloader because it needs to be loaded before everything else in the plugins. But it has its own autoloader inside it, following the PSR-4 pattern.

You should always check if the vendor folder is on the expected path before trying to include anything from inside it. If not on the standard folder, make sure to give an option to the use to define a constant that gives the custom path of the vendor directory.

Check the following example on how to include and instantiate the library, just make sure to add this code as the first thing that will be executed in your plugin, on the global escope, out of any hook.

Free Plugin example

Pro Plugin example

The only required change is that you need to include two more configurations: isProPlugin and freePluginName.

Final example

The final code should looks something like:


All versions of publishpress-instance-protection with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.20
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package publishpress/publishpress-instance-protection contains the following files

Loading the files please wait ....