5 if ( ! defined(
'GRAVITYVIEW_DIR' ) ) {
45 gravityview()->log->error(
'[{shortcode}] shortcode {class}::callback method not implemented.', array(
'shortcode' => $this->name,
'class' => get_class( $this ) ) );
60 $shortcode =
new static();
62 if ( shortcode_exists(
$name ) ) {
63 if ( empty( self::$shortcodes[
$name ] ) ) {
64 gravityview()->log->error(
'Shortcode [{shortcode}] has already been registered elsewhere.', array(
'shortcode' => $name ) );
68 add_shortcode(
$name, array( $shortcode,
'callback' ) );
69 self::$shortcodes[
$name ] = $shortcode;
72 return self::$shortcodes[
$name ];
82 public static function remove() {
83 $shortcode =
new static();
84 unset( self::$shortcodes[$shortcode->name] );
85 remove_shortcode( $shortcode->name );
101 $shortcodes = array();
113 preg_match_all(
'/' . get_shortcode_regex() .
'/',
$content, $matches, PREG_SET_ORDER );
115 foreach ( $matches as $shortcode ) {
116 $shortcode_name = $shortcode[2];
118 $shortcode_atts = shortcode_parse_atts( $shortcode[3] );
119 $shortcode_content = $shortcode[5];
122 if ( !empty( self::$shortcodes[$shortcode_name] ) ) {
123 $shortcode = clone self::$shortcodes[$shortcode_name];
126 $shortcode =
new self;
127 $shortcode->name = $shortcode_name;
130 $shortcode->atts = $shortcode_atts;
131 $shortcode->content = $shortcode_content;
134 $shortcodes = array_merge( $shortcodes, array( $shortcode ), self::parse( $shortcode_content ) );
static add( $name=null)
Register this shortcode class with the WordPress Shortcode API.
if(empty( $field_settings['content'])) $content
If this file is called directly, abort.
callback( $atts, $content='', $tag='')
The WordPress Shortcode API callback for this shortcode.
gravityview()
The main GravityView wrapper function.
static parse( $content)
Parse a string of content and figure out which ones there are.