Skip to content

Instantly share code, notes, and snippets.

View phirebase's full-sized avatar
🌍
Working from home

David Klhufek phirebase

🌍
Working from home
View GitHub Profile

Exclude Unit Price for Specific WooCommerce Products

This code snippet overrides the WooCommerce Price Per Unit plugin to exclude unit price for products in the your-category category. It dynamically removes the unit price display for specific products based on their category.

Usage

  1. Copy the code below into your WordPress theme's functions.php file or a custom plugin.
  2. Adjust the $excluded_categories array if needed to match your specific category slugs.
@phirebase
phirebase / languages-wp-cli-guide.md
Last active January 17, 2025 12:24
How to Initialize and Update `/languages` for a WordPress Plugin using WP-CLI

How to Initialize and Update /languages for a WordPress Plugin using WP-CLI

1️⃣ Create a .pot File

Generate the .pot file to include all translatable strings:

wp i18n make-pot . /languages/my-plugin.pot --domain=my-plugin
  • .: Root directory of your plugin.
@phirebase
phirebase / wp-cli-commands.md
Last active January 8, 2025 23:40
WP-CLI Quick Commands

WP-CLI Quick Commands

A collection of useful WP-CLI commands for managing your WordPress site effectively.

1️⃣ WordPress Core Management

Check WordPress version:

wp core version

Update WordPress:

@phirebase
phirebase / phpcs-phpcbf-guide.md
Last active January 26, 2025 13:45
PHPCS and PHPCBF Commands for WordPress

PHPCS and PHPCBF Commands for WordPress

1️⃣ Run PHPCS

Use the phpcs command to analyze your code:

phpcs --standard=WordPress ./path/to/your/file.php

2️⃣ Optional: Automatic Fixes with PHPCBF

@phirebase
phirebase / wordpress-db-get-autoload-size.sql
Created December 20, 2023 16:16 — forked from yanknudtskov/wordpress-db-get-autoload-size.sql
This will show you the autoloaded data size, how many entries are in the table, and the first 10 entries by size. #optimization #database #mysql
SELECT 'autoloaded data in KiB' as name, ROUND(SUM(LENGTH(option_value))/ 1024) as value FROM wp_options WHERE autoload='yes'
UNION
SELECT 'autoloaded data count', count(*) FROM wp_options WHERE autoload='yes'
UNION
(SELECT option_name, length(option_value) FROM wp_options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 10)
.et_mobile_menu .parent-menu-item > a {
background-color: transparent;
position: relative;
}
.et_mobile_menu .parent-menu-item > a:after {
font-family: 'ETmodules';
content: '\3b';
font-weight: normal;
position: absolute;
<script>
(function($) {
function collapse_menu() {
var ParentMenuItem = $('.et_mobile_menu .parent-menu-item > a');
ParentMenuItem.off('click').click(function() {
$(this).attr('href', '#');
$(this).parent().children().children().toggleClass('show-menu-items');
$(this).toggleClass('switched-icon');
});
}
@phirebase
phirebase / .htaccess
Created June 30, 2022 12:38 — forked from seoagentur-hamburg/.htaccess
UPDATE 2022/05: Perfect .htaccess file for highspeed and security. You can use it for every WordPress-Website without problems. Highspeed and Security - testet on hundreds of Websites. If you are using a WordPress Multisite, change the last part of this file.
########################################################################
# OPTIMAL .htaccess FILE FOR SPEED AND SECURITY @Version 2.0.4 - 05/2022
# ----------------------------------------------------------------------
# @Author: Andreas Hecht
# @Author URI: https://seoagentur-hamburg.com
# License: GNU General Public License v2 or later
# License URI: http://www.gnu.org/licenses/gpl-2.0.html
########################################################################
@phirebase
phirebase / per-kg.php
Created January 16, 2021 20:44 — forked from neilgee/per-kg.php
WooCommerce add a weight amount after the price such as 'per kg'
<?php //<~ don't add me in
add_filter( 'woocommerce_get_price_html', 'wb_change_product_html' );
// Change and return $price_html variable using the $price and weight amount
function wb_change_product_html( $price ) {
$price_html = '<span class="amount">' . $price . ' per kg </span>'; // change weight measurement here
return $price_html;
}
@phirebase
phirebase / divi-lightbox-snippet-for-functions.php
Created October 5, 2019 12:04 — forked from CoachBirgit/divi-lightbox-snippet-for-functions.php
DIVI: add lightbox to regular content images
/* add .et_pb_lightbox_image clss to content images */
add_filter('the_content', 'divi_add_lightbox');
function divi_add_lightbox($content) {
global $post;
$pattern ="/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
$replacement = '<a$1href=$2$3.$4$5 class="et_pb_lightbox_image" title="'.$post->post_title.'"$6>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}