Skip to content

Instantly share code, notes, and snippets.

View Njengah's full-sized avatar
👨‍💻
Coding & Learning Everyday

Joe Njenga Njengah

👨‍💻
Coding & Learning Everyday
View GitHub Profile
@vishalck
vishalck / woocommerce-custom-thank-you-page-redirect.php
Last active June 7, 2021 12:13
Redirect to Custom Thank You page in WooCommerce
<?php
add_action( 'template_redirect', 'woo_custom_redirect_after_purchase' );
function woo_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && !empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'http://localhost:8888/woocommerce/custom-thank-you/' );
exit;
}
}
@JaniKibichi
JaniKibichi / dbconnect.php
Created November 29, 2016 09:40
How to connect a USSD to a MYSQL DB
<?php
//Declare the Connection Credentials
$servername = 'localhost'; //or IP address for DB hosted elsewhere
$username = 'root';
$password = "";
$database = "ussd";
$dbport = 3306;
// Create connection
$db = new mysqli($servername, $username, $password, $database, $dbport);
// Check connection, if there is an error end the USSD connection
@abel-masila
abel-masila / index.php
Created July 13, 2016 09:16
A simple USSD registration application written in PHP
<?php
/* Simple sample USSD registration application
* USSD gateway that is being used is Africa's Talking USSD gateway
*/
// Print the response as plain text so that the gateway can read it
header('Content-type: text/plain');
/* local db configuration */
$dsn = 'mysql:dbname=dbname;host=127.0.0.1;'; //database name
@abegit
abegit / wc_order_status_changes.php
Created February 2, 2016 20:11
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
@trepmal
trepmal / toggle-debug.php
Last active September 4, 2020 15:42
WordPress experiment. Toggle debug from admin bar
<?php
/*
Plugin Name: Toggle Debug
Description: Proof-of-concept for an admin-bar debug mode toggle. Needs some UX love.
*/
/*
// In wp-config.php, wrap debug constants in a cookie conditional
if ( isset( $_COOKIE['wp-debug'] ) && $_COOKIE['wp-debug'] == 'on' ) {
define('WP_DEBUG', true);
}
@ideag
ideag / arunas-hides-plugins.php
Last active October 1, 2019 21:13
A simple proof-of-concept plugin to hide specific plugins from Plugins' list in WP Admin if it is a Multisite install and the user is not the Super Administrator.
<?php
/*
Plugin Name: Arunas Hides Plugins
Plugin URI: http://arunas.co/hidesplugins
Description: A simple proof-of-concept plugin to hide specific plugins from Plugins' list in WP Admin if it is a Multisite install and the user is not the Super Administrator.
Author: Arūnas Liuiza
Version: 0.2
Author URI: http://arunas.co/
*/
@numediaweb
numediaweb / functions.php
Last active October 25, 2022 22:46
Filter WordPress admin side navigation menues
function filter_admin_menues() {
// If administrator then do nothing
if (current_user_can('activate_plugins')) return;
// Remove main menus
$main_menus_to_stay = array(
// Dashboard
'index.php',
@BFTrick
BFTrick / install-wp.sh
Last active April 1, 2024 04:14
Download & Install WordPress via Curl
curl -O https://wordpress.org/latest.zip
unzip latest.zip
mv wordpress site
rm latest.zip
@Arahnoid
Arahnoid / RGB-Hex.js
Last active December 27, 2022 21:32
[Convert color format] Bunch of RGB to Hex and Hex to RGB convert javascript functions what works well in Photoshop #Photoshop
///////////////////////////////////////////////////////////////////////////////////
/// Colection of RGB to HSB, HSB to RGB convert functions
/// Source: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
///////////////////////////////////////////////////////////////////////////////////
/**
* componentToHex convert two digit htx value to R, G or B chanel value
* @param number c value from 0 to 225
* @return string value of R, G or B chanel
* @usage //alert (componentToHex(255)); //ff
@aahan
aahan / WordPress Custom Global Variables.md
Last active March 28, 2024 19:26
Creating and using custom global variables in wordpress.

First create global variables (in functions.php or as a mu-plugin):

<?php

/*
 * CUSTOM GLOBAL VARIABLES
 */
function wtnerd_global_vars() {