2017 © Pedro Peláez
 

library shortcodes

BBCode/Wordpress style shortcodes

image

jaybizzle/shortcodes

BBCode/Wordpress style shortcodes

  • Monday, April 9, 2018
  • by JayBizzle
  • Repository
  • 1 Watchers
  • 4 Stars
  • 1,435 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 50 % Grown

The README.md

, (*1)

Shortcodes

Shortcodes is a PHP library that will help parse WordPress/BBCode style shortcodes. It can turn something like this..., (*2)

[style color=#FF0000]Red Text[/style]

into this..., (*3)

<span style="color:#FF0000;">Red Text</span>

The output is not predefined, it is up to you to define how the output is handled. See below for examples., (*4)

Installation

composer require jaybizzle/shortcodes

Getting started *** (WIP) ***

Let's take a simple example. We want to create a Shortcode for video elements. We want to be able to write something like this..., (*5)

[video title="My Awesome Video" videoID=345 width=320 height=240]

and make it output something like this..., (*6)

<video width="320" height="240" controls>
    <source src="/videos/video-345.mp4" type="video/mp4">
    <source src="/videos/video-345.ogg" type="video/ogg">
    Your browser does not support the video tag.
</video>

Firstly, we need to create a class that is going to handle the parsed Shortcode and its attributes. We create a new class as follows..., (*7)

<?php

namespace App\Shortcodes;

use Jaybizzle\Shortcodes\Shortcode;

class VideoShortcode extends Shortcode
{
    public static $shortcode = 'video';

    public function parse()
    {
        // All shortcode attributes will be available in $this->attr
        // i.e. given the example above...
        // $this->attr['title']
        // $this->attr['videoID']
        // $this->attr['width']
        // $this->attr['height']
    }
}

Next, we need to add this Shortcode parse class to the Shortcodes library like this..., (*8)

<?php

namespace App\Libraries;

use App\Shortcodes\VideoShortcode;
use Jaybizzle\Shortcodes\Shortcodes;

class MyClass
{
    public function index()
    {
        $shortcodes = new Shortcodes
        $shortcodes->add(VideoClass::class);
    }
}

The Versions

09/04 2018

dev-master

9999999-dev

BBCode/Wordpress style shortcodes

  Sources   Download

MIT

The Development Requires

06/04 2018

v1.0.0

1.0.0.0

BBCode/Wordpress style shortcodes

  Sources   Download

MIT

The Development Requires

26/03 2018

dev-dev

dev-dev

BBCode/Wordpress style shortcodes

  Sources   Download

MIT

The Development Requires

21/03 2018

dev-analysis-qoOj6K

dev-analysis-qoOj6K

BBCode/Wordpress style shortcodes

  Sources   Download

MIT

The Development Requires