Skip to content

Instantly share code, notes, and snippets.

View sunshinephotocart's full-sized avatar

Sunshine Photo Cart sunshinephotocart

View GitHub Profile
@sunshinephotocart
sunshinephotocart / sunshine-single-image-exif.php
Last active October 5, 2023 18:59
Show all EXIF/image meta on single image view (Sunshine 3)
add_action( 'sunshine_after_image', 'sunshine_exif_data' );
function sunshine_exif_data( $image ) {
$meta = wp_get_attachment_metadata( $image->get_id() );
$image_meta = $meta['image_meta']; // Get the meta data/EXIF from the image upload
foreach ( $image_meta as $key => $value ) {
if ( !empty( $value ) ) {
echo ucwords( $key ) . ': '; // Display key as label
if ( is_array( $value ) ) {
echo join( ', ', $value ); // Display array values comma separated, likely keywords
} else {
@sunshinephotocart
sunshinephotocart / image-keywords.php
Created October 5, 2023 18:55
Show keywords for an image
add_action( 'sunshine_after_image', 'sunshine_show_image_keywords' );
function sunshine_show_image_keywords( $image ) {
$metadata = $image->get_meta_value( '_wp_attachment_metadata' );
if ( ! empty( $metadata['image_meta']['keywords'] ) ) {
echo join( ', ', $metadata['image_meta']['keywords'] );
}
}
@sunshinephotocart
sunshinephotocart / remove-register-login
Last active August 21, 2023 23:09
Remove Register and Login from Sunshine Photo Cart 3 Main Menu
// Add this to your theme's functions.php file or use a plugin like Code Snippets
add_filter( 'sunshine_main_menu', 'custom_sunshine_main_menu', 999 );
function custom_sunshine_main_menu( $menu ) {
unset( $menu[100] );
unset( $menu[110] );
return $menu;
}
// OR, alternatively add this to Sunshine > Settings > Design > Custom CSS
li.sunshine--login, li.sunshine--register { display: none; }
@sunshinephotocart
sunshinephotocart / entire-gallery-download-before-add-cart.php
Created June 5, 2023 17:35
Entire Gallery Download add to cart link before add to cart form
@sunshinephotocart
sunshinephotocart / sunshine-checkout-redirect.php
Last active May 31, 2023 18:18
Redirect to login or registration if not logged in at checkout
// Redirects to Login page.
add_action( 'template_redirect', function() {
global $sunshine;
if ( ! is_user_logged_in() && is_page( $sunshine->options['page_checkout'] ) ) {
wp_redirect( wp_login_url( get_permalink( $sunshine->options['page_checkout'] ) ) );
exit;
}
});
// Redirects to Registration page.
// Add this to your theme's functions.php file
// Or use this plugin https://wordpress.org/plugins/insert-headers-and-footers/
add_filter( 'sunshine_allowed_css', 'sunshine_custom_allowed_css' );
function sunshine_custom_allowed_css( $allowed ) {
$allowed[] = 'cookie'; // This must contain a keyword from the wp_enqueue_style from your plugin/theme
return $allowed;
}
// Add this to your theme's functions.php file
// Or use this plugin https://wordpress.org/plugins/my-custom-functions/
add_filter( 'sunshine_currencies', 'my_custom_sunshine_currencies' );
function my_custom_sunshine_currencies( $currencies ) {
$currencies['TND'] = 'Tunisian Dinar'; // TND = Currency code and then name
return $currencies;
}
@sunshinephotocart
sunshinephotocart / sunshine-custom-action-menu.php
Created September 20, 2021 17:24
Add menu item to action menu
// Add this to your theme's functions.php file
// Or use this plugin https://wordpress.org/plugins/my-custom-functions/
add_filter( 'sunshine_action_menu', 'my_custom_sunshine_action_menu' );
function my_custom_sunshine_action_menu( $menu ) {
$menu[97] = array(
'name' => 'PAGE_NAME',
'url' => "PAGE_URL',
);
return $menu;
}
@sunshinephotocart
sunshinephotocart / add-to-sunshine-main-menu.php
Last active July 12, 2021 21:04
Add item to Sunshine Main 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 ) {
$menu[3] = array( // The 3 represents the position this menu item will be, 1 will be first
'name' => 'NAME OF YOUR LINK',
'url' => 'URL_HERE'
);
return $menu;
}
@sunshinephotocart
sunshinephotocart / sunshine-related-images.php
Last active May 7, 2021 19:49
Show related images in single image view