Skip to content

Instantly share code, notes, and snippets.

Barry Hughes barryhughes

Block or report user

Report or block barryhughes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View hide-events-tagged-with-x.php
* Remove events tagged with any of the slugs listed below from
* event views.
* We deliberately avoid use of TEC functions and constants etc
* so that this doesn't break should that plugin temporarily be
* deactivated.
add_filter( 'pre_get_posts', function( $query ) {
View ip-address-protected-map-key.tec-views-v2.php
* Facilitates dictating a separate (IP-address protected) Google Maps
* API key for server-side geocoding requests.
class Server_Side_Google_Maps_Key {
* @var string
private $key = '';
barryhughes / fetch-csv-file.php
Created Jan 12, 2020
Load a CSV file and transform to an array. Simple helper for quick and dirty scripting.
View fetch-csv-file.php
* Given a path to a valid CSV file, returns an array containing the data
* (an array of arrays, with outer arrays representing the rows and inner
* arrays representing the columns).
* @param string $path_to_csv
* @return array
View woocommerce.get_or_create_attribute.php
namespace WooCommerce_Helpers {
* Looks for an existing WooCommerce attribute with the same label, or else
* creates a new attribute using the provided information.
* If a new attribute is successfully created, or an existing attribute is
* matched, the attribute object will be returned. Otherwise, bool false is
* returned.
barryhughes / php-streams.http-basic-auth.php
Last active Dec 31, 2019
HTTP authentication with file_get_contents() | PHP
View php-streams.http-basic-auth.php
* Make an HTTP request with basic authentication, using 'pure PHP'.
* @see
* @see
$username = 'http_username';
$password = 'http_password';
barryhughes / password-reset-link-generator.wp-cli.php
Last active Dec 20, 2019
Handy dandy WordPress password reset link generator (command line). Useful when we want to create a URL to share with a customer because they are for whatever reason having difficulties using the regular password reset facilities.
View password-reset-link-generator.wp-cli.php
barryhughes / bbpress-topic-ordering.php
Last active Nov 23, 2019
bbPress 2.6.x: don't allow "bumped" topics to surface to the top.
View bbpress-topic-ordering.php
* Order bbPress topic archives by post date (date created), not by last activity.
* This can be added either within a standalone plugin or to a theme's functions.php
* file.
* @param array $args
* @return array
View nextcloud.sample-nginx-remediation.CVE-2019-11043.patch
location / {
- rewrite ^ /index.php$request_uri;
+ rewrite ^ /index.php;
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
+ try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPTFILENAME $document_root$fastcgi_script_name;
barryhughes / plain-textify-html-links.php
Created Oct 10, 2019
Inelegant but handy and regex-free way of swapping out HTML links with a plain text equivalent.
View plain-textify-html-links.php
barryhughes / users-by-total-subscriptions.sql
Created Sep 18, 2019
Build a list of user IDs, ordered by the number of known (WooCommerce) subscriptions each user is associated with.
View users-by-total-subscriptions.sql
SELECT meta_value AS user_id,
COUNT(*) AS subscription_count
FROM wp_posts
JOIN wp_postmeta ON ID = post_id
WHERE post_type = 'shop_subscription'
AND meta_key = '_customer_user'
GROUP BY meta_value
ORDER BY subscription_count DESC
You can’t perform that action at this time.