Support » Plugin: Prosodia VGW OS » Shortcode mit Zeichenanzahl

  • Resolved Sebastian

    (@rockbaer)


    Manchmal böte es sich an, auch innerhalb des Artikels und nicht nur im Backend die Zeichenanzahl darzustellen. Da diese ja ohnehin schon berechnet wird, könntet ihr vielleicht freundlicherweise auch einen Shortcode à la [vgwort] anbieten?

    Was zusätlich klasse wäre: Optionen für diesen Shortcode. Für einen Teaser oder auch bei Paidcontent wäre es für “einfache” Leser gut, sie auf die Länge hinzuweisen, ggf. um einen Preis oder einen Klick zu rechtfertigen.

    Denkbar: “Dieser Artikel hat eine Länge von 8.000 Zeichen (inkl. Leerzeichen) bzw. 1.300 Wörtern und entspricht damit etwa 2 DIN A4-Seiten.” Das könnte man ja recht simpel handhaben, z.B. [wgwort option=”1″] oder so ähnlich.

    Auch wenn das mit den Optionen sicher etwas komplexer wäre, die reine Ausgabe der Zeichenanzahl wäre schon prima!

    Beste Grüße
    Sebastian

    https://wordpress.org/plugins/wp-vgwort/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Dr. Ronny Harbich

    (@raubvogel)

    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

    Thread Starter Sebastian

    (@rockbaer)

    Ach, klasse. Danke! 🙂

    Plugin Author Dr. Ronny Harbich

    (@raubvogel)

    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

    Thread Starter Sebastian

    (@rockbaer)

    Hi Ronny! Großartig! Hab vielen Dank dafür. Ich werde das in den kommenden Tagen/Wochen mal genauer anschauen. Sebastian

    Thread Starter Sebastian

    (@rockbaer)

    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.

    Plugin Author Dr. Ronny Harbich

    (@raubvogel)

    Pardon, nur kurz: In Ordnung, ich werde das in den kommenden Tagen umsetzen …

    Plugin Author Dr. Ronny Harbich

    (@raubvogel)

    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.
     */
    Thread Starter Sebastian

    (@rockbaer)

    Großartige Arbeit! Besten Dank und herzliche Grüße, Sebastian

    Plugin Author Dr. Ronny Harbich

    (@raubvogel)

    Gerne 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Shortcode mit Zeichenanzahl’ is closed to new replies.