Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/shortcod...
File: upcoming-events.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Display a list of upcoming events from a calendar.
[3] Fix | Delete
*
[4] Fix | Delete
* @package automattic/jetpack
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[8] Fix | Delete
exit( 0 );
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Register a upcomingevents shortcode.
[13] Fix | Delete
* Most of the heavy lifting done in iCalendarReader class,
[14] Fix | Delete
* where the icalendar_render_events() function controls the display.
[15] Fix | Delete
*/
[16] Fix | Delete
class Upcoming_Events_Shortcode {
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Register things.
[20] Fix | Delete
*/
[21] Fix | Delete
public static function init() {
[22] Fix | Delete
add_shortcode( 'upcomingevents', array( __CLASS__, 'shortcode' ) );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Register the shortcode.
[27] Fix | Delete
*
[28] Fix | Delete
* @param array $atts Shortcode attributes.
[29] Fix | Delete
*/
[30] Fix | Delete
public static function shortcode( $atts = array() ) {
[31] Fix | Delete
require_once JETPACK__PLUGIN_DIR . '/_inc/lib/icalendar-reader.php';
[32] Fix | Delete
$atts = shortcode_atts(
[33] Fix | Delete
array(
[34] Fix | Delete
'url' => '',
[35] Fix | Delete
'number' => 0,
[36] Fix | Delete
),
[37] Fix | Delete
$atts,
[38] Fix | Delete
'upcomingevents'
[39] Fix | Delete
);
[40] Fix | Delete
$args = array(
[41] Fix | Delete
'context' => 'shortcode',
[42] Fix | Delete
'number' => absint( $atts['number'] ),
[43] Fix | Delete
);
[44] Fix | Delete
[45] Fix | Delete
if ( empty( $atts['url'] ) ) {
[46] Fix | Delete
// If the current user can access the Appearance->Widgets page.
[47] Fix | Delete
if ( current_user_can( 'edit_theme_options' ) ) {
[48] Fix | Delete
return sprintf( '<p>%s</p>', __( 'You must specify a URL to an iCalendar feed in the shortcode. This notice is only displayed to administrators.', 'jetpack' ) );
[49] Fix | Delete
}
[50] Fix | Delete
return self::no_upcoming_event_text();
[51] Fix | Delete
}
[52] Fix | Delete
$events = icalendar_render_events( $atts['url'], $args );
[53] Fix | Delete
[54] Fix | Delete
if ( ! $events ) {
[55] Fix | Delete
$events = self::no_upcoming_event_text();
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
return $events;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Returns No Upcoming Event text.
[63] Fix | Delete
*/
[64] Fix | Delete
private static function no_upcoming_event_text() {
[65] Fix | Delete
return sprintf( '<p>%s</p>', __( 'No upcoming events', 'jetpack' ) );
[66] Fix | Delete
}
[67] Fix | Delete
}
[68] Fix | Delete
add_action( 'after_setup_theme', array( 'Upcoming_Events_Shortcode', 'init' ), 2 );
[69] Fix | Delete
[70] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function