This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Upscale images that are otherwise too small for thumbnail cropping */ | |
function gc_thumbnail_upscale( $default, $orig_w, $orig_h, $new_w, $new_h, $crop ){ | |
if ( !$crop ) return null; // let the WordPress default function handle this | |
$aspect_ratio = $orig_w / $orig_h; | |
$size_ratio = max($new_w / $orig_w, $new_h / $orig_h); | |
$crop_w = round($new_w / $size_ratio); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Hide a Flat Rate option (instance #7) when the "Call for Quote" shipping class is in the cart | |
* from: https://www.bolderelements.net/support/knowledgebase/hide-shipping-method-when-cart-contains-shipping-class/ | |
*/ | |
function fs_hide_shipping_when_class_is_in_cart( $rates, $package ) { | |
// shipping class IDs (slugs) that need the method removed | |
$shipping_classes = array('call-for-quote'); | |
$if_exists = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// create shortcode to list all Games in Page | |
add_shortcode( 'fs-game-schedule-page-loop', 'fs_sc_game_schedule_page_loop' ); | |
function fs_sc_game_schedule_page_loop( $atts ) { | |
ob_start(); | |
// define attributes and their defaults | |
extract( shortcode_atts( array ( | |
'post_type' => 'fs_schedule', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* NOTE, this causes PAGES AND POSTS TO NOT WORK! | |
*/ | |
/** | |
* NOTE, this also requires your post type (e.g., via CPT UI) to have a Rewrite to True, | |
* and a Custom Rewrite Slug of / (forward slash) ... which probably isn't best practice. | |
* Sources: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$local_args = array( | |
'posts_per_page' => -1, | |
'post_type' => 'fs_local', | |
); | |
$local_posts_array = get_posts( $local_args ); | |
foreach ( $local_posts_array as $post ) { | |
update_post_meta( $post->ID, 'us_header_id', '__defaults__' ); | |
update_post_meta( $post->ID, 'us_titlebar_id', '__defaults__' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode( 'fs-project-go-back', 'fs_product_go_back_shortcode' ); | |
function fs_product_go_back_shortcode( $atts ) { | |
// begin output buffering | |
ob_start(); | |
// grab the terms of the product's attribute | |
$project_cats = get_the_terms($post->ID, 'project_category'); | |
//$count = count($project_cats); | |
echo '<div class="fs-project-go-back">'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('wp_footer', 'fs_preloader_code'); | |
function fs_preloader_code(){ | |
if(is_front_page()) { ?> | |
<div class="fs-preloader"> | |
<div class="fs-status"></div> | |
</div> | |
<?php } | |
}; | |
add_action('wp_head', 'fs_preloader_js'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ACF Group Shortcode | |
function shortcode_acf_find_my_flowers( $atts ) { | |
// begin output buffering | |
ob_start(); | |
if( have_rows('where_to_find_my_flowers') ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tag_cloud_shortcode($atts) { | |
// first make sure we are within a category | |
if (is_category()) { | |
// get info of current category | |
$category = get_category( get_query_var( 'cat' ) ); | |
// get current category ID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** In WP All Export, add a new ID field and give it a custom Column Name, then... | |
* set the field to "Export the value returned by a PHP function"... | |
* where the function name is fs_format_get_date ... | |
* then add this function to the Function Editor, so that... | |
* the column in the export will use the proper date timezone and post time, rather than the "post_date_gmt" value | |
*/ | |
function fs_format_get_date ($id) { | |
$new_date = get_the_date($d = 'Y-m-d H:i:s', $id); | |
return $new_date; |