Skip to content

Instantly share code, notes, and snippets.

View bhowe's full-sized avatar

Blake Howe bhowe

View GitHub Profile
function accessible_slick_shortcode($atts) {
$atts = shortcode_atts([
'imgid' => ''
], $atts);
$img_ids = explode(',', $atts['imgid']);
if (empty($img_ids)) {
return '<p>No images found.</p>';
}
@bhowe
bhowe / gist:c91ecdf47a3fa7125be4b0c0beb4e07d
Last active October 17, 2024 11:34
Export gravity form entries every month
function export_gf_entries(){
$send_to = $_REQUEST['sendto'] ?? 'youremailhere';
$form_id = $_REQUEST['fid'] ?? 1;
$form = RGFormsModel::get_form_meta($form_id);
$fields = array();
if(is_array($form["fields"])){
foreach($form["fields"] as $field){
@bhowe
bhowe / gist:e37398f067d736b7f71fc7d50acb975f
Created September 16, 2024 13:17
Control what a client can see in WordPre
// Create the client_admin role
function create_client_admin_role() {
add_role(
'client_admin',
'Client Admin',
get_role('administrator')->capabilities
);
}
add_action('init', 'create_client_admin_role');
@bhowe
bhowe / server-timing-extra.php
Created February 9, 2023 02:59 — forked from felixarntz/server-timing-extra.php
Mini WordPress plugin that uses the Server Timing API of the Performance Lab plugin (also see https://github.com/WordPress/performance/pull/553) to capture additional metrics
<?php
/**
* Plugin Name: Server Timing Extra
* Plugin URI: https://gist.github.com/felixarntz/63c05392dbf7d51cc7f8f4a424b1ff39
* Description: Exposes additional Server-Timing metrics using the Performance Lab plugin's Server Timing API.
* Requires at least: 6.1
* Requires PHP: 5.6
* Version: 0.1.0
* Author: Felix Arntz
* Author URI: https://felix-arntz.me
@bhowe
bhowe / add-user.php
Created April 27, 2021 13:32
Add a user to a WordPress Site
<?php
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your Wordpress root directory and run it from your browser.
// Delete it when you're done.
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');
// ----------------------------------------------------
-> go to all sites > Add new site
-> After adding go to all All sites again and edit the newly added site.. change it's url to https://dev.test.com/
-> After that you have to go to all domains in cpanel.
-> Change the directory path of https://dev.test.com/ to public_html
-> Next.. go to wp-config.php in public_html
Change
define('DOMAIN_CURRENT_SITE', 'dev.whatever.com');
to
@bhowe
bhowe / gist:f0129261e1ec9e68c6d127904c15bd6d
Created December 24, 2020 15:43
Take you WordPress site down for maintenance
Add this to your HTACCESS make sure the down.php exists.
RewriteEngine On
RewriteBase /
#add exception for your IP address
RewriteCond %{REMOTE_ADDR} !111\.111\.111\.111$
RewriteCond %{REQUEST_URI} !^/down\.php$ RewriteRule ^(.*)$ /site-offine.php [L]
Some basic commands to get you started if you are familiar with ssh.
Find common problems in wordpress hacks
Finds eval or base64 decode
grep -ri "eval" [path]
grep -ri "base64_decode" [path]
Recently modified files
<?php
// Register new status
function register_outside_order_status() {
register_post_status( 'wc-outside', array(
'label' => 'Outside Waiting',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
@bhowe
bhowe / t5-plugin-log.php
Created August 26, 2020 17:33 — forked from thefuxia/t5-plugin-log.php
Plugin Log: Log all plugin (de)activations.
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Plugin Log
* Description: Log all plugin (de)activations.
* Version: 2012.05.27
* Author: Thomas Scholz <[email protected]>
* Author URI: http://toscho.de
* License: MIT
* License URI: http://www.opensource.org/licenses/mit-license.php
*