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
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@Njengah
Njengah / toggle-debug.php
Created September 12, 2019 12:43 — forked from trepmal/toggle-debug.php
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);
}
@Njengah
Njengah / functions.php
Created September 12, 2019 12:52 — forked from jarnesjo/functions.php
Clean up WordPress header
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'start_post_rel_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
@Njengah
Njengah / add-settings-link-to-wordpress-plugin.php
Created September 22, 2019 21:08
Adding a Settings link to your plugin settings page.
<?php
function themename_customize_register($wp_customize){
$wp_customize->add_section('themename_color_scheme', array(
'title' => __('Color Scheme', 'themename'),
'priority' => 120,
));
// =============================
@Njengah
Njengah / tiny_login.php
Created October 1, 2019 21:16 — forked from ideag/tiny_login.php
WordPress front-end login and registration forms
<?php
/*
Plugin Name: tinyLogin
Plugin URI: http://wp.tribuna.lt/tiny-login
Description: A simple front-end login/registration system. Adds template tags and shortcodes. Shortcodes: [tiny_form_login]/[tiny_form_register]. Template tags: get_tiny_form_login()/get_tiny_form_register() and the_tiny_form_login()/the_tiny_form_register()
Version: 0.1
Author: Arūnas
Author URI: http://wp.tribuna.lt/
Text Domain: tiny_login
*/
@Njengah
Njengah / functions.php
Created October 1, 2019 21:17 — forked from ideag/functions.php
Wordpress frontend file uploading
<?php
// simple frontend file upload
// written by Arūnas Liuiza | tinyStudio | wp.tribuna.lt
// Usage: use [tiny_upload] shortcode or get_tiny_upload()/the_tiny_upload() template tags
// Localization: replace 'theme' with your text domain string.
// ======= UPLOAD FORM =====>
// return form #1
@Njengah
Njengah / fiddle_493421.php
Created October 9, 2019 14:51 — forked from phpfiddle/fiddle_493421.php
Php color palette shade generator
<?php
class ColorPalette{
public $color;
public function __construct($color){
$this->color = $color;
}
public function color_mod($hex, $diff) {
$rgb = str_split(trim($hex, '# '), 2);
@Njengah
Njengah / remove_wordpress_admin_menus.php
Created January 18, 2020 23:12
Using remove_page and remove_submenu_page functions to remove admin menus WordPress
<?php
/**
* Using remove_page and remove_submenu_page functions to remove admin menus WordPress
*/
#1. Remove the main menu item together with the subpages
add_action( 'admin_menu', 'remove_admin_menu_items', 999 );
@Njengah
Njengah / registering-a-sidebar-in-wordpress.php
Last active January 18, 2020 23:20
Functions to register sidebar in WordPress
<?php
//Callback function
function njengah_register_sidebar_tutorial() {
//Register Sidebar function - https://developer.wordpress.org/reference/functions/register_sidebar/
register_sidebar(
array(
'name' => __( 'Sidebar Example', 'textdomain' ),