Hallo, Sebastian,
eigentlich sollte das Plugin nur die Shortcode-Tags ?l?schen“ und nicht den Inhalt zwischen ihnen. Der Code zur Berechnung ist der:
/**
* @var string Regex that matches shortcodes, but not content between shortcodes. It is escaping aware.
*/
$shortcodeRegex = '/(?<!\[)\[[^\[\]]+\](?!\])/i';
/**
* @var string Regex that matches the caption shortcode and its content. It is escaping aware.
*/
$captionShortcodeRegex = '%(?<!\[)\[caption\s.*?\[/caption\](?!\])%i';
// replace <br> tags by new lines (\n)
$post_content = preg_replace(
'%<br\s*/?>%si',
"\n",
$post_content
);
// remove all HTML tags, but not the content between the tags;
$post_content = strip_tags( $post_content );
// remove whitespaces from the beginning and end
$post_content = trim( $post_content );
// remove shortcodes and whitespaces sequences
$post_content = preg_replace( array(
WPVGW_Helper::$captionShortcodeRegex, // remove caption shortcodes and its content
WPVGW_Helper::$shortcodeRegex, // remove shortcodes, but not content between shortcodes; it is escaping aware
'/\s{2,}/i' // remove sequences of 2 or more whitespaces
),
array(
'',
'',
' '
),
$post_content
);
// convert html entities (e. g. & to &)
$post_content = html_entity_decode( $post_content );
// return the number of characters of the cleaned post content
return ( mb_strlen( $post_title ) + mb_strlen( $post_content ) );
K?nntest Du mir bitte ein Beispiel von Dir schicken, bei dem es nicht korrekt funktioniert? Gerne auch an developer<AT-ZEICHEN-EINFüGEN>prosodia.de
Sch?ne Grü?e
Ronny