Below, you’ll find a detailed guide on how to add the Bangla Date Display Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Bangla Date Display Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Bangla Date Display Plugin and the shortcodes it provides:
"Bangla Date Display is a unique WordPress plugin that transforms your website's default date format into the Bangla calendar system. Perfect for engaging your Bangla-speaking audience."
- [bangla_time]
- [bangla_day]
- [bangla_date]
- [bddp_bn_season]
- [english_date]
- [hijri_date]
Bangla Date Display [bangla_time] Shortcode
The Bangla Date Display shortcode is a PHP function that outputs the current time in a Bangla format. This function checks the current time and translates it into specific Bangla periods of the day, such as “ভোর” for morning or “রাত” for night. The resulting time is then displayed in Bangla notation.
Shortcode: [bangla_time]
Examples and Usage
Basic Example – Displaying the Bangla time on your website.
[bangla_time /]
PHP Function Code
In case you have difficulties debugging what causing issues with [bangla_time]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('bangla_time', 'render_bangla_clock');
Shortcode PHP function:
function render_bangla_clock() {
$bddp_options = get_option( "bddp_options" );
$offset = isset($bddp_options['en_tz']) ? $bddp_options['en_tz']*60*60 : 21600;
$hour = gmdate("G", time()+$offset);
if ( $hour >= 5 && $hour <= 5 ) {
$event = "ভোর ";
} else if ( $hour >= 6 && $hour <= 11 ) {
$event = "সকাল ";
} else if ( $hour >= 12 && $hour <= 14 ) {
$event = "দুপুর ";
} else if ( $hour >= 15 && $hour <= 17 ) {
$event = "বিকাল ";
} else if ( $hour >= 18 && $hour <= 19 ) {
$event = "সন্ধ্যা ";
} else {
$event = "রাত ";
}
ob_start(); // begin output buffering
echo $event.en_to_bn(gmdate("g:i", time()+$offset));
$output = ob_get_contents(); // end output buffering
ob_end_clean(); // grab the buffer contents and empty the buffer
return $output;
}
Code file location:
bangla-date-display/bangla-date-display/bangla-date-display.php
Bangla Date Display [bangla_day] Shortcode
The Bangla Day shortcode is a feature of the bangla-date-display plugin. It displays the current day in Bangla. The shortcode uses the ‘render_bangla_day’ function. It retrieves timezone settings from the plugin options, calculates the offset, and converts the current day to Bangla.
Shortcode: [bangla_day]
Examples and Usage
Basic example – Display the current day in Bangla language using the shortcode ‘bangla_day’.
[bangla_day /]
PHP Function Code
In case you have difficulties debugging what causing issues with [bangla_day]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('bangla_day', 'render_bangla_day');
Shortcode PHP function:
function render_bangla_day() {
ob_start(); // begin output buffering
$bddp_options = get_option( "bddp_options" );
$offset = isset($bddp_options['en_tz']) ? $bddp_options['en_tz']*60*60 : 21600;
return en_to_bn(gmdate("l", time()+$offset));
$output = ob_get_contents(); // end output buffering
ob_end_clean(); // grab the buffer contents and empty the buffer
return $output;
}
Code file location:
bangla-date-display/bangla-date-display/bangla-date-display.php
Bangla Date Display [bangla_date] Shortcode
The Bangla Date Display shortcode translates the date into Bangla format. It uses an array to convert day numbers into Bangla equivalents. The shortcode also includes options for date separators and suffixes.
Shortcode: [bangla_date]
Examples and Usage
Basic example – Display the current date in Bangla on your website.
[bangla_date /]
PHP Function Code
In case you have difficulties debugging what causing issues with [bangla_date]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('bangla_date', 'render_bangla_date');
Shortcode PHP function:
function render_bangla_date() {
$day_number = array( "১" => "১লা", "২" => "২রা", "৩" => "৩রা", "৪" => "৪ঠা", "৫" => "৫ই", "৬" => "৬ই", "৭" => "৭ই", "৮" => "৮ই", "৯" => "৯ই", "১০" => "১০ই", "১১" => "১১ই", "১২" => "১২ই", "১৩" => "১৩ই", "১৪" => "১৪ই", "১৫" => "১৫ই", "১৬" => "১৬ই", "১৭" => "১৭ই", "১৮" => "১৮ই", "১৯" => "১৯শে", "২০" => "২০শে", "২১" => "২১শে", "২২" => "২২শে", "২৩" => "২৩শে", "২৪" => "২৪শে", "২৫" => "২৫শে", "২৬" => "২৬শে", "২৭" => "২৭শে", "২৮" => "২৮শে", "২৯" => "২৯শে", "৩০" => "৩০শে", "৩১" => "৩১শে" );
$bddp_options = get_option("bddp_options");
if (!is_array($bddp_options)) {
$bddp_options = array(
'separator' => ', ',
'last_word' => '1',
'ord_suffix' => '1'
);
}
$dt_change = isset($bddp_options['dt_change']) ? $bddp_options['dt_change'] : 0;
$separator = isset($bddp_options['separator']) ? $bddp_options['separator'] : ', ';
$last_word = isset($bddp_options['last_word']) ? " বঙ্গাব্দ" : "";
$offset = isset($bddp_options['bangla_tz']) ? $bddp_options['bangla_tz']*60*60 : 21600;
$timestamp = time()+$offset;
$banglaDate = new BanglaDate($timestamp, $dt_change);
$the_date = $banglaDate->get_date();
$day = isset($bddp_options['ord_suffix']) ? $day_number[$the_date[0]] : $the_date[0];
$month_year = $the_date[1].$separator.$the_date[2];
ob_start(); // begin output buffering
echo $day.' '.$month_year.$last_word;
$output = ob_get_contents(); // end output buffering
ob_end_clean(); // grab the buffer contents and empty the buffer
return $output;
}
Code file location:
bangla-date-display/bangla-date-display/bangla-date-display.php
Bangla Date Display [bddp_bn_season] Shortcode
The Bangla Date Display plugin shortcode, ‘bangla_season’, is designed to display the current season in Bangla based on the Bangla calendar. The PHP code for this shortcode calculates the current Bangla month and then returns the corresponding season in Bangla. The timezone offset is adjustable, allowing for accurate season display.
Shortcode: [bddp_bn_season]
Examples and Usage
Basic example – The shortcode [bangla_season] can be used to display the current Bangla season based on the Bangla month. The shortcode does not require any parameters or attributes, as it will automatically fetch the current date and calculate the corresponding Bangla season.
[bangla_season]
PHP Function Code
In case you have difficulties debugging what causing issues with [bddp_bn_season]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('bangla_season', 'bddp_bn_season');
Shortcode PHP function:
function bddp_bn_season() {
ob_start(); // begin output buffering
$bddp_options = get_option( "bddp_options" );
$offset = isset($bddp_options['bangla_tz']) ? $bddp_options['bangla_tz']*60*60 : 21600;
$banglaDate = new BanglaDate(time()+$offset, 0);
$month = $banglaDate->get_date()[1];
if ( $month == "বৈশাখ" || $month == "জ্যৈষ্ঠ" ) {
return "গ্রীষ্মকাল";
} else if ( $month == "আষাঢ়" || $month == "শ্রাবণ" ) {
return "বর্ষাকাল";
}
else if ( $month == "ভাদ্র" || $month == "আশ্বিন" ) {
return "শরৎকাল";
}
else if ( $month == "কার্তিক" || $month == "অগ্রহায়ণ" ) {
return "হেমন্তকাল";
}
else if ( $month == "পৌষ" || $month == "মাঘ" ) {
return "শীতকাল";
}
else {
return "বসন্তকাল";
}
$output = ob_get_contents(); // end output buffering
ob_end_clean(); // grab the buffer contents and empty the buffer
return $output;
}
Code file location:
bangla-date-display/bangla-date-display/bangla-date-display.php
Bangla Date Display [english_date] Shortcode
The Bangla Date Display shortcode ‘english_date’ converts the current Gregorian date into a Bangla formatted date. It adjusts time zone, includes ordinal suffixes, and offers customization options.
Shortcode: [english_date]
Examples and Usage
Basic example – The shortcode can be used to display the current Gregorian date in Bangla.
[english_date /]
PHP Function Code
In case you have difficulties debugging what causing issues with [english_date]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('english_date', 'render_gregorian_date');
Shortcode PHP function:
function render_gregorian_date() {
$bddp_options = get_option("bddp_options");
$bddp_options = get_option("bddp_options");
if (!is_array($bddp_options)) {
$bddp_options = array(
'separator' => ', ',
'last_word' => '1',
'ord_suffix' => '1'
);
}
$separator = isset($bddp_options['separator']) ? $bddp_options['separator'] : ', ';
$last_word = isset($bddp_options['last_word']) ? " খ্রিস্টাব্দ" : "";
$day_number = array( "1" => "১লা", "2" => "২রা", "3" => "৩রা", "4" => "৪ঠা", "5" => "৫ই", "6" => "৬ই", "7" => "৭ই", "8" => "৮ই", "9" => "৯ই", "10" => "১০ই", "11" => "১১ই", "12" => "১২ই", "13" => "১৩ই", "14" => "১৪ই", "15" => "১৫ই", "16" => "১৬ই", "17" => "১৭ই", "18" => "১৮ই", "19" => "১৯শে", "20" => "২০শে", "21" => "২১শে", "22" => "২২শে", "23" => "২৩শে", "24" => "২৪শে", "25" => "২৫শে", "26" => "২৬শে", "27" => "২৭শে", "28" => "২৮শে", "29" => "২৯শে", "30" => "৩০শে", "31" => "৩১শে" );
ob_start(); // begin output buffering
$offset = isset($bddp_options['en_tz']) ? $bddp_options['en_tz']*60*60 : 21600;
$date = explode(' ', gmdate( "j F Y", time()+$offset ));
$day = isset($bddp_options['ord_suffix']) ? $day_number[$date[0]] : en_to_bn($date[0]);
$month_year = en_to_bn($date[1].$separator.$date[2]);
echo $day.' '.$month_year.$last_word;
$output = ob_get_contents(); // end output buffering
ob_end_clean(); // grab the buffer contents and empty the buffer
return $output;
}
Code file location:
bangla-date-display/bangla-date-display/bangla-date-display.php
Bangla Date Display [hijri_date] Shortcode
The ‘hijri_date’ shortcode from the Bangla Date Display plugin is used to display the current date in the Hijri calendar format. It adjusts the timezone and date as per the plugin settings.
Shortcode: [hijri_date]
Examples and Usage
Basic example – Displaying the Hijri date using the shortcode
[hijri_date /]
PHP Function Code
In case you have difficulties debugging what causing issues with [hijri_date]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('hijri_date', 'render_hijri_date');
Shortcode PHP function:
function render_hijri_date() {
$bddp_options = get_option( "bddp_options" );
if ( !is_array( $bddp_options ) ) {
$bddp_options = array(
'hijri_tz' => '6',
'hijri_adjust' => '0',
'separator' => ', ',
'last_word' => '1',
'ord_suffix' => '1' );
}
if(!array_key_exists('hijri_tz', $bddp_options)) {
$bddp_options['hijri_tz'] = 6;
}
$last_word = isset($bddp_options['last_word']) ? " হিজরি" : "";
$d = new uCal;
$day_number = array( "1" => "১লা", "2" => "২রা", "3" => "৩রা", "4" => "৪ঠা", "5" => "৫ই", "6" => "৬ই", "7" => "৭ই", "8" => "৮ই", "9" => "৯ই", "10" => "১০ই", "11" => "১১ই", "12" => "১২ই", "13" => "১৩ই", "14" => "১৪ই", "15" => "১৫ই", "16" => "১৬ই", "17" => "১৭ই", "18" => "১৮ই", "19" => "১৯শে", "20" => "২০শে", "21" => "২১শে", "22" => "২২শে", "23" => "২৩শে", "24" => "২৪শে", "25" => "২৫শে", "26" => "২৬শে", "27" => "২৭শে", "28" => "২৮শে", "29" => "২৯শে", "30" => "৩০শে", "31" => "৩১শে" );
$month_name = array( "Muh" => "মহর্রম", "Saf" => "সফর", "Rb1" => "রবিউল আউয়াল", "Rb2" => "রবিউস সানি", "Jm1" => "জমাদিউল আউয়াল", "Jm2" => "জমাদিউস সানি", "Raj" => "রজব", "Shb" => "শাবান", "Rmd" => "রমজান", "Shw" => "শাওয়াল", "DhQ" => "জিলকদ", "DhH" => "জিলহজ" );
$separator = isset($bddp_options['separator']) ? $bddp_options['separator'] : ', ';
$offset = ($bddp_options['hijri_adjust']*60*60) + ($bddp_options['hijri_tz']*60*60);
$timestamp = strtotime(gmdate('Y-m-d', time()+$offset));
$date = explode(' ', $d->date( "j M Y", $timestamp));
$day = isset($bddp_options['ord_suffix']) ? $day_number[$date[0]] : en_to_bn($date[0]);
$month_year = $month_name[$date[1]].$separator.en_to_bn($date[2]);
ob_start(); // begin output buffering
echo $day.' '.$month_year.$last_word;
$output = ob_get_contents(); // end output buffering
ob_end_clean(); // grab the buffer contents and empty the buffer
return $output;
}
Code file location:
bangla-date-display/bangla-date-display/bangla-date-display.php
Conclusion
Now that you’ve learned how to embed the Bangla Date Display Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply