Skip to content

Instantly share code, notes, and snippets.

View leewillis77's full-sized avatar

Lee Willis leewillis77

View GitHub Profile
add_action ( 'init', function() {
global $wp_rewrite;
add_rewrite_endpoint('testendpoint', EP_ROOT);
$wp_rewrite->flush_rules();
});
@leewillis77
leewillis77 / Drupal Sirportly Integration patch
Created November 23, 2012 21:10
Drupal Sirportly Integration patch
diff --git a/sirportly.module b/sirportly.module
index 6872dcf..2fbe075 100644
--- a/sirportly.module
+++ b/sirportly.module
@@ -33,6 +33,21 @@ function sirportly_init() {
}
/**
+ * Implements hook_libraries_info().
+ */
@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 / subselect.diff
Created June 28, 2017 20:42
Subselect instead of view proof-of-concept
diff --git a/includes/class-campaigns-db.php b/includes/class-campaigns-db.php
index bc572401..ee2e9892 100644
--- a/includes/class-campaigns-db.php
+++ b/includes/class-campaigns-db.php
@@ -27,10 +27,21 @@ class Affiliate_WP_Campaigns_DB extends Affiliate_WP_DB {
if( defined( 'AFFILIATE_WP_NETWORK_WIDE' ) && AFFILIATE_WP_NETWORK_WIDE ) {
// Allows a single visits table for the whole network
- $this->table_name = 'affiliate_wp_campaigns';
+ $visits_db = 'affiliate_wp_visits';
@leewillis77
leewillis77 / functions.php
Created January 9, 2018 10:55
Redirect to cart from cart recovery emails : https://wp-cart-recovery.com
function lw_crfw_return_redirect_url( $redirect_url, $cart ) {
if ( ! function_exists( 'wc_get_cart_url' ) ) {
WC()->frontend_includes();
}
return wc_get_cart_url();
}
add_action( 'crfw_return_redirect_url', 'lw_crfw_return_redirect_url', 10, 2 );