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 add to card text change with multi lang.php
Created May 22, 2021 23:43
woocommerce add to card text change with multi language
/**
* custom_woocommerce_template_loop_add_to_cart
*/
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
function custom_woocommerce_product_add_to_cart_text() {
global $product;
$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$text = "View Product";
@hmbashar
hmbashar / Show total sales on woocommerce.php
Created July 20, 2020 16:58
Show total sales on woocommerce
<?php
/**
* @snippet Show Total Sales
* @how-to Get CustomizeWoo.com FREE
* @author Md Abul Bashar
* @compatible Woo 3.7+
*/
add_action( 'woocommerce_before_add_to_cart_button', 'bbloomer_product_sold_count', 11 );
@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 <[email protected]>
*/
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;