Split feed links and fix parsing issue when no location set
This commit is contained in:
@@ -25,15 +25,29 @@ class SP_Meta_Box_Calendar_Feeds {
|
||||
$calendar_feeds = $feeds->calendar;
|
||||
?>
|
||||
<div>
|
||||
<?php foreach ( $calendar_feeds as $feed => $name ) { ?>
|
||||
<?php $link = str_replace( array( 'http:', 'https:' ), 'webcal:', add_query_arg( 'feed', 'sp-' . $feed, untrailingslashit( get_post_permalink( $post ) ) ) ); ?>
|
||||
<p>
|
||||
<strong><?php echo $name; ?></strong>
|
||||
<a class="sp-link" href="<?php echo $link; ?>" title="<?php _e( 'Link', 'sportspress' ); ?>"></a>
|
||||
</p>
|
||||
<p>
|
||||
<input type="text" value="<?php echo $link; ?>" readonly="readonly" class="code widefat">
|
||||
</p>
|
||||
<?php foreach ( $calendar_feeds as $slug => $formats ) { ?>
|
||||
<?php $link = add_query_arg( 'feed', 'sp-' . $slug, untrailingslashit( get_post_permalink( $post ) ) ); ?>
|
||||
<?php foreach ( $formats as $format ) { ?>
|
||||
<?php
|
||||
$protocol = sp_array_value( $format, 'protocol' );
|
||||
if ( $protocol ) {
|
||||
$feed = str_replace( array( 'http:', 'https:' ), 'webcal:', $link );
|
||||
} else {
|
||||
$feed = $link;
|
||||
}
|
||||
$prefix = sp_array_value( $format, 'prefix' );
|
||||
if ( $prefix ) {
|
||||
$feed = $prefix . urlencode( $feed );
|
||||
}
|
||||
?>
|
||||
<p>
|
||||
<strong><?php echo sp_array_value( $format, 'name' ); ?></strong>
|
||||
<a class="sp-link" href="<?php echo $feed; ?>" target="_blank" title="<?php _e( 'Link', 'sportspress' ); ?>"></a>
|
||||
</p>
|
||||
<p>
|
||||
<input type="text" value="<?php echo $feed; ?>" readonly="readonly" class="code widefat">
|
||||
</p>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
@@ -22,15 +22,27 @@ class SP_Feeds {
|
||||
public function __construct() {
|
||||
$data = array(
|
||||
'calendar' => array(
|
||||
'ical' => __( 'iCal', 'sportspress' ),
|
||||
'ical' => array(
|
||||
'apple' => array(
|
||||
'name' => __( 'Apple Calendar', 'sportspress' ),
|
||||
'protocol' => 'webcal',
|
||||
),
|
||||
'outlook' => array(
|
||||
'name' => __( 'Outlook', 'sportspress' ),
|
||||
'protocol' => 'webcal',
|
||||
),
|
||||
'google' => array(
|
||||
'name' => __( 'Google', 'sportspress' ),
|
||||
'prefix' => 'http://www.google.com/calendar/render?cid=',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->data = apply_filters( 'sportspress_feeds', $data );
|
||||
|
||||
foreach ( $data as $type => $feeds ) {
|
||||
foreach ( $feeds as $slug => $name ) {
|
||||
$this->feed = $slug;
|
||||
foreach ( $data as $post_type => $feeds ) {
|
||||
foreach ( $feeds as $slug => $formats ) {
|
||||
add_feed( 'sp-' . $slug, array( $this, $slug . '_feed' ) );
|
||||
}
|
||||
}
|
||||
@@ -45,7 +57,7 @@ class SP_Feeds {
|
||||
}
|
||||
|
||||
public static function ical_feed() {
|
||||
$feed_template = SP()->plugin_path() . '/feeds/ical.php';
|
||||
$feed_template = SP()->plugin_path() . '/feeds/ical.php';
|
||||
load_template( $feed_template );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user