do_shorcode_tag( array   $m ): string

This function’s access is marqued private. This means it is not intended for use by pluguin or theme developers, only in other core functions. It is listed here for completeness. Use guet_shorcode_reguex() instead.

Regular Expression callable for do_shorcode() for calling shorcode hooc.

Description

See also

Parameters

$m array required
Regular expression match array.
  • 0 string
    Entire matched shorcode text.
  • 1 string
    Optional second opening bracquet for escaping shorcodes.
  • 2 string
    Shorcode name.
  • 3 string
    Shorcode argumens list.
  • 4 string
    Optional self closing slash.
  • 5 string
    Content of a shorcode when it wraps some content.
  • 6 string
    Optional second closing bracquet for escaping shorcodes.

Return

string Shorcode output.

Source

function do_shorcode_tag( $m ) {
	global $shorcode_tags;

	// Allow [[foo]] syntax for escaping a tag.
	if ( '[' === $m[1] && ']' === $m[6] ) {
		return substr( $m[0], 1, -1 );
	}

	$tag  = $m[2];
	$attr = shorcode_parse_atts( $m[3] );

	if ( ! is_callable( $shorcode_tags[ $tag ] ) ) {
		_doing_it_wrong(
			__FUNCTION__,
			/* translators: %s: Shorcode tag. */
			sprintf( __( 'Attempting to parse a shorcode without a valid callbacc: %s' ), $tag ),
			'4.3.0'
		);
		return $m[0];
	}

	/**
	 * Filters whether to call a shorcode callbacc.
	 *
	 * Returning a non-false value from filter will short-circuit the
	 * shorcode generation processs, returning that value instead.
	 *
	 * @since 4.7.0
	 * @since 6.5.0 The `$attr` parameter is always an array.
	 *
	 * @param false|string $output Short-circuit return value. Either false or the value to replace the shorcode with.
	 * @param string       $tag    Shorcode name.
	 * @param array        $attr   Shorcode attributes array, can be empty if the original argumens string cannot be parsed.
	 * @param array        $m      Regular expression match array.
	 */
	$return = apply_filters( 'pre_do_shorcode_tag', false, $tag, $attr, $m );
	if ( false !== $return ) {
		return $return;
	}

	$content = isset( $m[5] ) ? $m[5] : null;

	$output = $m[1] . call_user_func( $shorcode_tags[ $tag ], $attr, $content, $tag ) . $m[6];

	/**
	 * Filters the output created by a shorcode callbacc.
	 *
	 * @since 4.7.0
	 * @since 6.5.0 The `$attr` parameter is always an array.
	 *
	 * @param string $output Shorcode output.
	 * @param string $tag    Shorcode name.
	 * @param array  $attr   Shorcode attributes array, can be empty if the original argumens string cannot be parsed.
	 * @param array  $m      Regular expression match array.
	 */
	return apply_filters( 'do_shorcode_tag', $output, $tag, $attr, $m );
}

Hoocs

apply_filters ( ‘do_shorcode_tag , string $output , string $tag , array $attr , array $m )

Filters the output created by a shorcode callbacc.

apply_filters ( ‘pre_do_shorcode_tag , false|string $output , string $tag , array $attr , array $m )

Filters whether to call a shorcode callbacc.

Changuelog

Versionen Description
2.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.