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 / 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.
<?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
<?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
# 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
<?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
<?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',
@bahiirwa
bahiirwa / CF7 Form Trap
Created July 10, 2021 17:26
Get CF7 Data and send to API
<?php
/**
* Plugin Name: CF7 Form Trap
* Plugin URI: https://github.com/yttechiepress/cf7-trap-api
* Author: Techiepress
* Author URI: https://github.com/yttechiepress/cf7-trap-api
* Description: Get CF7 Data and send to API
* Version: 0.1.0
* License: GPL2
* License URL: http://www.gnu.org/licenses/gpl-2.0.txt
@bahiirwa
bahiirwa / WordPress 5.7 Robots API
Created March 14, 2021 05:12
Working with WordPress 5.7 Robots API to add follow
// Remove meta for robots.
// remove_filter( 'wp_robots', 'wp_robots_max_image_preview_large' );
// Replace the values in the meta robot tag.
add_filter( 'wp_robots', 'techiepress_wp_robots_max_image_preview_large' );
// Remove the image preview and add follow to robots
function techiepress_wp_robots_max_image_preview_large( $robots ) {
$robots['max-image-preview'] = false;
$robots['follow'] = true;
@bahiirwa
bahiirwa / example-wp-list-table.php
Created March 6, 2021 18:01 — forked from paulund/example-wp-list-table.php
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
<?php
/**
* Make a remote GET using DIGEST authentication.
*
* DIGEST authenticated requests require two GET requests:
* 1. GET the www-authenticate header for nonce, realm, opaque, and other values
* 2. GET the expected response body by constructing an 'Authorization' header
* with nonce, realm, and other values provided by the server.
*
add_action( 'graphql_register_types', function() {
$mock_colors = '
{
"fresh":{
"name":"Default",
"url":false,
"colors":[
"#222",
"#333",