fix(structure): Rename assets and inc folders for Linux compatibility
- assets → Assets - inc → Inc Completes the case-sensitivity fixes for Linux servers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
127
Inc/social-share.php
Normal file
127
Inc/social-share.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* Social Share Buttons
|
||||
*
|
||||
* Funciones para mostrar botones de compartir en redes sociales
|
||||
* en posts individuales. Utiliza URLs nativas sin dependencias de JavaScript.
|
||||
*
|
||||
* @package ROI_Theme
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
// Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el HTML de los botones de compartir en redes sociales
|
||||
*
|
||||
* @param int $post_id ID del post (opcional, usa el post actual si no se proporciona)
|
||||
* @return string HTML de los botones de compartir
|
||||
*/
|
||||
function roi_get_social_share_buttons( $post_id = 0 ) {
|
||||
// Si no se proporciona post_id, usar el post actual
|
||||
if ( ! $post_id ) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
|
||||
// Verificar que es un post válido
|
||||
if ( ! $post_id ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Obtener información del post
|
||||
$post_title = get_the_title( $post_id );
|
||||
$post_url = get_permalink( $post_id );
|
||||
$post_url_encoded = urlencode( $post_url );
|
||||
$post_title_encoded = urlencode( $post_title );
|
||||
|
||||
// URLs de compartir para cada red social
|
||||
$facebook_url = 'https://www.facebook.com/sharer/sharer.php?u=' . $post_url_encoded;
|
||||
$twitter_url = 'https://twitter.com/intent/tweet?url=' . $post_url_encoded . '&text=' . $post_title_encoded;
|
||||
$linkedin_url = 'https://www.linkedin.com/shareArticle?mini=true&url=' . $post_url_encoded . '&title=' . $post_title_encoded;
|
||||
$whatsapp_url = 'https://api.whatsapp.com/send?text=' . $post_title_encoded . '%20' . $post_url_encoded;
|
||||
$email_url = 'mailto:?subject=' . $post_title_encoded . '&body=' . $post_url_encoded;
|
||||
|
||||
// Obtener texto de compartir desde BD (Clean Architecture)
|
||||
$share_text = roi_get_component_setting( 'social-share', 'content', 'share_text', __( 'Compartir:', 'roi-theme' ) );
|
||||
|
||||
// Construir el HTML
|
||||
ob_start();
|
||||
?>
|
||||
<!-- Share Buttons Section -->
|
||||
<div class="social-share-section my-5 py-4 border-top">
|
||||
<p class="mb-3 text-muted"><?php echo esc_html( $share_text ); ?></p>
|
||||
<div class="d-flex gap-2 flex-wrap share-buttons">
|
||||
<!-- Facebook -->
|
||||
<a href="<?php echo esc_url( $facebook_url ); ?>"
|
||||
class="btn btn-outline-primary btn-sm"
|
||||
aria-label="<?php esc_attr_e( 'Compartir en Facebook', 'roi-theme' ); ?>"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
<i class="bi bi-facebook"></i>
|
||||
</a>
|
||||
|
||||
<!-- X (Twitter) -->
|
||||
<a href="<?php echo esc_url( $twitter_url ); ?>"
|
||||
class="btn btn-outline-dark btn-sm"
|
||||
aria-label="<?php esc_attr_e( 'Compartir en X', 'roi-theme' ); ?>"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
<i class="bi bi-twitter-x"></i>
|
||||
</a>
|
||||
|
||||
<!-- LinkedIn -->
|
||||
<a href="<?php echo esc_url( $linkedin_url ); ?>"
|
||||
class="btn btn-outline-info btn-sm"
|
||||
aria-label="<?php esc_attr_e( 'Compartir en LinkedIn', 'roi-theme' ); ?>"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
<i class="bi bi-linkedin"></i>
|
||||
</a>
|
||||
|
||||
<!-- WhatsApp -->
|
||||
<a href="<?php echo esc_url( $whatsapp_url ); ?>"
|
||||
class="btn btn-outline-success btn-sm"
|
||||
aria-label="<?php esc_attr_e( 'Compartir en WhatsApp', 'roi-theme' ); ?>"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
<i class="bi bi-whatsapp"></i>
|
||||
</a>
|
||||
|
||||
<!-- Email -->
|
||||
<a href="<?php echo esc_url( $email_url ); ?>"
|
||||
class="btn btn-outline-secondary btn-sm"
|
||||
aria-label="<?php esc_attr_e( 'Compartir por Email', 'roi-theme' ); ?>">
|
||||
<i class="bi bi-envelope"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Template tag para mostrar los botones de compartir
|
||||
*
|
||||
* Muestra los botones de compartir en redes sociales solo en posts individuales
|
||||
* si la opción está habilitada en el panel de opciones del tema.
|
||||
*
|
||||
* @param int $post_id ID del post (opcional)
|
||||
*/
|
||||
function roi_display_social_share( $post_id = 0 ) {
|
||||
// Solo mostrar en posts individuales
|
||||
if ( ! is_single() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verificar si los botones de compartir están habilitados (Clean Architecture)
|
||||
$is_enabled = roi_get_component_setting( 'social-share', 'visibility', 'is_enabled', true );
|
||||
if ( !$is_enabled ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Mostrar los botones
|
||||
echo roi_get_social_share_buttons( $post_id );
|
||||
}
|
||||
Reference in New Issue
Block a user