Download the PHP package dimadin/commonwp without Composer

On this page you can find all versions of the php package dimadin/commonwp. 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 commonwp

commonWP

Build Status Latest Stable Version

commonWP is a plugin that enables usage of free CDN for open source JavaScript and CSS files. It aims to be both lightweight and very secure.

Usage

There are three ways to install commonWP:

After activation, there are no any settings. It will fill up its cache in the background, and that may take some time depending on number of resources site uses.

You may change some default commonWP settings by using WordPress hooks which are listed below.

FAQ

Marking files that exist in npm

Some external libraries that you use in your theme or plugin might be also available on npm. It is preferred to rewrite using /npm path on jsDelivr and marking those files as available on npm enables that. This works even for your custom or premium plugins/themes.

What you need to know is handle by which you registered that file in WordPress and you need to know name of npm package and path from package's root, including file name but without extension. Separate filters are used for JavaScript and CSS files. In both cases, you extend default array with key that is dependencies handle and value that is array of settings of that file on npm.

In this example, we would use Bootstrap files but also mark to commonWP that they are available on npm.

Note that your local files and remote files must be identical, Otherwise, commonWP won't use remote files and will not rewrite. To make sure that files are identical, you can get files for local directory from npm package.

Also note that when using filter you shouldn't use file extension and you shouldn't enter package version (but you should enter correct file version when registering dependency).

You can skip minified key if you don't have development version locally and just append .min to the value of file.

Using these filters is safe since they are triggered only when commonWP is used.

Using commonWP with object cache enabled

By default, commonWP stores its data in a standard option value. If you have object cache enabled, you can skip database and directly use object cache. Other than not having database calls, this also reduces size of autoloaded options cache when used on single site installations.

In this example, transients functions are used because transients do not use database when object cache is enabled. Network transients are used because they use global cache group on multisite installations.

If you start using this approach, deactivate commonWP plugin, add this code and activate again, or delete option commonwp_data (on multisite installation that is network option) via other means to reduce size of autoloaded options cache.

Deciding should path be rewritten

It is possible to avoid rewriting of some file paths by using filter. Those file paths won't be processed at all so there will be no cache in the database. This can be used, for example, for custom or premium plugins/themes that you know for sure that they don't have corresponding files on jsDelivr, even in /npm path.

Returning path before storage lookup

You can return remote file path before touching commonWP storage or before regular processing. For example, some files used in MU Plugin might exist in a custom GitHub repository and you might want to use that.

Cache Expiration

When commonWP sees new file, it processes that file in the background task to see if identical copy exists on jsDelivr or not. Result of that processing is cached so that next time commonWP immediately knows should it rewrite or not. Expiration time of cache of each file path (TTL) is different based on result of processing and of type of file, and can be changed using filters.

Exposing private details

Because of the way jsDelivr works, if file is not loaded from /npm path, it is showing exact version of core, plugin, or theme in the full path to the file. This isn't problem as versions could already be discovered via other means. In case that core, plugin, or theme has an update available, you can tell commonWP not to cache paths of files of that core, plugin, or theme with their installed version and instead use their latest version. Note that your site won't be secured by this, you just won't explicitly show installed versions in jsDelivr URLs, but that doesn't mean that you won't show versions elsewhere. You should keep core, plugins, and themes up to date anyway, and upgrade to newer version when they are available. Also note that since cache might last for up to two days, jsDelivr URLs might still be used and thus versions shown.

To use latest version in URL when caching paths when there is an update available, you can do that by type. Argument with \dimadin\WP\Plugin\commonWP\Process object is passed, and thus file name, theme or plugin. This will have no effect if file is marked as available on npm.

For core files, there are two filters: one is used when you have latest version in your branch but there is new branch available (major), second is used when you don't use latest version in a branch (minor).

Rewriting files whose remote copy on npm isn't identical

While it sounds non-logical to rewrite to remote file that are not identical as local one, there are valid cases where this could happen.

For example, some libraries used in WordPress core do not provide development version. This means that it won't rewrite to development version available on npm but to identical, minified version. Or, when minified version in npm package uses different tool for minification from tool in local version so files aren't identical.

You can rewrite to those remote files even if comparison fails by using filter. Note that this is only available for files marked as available in npm, and that it never happens by default, you must enable it via filter. Also note that remote file must exist before triggering this hook.

Disabling subresource integrity

If you are sure that jsDelivr won't be compromised and you want to reduce page size, you can disable subresource integrity, either globally or on file by file basis.

Globally

You can remove it for either scripts, styles, or both.

Per file

WP-CLI

commonWP implements the following commands:

wp commonwp clean

Delete from commonWP store.

wp commonwp clean all

Delete all data that commonWP is using.

wp commonwp clean all

EXAMPLES

$ wp commonwp clean all
commonWP data was deleted.

wp commonwp clean expired

Delete paths whose TTL has passed.

wp commonwp clean expired

EXAMPLES

$ wp commonwp clean expired
Expired paths were deleted.

wp commonwp clean starting-with

Delete paths that start with requested path.

wp commonwp clean starting-with <path>

OPTIONS

<path>
    Path that paths should start with.

EXAMPLES

# Delete paths that are from /wp-admin folder.
$ wp commonwp starting-with /wp-admin
Paths that start with /wp-admin were deleted.

wp commonwp paths

Get stored paths data.

wp commonwp paths list

List all type of paths.

wp commonwp paths list

EXAMPLES

$ wp commonwp paths list

wp commonwp paths list active

List paths that can be rewritten.

wp commonwp paths list active

EXAMPLES

$ wp commonwp paths list active

wp commonwp paths list inactive

List paths that are not rewritten.

wp commonwp paths list inactive

EXAMPLES

$ wp commonwp paths list inactive

wp commonwp paths list queue

List paths that that should be processed.

wp commonwp paths list queue

EXAMPLES

$ wp commonwp paths list queue

wp commonwp queue

Process queued paths.

wp commonwp queue process

Process all waiting paths.

wp commonwp queue process

EXAMPLES

$ wp commonwp queue process
Queue was processed.

All versions of commonwp with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
composer/installers Version ~1.0
dimadin/wp-temporary Version ^1.0
dimadin/backdrop Version ^1.0
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 dimadin/commonwp contains the following files

Loading the files please wait ....