Skip to content

Instantly share code, notes, and snippets.

View davekuhar's full-sized avatar
🧑‍🚀

Dave Kuhar davekuhar

🧑‍🚀
  • 03:10 (UTC -04:00)
View GitHub Profile
<?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' );
} );
<span class="fl-icon"><i class="far fa-address-card" aria-hidden="true"></i></span>
<span class="fl-icon"><i class="fab fa-linkedin-in" aria-hidden="true"></i></span>
<span class="fl-icon"><i class="far fa-envelope" aria-hidden="true"></i></span>
<span class="fl-icon"><i class="fas fa-phone" aria-hidden="true"></i></span>
<span class="fl-icon"><i class="fab fa-facebook-square" aria-hidden="true"></i></span>
<?php
// via https://metabox.io/beaver-builder-remove-scripts-styles/
// remove unneeded scripts/styles in BB
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_style( 'font-awesome' ); // FontAwesome 4
wp_enqueue_style( 'font-awesome-5' ); // FontAwesome 5
wp_dequeue_style( 'jquery-magnificpopup' );
wp_dequeue_script( 'jquery-magnificpopup' );