Skip to content

Instantly share code, notes, and snippets.

View QWp6t's full-sized avatar
😏
Feel free to ask for a refund.

QWp6t QWp6t

😏
Feel free to ask for a refund.
View GitHub Profile
@QWp6t
QWp6t / VirtualFileSystem.php
Created July 28, 2018 19:28
Trait for using mikey179/vfsStream with phpunit
<?php
namespace QWp6t\Tests;
/** composer require mikey179/vfsStream --dev */
use org\bovigo\vfs\vfsStream;
trait VirtualFileSystem
{
protected $filesystem;
@QWp6t
QWp6t / BedrockMultisiteValetDriver.php
Last active June 17, 2024 07:43
Fix Laravel Valet when using WordPress subdirectory multisite + Bedrock
<?php
namespace Valet\Drivers\Custom;
class BedrockMultisiteValetDriver extends \Valet\Drivers\Specific\BedrockValetDriver
{
/**
* Determine if the incoming request is for a static file.
*
* @return string|false
@QWp6t
QWp6t / Bootstrap.php
Created April 16, 2017 03:20
NavWalkers
<?php namespace App\NavWalker;
use Roots\Soil\Nav\NavWalker as SoilNavWalker;
/**
* @author QWp6t
* @license OSL-3.0
*/
class Bootstrap extends SoilNavWalker
{
@QWp6t
QWp6t / wc-checkout-fields-optgroup.php
Created June 30, 2016 00:51
Add optgroup support to WooCommerce select form fields
<?php
/**
* Plugin Name: Add optgroup support to WooCommerce select form fields
* Description: Converts <code>Group: Option</code> syntax in WooCommerce select form fields into <code>&lt;optgroup...&gt;&lt;option...&gt;</code>
* Author: QWp6t
* Author URI: https://qwp6t.me/
*/
/** NOTE: This shit was quickly hacked together. Worked for me. YMMV. */
@QWp6t
QWp6t / process-input.php
Created September 22, 2015 15:00
`filter_input` validation
<?php
$recaptcha = filter_input(INPUT_POST, 'g-recaptcha-response', FILTER_CALLBACK, ['options' => validateReCaptcha('<your-secret-here>')]);
$phone = filter_input(INPUT_POST, 'phone', FILTER_CALLBACK, ['options' => validateTelephoneNumber()]);
@QWp6t
QWp6t / acf-post-type-supports.php
Last active July 24, 2024 18:14
Adds ACF Field Group location rule for Post Type Support.
<?php
/**
* Plugin Name: Field Group Location: Post Type Supports
* Plugin URI: http://qwp6t.me/acf-post-type-supports
* Description: Adds ACF Field Group location rule for Post Type Support. NOTE: You must first declare the supported feature in your theme.
* Version: 1.0.0
* Author: QWp6t
* Author URI: http://qwp6t.me
* License: MIT License
*/
@QWp6t
QWp6t / gist:5168151
Created March 15, 2013 07:45
SQL function(s) to convert phpBB3 HTML URLs to BBCODE. In particular, I used this when migrating from phpBB3 to MyBB. These two functions could easily be refactored for doing many other HTML->BBCODE conversions. Just follow the patterns.
DELIMITER ||
DROP FUNCTION IF EXISTS GET_DATA||
CREATE FUNCTION GET_DATA( _data LONGTEXT, _begin LONGTEXT, _end LONGTEXT) RETURNS LONGTEXT
LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA
BEGIN
DECLARE _startPos INT UNSIGNED;
DECLARE _endPos INT UNSIGNED;
SET _startPos = LOCATE(_begin, _data, 1);
IF _startPos < 1 THEN RETURN NULL; END IF;
SET _startPos = _startPos + LENGTH(_begin);
@QWp6t
QWp6t / gist:3594932
Created September 2, 2012 05:01
AutoIt3 UDF and Preprocessor keywords
var preprocessor =
'#autoit3wrapper_au3check_parameters #autoit3wrapper_au3check_stop_onwarning ' +
'#autoit3wrapper_change2cui #autoit3wrapper_compression #autoit3wrapper_cvswrapper_parameters ' +
'#autoit3wrapper_icon #autoit3wrapper_outfile #autoit3wrapper_outfile_type #autoit3wrapper_plugin_funcs ' +
'#autoit3wrapper_res_comment #autoit3wrapper_res_description #autoit3wrapper_res_field ' +
'#autoit3wrapper_res_file_add #autoit3wrapper_res_fileversion #autoit3wrapper_res_fileversion_autoincrement ' +
'#autoit3wrapper_res_icon_add #autoit3wrapper_res_language #autoit3wrapper_res_legalcopyright ' +
'#autoit3wrapper_res_requestedexecutionlevel #autoit3wrapper_res_savesource #autoit3wrapper_run_after ' +
'#autoit3wrapper_run_au3check #autoit3wrapper_run_before #autoit3wrapper_run_cvswrapper ' +
'#autoit3wrapper_run_debug_mode #autoit3wrapper_run_obfuscator #autoit3wrapper_run_tidy ' +