| 1 |
<?php |
| 2 |
/** |
| 3 |
* Social media icons CSS partial - shared across all campaign templates. |
| 4 |
* |
| 5 |
* This file generates CSS for social media icon background images using |
| 6 |
* proper absolute URLs instead of broken relative URLs. |
| 7 |
* |
| 8 |
* @package Charitable/CSS-Templates/Admin/Partials |
| 9 |
* @author WP Charitable LLC |
| 10 |
* @copyright Copyright (c) 2024, WP Charitable LLC |
| 11 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 12 |
* @since 1.8.9.2 |
| 13 |
* @version 1.8.9.4 |
| 14 |
*/ |
| 15 |
|
| 16 |
// Exit if accessed directly. |
| 17 |
if ( ! defined( 'ABSPATH' ) ) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
// Ensure required variables are available. |
| 22 |
if ( ! isset( $wrapper ) || ! isset( $icon_style ) ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
// Define available social media icons. |
| 27 |
$social_icons = array( |
| 28 |
'twitter', |
| 29 |
'facebook', |
| 30 |
'linkedin', |
| 31 |
'instagram', |
| 32 |
'pinterest', |
| 33 |
'tiktok', |
| 34 |
'mastodon', |
| 35 |
'youtube', |
| 36 |
'threads', |
| 37 |
'bluesky', |
| 38 |
); |
| 39 |
|
| 40 |
// Determine icon suffix based on style. |
| 41 |
$icon_suffix = ( $icon_style === 'white' ) ? '-white' : '-dark'; |
| 42 |
|
| 43 |
/** |
| 44 |
* Filter the social media icons to include in templates. |
| 45 |
* |
| 46 |
* @since 1.8.9.2 |
| 47 |
* @version 1.8.9.4 |
| 48 |
* |
| 49 |
* @param array $social_icons List of social media icon names. |
| 50 |
* @param string $icon_style Icon style ('dark' or 'white'). |
| 51 |
*/ |
| 52 |
$social_icons = apply_filters( 'charitable_campaign_builder_social_icons', $social_icons, $icon_style ); |
| 53 |
|
| 54 |
// Output CSS for each social media icon. |
| 55 |
foreach ( $social_icons as $icon ) { |
| 56 |
$icon_path = "images/campaign-builder/fields/social-links/{$icon}{$icon_suffix}.svg"; |
| 57 |
$icon_url = charitable_get_campaign_builder_asset_url( $icon_path ); |
| 58 |
|
| 59 |
// Skip if asset URL couldn't be generated. |
| 60 |
if ( empty( $icon_url ) ) { |
| 61 |
continue; |
| 62 |
} |
| 63 |
|
| 64 |
// Output CSS for both social linking and social sharing variants. |
| 65 |
?> |
| 66 |
/* <?php echo esc_html( ucfirst( $icon ) ); ?> Icon */ |
| 67 |
<?php echo charitable_esc_attr_php( $wrapper ); ?> .charitable-field-preview-social-linking .charitable-social-linking-preview-<?php echo esc_attr( $icon ); ?> .charitable-placeholder, |
| 68 |
<?php echo charitable_esc_attr_php( $wrapper ); ?> .charitable-field-preview-social-sharing .charitable-social-sharing-preview-<?php echo esc_attr( $icon ); ?> .charitable-placeholder { |
| 69 |
background-image: url('<?php echo esc_url( $icon_url ); ?>'); |
| 70 |
} |
| 71 |
<?php |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Allow templates to add custom social icon CSS. |
| 76 |
* |
| 77 |
* @since 1.8.9.2 |
| 78 |
* @version 1.8.9.4 |
| 79 |
* |
| 80 |
* @param string $wrapper CSS wrapper selector. |
| 81 |
* @param string $icon_style Icon style ('dark' or 'white'). |
| 82 |
*/ |
| 83 |
do_action( 'charitable_campaign_builder_social_icons_css', $wrapper, $icon_style ); |
| 84 |
?> |