Skip to content

Instantly share code, notes, and snippets.

@userabuser
userabuser / laravel-custom-blade-directive.php
Last active Apr 14, 2018
Custom Laravel Blade Directive for use with @yield and @section (Laravel)
View laravel-custom-blade-directive.php
<?php
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider {
/**
* Bootstrap any application services.
*
@userabuser
userabuser / wp-logger.php
Last active Feb 19, 2016
Dirty little logger function for WordPress (mu-plugins)
View wp-logger.php
/**
* By pass the need to define up to three constants, WP_DEBUG, WP_DEBUG_LOG
* and WP_DEBUG_DISPLAY by setting the error_log ini value so that any time
* logger() is called data is written to debug.log.
*/
ini_set('log_errors', 1);
ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
/**
@userabuser
userabuser / wp-after-delete-user.php
Last active Apr 14, 2018
Perform an action after a user is deleted with access to additional user data (role, name, email, etc) in addition to user ID. (WordPress)
View wp-after-delete-user.php
<?php
/*
* The deleted_user hook fires after a user is deleted and receives
* only one arguement, the $user_id but there is no way to check,
* based on the $user_id, if the user belongs to a specific user role
* as the user no longer exists. Solution: add deleted_user action within
* the delete_user callback function which fires prior to a user being
* deleted and inject a closure on the deleted_user callback.
*
* http://wordpress.stackexchange.com/q/99959/13418