Skip to content

Instantly share code, notes, and snippets.

View simonhughes's full-sized avatar

Simon Hughes simonhughes

  • Norwich, England
  • 07:23 (UTC +01:00)
View GitHub Profile
@simonhughes
simonhughes / phpdoc.xml
Created May 10, 2018 11:15
An example phpdocs config for a Laravel project type.
<?xml version="1.0" encoding="UTF-8" ?>
<phpdoc>
<target>output</target>
<encoding>utf8</encoding>
<parser>
<target>docs</target>
<markers>
<item>TODO</item>
<item>FIXME</item>
</markers>
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->exclude('database/migrations')
->exclude('database/seeds')
->files('*.php')
;
return PhpCsFixer\Config::create()
@simonhughes
simonhughes / add_custom_taxonomies_to_search_query.php
Created December 14, 2018 11:23
WordPress: add custom taxonomies to search query.
/**
* Filter: extend search query to look for custom taxonomies.
*/
add_filter('posts_where', function ($where) {
global $wpdb;
if (is_search()) {
$where .= " OR (t.name LIKE '%".get_search_query() . "%' AND {$wpdb->posts}.post_status = 'publish') ";
}
@simonhughes
simonhughes / function.php
Created August 12, 2019 15:50
WordPress: convert bbcode in ACF field messages and instructions to HTML markup.
/**
* Filter: convert bbcode into html markup for added emphasis to ACF fields.
*
* @note thanks to StackOverflow https://stackoverflow.com/questions/24200048/show-bbcode-in-html-page-with-php
* @return $field
*/
add_filter('acf/prepare_field', function($field){
// Are both viable fields empty; else: bail out.
if (empty($field['message']) && empty($field['instructions']))
<ul>
<li>About me point 1</li>
<li>About me point 2</li>
<li>About me point 3</li>
</ul>