Hallo, Sebastian,
das sollte recht leicht umzusetzen sein. Ich werde mich die kommenden Tage daransetzen. Ich melde mich dann wieder.
Schöne Grüße
Ronny
Hallo, Sebastian,
ich bin nun soweit fertig. Der Shortcode heißt [pvgw_post_stats]
. Ich muss noch eine Anleitung dafür schreiben. Damit Du den Shortcode allerdings schon verwenden kannst, hier die Dokumentation aus dem Source Code dazu:
/**
* Shortcode that returns the post stats, e. g. post character count, according to the specified attributes: [pvgw_post_stats]
* Called by WordPress if a post stats shortcode should be resolved.
* Warning: This function is called by a WordPress hook. Do not call it directly.
*
* @param array $attributes Attributes of the post stats shortcode: array(
* 'post_id' => int A post ID to get the stats for or null for the current post (optional, default is null),
* 'formatted' => bool Whether the output number will be language formatted (optional, default is true),
* 'decimals' => int The number of decimal places the outputted number will have (optional, default is 0),
* 'text' => string A text that contain %1$s that is replaced by the number of characters and %2$s that is replaced by the number of standard pages (aka Normseiten) (optional, default is text from settings),
* 'type' => string The type of the output: 'character-count' is the number of characters, 'standard-page-count' is the number of standard pages (aka Normseiten), 'text' is the string given in the attribute 'text' (optional, default ist 'character-count').
* )
* @param null $content The content between opening and closing tag.
*
* @return float|string Returns the post stats, e. g. post character count, according to the specified attributes.
*/
Hoffe, das hilft zunächst.
Wenn Du im Übrigen gedenkst, den Shortcode bei jedem Beitrag einzusetzen, wäre es wohl sinnvoller den Shortcode direkt in Deinem Theme oder Post Template auszuführen – sonst müsstest Du ihn jedes Mal manuell einfügen …
Schöne Grüße
Ronny
Hi Ronny! Großartig! Hab vielen Dank dafür. Ich werde das in den kommenden Tagen/Wochen mal genauer anschauen. Sebastian
Ein Punkt vielleicht schon mal: Für $standardPageCount berechnest Du 1500 Zeichen. Das ist natürlich recht knapp. Selbst für eine normale Buchseite kalkulieren die Verlage 1800 Zeichen inklusive Leerzeiuchen. Für eine DIN A4-Seite (Arial, Schrifgröße 12, einfacher Zeilenabstände, 2 Absätze) sind’s dann schon mal mehr als 4.000 Zeichen.
Ich weiß, Du nimmst für die Berechnung die Normseite, wie sie die VG Wort vorschreibt. Das Ziel des Shortcodes und die Einbindung in einen Artikel ist allerdings weniger der Admin oder der Experte, der sich damit auskennt, sondern der “einfache” Leser – und der kann damit wenig anfangen. Wenn man ihm aber (z.B. im Teaser für einen kostenpflichtigen Artikel) mitteilt, dass der Artikel eine Länger von 4 Buchseiten oder 2 DIN A4-Seiten hat, kann er das schon eher abschätzen.
Daher möchte ich vorschlagen, dass Du die Zahl als Setting zur Wahl stellst (vielleicht als Hilfe ergänzend die Angabge der Zeichenanzahl für Normseiten, Buchseiten und DIN A4-Seiten).
Außerdem vielleicht noch auf eine halbe Seite runden: Also “4,5 Seiten” bei “4,3”… und “4” Seiten bei “4,24”… und “5” Seiten bei “4,76”. Bei DINA4-Seiten macht das ja schon was aus.
Pardon, nur kurz: In Ordnung, ich werde das in den kommenden Tagen umsetzen …
Mit der aktuellen Version 3.8.0 ist gewünschtes nun umgesetzt 🙂 Hier die aktuelle technische Dokumentation dazu:
/**
* Shortcode that returns the post stats, e. g. post character count, according to the specified attributes: [pvgw_post_stats]
* Called by WordPress if a post stats shortcode should be resolved.
* Warning: This function is called by a WordPress hook. Do not call it directly.
*
* @param array $attributes Attributes of the post stats shortcode: array(
* 'post_id' => int A post ID to get the stats for or null for the current post (optional, default is null),
* 'formatted' => bool Whether the output number will be language formatted; implies round=true (optional, default is true),
* 'decimals' => int The number of decimal places the outputted number will have (optional, default is 0),
* 'round' => bool Whether to to round numbers or not (optional, default is false),
* 'round_half' => bool Whether to round numbers to half values (only if round is true), i. e., 1.00 – 1.24 to 1.0, 1.25 – 1.74 to 1.5 and 1.75 – 1.99 to 2.0 (optional, default is false),
* 'page_count_divisor' => int The divisor to calculate the custom page count (custom page count = character count / page count divisor) (optional, default is 1800),
* 'text' => string A text that contain %1$s that is replaced by the number of characters and %2$s that is replaced by the number of standard pages (aka Normseiten), %3$s that is replaced by the number of custom pages (optional, default is taken from settings),
* 'type' => string The type of the output: 'character-count' is the number of characters, 'standard-page-count' is the number of standard pages (aka Normseiten), 'custom-page-count' is the number of pages by custom divisor, 'text' is the string given in the attribute 'text' (optional, default ist 'character-count').
* )
* @param null $content The content between opening and closing tag.
*
* @return float|string Returns the post stats, e. g. post character count, according to the specified attributes.
*/
Großartige Arbeit! Besten Dank und herzliche Grüße, Sebastian