WPV_Editor_Parser

class WPV_Editor_Parser

Methods

Initialize the parser

__construct(string $content, array $shortcodes = array()) 

Arguments

$content

string

string to parse

$shortcodes

array

list of supported shortcodes and their options

Creates a tree of the content

parse() : \[type]

Two special node types:

  1. ROOT - a single root element
  2. text - unrecognized shortcodes and text blocks. Adjascent text nodes are collapsed together

Response

\[type]

[description]

Initial cleanup of the content

prepare() : string

Response

string

cleaned up content

Constructs a new node

new_block(string $type, \&object &$parent = null) : object

Arguments

$type

string

node type

$parent

\&object

reference to the new node's parent node

Response

object

newly constructed node

Trims unrecognized shortcodes and arbitrary text and puts it in a text node

trim_text_nodes(int $pos) : int

Arguments

$pos

int

parser position

Response

int

parser position after trimming the text

Get shortcode type

get_type(int $pos) : array

Arguments

$pos

int

parser position

Response

array

array of two elements - shortcode type and parser position

Get atrributes when inside an opening shortcode tag

get_attributes(int $pos) 

Arguments

$pos

int

parser position

Moves the parser position at the end of the whitespace

ignore_whitespace(int $pos) : int

Arguments

$pos

int

parser position

Response

int

parser position

Whether a shortcode of type $type accepts nested shortcodes

is_accepting(string $type) : boolean

Arguments

$type

string

shortcode type

Response

boolean

true if nested shortcodes are enabled for $type

Whether a shortcode of type $type is supported by the Vamtam editor

is_supported(string $type) : boolean

Arguments

$type

string

shortcode type

Response

boolean

true if a shortcode of type $type is supported by the Vamtam editor

Maps the list of supported shortcodes to $this->accepting and $this->supported (i.e. splits the original list in two)

known_shortcodes()