Skip to content

Instantly share code, notes, and snippets.

View hmbashar's full-sized avatar
🏠
Working from home

Md Abul Bashar hmbashar

🏠
Working from home
View GitHub Profile
@hmbashar
hmbashar / woocommerce.php
Created July 17, 2020 09:07
woocommerce hook order details
<?php
//Using some WC_Order and WC_Abstract_Order methods (example):
// Get an instance of the WC_Order object (same as before)
$order = wc_get_order( $order_id );
$order_id = $order->get_id(); // Get the order ID
$parent_id = $order->get_parent_id(); // Get the parent order ID (for subscriptions…)
$user_id = $order->get_user_id(); // Get the costumer ID
$user = $order->get_user(); // Get the WP_User object
@hmbashar
hmbashar / add-wordpress-settings-page.php
Created April 9, 2020 19:28 — forked from DavidWells/add-wordpress-settings-page.php
WordPress :: Add Settings Page with All Fields
<?php
/*
Plugin Name: Homepage Settings for BigBang
Plugin URI: http://www.inboundnow.com/
Description: Adds additional functionality to the big bang theme.
Author: David Wells
Author URI: http://www.inboundnow.com
*/
// Specify Hooks/Filters
@hmbashar
hmbashar / add new column in post.php
Created April 1, 2020 20:18
How to add column into post list in the wordpress dashboard
// ADD NEW COLUMN
function suga_columns_head($defaults) {
$defaults['featured_image'] = 'Post ID';
return $defaults;
}
// show value in the new column
function suga_columns_content($column_name, $post_ID) {
if ($column_name == 'featured_image') {
echo 'Post ID: <strong>'.get_the_ID().'</strong>';
}
<?php
function nova_allowed_html() {
$allowed_tags = array(
'a' => array(
'class' => array(),
'href' => array(),
'rel' => array(),
'title' => array(),
),
<?php
//comment time ago convert
function varsity_get_comment_time( $comment_id = 0 ){
return sprintf(
_x( '%s ago', 'Human-readable time', 'varsity' ),
human_time_diff(
get_comment_date( 'U', $comment_id ),
current_time( 'timestamp' )
)
);
<?php
/**
* Bangla Date translate class for WordPress
*
* Converts English months, dates to equivalent Bangla digits
* and month names.
*
* @author Tareq Hasan <tareq@wedevs.com>
*/
class WP_BanglaDate {
<?php
class BanglaConverter {
public static $bn = array("১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০");
public static $en = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
public static function bn2en($number) {
return str_replace(self::$bn, self::$en, $number);
}
public static function en2bn($number) {
@hmbashar
hmbashar / menu-class.php
Last active February 22, 2020 08:01
WordPress Menu class edit
<?php
$menu_class_add = wp_nav_menu(array(
'theme_location' => 'main-menu',
'echo' => false,
));
$menu_class = str_replace('menu-item-has-children', 'menu-item-has-children amar-has-children', $menu_class_add);
echo $menu_class;
@hmbashar
hmbashar / cuxtom taxonomy in single.php
Created October 6, 2019 15:16
Show cuxtom taxonomy in the single page for cusotm post type
<?php
$cb_faq_cat = get_the_terms(get_the_ID(), 'cb_faq_cat');
if(is_array($cb_faq_cat)) {
foreach ($cb_faq_cat as $cb_cat) {
echo esc_html($cb_cat->name);
}
}
?>