Skip to content

Instantly share code, notes, and snippets.

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

Khandaker Ikrama khikrama

🏠
Working from home
View GitHub Profile
@khikrama
khikrama / gist:691206616cb9686415a4c0eaabec050a
Created November 14, 2019 19:05 — forked from MindyPostoff/gist:a10148daa110119b262f
Change "Proceed to PayPal" Text on Checkout Button in WooCommerce
/* Change the "Proceed to PayPal" button text in the WooCommerce checkout screen
* Add this to your theme's functions.php file
*/
add_filter( 'gettext', 'custom_paypal_button_text', 20, 3 );
function custom_paypal_button_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Proceed to PayPal' :
$translated_text = __( 'NEW BUTTON TEXT', 'woocommerce' );
break;
}
@khikrama
khikrama / wp-config.php
Created October 20, 2019 13:15
Set WordPress site URL in the config file instead of the database
<?php
// WordPress stores the site URL in the database by default (which I have never
// understood), and it's a pain to have to type out the UPDATE SQL or search in
// phpMyAdmin to change it. This is a simple way to put the URL into
// wp-config.php instead.
// Note that you will still need to update any URLs that appear in the content,
// especially when you copy a database from a development site to production:
// https://gist.github.com/davejamesmiller/a8733a3fbb17e0ff0fb5
@khikrama
khikrama / gist:42c2a31f65386b5470f269c36ffca14c
Created September 30, 2019 05:36 — forked from muratpurc/gist:2314727
PHP: Regex to validate different phone number formats
<?php
/**
* Regular expression to validate different types of phone numbers
*/
// simple pattern
$pattern = '/^[0-9\-\(\)\/\+\s]*$/';
// example phone numbers
$phoneNumbers = '
@khikrama
khikrama / functions.php
Created July 7, 2019 21:40 — forked from maddisondesigns/functions.php
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@khikrama
khikrama / wc-add-additional-information.php
Created July 7, 2019 21:05 — forked from woogists/wc-add-additional-information.php
[Frontend Snippets][Editing product data tabs] Add additional information
/**
* Check if product has attributes, dimensions or weight to override the call_user_func() expects parameter 1 to be a valid callback error when changing the additional tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product;
if( $product->has_attributes() || $product->has_dimensions() || $product->has_weight() ) { // Check if product has attributes, dimensions or weight
@khikrama
khikrama / wc-add-custom-tab.php
Created July 7, 2019 21:05 — forked from woogists/wc-add-custom-tab.php
[Frontend Snippets][Editing product data tabs] Add a custom tab
/**
* Add a custom product data tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __( 'New Product Tab', 'woocommerce' ),
@khikrama
khikrama / wc-custom-tab.php
Created July 7, 2019 21:05 — forked from woogists/wc-custom-tab.php
[Frontend Snippets][Editing product data tabs] Customize a tab
/**
* Customize product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$tabs['description']['callback'] = 'woo_custom_description_tab_content'; // Custom description callback
return $tabs;
}
@khikrama
khikrama / wc-reorder-tabs.php
Created July 7, 2019 21:04 — forked from woogists/wc-reorder-tabs.php
[Frontend Snippets][Editing product data tabs] Reordering product data tabs
/**
* Reorder product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
$tabs['additional_information']['priority'] = 15; // Additional information third
@khikrama
khikrama / wc-rename-tabs.php
Created July 7, 2019 21:04 — forked from woogists/wc-rename-tabs.php
[Frontend Snippets][Editing product data tabs] Renaming product data tabs
/**
* Rename product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
$tabs['reviews']['title'] = __( 'Ratings' ); // Rename the reviews tab
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab
@khikrama
khikrama / wc-remove-tabs.php
Created July 7, 2019 21:04 — forked from woogists/wc-remove-tabs.php
[Frontend Snippets][Editing product data tabs] Remove product data tabs
/**
* Remove product data tabs
*/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab