Skip to content

Instantly share code, notes, and snippets.

View bobwol's full-sized avatar
💭
coding as usual

bobwol

💭
coding as usual
View GitHub Profile
@bobwol
bobwol / WC_Widget_Layered_Nav_Categories.php
Created May 20, 2024 21:37 — forked from oscb/WC_Widget_Layered_Nav_Categories.php
Add Category Filters to Woocommerce Layered Nav
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Layered Navigation Widget extended to include Categories
*
* @author Oscar Bazaldua
* @category Widgets
@bobwol
bobwol / custom-my-account-endpoint.php
Created November 6, 2023 20:10 — forked from claudiosanches/custom-my-account-endpoint.php
Example of custom My Account endpoint.
<?php
class My_Custom_My_Account_Endpoint {
/**
* Custom endpoint name.
*
* @var string
*/
public static $endpoint = 'my-custom-endpoint';
@bobwol
bobwol / functions.php
Created November 6, 2023 20:09 — forked from claudiosanches/functions.php
WooCommerce - Use "Starting at" prefix for variable price range
<?php
/**
* Custom variable price HTML.
* Shows "Starting at" prefix with when min price is different from max price.
*
* @param stirng $price Product price HTML
* @param WC_Product_Variable $product Product data.
* @return string
*/
function cs_my_wc_custom_variable_price_html( $price, $product ) {
@bobwol
bobwol / wc-products-disable-gutenberg.php
Created November 6, 2023 20:09 — forked from claudiosanches/wc-products-disable-gutenberg.php
Disable Gutenberg in Edit Product screen for WooCommerce 3.4.x or older
<?php
/**
* Plugin Name: No Gutenberg for old versins of WooCommerce
* Plugin URI: https://gist.github.com/claudiosanches/d0231798eb6041e4911b4bca409ec1ac
* Description: Disable Gutenberg in Edit Product screen for WooCommerce 3.4.x.
* Author: Claudio Sanches
* Author URI: https://claudiosanches.com
* Version: 1.0.0
* License: GPLv3
*
@bobwol
bobwol / functions.php
Created November 6, 2023 19:38 — forked from claudiosanches/functions.php
WooCommerce - Custom Simple Product price format.
<?php
/**
* Custom simple product price format.
*
* Adds credit cart parcels in price html.
*
* @param string $price Old price format.
*
* @return string Price format with credit card parcels.
*/
@bobwol
bobwol / woocommerce-optimize-scripts.php
Created July 18, 2023 17:56 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@bobwol
bobwol / functions.php
Created June 21, 2023 23:19 — forked from iyut/functions.php
wp_remote_post using x-www-form-urlencoded
function request_token() {
$encoded_auth = base64_encode( $this->client_id . ":" . $this->client_secret );
$args = array(
'method' => 'POST',
'httpversion' => '1.1',
'headers' => array(
'Authorization' => 'Basic '. $encoded_auth,
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
),
@bobwol
bobwol / functions.php
Created May 24, 2022 16:21 — forked from TimBHowe/functions.php
Add "Company" field to WordPress user account and add sortable company column to the user backend.
//add&remove field from user profiles - sorce:http://davidwalsh.name/add-profile-fields
function modify_contact_methods($profile_fields) {
// Add new fields
$profile_fields['company'] = 'Company';
// Remove old fields
//unset($profile_fields['aim']);
return $profile_fields;
@bobwol
bobwol / slug.php
Created August 18, 2021 23:56
Tirar acentos, caracteres especiais e espaços de titulos e frases para torna-los slug
<?php
function tirarAcentos($string){
$string = preg_replace(array("/(á|à|ã|â|ä)/","/(Á|À|Ã|Â|Ä)/","/(é|è|ê|ë)/","/(É|È|Ê|Ë)/","/(í|ì|î|ï)/","/(Í|Ì|Î|Ï)/","/(ó|ò|õ|ô|ö)/","/(Ó|Ò|Õ|Ô|Ö)/","/(ú|ù|û|ü)/","/(Ú|Ù|Û|Ü)/","/(ñ)/","/(Ñ)/","/(ç)/","/(Ç)/"),explode(" ","a A e E i I o O u U n N c C"),$string);
$char = array(' & ', 'ª ', ' (', ') ', '(', ')', ' - ', ' / ', ' /', '/ ', '/', ' | ', ' |', '| ', ' | ', '|', '_', '.', ' ');
return strtolower(str_replace($char, '-', $string));
}