Skip to content

Instantly share code, notes, and snippets.

@QWp6t
QWp6t / VirtualFileSystem.php
Created Jul 28, 2018
Trait for using mikey179/vfsStream with phpunit
View VirtualFileSystem.php
<?php
namespace QWp6t\Tests;
/** composer require mikey179/vfsStream --dev */
use org\bovigo\vfs\vfsStream;
trait VirtualFileSystem
{
protected $filesystem;
@QWp6t
QWp6t / BedrockMultisiteDriver.php
Last active Jan 4, 2019
Fix Laravel Valet when using WordPress subdirectory multisite + Bedrock
View BedrockMultisiteDriver.php
<?php
class BedrockMultisiteDriver extends BedrockValetDriver
{
/**
* Determine if the incoming request is for a static file.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
View Bootstrap.php
<?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 Jun 30, 2016
Add optgroup support to WooCommerce select form fields
View wc-checkout-fields-optgroup.php
<?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 Sep 22, 2015
`filter_input` validation
View process-input.php
<?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 Oct 14, 2018
Adds ACF Field Group location rule for Post Type Support.
View acf-post-type-supports.php
<?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 Mar 15, 2013
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.
View gist:5168151
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 Sep 2, 2012
AutoIt3 UDF and Preprocessor keywords
View gist:3594932
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 ' +
You can’t perform that action at this time.