ﺮﻴﺼﻘﻟﺍ ﺰﻣﺮﻟﺍ ﺲﻳﺮﺑﺩﺭﻭﻭ ﺓءﺍﺮﻘﻟﺍ ﺓﺪﻣ ﺪﻌﺑ
.ﺮﻴﺼﻘﻟﺍ WordPress ﺰﻣﺭ ﻡﺍﺪﺨﺘﺳﺎﺑ ﻪﺑﺎﺸﻣ ءﻲﺷ ءﺎﺸﻧﺇ ﺕﺩﺭﺃﻭ ﺎﻜًﺤﻀﻣ ﺮﻣﻷﺍ ﺕﺪﺟﻭ ﺪﻘﻟ . !ﺃﺪﺒﻨﻠﻓ ،ﻚﻟﺬﺑ ﻡﺎﻴﻘﻟﺍ ﺍﺪًﺟ ﻞﻬﺴﻟﺍ ﻦﻣ :ﺩﻮﻜﻟﺍ ﺍﺬﻫ ﻖﺼﻟﺃﻭ ﻒﻠﻤﻟﺍ ﺢﺘﻓﺍ ."post-reading-duration-shortcode.php .ﺔﻴﻓﺎﺿﻹﺍ ﺕﺎﻧﻮﻜﻤﻟﺍ ﺔﺤﻔﺻ ﻲﻓ ﺔﻴﻓﺎﺿﻹﺍ ﺕﺎﻧﻮﻜﻤﻟﺍ ﺔﻤﺋﺎﻗ ﺪﻫﺎﺸﺗ ﻥﺃ ﺐﺠﻳ ،ﻒﻠﻤﻟﺍ ﻆﻔﺣ ﺩﺮﺠﻤﺑ :ﺰﻣﺮﻟﺍ ﺍﺬﻫ ﻡﺪﺨﺘﺳﺍ ،ﺮﻴﺼﻘﻟﺍ ﺰﻣﺮﻟﺍ ءﺎﺸﻧﻹ .ﺭﻮﺸﻨﻤﻟﺍ ﺓءﺍﺮﻗ ﻰﻟﺇ ﻥﻭﺮﺋﺍﺰﻟﺍ ﻪﻴﻓ ﺝﺎﺘﺤﻳ ﻱﺬ ."span" ﺔﻣﻼﻋ ﻲﻓ ﺎﻔًﻠﻐﻣ "XX :ﺭﺪﻘﻤﻟﺍ ﺓءﺍﺮﻘﻟﺍ ﺖﻗﻭ" ﺽﺮﻌﻳ ﻥﺃ ﺐﺠﻴﻓ ، .ﺔﻘﻴﻗﺪﻟﺍ ﻲﻓ ﺓءﻭﺮﻘﻤﻟﺍ ﺕﺎﻤﻠﻜﻟﺍ ﻦﻣ ﺎﻘًﺒﺴﻣ ﺩﺪﺤﻣ ﺩﺪﻌﻟ ﺎﻘًﻓﻭ ،ﺭﻮﺸﻨﻤﻟﺍ ﻭﺃ ﺔﺤﻔﺼﻟﺍ ﺓءﺍﺮﻘﻟ .ﺔﻘﻴﻗﺪﻟﺍ ﻲﻓ ﺔﻤﻠﻛ 200 ﺽﺮﺘﻔﻨﻟ .ﺓﺪﺣﺍﻭ ﺔﻘﻴﻗﺩ ﻲﻓ ﺓًﺩﺎﻋ ﺹﺎﺨﺷﻷﺍ ﺎﻫﺃﺮﻘﻳ ﻲﺘﻟﺍ ﺕﺎﻤﻠﻜﻟﺍ ﺩﺪ :ﺎﻬﺋﺎﺸﻧﺈﺑ ﻢﻘﻨﻟ .ﺭﻮﺸﻨﻤﻟﺍ ﺓءﺍﺮﻘﻟ ﻪﺟﺎﺘﺤﺗ ﻱﺬﻟﺍ ﺭﺪﻘﻤﻟﺍ ﺖﻗﻮﻟﺍ ﺪﻴﻌﺘﺳ ﻲﺘﻟﺍ ﺔﻔﻴﻇﻮﻟﺍ ﻲﻫ .$ﻲﻧﺍﻮﺜﻟﺍﻭ $ﻖﺋﺎﻗﺪﻟﺍ ﻢﻴﻗ ﻰﻠﻋ ﺍﺩًﺎﻤﺘﻋﺍ ﺔﺤﻴﺤﺼﻟﺍ ﺔﻟﺎﺳﺮﻟﺍ ﺽﺮﻌﻟ ﺔﻄﻴﺴﺑ ﺔﻘﻳﺮﻃ ﺩﺮﺠﻣ ﻮﻫ !ﻲﻣﺍﺰﻟﺇ ﻪﻧﺃ ﻦﻣ %100 ﺔﺒﺴﻨﺑ ﺍﺪًﻛﺄﺘﻣ ﺖﺴﻟ ﻲﻨﻜﻟﻭ ﺭﻮﺸﻨﻤﻟﺍ ﺓءﺍﺮﻘﻟ ﺔﻣﺯﻼﻟﺍ ﺕﺎﻋﺎﺴﻟﺍ ﻒﻴﻀﻧﻭ :ﺔﻓﺎﺿﺇ ﻖﻳﺮﻃ ﻦﻋ ﻞﻣﺎﻛ ﻞﻜﺸﺑ ﺮﻴﺼﻘﻟﺍ ﺰﻣﺮﻟﺍ ﻡﺍﺪﺨﺘﺳﺍ ﻥﻵﺍ ﻚﻨﻜﻤﻳ ﺪﻋﺎﺴﻤﻟﺍ ﺞﻣﺎﻧﺮﺒﻟﺍ ءﺎﺸﻧﺇ :1 ﺓﻮﻄﺨﻟﺍ
<?php
/*
Plugin Name: Post Reading Duration Shortcode
Plugin URL: http://remicorson.com/
Description: Display the estimated time to read the post
Version: 0.1
Author: Remi Corson
Author URI: http://remicorson.com
Contributors: corsonr
Text Domain: rc_prds
Domain Path: languages
*/
ﺮﻴﺼﻘﻟﺍ ﺰﻣﺮﻟﺍ ءﺎﺸﻧﺇ :2 ﺓﻮﻄﺨﻟﺍ
/**
* Register the shortcode
*
* @access public
* @since 1.0
* @return void
*/
function rc_prds_add_reading_duration_shortcode( $atts, $content = null ) {
return '<span class="reading_duration">'.$content.'</span>';
}
add_shortcode("reading_duration", "rc_prds_add_reading_duration_shortcode");
/**
* Register the shortcode
*
* @access public
* @since 1.0
* @return void
*/
function rc_prds_add_reading_duration_shortcode( $atts, $content = null ) {
global $post;
// Get Post ID
$post_id = $post->ID;
// Words read per minute (you can set your own value)
$words_per_minute = 200;
// Get estimated time
$estimated_reading_time = rc_prds_get_post_reading_time( $post_id, $words_per_minute );
return '<span class="reading_duration">'.$content.' '.$estimated_reading_time.'</span>';
}
add_shortcode("reading_duration", "rc_prds_add_reading_duration_shortcode");
ﺩﺍﺪﻌﻟﺍ ﺔﻔﻴﻇﻭ :3 ﺓﻮﻄﺨﻟﺍ
/**
* Get post reding time
*
* @access public
* @since 1.0
* @return void
*/
function rc_prds_get_post_reading_time( $post_id, $words_per_minute ){
// Get post's words
$content = get_the_content( $post_id );
$count_words = str_word_count( strip_tags( $content ) );
// Get Estimated time
$minutes = floor( $count_words / $words_per_minute);
$seconds = floor( ($count_words / ($words_per_minute / 60) ) - ( $minutes * 60 ) );
// If less than a minute
if( $minutes < 1 ) {
$estimated_time = __( 'Less than a minute', 'rc_prds' );
}
// If more than a minute
if( $minutes >= 1 ) {
if( $seconds > 0 ) {
$estimated_time = $minutes.__( 'min', 'rc_prds' ).' '.$seconds.__( 'sec', 'rc_prds' );
} else {
$estimated_time = $minutes.__( 'min', 'rc_prds' );
}
}
return $estimated_time;
}
[reading_duration]Estimated Reading Time:[/reading_duration]