Skip to content

Instantly share code, notes, and snippets.

@tozbey
tozbey / Read more-less.php
Created August 9, 2023 19:54
Read more/less in WooCommerce product categories
<?php
/**
* Plugin Name: Read more/less
* Plugin URI: https://ozbey.se
* Description: Read more/less in WooCommerce product categories
* Version: 2
* Author: Tolga Ozbey
* Author URI: https://ozbey.se
* Requires at least: 5.6
* Requires PHP: 7.4
<?php
/**
* Plugin Name: WooCommerce Registration Fields
* Description: My Custom registration fields.
* Version: 1.0
* Author: T
*/
/* Extra Fields in WooCommerce Registration */
@tozbey
tozbey / disable-email.php
Created September 30, 2020 19:02
Woocommerce - Disable Admin Notification of User Password Change
<?php
/**
* Disable Admin Notification of User Password Change
*
* Credit: https://wordpress.stackexchange.com/a/266006/67466
*
* Suppressing this email notification has to be handled
* with a plugin because pluggable.php is loaded earlier
* than a theme's functions.php file.
{
"editor.fontSize": 16,
"editor.lineHeight": 24,
"editor.letterSpacing": 0.2,
"editor.fontFamily": "Source Code Pro",
"editor.fontLigatures": true,
"workbench.iconTheme": "vs-seti",
"editor.minimap.enabled": false,
"workbench.colorCustomizations": {
"tab.inactiveBackground": "#31353d",
@tozbey
tozbey / gist:b1aa2cf11a699b72ad390cb5aa749e81
Created October 25, 2019 09:29
Hide admin menu items and subitems
/**
* Hide admin menu items. Can be both parents and children in dropdowns.
* Specify link to parent and link to child.
* @link https://codex.wordpress.org/Function_Reference/remove_menu_page
*/
add_action( 'admin_menu', function () {
// Remove Settings
remove_menu_page( 'options-general.php' );
// Remove Settings -> Writing
@tozbey
tozbey / remove_checkout_fields.php
Last active October 24, 2019 19:02 — forked from cryptexvinci/remove_checkout_fields.php
Remove fields from WooCommerce checkout page.
add_filter( 'woocommerce_checkout_fields' , 'custom_remove_woo_checkout_fields');
add_filter('woocommerce_enable_order_notes_field', '__return_false');
function custom_remove_woo_checkout_fields( $fields ) {
// remove billing fields
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
@tozbey
tozbey / gist:9b46e107ae32871361b64c72f6246d22
Created October 24, 2019 18:36
Woocommerce - Remove all tabs on product page
// Remove all tabs on product page
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
return $tabs;
@tozbey
tozbey / gist:7f0c00f53056b6fc23f0f7b8958f2c54
Created October 24, 2019 18:34
Add save amount next to sale item prices
// Add save amount next to sale item prices
add_filter( 'woocommerce_get_price_html', 'modify_woocommerce_get_price_html', 10, 2 );
function modify_woocommerce_get_price_html( $price, $product ) {
if( $product->is_on_sale() && ! is_admin() )
return $price . sprintf( __('<p class="saveprice">Du sparar: <span class="woocommerce-Price-amount amount">%s <span class="woocommerce-Price-currencySymbol">kr</span></span></p>', 'woocommerce' ), $product->regular_price - $product->sale_price );
else
return $price;
}
@tozbey
tozbey / gist:f0132bdddf152dc68fe3ff552ba9ba5c
Created October 24, 2019 18:32
Hide WordPress admin notices
// Hide WordPress admin notices
function oz_disable_admin_notices() {
global $wp_filter;
if ( is_user_admin() ) {
if ( isset( $wp_filter['user_admin_notices'] ) ) {
unset( $wp_filter['user_admin_notices'] );
}
} elseif ( isset( $wp_filter['admin_notices'] ) ) {
unset( $wp_filter['admin_notices'] );
}