Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/my-calendar/includes/post-types.php
+++ b/my-calendar/includes/post-types.php
@@ -37,12 +37,21 @@
}
$opts = array( 'label_for' => 'mc_cpt_base' );
// Add a settings field to the permalink page.
- add_settings_field( 'mc_hosts_cpt_base', __( 'My Calendar Hosts base', 'my-calendar' ), 'mc_field_callback', 'permalink', 'optional', $opts );
+ add_settings_field( 'mc_hosts_cpt_base', __( 'My Calendar Hosts base', 'my-calendar' ), 'mc_hosts_callback', 'permalink', 'optional', $opts );
}
}
add_action( 'load-options-permalink.php', 'mc_load_permalinks' );
/**
+ * Prevent error if hosts callback doesn't exist.
+ */
+function mc_hosts_callback() {
+ if ( function_exists( 'mcs_hosts_callback' ) ) {
+ mcs_hosts_callback();
+ }
+}
+
+/**
* Custom field callback for permalinks settings
*/
function mc_field_callback() {
--- a/my-calendar/includes/screen-options.php
+++ b/my-calendar/includes/screen-options.php
@@ -85,12 +85,13 @@
);
$output = '';
+ $admin = ( 'true' === mc_get_option( 'input_options_administrators', 'true' ) && current_user_can( 'manage_options' ) ) ? true : false;
asort( $input_labels );
foreach ( $input_labels as $key => $value ) {
$enabled = ( isset( $input_options[ $key ] ) ) ? $input_options[ $key ] : false;
$checked = ( 'on' === $enabled ) ? "checked='checked'" : '';
$allowed = ( isset( $settings_options[ $key ] ) && 'on' === $settings_options[ $key ] ) ? true : false;
- if ( current_user_can( 'manage_options' ) || $allowed ) {
+ if ( ( current_user_can( 'manage_options' ) && $admin ) || $allowed ) {
$output .= "<label for='mci_$key'><input type='checkbox' id='mci_$key' name='mc_show_on_page[$key]' value='on' $checked /> $value</label>";
} else {
// don't display options if this user can't use them.
--- a/my-calendar/my-calendar-categories.php
+++ b/my-calendar/my-calendar-categories.php
@@ -402,6 +402,7 @@
*/
$add = apply_filters( 'mc_pre_add_category', $add, $category );
$wpdb->insert( my_calendar_categories_table(), $add, $formats );
+ delete_transient( 'mc_generated_category_styles' );
$cat_id = $wpdb->insert_id;
/**
* Execute action after inserting a new category into the My Calendar database.
@@ -525,6 +526,10 @@
<?php mc_help_link( __( 'Show Category Icons', 'my-calendar' ), __( 'Category Icons', 'my-calendar' ), 'Category Icons', 6 ); ?>
</div>
<?php
+ } else {
+ ?>
+ <input type='hidden' name='category_icon' id="mc_category_icon" value='<?php echo esc_attr( $icon ); ?>' />
+ <?php
}
if ( 'add' === $view ) {
$private_checked = false;
@@ -1135,9 +1140,10 @@
$category_name = wp_strip_all_tags( wp_unslash( trim( $cat->category_name ) ) );
$category_name = ( '' === $category_name ) ? '(' . __( 'Untitled category', 'my-calendar' ) . ')' : $category_name;
if ( $multiple ) {
- $icon = mc_category_icon( $cat );
- $icon = ( $icon ) ? mc_wrap_category_icon( $icon, $cat ) : $category_name;
- $c = '<li class="mc_cat_' . $cat->category_id . '"><input type="checkbox"' . $selected . ' name="' . esc_attr( $name ) . '" id="' . $id . $cat->category_id . '" value="' . $cat->category_id . '" ' . $selected . ' /> <label for="' . $id . $cat->category_id . '">' . $icon . '</label></li>';
+ $icon = mc_category_icon( $cat );
+ $colors = ( 'default' === mc_get_option( 'apply_color' ) ) ? false : true;
+ $icon = ( $icon || $colors ) ? mc_wrap_category_icon( $icon, $cat ) : $category_name;
+ $c = '<li class="mc_cat_' . $cat->category_id . '"><input type="checkbox"' . $selected . ' name="' . esc_attr( $name ) . '" id="' . $id . $cat->category_id . '" value="' . $cat->category_id . '" ' . $selected . ' /> <label for="' . $id . $cat->category_id . '">' . $icon . '</label></li>';
} else {
$c = '<option value="' . $cat->category_id . '" ' . $selected . '>' . $category_name . '</option>';
}
@@ -1329,9 +1335,10 @@
* @return string
*/
function mc_wrap_category_icon( $icon, $category ) {
- if ( $icon && $category ) {
+ if ( $category ) {
$hex = ( 0 !== strpos( $category->category_color, '#' ) ) ? '#' : '';
$type = ( stripos( $icon, 'svg' ) ) ? 'svg' : 'img';
+ $type = ( '' === $icon ) ? 'color' : $type;
$back = ( 'background' === mc_get_option( 'apply_color' ) ) ? ' style="background:' . $hex . $category->category_color . ';"' : '';
$icon = '<span class="mc-category"><span class="mc-category-color ' . $type . '"' . $back . '>' . $icon . '</span><span>' . $category->category_name . '</span></span>';
}
--- a/my-calendar/my-calendar-core.php
+++ b/my-calendar/my-calendar-core.php
@@ -2318,8 +2318,10 @@
if ( mc_is_single_event() ) {
$mc_id = ( isset( $_GET['mc_id'] ) && is_numeric( $_GET['mc_id'] ) ) ? $_GET['mc_id'] : false;
if ( ! $mc_id ) {
- $post_id = get_the_ID();
- $mc_id = get_post_meta( $post_id, '_mc_event_id', true );
+ $post_id = get_the_ID();
+ $parent_id = get_post_meta( $post_id, '_mc_event_id', true );
+ $event = mc_get_nearest_event( $parent_id, true );
+ $mc_id = $event->occur_id;
}
$event = mc_adjacent_event( $mc_id, 'previous' );
if ( empty( $event ) ) {
@@ -2349,8 +2351,10 @@
if ( mc_is_single_event() ) {
$mc_id = ( isset( $_GET['mc_id'] ) && is_numeric( $_GET['mc_id'] ) ) ? $_GET['mc_id'] : false;
if ( ! $mc_id ) {
- $post_id = get_the_ID();
- $mc_id = get_post_meta( $post_id, '_mc_event_id', true );
+ $post_id = get_the_ID();
+ $parent_id = get_post_meta( $post_id, '_mc_event_id', true );
+ $event = mc_get_nearest_event( $parent_id, true );
+ $mc_id = $event->occur_id;
}
$event = mc_adjacent_event( $mc_id, 'next' );
if ( empty( $event ) ) {
--- a/my-calendar/my-calendar-event-editor.php
+++ b/my-calendar/my-calendar-event-editor.php
@@ -1065,7 +1065,7 @@
$input = array_merge( $defaults, $input );
$user = get_current_user_id();
$show = get_user_meta( $user, 'mc_show_on_page', true );
- if ( empty( $show ) || $show < 1 ) {
+ if ( empty( $show ) || ! is_array( $show ) ) {
$show = mc_get_option( 'input_options' );
}
// if this doesn't exist in array, leave it on.
--- a/my-calendar/my-calendar-events.php
+++ b/my-calendar/my-calendar-events.php
@@ -349,8 +349,8 @@
$time = isset( $args['time'] ) && '' !== $args['time'] ? strtotime( $args['time'] ) + $offset : 'now';
$mcdb = mc_is_remote_db();
- $now = ( 'now' === $time ) ? 'DATE_ADD( NOW(), INTERVAL ' . $offset_hours . ' HOUR)' : $time;
- $now_limit = ( 'now' === $time ) ? 'DATE_ADD( NOW(), INTERVAL ' . $offset_hours . ' HOUR)' : "from_unixtime($time)";
+ $now = ( 'now' === $time ) ? 'DATE_ADD( UTC_TIMESTAMP(), INTERVAL ' . $offset_hours . ' HOUR)' : $time;
+ $now_limit = ( 'now' === $time ) ? 'DATE_ADD( UTC_TIMESTAMP(), INTERVAL ' . $offset_hours . ' HOUR)' : "from_unixtime($time)";
$exclude_categories = mc_private_categories( $args );
$cat_limit = ( 'default' !== $category ) ? mc_select_category( $category ) : array();
$join = ( isset( $cat_limit[0] ) ) ? $cat_limit[0] : '';
@@ -496,7 +496,7 @@
FROM ' . my_calendar_event_table() . '
JOIN ' . my_calendar_table() . ' AS e ON (event_id=occur_event_id)
JOIN ' . my_calendar_categories_table() . " AS c ON (e.event_category=c.category_id) $cat
- AND event_added > NOW() - INTERVAL $limit DAY
+ AND event_added > UTC_TIMESTAMP() - INTERVAL $limit DAY
$exclude_categories
ORDER BY event_added DESC"
);
--- a/my-calendar/my-calendar-generator.php
+++ b/my-calendar/my-calendar-generator.php
@@ -98,7 +98,7 @@
mc_update_option( 'last_shortcode_' . $type, $output );
}
if ( 'shortcode' === $format && ! is_array( $output ) ) {
- $return = "<div class='updated'><p><textarea readonly='readonly' class='large-text readonly'>[$output]</textarea>$append</p></div>";
+ $return = "<div class='notice notice-success'><p><textarea readonly='readonly' class='large-text readonly'>[$output]</textarea>$append</p></div>";
echo wp_kses( $return, mc_kses_elements() );
} else {
if ( is_array( $output ) ) {
--- a/my-calendar/my-calendar-limits.php
+++ b/my-calendar/my-calendar-limits.php
@@ -200,7 +200,7 @@
} else {
$author = trim( $author );
if ( 'current' === $author ) {
- $author = wp_get_current_user();
+ $author = wp_get_current_user();
$return[] = $author->ID;
} else {
$author = get_user_by( 'login', $author ); // Get author by username.
--- a/my-calendar/my-calendar-output.php
+++ b/my-calendar/my-calendar-output.php
@@ -498,7 +498,7 @@
$hlevel = apply_filters( 'mc_heading_level_table', $hlevel, $type, $time, $template );
// Set up .summary - required once per page for structured data. Should only be added in cases where heading & anchor are removed.
if ( 'single' === $type ) {
- $title = ( ! is_singular( 'mc-events' ) ) ? " <$hlevel class='event-title summary'>$image<div>$event_title</div></$hlevel>n" : ' <span class="summary screen-reader-text">' . wp_strip_all_tags( $event_title ) . '</span>';
+ $title = ( ! is_singular( 'mc-events' ) ) ? " <$hlevel class='event-title summary'>$image<div class='event-title-container'>$event_title</div></$hlevel>n" : ' <span class="summary screen-reader-text">' . wp_strip_all_tags( $event_title ) . '</span>';
} elseif ( 'list' !== $type || ( 'list' === $type && 'true' === mc_get_option( 'list_link_titles' ) ) ) {
/**
* Filter event title inside event heading.
@@ -511,7 +511,7 @@
*
* @return string
*/
- $inner_heading = apply_filters( 'mc_heading_inner_title', $wrap . $image . '<div>' . trim( $event_title ) . '</div>' . $balance, $event_title, $event );
+ $inner_heading = apply_filters( 'mc_heading_inner_title', $wrap . $image . '<div class="event-title-container">' . trim( $event_title ) . '</div>' . $balance, $event_title, $event );
$title = " <$hlevel class='event-title summary$group_class' id='mc_$event->occur_id-title-$id'>$inner_heading</$hlevel>n";
} else {
$title = '';
--- a/my-calendar/my-calendar-print.php
+++ b/my-calendar/my-calendar-print.php
@@ -68,7 +68,8 @@
if ( isset( $_GET['href'] ) ) {
// Only support URLs on the same home_url().
$ref_url = sanitize_text_field( urldecode( wp_unslash( $_GET['href'] ) ) );
- $ref_root = ( wp_parse_url( $ref_url ) ) ? wp_parse_url( $ref_url )['host'] : false;
+ $parsed = wp_parse_url( $ref_url );
+ $ref_root = ( $parsed && isset( $parsed['host'] ) ) ? $parsed['host'] : false;
$root = wp_parse_url( home_url() )['host'];
$local = false;
if ( $ref_root ) {
--- a/my-calendar/my-calendar-settings.php
+++ b/my-calendar/my-calendar-settings.php
@@ -161,13 +161,17 @@
} else {
$value = ( ! empty( $value ) ) ? (array) $value : $default;
}
+ $icon = '';
+ if ( $note ) {
+ $icon = str_contains( $note, 'dashicons' ) ? '' : "<i class='dashicons dashicons-editor-help' aria-hidden='true'></i>";
+ }
switch ( $type ) {
case 'text':
case 'url':
case 'email':
if ( $note ) {
$note = sprintf( str_replace( '%', '', $note ), "<code>$value</code>" );
- $note = "<span id='$id-note' class='mc-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>$note</span>";
+ $note = "<span id='$id-note' class='mc-input-description'>$icon$note</span>";
$aria = " aria-describedby='$id-note'";
} else {
$note = '';
@@ -183,7 +187,7 @@
case 'textarea':
if ( $note ) {
$note = sprintf( $note, "<code>$value</code>" );
- $note = "<span id='$id-note' class='mc-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>$note</span>";
+ $note = "<span id='$id-note' class='mc-input-description'>$icon$note</span>";
$aria = " aria-describedby='$id-note'";
} else {
$note = '';
@@ -194,7 +198,7 @@
case 'checkbox-single':
$checked = checked( 'true', mc_get_option( str_replace( 'mc_', '', $name ) ), false );
if ( $note ) {
- $note = "<div id='$id-note' class='mc-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>" . sprintf( $note, "<code>$value</code>" ) . '</div>';
+ $note = "<div id='$id-note' class='mc-input-description'>$icon" . sprintf( $note, "<code>$value</code>" ) . '</div>';
$aria = " aria-describedby='$id-note'";
} else {
$note = '';
@@ -206,7 +210,7 @@
case 'radio':
if ( $note ) {
$note = sprintf( $note, "<code>$value</code>" );
- $note = "<span id='$id-note' class='mc-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>$note</span>";
+ $note = "<span id='$id-note' class='mc-input-description'>$icon$note</span>";
$aria = " aria-describedby='$id-note'";
} else {
$note = '';
@@ -231,7 +235,7 @@
case 'select':
if ( $note ) {
$note = sprintf( $note, "<code>$value</code>" );
- $note = "<span id='$id-note' class='mc-input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i>$note</span>";
+ $note = "<span id='$id-note' class='mc-input-description'>$icon$note</span>";
$aria = " aria-describedby='$id-note'";
} else {
$note = '';
@@ -1232,7 +1236,7 @@
'atts' => array(
'placeholder' => __( 'More information', 'my-calendar' ),
),
- 'note' => "<a href='" . admin_url( 'admin.php?page=my-calendar-design#my-calendar-templates' ) . "'>" . __( 'Templating Help', 'my-calendar' ) . '</a>',
+ 'note' => mc_help_link( __( 'Template Tag Help', 'my-calendar' ), __( 'Template Tags', 'my-calendar' ), 'template tags', 5, false ),
)
);
?>
@@ -1390,7 +1394,7 @@
'atts' => array(
'placeholder' => '{title}',
),
- 'note' => "<a href='" . admin_url( 'admin.php?page=my-calendar-design#my-calendar-templates' ) . "'>" . __( 'Templating Help', 'my-calendar' ) . '</a>',
+ 'note' => mc_help_link( __( 'Template Tag Help', 'my-calendar' ), __( 'Template Tags', 'my-calendar' ), 'template tags', 5, false ),
)
);
?>
@@ -1405,7 +1409,7 @@
'atts' => array(
'placeholder' => '{title}',
),
- 'note' => "<a href='" . admin_url( 'admin.php?page=my-calendar-design#my-calendar-templates' ) . "'>" . __( 'Templating Help', 'my-calendar' ) . '</a>',
+ 'note' => mc_help_link( __( 'Template Tag Help', 'my-calendar' ), __( 'Template Tags', 'my-calendar' ), 'template tags', 5, false ),
)
);
?>
@@ -1420,7 +1424,7 @@
'atts' => array(
'placeholder' => '{title}',
),
- 'note' => "<a href='" . admin_url( 'admin.php?page=my-calendar-design#my-calendar-templates' ) . "'>" . __( 'Templating Help', 'my-calendar' ) . '</a>',
+ 'note' => mc_help_link( __( 'Template Tag Help', 'my-calendar' ), __( 'Template Tags', 'my-calendar' ), 'template tags', 5, false ),
)
);
?>
@@ -1435,7 +1439,7 @@
'atts' => array(
'placeholder' => '{title}',
),
- 'note' => "<a href='" . admin_url( 'admin.php?page=my-calendar-design#my-calendar-templates' ) . "'>" . __( 'Templating Help', 'my-calendar' ) . '</a>',
+ 'note' => mc_help_link( __( 'Template Tag Help', 'my-calendar' ), __( 'Template Tags', 'my-calendar' ), 'template tags', 5, false ),
)
);
?>
@@ -2142,7 +2146,7 @@
'name' => 'mc_event_mail_message',
'label' => __( 'Message Body', 'my-calendar' ),
'default' => __( 'New Event:', 'my-calendar' ) . "nn{title}: {date}, {time} - {event_status}nnEdit Event: {edit_link}",
- 'note' => "<a href='" . admin_url( 'admin.php?page=my-calendar-design#my-calendar-templates' ) . "'>" . __( 'Templating Help', 'my-calendar' ) . '</a>',
+ 'note' => mc_help_link( __( 'Template Tag Help', 'my-calendar' ), __( 'Template Tags', 'my-calendar' ), 'template tags', 5, false ),
'atts' => array(
'cols' => 60,
'rows' => 6,
--- a/my-calendar/my-calendar.php
+++ b/my-calendar/my-calendar.php
@@ -16,7 +16,7 @@
* Text Domain: my-calendar
* License: GPL-2.0+
* License URI: http://www.gnu.org/license/gpl-2.0.txt
- * Version: 3.7.14
+ * Version: 3.7.15
*/
/*
@@ -53,7 +53,7 @@
if ( ! $version ) {
return get_option( 'mc_version', '' );
}
- return '3.7.14';
+ return '3.7.15';
}
define( 'MC_DEBUG', false );