Skip to content

Instantly share code, notes, and snippets.

View davekuhar's full-sized avatar
🧑‍🚀

Dave Kuhar davekuhar

🧑‍🚀
  • 09:14 (UTC -04:00)
View GitHub Profile
/* remove pesky youtube links from post excerpts */
add_filter('wpv_filter_post_excerpt', 'xmit_remove_youtubelinks');
function xmit_remove_youtubelinks($excerpt){
return $excerpt = preg_replace('~(?:http|https|)(?::\/\/|)(?:www.|)(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[a-z0-9;:@?&%=+\/\$_.-]*~i', '', $excerpt);
}
@davekuhar
davekuhar / string-utils.js
Created June 28, 2019 16:17 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str){
return str.toLowerCase();
<?php
// Sort a CPT by Title – just change the CPT slug at is_post_type_archive
add_filter( 'parse_query', 'sorting_archives' );
function sorting_archives( $wp_query ) {
if (is_post_type_archive( 'gg_engagement' ) || is_tax()) {
$wp_query->set( 'orderby', 'title' );
$wp_query->set( 'order', 'ASC' );
}
return $wp_query;
<input type="email" id="validateEmailAddress" class="form-control" autocomplete="off" onpaste="return false;" required="" placeholder="Re-enter your email address here..." data-com.agilebits.onepassword.user-edited="yes">
<?php
function add_tracking_to_footer() {
?>
<script type="text/javascript"> _linkedin_partner_id = "1061154"; window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || []; window._linkedin_data_partner_ids.push(_linkedin_partner_id); </script><script type="text/javascript"> (function(){var s = document.getElementsByTagName("script")[0]; var b = document.createElement("script"); b.type = "text/javascript";b.async = true; b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js"; s.parentNode.insertBefore(b, s);})(); </script> <noscript> <img height="1" width="1" style="display:none;" alt="" src="https://dc.ads.linkedin.com/collect/?pid=1061154&fmt=gif" /> </noscript>
<?php
}
add_action ('wp_footer', 'add_tracking_info_to_footer', 99);
In Woocommerce -> Settings -> Shipping, set up a Shipping Zone for Standard Shipping.
Add Shipping methods, in this case three: Standard Shipping ($7), Discounted Shipping ($5), and Free Shipping ($0).
Add the PHP to functions.php. To find out the id # of the rates, inspect the shipping methods in your browser;
the data-id of the table row for each is what has to go into the 'flat_rate:x' string.
@davekuhar
davekuhar / image_optimize-wordpress.php
Created April 24, 2019 20:56 — forked from wycks/image_optimize-wordpress.php
Remove WordPress full size images from being inserted into a post + option to and add max size to to prevent users from inserting massive images.
<?php
/**
*
* This removes the ability to add the FULL image size into a post, it does not alter or delete the image
* Add whataever extra image sizes to the insert dropdown in WordPress you create via add_image_size
*
* For now we have to do it this way to make the labels translatable, see trac ref below.
*
* If your theme has $content_width GLOBAL make sure and remove it
<?php
// first, create the function to put your tracking code into
function add_tracking_info_to_head() {
// paste your tracking code between the ?> and <?php below – in this case it's for Google Analytics
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<?php
add_filter( 'fl_builder_override_lightbox', '__return_true' );
?>
@davekuhar
davekuhar / enqueue-font-awesome-5.php
Last active February 22, 2019 19:53 — forked from Pross/functions.php
Font Awesome 5
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_style( 'font-awesome-5' );
} );