Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Laurence Bahiirwa bahiirwa

🏠
Working from home
View GitHub Profile
View Settings-api-fix
<?php
/*
Plugin Name: Query APIs
Plugin URI: https://omukiguy.com
Description: Plugin Working with External API calls in WordPress.
Version: 0.1.0
Author: Laurence Bahiirwa
Author URI: https://omukiguy.com/
License: GPL-3.0+
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
View geblock.js
/**
* Internal block libraries
*/
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const { RichText } = wp.editor;
/**
* Register block
*/
@bahiirwa
bahiirwa / push.php
Last active Aug 22, 2018
push notification to external URL
View push.php
<?php
function wp_plugin_event_handler () {
global $post;
$url = 'https://us-central1-smackapp-7eab7.cloudfunctions.net/sendNotification';
if( get_post_type( $post->ID ) == 'post' ) {
@bahiirwa
bahiirwa / php-block.js
Created Jul 30, 2018 — forked from pento/php-block.js
Converting a shortcode to a block
View php-block.js
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@bahiirwa
bahiirwa / curl.md
Created Jun 14, 2018 — forked from subfuzion/curl.md
curl POST examples
View curl.md

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

View Vanilla JS Smooth scroll on page anchors.
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
@bahiirwa
bahiirwa / README.md
Created Apr 17, 2018 — forked from ericclemmons/README.md
Hot take on Zach Silveira's Gutenblock Demo!
View README.md
@bahiirwa
bahiirwa / block-template.php
Created Mar 9, 2018 — forked from zgordon/block-template.php
Example of how to add block templates to post types in WordPress
View block-template.php
<?php
function mytheme_block_templates( $args, $post_type ) {
// Only add template to 'post' post type
// Change for your post type: eg 'page', 'event', 'product'
if ( 'post' == $post_type ) {
// Optionally lock templates from further changes
// Change to 'insert' to allow adding other blocks, but lock defined blocks
@bahiirwa
bahiirwa / wc-prevent-checkout-for-cart-with-specific-category.php Prevents checkout if the WooCommerce cart only contains items from a specific category
View wc-prevent-checkout-for-cart-with-specific-category.php
<?php // only copy this line if needed
/**
* Renders a notice and prevents checkout if the cart
* only contains products in a specific category
*/
function sv_wc_prevent_checkout_for_category() {
// set the slug of the category for which we disallow checkout
$category = 'clothing';
@bahiirwa
bahiirwa / AdminPage.php
Created Dec 25, 2017 — forked from carlalexander/AdminPage.php
WordPress and the single responsibility principle
View AdminPage.php
<?php
/**
* The WordPress Meme Shortcode admin page.
*
* @author Carl Alexander
*/
class WPMemeShortcode_AdminPage
{
/**