Skip to content

Instantly share code, notes, and snippets.

View leewillis77's full-sized avatar

Lee Willis leewillis77

View GitHub Profile
@leewillis77
leewillis77 / Revised Drupal Sirportly module patch.diff
Created November 23, 2012 21:23
Revised Drupal Sirportly module patch
diff --git a/sirportly.module b/sirportly.module
index 6872dcf..4463647 100644
--- a/sirportly.module
+++ b/sirportly.module
@@ -33,6 +33,24 @@ function sirportly_init() {
}
/**
+ * Implements hook_libraries_info().
+ */
<?php
$array_1 = array( 'apple', 'orange', 'bananna', 'grape' );
$array_2 = array(
'apple' => 'pear',
'grape' => 'pineapple',
);
$result = array();
@leewillis77
leewillis77 / gist:5853523
Last active December 18, 2015 22:19
What would cause this HTML to display as three radio buttons, but *ALL* unchecked?
<input type="radio" class="quote-method" name="quote_method" value="total" checked>Single quote for total cart weight<br>
<input type="radio" class="quote-method" name="quote_method" value="items" >Sum of quotes for individual items<br>
<input type="radio" class="quote-method" name="quote_method" value="consolidateditems" >Sum of quotes for consolidated items<br>
<?php
class foo {
public function bar() {
}
}
@leewillis77
leewillis77 / gist:6500568
Created September 9, 2013 19:48
All-in-one SEO pack title change
Index: aioseop_class.php
===================================================================
--- aioseop_class.php (revision 769315)
+++ aioseop_class.php (working copy)
@@ -1545,7 +1545,7 @@
$this->title_end = $end;
$this->orig_title = $title;
- return preg_replace( '/<title>(.*?)<\/title>/is', '<title>' . preg_replace('/(\$|\\\\)(?=\d)/', '\\\\\1', strip_tags( $title ) ) . '</title>', $content );
+ return preg_replace( '/<title>(.*?)<\/title>/is', '<title>' . preg_replace('/(\$|\\\\)(?=\d)/', '\\\\\1', strip_tags( $title ) ) . '</title>', $content, 1 );
@leewillis77
leewillis77 / gist:7203840
Last active December 26, 2015 19:49
Process feed in smaller chunks
<?php
function gpf_filter_chunk_size($size) {
return 5;
}
add_filter('woocommerce_gpf_chunk_size', 'gpf_filter_chunk_size',10, 1);
@leewillis77
leewillis77 / gist:8348193
Last active October 25, 2018 15:25
How to use config values in Codeception tests?

I'm currently looking at using Codeception to test WordPress plugins. I've got most things set up how I'd like, but there's one final step that doesn't feel right. Because the tests will be distributed, and I want anyone to be able to run them on an install of their choosing some of the "config" for the tests needs to be easily changeable.

So - I need the real config to not be stored in version control. For site URL that's straightforward, I can not distribute the acceptance.suite.yml and instead distribute a sample file that the user can copy to acceptance.suite.yml and customise as appropriate.

However - my tests also need some other config that I'd want to be outside of version control. Ideally I'd add this config to the same YML file, but I need to be able to access it from the tests, e.g.

acceptance.suite.yml:

class_name: WebGuy
modules:
@leewillis77
leewillis77 / gist:18a04eef8f6305711ca4
Last active August 29, 2015 14:08
Hook/Filter arg best practice
<?php
// Consider the following hook
do_action( 'my_swanky_hook', $a, $b, $c );
/*
* I would traditionally attach as follows:
*/
function my_swanky_hook_handler( $a, $b, $c ) {
@leewillis77
leewillis77 / ansi-colors.css
Created April 23, 2015 15:23
Replacement build log stylesheet for PHPCI
.ansi_color_fg_black { color: black }
.ansi_color_bg_black { background-color: black }
.ansi_color_fg_red { color: orangered; font-weight: bold }
.ansi_color_bg_red { background-color: red }
.ansi_color_fg_green { color: lawngreen; }
.ansi_color_bg_green { background-color: green }
.ansi_color_fg_yellow { color: yellow; }
.ansi_color_bg_yellow { background-color: yellow }
.ansi_color_fg_blue { color: blue; }
.ansi_color_bg_blue { background-color: blue }
@leewillis77
leewillis77 / functions.php
Created April 28, 2016 10:58
Schema.org video markup for Vimeo video embeds on WordPress
<?php
function crfw_embed_oembed_html($html, $url, $attr, $post_id) {
// Only do something if this is Vimeo embed.
if ( stripos( $url, 'https://vimeo.com' ) !== 0 ) {
return $html;
}
// Grab the data we need.
$title = preg_replace('/.*title="([^"]*)".*/', '$1', $html);