Download the PHP package wpsmith/shortcode without Composer

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

WordPress Shortcode Class

This library provides a skeleton to build shortcodes for WordPress.

Description

This library provides the skeleton for:

  1. Registering the shortcode. If a shortcode exists with the same name, it will automatically remove the shortcode before adding this shortcode.
  2. Ensuring that scripts/styles are only printed when the shortcode is being used.
  3. Merging shortcode attributes with default attributes.

The Shortcode Base Class

The shortcode is registered at plugins_loaded hook or immediately upon class instantiation via singleton implementation: MyShortcode::get_instance().

This class checks the following to determine whether a shortcode exists on a page:

Additionally, the class provides a filter wps_shortcode_{}_is_active to further extend checks to determine whether the shortcode exists on a page.

The AjaxShortcode Class

This class extends the Shortcode base class providing additional features:

  1. Skeleton for registering AJAX calls with checking the ajax refer nonce.
  2. doing_ajax() static function.
  3. get_random_string() static function.

Installation

To install via composer:

Otherwise copy the Shortcode (and AjaxShortcode) class(es) to your folder.

Usage

This library is easy to use in two simple steps:

  1. Extend the class implementing the method public function shortcode( $atts, $content = null ){}. Note:
    • Your defaults as defined in get_defaults() method will already be merged (and also available via $this->atts)
    • Your script(s)/style(s) as enqueued in enqueue_scripts() method will already be printed or enqueued.
  2. Instantiate the singleton in your theme/plugin: MyShortcode::get_instance().

Optionally, you can do the following:

Examples

You can find these and more examples at Shortcodes.


All versions of shortcode with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
wpsmith/singleton Version ^1.0.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 wpsmith/shortcode contains the following files

Loading the files please wait ....