Download the PHP package maiorano84/shortcodes without Composer

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

Shortcodes

Implementation of Wordpress' Shortcode syntax as a standalone package. Content from editors, databases, etc. can be scanned by the Shortcode Manager and the contents replaced by a custom callback.


Latest Stable Version Latest Unstable Version Total Downloads License Build Status Scrutinizer Code Quality Code Coverage StyleCI

Requirements

Shortcodes requires PHP 7.1 or greater.

Composer

This package may be installed as a Composer dependency by running the following command:

composer require maiorano84/shortcodes

If you would like to use the latest unstable version, you can run:

composer require maiorano84/shortcodes:dev-master

What are "Shortcodes"?

Shortcodes are a common format used to provide macro support in various CMSs, editors, and libraries. Perhaps the most famous example is the Wordpress Shortcode API, which provides developers an avenue by which they can enhance their theme or plugin's ease of use.

The anatomy of a shortcode is as follows:

There are many formats that shortcodes can follow, but ultimately the idea is that when a shortcode tag is matched, its contents are replaced by a server-side callback.

Usage

This package comes with everything you need to get started in defining your own custom shortcodes and their respective callbacks. To define a custom Shortcode programatically, you can use the SimpleShortcode class:

Now, when you process a string that contains [example] it will be replaced by your custom callback.

Nested Shortcodes

In most cases, the SimpleShortcode class will be sufficient in covering your app's needs. However, some cases may require a bit more configuration that the SimpleShortcode class doesn't assume out of the box.

One fairly common scenario you might run into is the need for Nested Shortcodes:

'[foo][bar/][/foo]'

In all of the examples thus far, none of them cover what would happen when you register two shortcodes where one wraps another. Let's see what happens:

Shortcodes - by their very nature - are meant to encapsulate content. That content is processed and returned to the manager for output.

The problem here is that [bar/] is matched and passed by the manager as content. Not Shortcode.

To handle this, there are several avenues we can take. Let's set up a manager that uses three shortcodes:

[foo] - Render shortcode as text with content appended that permits [bar] to be processed
[bar] - Render shortcode as text with content appended
[baz] - Render shortcode as text

Option 1: Selective

The benefit to this approach is that YOU can decide what gets processed and what doesn't. If there's a possibility that your Shortcode contains content that should be processed by the manager that called it, then your best bet would be to return the content wrapped in another call to doShortcode.

Option 2: Permissive

There is an optional third parameter that you can set within doShortcode, which will allow the manager to decide which tags to render and run recursively until everything has been processed.

Even though we've defined that only [bar] is permitted to be processed in the [foo] callback, the Shortcode Manager can choose to override it any time.

Option 3: Scorched Earth

Don't care? Just want to handle all possible shortcodes and let the chips fall where they may?

Hold my beer:

Aliasing

If you would like to create aliases for preexisting shortcodes, there are a number of ways to do this:

Now when you use [bold] or [b], they will both do the same thing.

Be careful: When registering aliases, deregistering the original shortcode will also deregister its associated aliases by default.

If you would like to deregister a particular shortcode but leave its aliases intact, you may optionally provide a second parameter that will tell the manager not to deregister aliases:

Now, [b] will continue to be rendered, but [bold] will no longer be recognized.

Shortcuts

There are a number of shortcuts provided for you out of the box. Registration can be as easy as this:

You may also alias a SimpleShortcode directly:

In addition to the above, you may also run doShortcode on a SimpleShortcode directly. These two statements are identical:

And finally, deregistering a Shortcode and its aliases can be done like so:

Other Notes

You might have noticed that the SimpleShortcode class can call to a protected member in order to achieve certain results. In every Shortcode that leverages the inherent handle method from the CallableTrait, the callback is bound to the scope of that particular instance. That means that even when protected and private members are declared, you still have access to those members within the scope of your callback.

Ultimately, the goal is to keep everything as flexible as possible in allowing you - the developer - to build your application in the way you want it.

Enjoy!


All versions of shortcodes with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
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 maiorano84/shortcodes contains the following files

Loading the files please wait ....