پیشنمایش شورتکد
نمونهٔ خروجی برای نوشتهای با ۳۵۰ کلمه.
2 minشروع کار
از وردپرس محلی استفاده کن. plugin.zip را از بخش افزودن افزونه نصب و فعال کن. شورتکد را به یک نوشتهٔ آزمایشی اضافه کن.
[betavan_reading_time] سازگاری و بازبینی
از دادهٔ ساختگی استفاده کن و پیش از تغییر نمونه، عملکردش را در ابزار خودت بررسی کن.
فایلهای منبع
محتوای اصلی را بررسی کن و هر فایل را جداگانه دریافت کن.
<?php
/**
* Plugin Name: Betavan Reading Time Demo
* Description: Adds an estimated reading time through the [betavan_reading_time] shortcode.
* Version: 0.1.0
* License: MIT
*/
if (!defined("ABSPATH")) { exit; }
add_shortcode("betavan_reading_time", function () {
$post = get_post();
if (!$post) { return ""; }
$content = wp_strip_all_tags(strip_shortcodes($post->post_content));
$words = preg_split("/\s+/u", trim($content), -1, PREG_SPLIT_NO_EMPTY);
$minutes = max(1, (int) ceil(count($words ?: []) / 220));
return esc_html((string) $minutes) . " min";
});
Reading Time Shortcode
Install the ZIP on a local WordPress site and add [betavan_reading_time] to a test post. It estimates reading time at 220 words per minute.
ZIP را روی وردپرس محلی نصب کن و شورتکد را به نوشتهٔ آزمایشی اضافه کن. سرعت مبنا ۲۲۰ کلمه در دقیقه است.
MIT · Betavan demo.
مارکداون خام
# Reading Time Shortcode
Install the ZIP on a local WordPress site and add [betavan_reading_time] to a test post. It estimates reading time at 220 words per minute.
ZIP را روی وردپرس محلی نصب کن و شورتکد را به نوشتهٔ آزمایشی اضافه کن. سرعت مبنا ۲۲۰ کلمه در دقیقه است.
MIT · Betavan demo.