Skip to content

Instantly share code, notes, and snippets.

View sunshinephotocart's full-sized avatar

Sunshine Photo Cart sunshinephotocart

View GitHub Profile
@sunshinephotocart
sunshinephotocart / gist:74a54b2d20bc9279e586
Last active January 26, 2016 17:45
Add cart/checkout to action menu (gallery and image pages)
add_filter( 'sunshine_action_menu', 'my_sunshine_action_menu' );
function my_sunshine_action_menu( $menu ) {
global $sunshine;
if ( !empty( $sunshine->cart->content ) )
$cart_count = '<span class="sunshine-count sunshine-cart-count">'.$sunshine->cart->item_count.'</span>';
$menu[90] = array(
'name' => __( 'Cart','sunshine' ),
'url' => sunshine_url( 'cart' ),
@sunshinephotocart
sunshinephotocart / new-favorites-icon
Created April 4, 2016 22:14
Change favorites icon
add_filter( 'sunshine_action_menu', 'sunshine_favorites_custom_action_menu_icon', 90 );
function sunshine_favorites_custom_action_menu_icon( $menu ) {
if ( isset( $menu[15] ) ) {
$menu[15]['icon'] = 'WHATEVER'; // See http://fortawesome.github.io/Font-Awesome/cheatsheet/
}
return $menu;
}
@sunshinephotocart
sunshinephotocart / gist:64bf83fd97a49f135e7b46478914bfa5
Last active July 22, 2016 18:28
Default lightbox quantity to 1
<?php
// Add following to your theme's functions.php file or use something like https://wordpress.org/plugins/custom-css-js-php/
add_action( 'sunshine_before_add_to_cart_form', 'sunshine_lightbox_default_qty_1' );
function sunshine_lightbox_default_qty_1() {
?>
<script>
jQuery( document ).ready( function($){
$( 'input[name="quantity"]' ).val( 1 );
});
</script>
@sunshinephotocart
sunshinephotocart / change-in-cart-icon
Created November 8, 2016 16:42
Different icon when image in cart
add_filter( 'sunshine_image_menu', 'sunshine_in_cart_icon', 90, 2 );
function sunshine_in_cart_icon( $menu, $image ) {
global $sunshine;
if ( isset( $menu[10] ) ) {
$cart = $sunshine->cart->get_cart();
if ( is_array( $cart ) ) {
foreach ( $cart as $item ) {
if ( $item['image_id'] == $image->ID ) {
$menu[10]['icon'] = 'check'; // See http://fortawesome.github.io/Font-Awesome/cheatsheet/
}
@sunshinephotocart
sunshinephotocart / gist:012b9ddc454b0fbed8ca
Last active January 9, 2018 18:10
Add link to Sunshine Main Menu
/*
Add a link to a Sunshine Photo Cart Main Menu
Add this code to your theme's functions.php
OR
Use this plugin: https://wordpress.org/plugins/my-custom-functions/
*/
add_filter( 'sunshine_main_menu', 'sunshine_custom_menu_item', 100 );
function sunshine_custom_menu_item( $menu ) {
$menu[45] = array( // Change 45 to any number, it determines where in the menu it shows
'name' => 'PAGE_NAME_HERE',
@sunshinephotocart
sunshinephotocart / gist:cda4a46b1358adc795aa
Last active January 15, 2018 21:42
Remove main galleries page from Sunshine Menu
// Add this to your theme's functions.php file
// Or use this plugin https://wordpress.org/plugins/my-custom-functions/
add_filter( 'sunshine_main_menu', 'custom_sunshine_main_menu', 999 );
function custom_sunshine_main_menu( $menu ) {
unset( $menu[10] );
return $menu;
}
// OR, alternatively add this to Sunshine > Settings > Design > Custom CSS
li.sunshine-galleries { display: none; }
@sunshinephotocart
sunshinephotocart / gist:5409b51662c793f2dab4a8634bb734d2
Created May 23, 2018 19:21
Hide Cart/Checkout when individual gallery has products disabled
// Add this to your theme's functions.php file
// Or use this plugin https://wordpress.org/plugins/my-custom-functions/
add_filter( 'sunshine_main_menu', 'custom_sunshine_main_menu', 999 );
function custom_sunshine_main_menu( $menu ) {
if ( isset( SunshineFrontend::$current_gallery ) && get_post_meta( SunshineFrontend::$current_gallery->ID, 'sunshine_gallery_disable_products', true ) ) {
unset( $menu[40] );
unset( $menu[50] );
}
return $menu;
}
@sunshinephotocart
sunshinephotocart / sunshine-allowed-file-types.php
Created October 26, 2018 16:27
Allow more file types in downloads
// Add this to your theme's functions.php file
// Or use this plugin https://wordpress.org/plugins/my-custom-functions/
add_filter( 'sunshine_allowed_file_extensions', 'sunshine_custom_allowed_file_extensions' );
function sunshine_custom_allowed_file_extensions( $extensions ) {
$download_extensions = array( 'mp4' );
return array_merge( $extensions, $download_extensions );
}
@sunshinephotocart
sunshinephotocart / sunshine-filter-image-name.php
Last active October 29, 2018 18:41
Sunshine Photo Cart: Filter image name to show file name
// Add this to your theme's functions.php file
// Or use this plugin https://wordpress.org/plugins/my-custom-functions/
add_filter( 'sunshine_image_name', 'my_sunshine_image_name', 10, 2 );
function my_sunshine_image_name( $name, $image ) {
return basename( get_attached_file( $image->ID ) );
}
@sunshinephotocart
sunshinephotocart / sunshine-show-caption
Last active January 29, 2019 22:11
Show caption name
// Add this to your theme's functions.php file
// Or use this plugin https://wordpress.org/plugins/my-custom-functions/
// Show caption under thumbnail
add_filter( 'sunshine_image_name', 'sunshine_thumbnail_show_caption', 10, 2 );
function sunshine_thumbnail_show_caption( $caption, $image ) {
if ( !empty( $image->post_excerpt ) ) {
$caption = $image->post_excerpt;
}
return $caption;