Overview

Namespaces

  • None
  • Xmf
    • Database
    • Module
      • Helper
    • Template
  • Xoops
    • Auth
    • Core
      • Cache
      • Database
        • Logging
        • Schema
      • Exception
      • Handler
        • Scheme
      • Kernel
        • Dtype
        • Handlers
        • Model
      • Lists
      • Locale
        • Punic
      • Service
        • Contract
      • Session
      • Text
        • Sanitizer
          • Extensions
      • Theme
        • Plugins
    • Form
    • Html
    • Locale
    • Module
      • Helper
      • Plugin

Classes

  • Sanitizer
  • ShortCodes
  • Overview
  • Namespace
  • Class
  • Tree

Class ShortCodes

WordPress style ShortCodes This is taken from https://github.com/Badcow/Shortcodes where it was described as:

This is a port of WordPress' brilliant shortcode feature for use outside of WordPress. The code has remained largely unchanged

WordPress, source of the original code, wp-includes/shortcodes.php, is licensed under the GPL

Namespace: Xoops\Core\Text
Package: Xoops\Core\Text
Category: Sanitizer\ShortCodes
License: GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
Author: Sam Williams sam@swilliams.com.au
Link: https://github.com/Badcow/Shortcodes
Link: https://github.com/WordPress/WordPress/blob/master/wp-includes/shortcodes.php
Located at oops_lib/Xoops/Core/Text/ShortCodes.php
Methods summary
public
# addShortcode( string $tag, callable $function )

add a shortcode to the active set

add a shortcode to the active set

Parameters

$tag
shortcode name
$function
shortcode processor

Throws

ErrorException
public
# removeShortcode( string $tag )

remove shortcode from the active set

remove shortcode from the active set

Parameters

$tag
short code tag
public array
# getShortcodes( )

get the current shortcode set

get the current shortcode set

Returns

array
of tag => callable
public boolean
# hasShortcode( string $shortcode )

Check if a shortcode is defined

Check if a shortcode is defined

Parameters

$shortcode
shortcode tag

Returns

boolean
true is shortcode is defined in the active set
public boolean
# contentHasShortcode( string $content, string $tag )

Tests whether content has a particular shortcode

Tests whether content has a particular shortcode

Parameters

$content
content to check
$tag
tag to look for

Returns

boolean
true if tag is used in content, otherwise false
public string
# process( string $content )

Search content for shortcodes and filter shortcodes through their hooks.

Search content for shortcodes and filter shortcodes through their hooks.

If there are no shortcode tags defined, then the content will be returned without any filtering. This might cause issues when plugins are disabled but the shortcode will still show up in the post or content.

Parameters

$content
Content to search for shortcodes

Returns

string
Content with shortcodes filtered out.
public string
# stripAllShortcodes( string $content )

Remove all shortcode tags from the given content.

Remove all shortcode tags from the given content.

Parameters

$content
Content to remove shortcode tags.

Returns

string
Content without shortcode tags.
public array
# shortcodeAttributes( array $defaults, array $attributes )

Combine user attributes with known attributes and fill in defaults when needed.

Combine user attributes with known attributes and fill in defaults when needed.

The $defaults should be considered to be all of the attributes which are supported by the caller and given as a list. The returned attributes will only contain the attributes in the $defaults list.

If the $attributes list has unsupported attributes, then they will be ignored and removed from the final returned list.

Parameters

$defaults
Entire list of supported attributes and their defaults.
$attributes
User defined attributes in shortcode tag.

Returns

array
Combined and filtered attribute list.
API documentation generated by ApiGen