Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Laurence Bahiirwa bahiirwa

🏠
Working from home
View GitHub Profile
@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
View Using block templates parts:: Converting Classic Themes to Block Theme
<?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' );
}
View Add New Block style to the heading in Gutenberg WP Editor
<?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(
@bahiirwa
bahiirwa / phpcs_cbf.sh
Created June 14, 2022 06:42 — forked from aleferreiranogueira/phpcs_cbf.sh
Install PHPCBF and PHPCS
View phpcs_cbf.sh
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
@bahiirwa
bahiirwa / ActionSchedulerHighVolume.php
Created June 3, 2022 06:27 — forked from devinsays/ActionSchedulerHighVolume.php
Modifications to Action Scheduler in order to run higher volumes of actions.
View ActionSchedulerHighVolume.php
<?php
/**
* High volume modifications to Action Scheduler.
*
* Adapted from https://github.com/woocommerce/action-scheduler-high-volume/
*
* Increase Action Scheduler batch size, concurrency, timeout period, and claim action query
* ORDER BY to process large queues of actions more quickly on servers with more server resources.
*
* @package UniversalYums\ActionScheduler
@bahiirwa
bahiirwa / OrdersList.php
Created June 3, 2022 06:26 — forked from devinsays/OrdersList.php
Speeds up the loading of /wp-admin/edit.php?post_type=shop_order and /wp-admin/edit.php?post_type=subscription.
View OrdersList.php
<?php
namespace UniversalYums\Admin\Performance;
class OrdersList {
/**
* The single instance of the class.
*/
protected static $instance;
@bahiirwa
bahiirwa / php-block-styles.php
Created May 11, 2022 16:30 — forked from wpmark/php-block-styles.php
Register WordPress block styles with PHP
View php-block-styles.php
<?php
/**
* Register some default block editor styles for this block.
*/
function hd_testimonials_register_testimonials_block_styles() {
// add the small image style.
register_block_style(
'core/heading', // name of your block
array(
@bahiirwa
bahiirwa / deploy.yml
Created May 10, 2022 06:26 — forked from hhhonzik/deploy.yml
Kinsta Deployment
View deploy.yml
# Kinsta Deployment through Github Actions for Bedrock/Sage.
#
# Placed at: .github/workflow/deploy.yml
#
# Process should be studied from code, but some quick brief:
# - runs composer / sage installation
# - moves correct `.env.*` file for multiple configs
# - uses rsync to sync files, uses /.rsyncignore file to exclude whatever should not be there
# - symlinks uploads folder and symlink release folder to kinsta public hostname
# - if you want to clear cache, please uncomment the last job
@bahiirwa
bahiirwa / write-log.php
Created February 21, 2022 08:58
Write Error Log Function
View write-log.php
<?php
/**
* Plugin Name: TechiePress Write Error Log Function
*/
if (!function_exists('write_log')) {
function write_log ( $log ) {
if ( true === WP_DEBUG ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
@bahiirwa
bahiirwa / Troubleshoot Post Meta Value
Last active November 5, 2021 05:14
See Post Related Meta in a side metabox
View Troubleshoot Post Meta Value
<?php
/**
* Show Post Meta in a metabox
*/
add_action( 'add_meta_boxes', 'wpdocs_register_meta_boxes' );
function wpdocs_register_meta_boxes() {
add_meta_box(
'meta-box-id',
View Create ACF Admin menu Options Page & Sub Pages with Advanced Custom Fields
<?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