This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function randomColor() { | |
//Start Color with # | |
$str = '#'; | |
//Total Number of Iteration Required for HEX Color is 6 | |
for ($i = 0; $i < 6; $i++) { | |
//Genrate Random Number Between 0 to 15 | |
$randNum = rand(0, 15); | |
//Replace 10 - 15 to A - F | |
switch ($randNum) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Registering Menu Items to REST API (API URL : http://website.com/wp-json/menu/) | |
function get_menu() { | |
# Change 'hamburger' to your own navigation slug. | |
return wp_get_nav_menu_items('hamburger'); | |
} | |
add_action( 'rest_api_init', function () { | |
register_rest_route( 'spirit', '/menu', array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom Wordpress Customize Settings -- By Darshan Gada | |
* @param webgeeks (Replace webgeeks with your theme name) | |
* @function webgeeks_theme_options | |
*/ | |
function webgeeks_theme_options( $wp_customize ) { | |
//Sections, settings and controls will be added here | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Removing the Breadcrumbs -- By Darshan Gada | |
add_action('init','fila_remove_wc_breadcrumbs'); | |
function fila_remove_wc_breadcrumbs() { | |
remove_action('woocommerce_before_main_content','woocommerce_breadcrumb',20,0); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//WooCommerce. How to change “Add to cart” button text -- By Darshan Gada | |
add_filter( 'add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // < 2.1 | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' ); // 2.1 + | |
function woo_custom_cart_button_text() { | |
return __( 'ADD TO BASKET', 'woocommerce' ); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = 'Hello'; | |
$$a = 'World!'; // This interprets $hello = 'world'; | |
echo "$a ${$a}"; //This will Print Hello World {PHP 7.0} | |
echo "$a $hello"; // This will also produce the same output Hello World | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Return the permalink of the shop page for the continue shopping redirect filter -- By Darshan Gada | |
* | |
* @param string $return_to | |
* @return string | |
*/ | |
function my_woocommerce_continue_shopping_redirect( $return_to ) { | |
return get_permalink( wc_get_page_id( 'shop' ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Changing Number of Upsell products display on Single Product page -- By Darshan Gada | |
add_filter( 'woocommerce_output_related_products_args', 'wc_change_number_related_products' ); | |
function wc_change_number_related_products( $args ) { | |
$args['posts_per_page'] = 1; | |
$args['columns'] = 4; //change number of upsells here | |
return $args; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Updating Select Options and Add to Cart Button Text on Shop Archive Page -- By Darshan Gada | |
add_filter( 'woocommerce_product_add_to_cart_text' , 'woo_custom_view_button_text' ); | |
function woo_custom_view_button_text() { | |
global $product; | |
$product_type = $product->get_type(); | |
switch ($product_type) { | |
case 'variable': | |
return __( 'VIEW PRODUCT', 'woocommerce' ); //this will change "Select Options" to "View Product" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Change Number of Products Display on Shop Archive Page -- By Darshan Gada | |
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 ); | |
function new_loop_shop_per_page( $cols ) { | |
// $cols contains the current number of products per page based on the value stored on Options -> Reading | |
// Return the number of products you wanna show per page. | |
$cols = 100; | |
return $cols; | |
} |
OlderNewer