Skip to content

Instantly share code, notes, and snippets.

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

Laurence Bahiirwa bahiirwa

🏠
Working from home
View GitHub Profile
@bahiirwa
bahiirwa / log.js
Created April 25, 2024 16:46 — forked from youknowriad/log.js
Gutenberg Log Deprecations
const { createElement: el, useState, useEffect } = React;
const PanelBody = wp.components.PanelBody;
const PluginSidebar = wp.editor.PluginSidebar;
const addAction = wp.hooks.addAction;
const registerPlugin = wp.plugins.registerPlugin;
function MyPluginSidebar() {
const [ deprecations, setDeprecations ] = useState( [] );
useEffect( () => {
addAction(
@bahiirwa
bahiirwa / webpack.config.js
Created March 26, 2023 15:24
Multiple entry points for webpack.config.js using @wordpress/scripts
// Set from https://www.npmjs.com/package/@wordpress/scripts
// Add package.json with the @wordpress/scripts dependency.
// Add a root file called webpack.config.js
// Import the original config from the @wordpress/scripts package.
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
// Import the helper to find and generate the entry points in the src directory
const { getWebpackEntryPoints } = require( '@wordpress/scripts/utils/config' );
Disable the WordPress Admin Bar for all Users and Visitors
Turn off the toolbar with one simple line.
view plain
/*
* Disable the WordPress Admin Bar for all Users and Visitors
*/
remove_action( 'init', '_wp_admin_bar_init' );
^ top
Enable the WordPress Admin Bar for admins only
public function is_cache_plugin_installed() {
return
function_exists( 'w3tc_flush_post' ) ||
function_exists( 'wp_cache_post_change' ) ||
function_exists( 'rocket_clean_post' ) ||
has_action( 'cachify_remove_post_cache' ) ||
has_action( 'litespeed_purge_post' ) ||
function_exists( 'wpfc_clear_post_cache_by_id' ) ||
class_exists( 'WPO_Page_Cache' ) ||
has_action( 'cache_enabler_clear_page_cache_by_post' ) ||
<?php
/**
* WP_HTML_Table_Processor
* @author Seth Rubenstein
*/
/**
* Pass in a table and get back an array of the header, rows, and footer cells quickly and effeciently.
*
* The WP_HTML_Tag_Processor bookmark tree navigation is heavily cribbed from WP_Directive_Processor class https://github.com/WordPress/block-interactivity-experiments/pull/169/files#diff-ad36045951e27010af027ae380350ae4b07b56a659a3127b40b7967b2308d5bc
@bahiirwa
bahiirwa / Using block templates parts:: Converting Classic Themes to Block Theme
Created February 6, 2023 16:44
Converting Classic Themes to Block Theme. How to use block templates parts
<?php
/**
* Footer template.
* Add this to the HTML template in the parts directory in the theme.
*/
if ( function_exists( 'block_template_part' ) ) {
block_template_part( 'footer-new-blocks' );
}
<?php
/**
* Add new h4 block style.
* Add custom styles and scripts support for the Block Theme.
*
* @package Safari_Block_Theme
*/
if ( function_exists( 'register_block_style' ) ) {
register_block_style(
<?php
/**
* Plugin Name: Techie Options
* Plugin URI: https://github.com/yttechiepress/techie-options-page
* Author: Techiepress
* Author URI: https://github.com/yttechiepress/techie-options-page
* Description: This plugin adds an ACF Options Page to WP.
* Version: 0.1.0
* License: GPL2
* License URL: http://www.gnu.org/licenses/gpl-2.0.txt
@bahiirwa
bahiirwa / Change-Kuwait-Currency-for-WooCommerce.php
Created January 26, 2021 15:55
Change Kuwaiti Currency in WooCommerce
<?php
/**
* Plugin Name: Change Kuwaiti Currency in WooCommerce
* Plugin URI: https://github.com/yttechiepress/kuwaiti-currency
* Author: TechiePress
* Author URI: https://github.com/yttechiepress/kuwaiti-currency
* Description: Change Currencies in WooCommerce
* Version: 0.1.0
* License: GPL2
* License URL: http://www.gnu.org/licenses/gpl-2.0.txt
@bahiirwa
bahiirwa / phpcs_cbf.sh
Created June 14, 2022 06:42 — forked from aleferreiranogueira/phpcs_cbf.sh
Install PHPCBF and PHPCS
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
curl -L http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o php-cs-fixer
# Those files should be either on /usr/local/bin or /usr/bin depending on your machine
sudo mv phpcbf.phar /usr/local/bin/phpcbf
sudo mv phpcs.phar /usr/local/bin/phpcs
sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
sudo chmod a+x /usr/local/bin/php-cs-fixer