-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,21 +10,22 @@ | |
Version: 2.6.0-beta1 | ||
*/ | ||
|
||
/* Copyright 2009-2018 Joe Dolson (email : [email protected]) | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
/* | ||
Copyright 2009-2018 Joe Dolson (email : [email protected]) | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
|
@@ -41,14 +42,15 @@ | |
* Actions to execute on activation. | ||
*/ | ||
function mc_plugin_activated() { | ||
$required_php_version = '5.3.0'; | ||
$required_php_version = '5.3.0'; | ||
|
||
if ( version_compare( PHP_VERSION, $required_php_version, '<' ) ) { | ||
if ( version_compare( PHP_VERSION, $required_php_version, '<' ) ) { | ||
$plugin_data = get_plugin_data(__FILE__, false); | ||
$message = sprintf( __( '%s requires PHP version %s or higher. Your current PHP version is %s', 'my-calendar' ), $plugin_data['Name'], $required_php_version, phpversion() ); | ||
// Translators: Name of plug-in, required PHP version, current PHP version. | ||
$message = sprintf( __( '%1$s requires PHP version %2$s or higher. Your current PHP version is %3$s', 'my-calendar' ), $plugin_data['Name'], $required_php_version, phpversion() ); | ||
echo "<div class='error'><p>$message</p></div>"; | ||
exit; | ||
} | ||
} | ||
|
||
flush_rewrite_rules(); | ||
if ( my_calendar_exists() ) { | ||
|
@@ -99,22 +101,22 @@ function mc_plugin_deactivated() { | |
* Load internationalization. | ||
*/ | ||
function mc_load_textdomain() { | ||
// don't change this; remove shipped translations as .org trans become complete(r). | ||
// Don't change this; remove shipped translations as .org trans become complete(r). | ||
load_plugin_textdomain( 'my-calendar', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' ); | ||
} | ||
|
||
// Add actions. | ||
add_action( 'admin_menu', 'my_calendar_menu' ); | ||
add_action( 'wp_head', 'my_calendar_head' ); | ||
add_action( 'delete_user', 'mc_deal_with_deleted_user' ); | ||
add_action( 'widgets_init', 'mc_register_widgets' ); | ||
add_action( 'init', 'my_calendar_add_feed' ); | ||
add_action( 'wp_footer', 'mc_footer_js' ); | ||
add_action( 'init', 'mc_export_vcal', 200 ); | ||
add_action( 'admin_menu', 'my_calendar_menu' ); | ||
add_action( 'wp_head', 'my_calendar_head' ); | ||
add_action( 'delete_user', 'mc_deal_with_deleted_user' ); | ||
add_action( 'widgets_init', 'mc_register_widgets' ); | ||
add_action( 'init', 'my_calendar_add_feed' ); | ||
add_action( 'wp_footer', 'mc_footer_js' ); | ||
add_action( 'init', 'mc_export_vcal', 200 ); | ||
// Add filters. | ||
add_filter( 'widget_text', 'do_shortcode', 9 ); | ||
add_filter( 'widget_text', 'do_shortcode', 9 ); | ||
add_filter( 'plugin_action_links', 'mc_plugin_action', 10, 2 ); | ||
add_filter( 'wp_title', 'mc_event_filter', 10, 3 ); | ||
add_filter( 'wp_title', 'mc_event_filter', 10, 3 ); | ||
|
||
/** | ||
* Register all My Calendar widgets | ||
|
@@ -127,7 +129,6 @@ function mc_register_widgets() { | |
register_widget( 'my_calendar_filters' ); | ||
} | ||
|
||
|
||
/** | ||
* Customize canonical URL for My Calendar custom links | ||
*/ | ||
|
@@ -141,24 +142,23 @@ function mc_custom_canonical() { | |
* Generate canonical link | ||
*/ | ||
function mc_canonical() { | ||
// original code. | ||
// Original code. | ||
if ( !is_singular() ) { | ||
return; | ||
} | ||
|
||
global $wp_the_query; | ||
if ( ! $id = $wp_the_query->get_queried_object_id() ) { | ||
|
||
$id = get_queried_object_id(); | ||
|
||
if ( 0 === $id ) { | ||
return; | ||
} | ||
|
||
$link = wp_get_canonical_url( $id ); | ||
|
||
// end original code. | ||
$link = get_permalink( $id ); | ||
if ( $page = get_query_var('cpage') ) { | ||
$link = get_comments_pagenum_link( $page ); | ||
} | ||
// End original code. | ||
if ( isset( $_GET['mc_id'] ) ) { | ||
$mc_id = ( absint( $_GET['mc_id'] ) ) ? $_GET['mc_id'] : false; | ||
$link = add_query_arg( 'mc_id', $mc_id, $link ); | ||
$link = add_query_arg( 'mc_id', $mc_id, $link ); | ||
} | ||
|
||
echo "<link rel='canonical' href='$link' />\n"; | ||
|
@@ -167,11 +167,9 @@ function mc_canonical() { | |
/** | ||
* Produce My Calendar admin sidebar | ||
* | ||
* @param string $show deprecated | ||
* @param mixed $add boolean or array | ||
* @param boolean $remove Hide commercial blocks | ||
* | ||
* @return string HTML output | ||
* @param string $show deprecated. | ||
* @param mixed array/boolean $add boolean or array. | ||
* @param boolean $remove Hide commercial blocks. | ||
*/ | ||
function mc_show_sidebar( $show = '', $add = false, $remove = false ) { | ||
$add = apply_filters( 'mc_custom_sidebar_panels', $add ); | ||
|
@@ -180,7 +178,8 @@ function mc_show_sidebar( $show = '', $add = false, $remove = false ) { | |
?> | ||
<div class="postbox-container jcd-narrow"> | ||
<div class="metabox-holder"> | ||
<?php if ( is_array( $add ) ) { | ||
<?php | ||
if ( is_array( $add ) ) { | ||
foreach ( $add as $key => $value ) { | ||
?> | ||
<div class="ui-sortable meta-box-sortables"> | ||
|
@@ -196,13 +195,19 @@ function mc_show_sidebar( $show = '', $add = false, $remove = false ) { | |
} | ||
} | ||
if ( ! $remove ) { | ||
if ( ! function_exists( 'mcs_submit_exists' ) ) { ?> | ||
if ( ! function_exists( 'mcs_submit_exists' ) ) { | ||
?> | ||
<div class="ui-sortable meta-box-sortables"> | ||
<div class="postbox sell support"> | ||
<h2 class='sales hndle'><strong><?php _e( 'My Calendar Pro', 'my-calendar' ); ?></strong></h2> | ||
|
||
<div class="inside resources"> | ||
<p class="mcbuy"><?php printf( __( "Buy <a href='%s' rel='external'>My Calendar Pro</a> — a more powerful calendar for your site.", 'my-calendar' ), 'https://www.joedolson.com/my-calendar/pro/' ); ?></p> | ||
<p class="mcbuy"> | ||
<?php | ||
// Translators: URL for My Calendar Pro. | ||
printf( __( "Buy <a href='%s' rel='external'>My Calendar Pro</a> — a more powerful calendar for your site.", 'my-calendar' ), 'https://www.joedolson.com/my-calendar/pro/' ); | ||
?> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
|
@@ -215,7 +220,12 @@ function mc_show_sidebar( $show = '', $add = false, $remove = false ) { | |
<h2 class='sales hndle'><strong><?php _e( 'My Tickets', 'my-calendar' ); ?></strong></h2> | ||
|
||
<div class="inside resources"> | ||
<p class="mcbuy"><?php printf( __( 'Do you sell tickets to your events? <a href="%s" class="thickbox open-plugin-details-modal" rel="external">Use My Tickets</a> and sell directly from My Calendar.', 'my-calendar' ), admin_url( 'plugin-install.php?tab=plugin-information&plugin=my-tickets&TB_iframe=true&width=600&height=550' ) ); ?></p> | ||
<p class="mcbuy"> | ||
<?php | ||
// Translators: URL to view details about My Tickets. | ||
printf( __( 'Do you sell tickets to your events? <a href="%s" class="thickbox open-plugin-details-modal" rel="external">Use My Tickets</a> and sell directly from My Calendar.', 'my-calendar' ), admin_url( 'plugin-install.php?tab=plugin-information&plugin=my-tickets&TB_iframe=true&width=600&height=550' ) ); | ||
?> | ||
</p> | ||
|
||
</div> | ||
</div> | ||
|
@@ -254,26 +264,28 @@ class="twitter-follow-button" data-size="small" data-related="joedolson">Follow | |
</div> | ||
</div> | ||
</div> | ||
<?php } ?> | ||
<?php } ?> | ||
<?php | ||
} | ||
} | ||
?> | ||
<div class="ui-sortable meta-box-sortables"> | ||
<div class="postbox"> | ||
<h2 class='hndle'><?php _e( 'Get Help', 'my-calendar' ); ?></h2> | ||
|
||
<div class="inside"> | ||
<ul> | ||
<li> | ||
<strong><a href="https://docs.joedolson.com/my-calendar/quick-start/"><?php _e( "Documentation", 'my-calendar' ); ?></a></strong> | ||
<strong><a href="https://docs.joedolson.com/my-calendar/quick-start/"><?php _e( 'Documentation', 'my-calendar' ); ?></a></strong> | ||
</li> | ||
<li> | ||
<strong><a href="<?php echo admin_url( "admin.php?page=my-calendar-help" ); ?>#mc-generator"><?php _e( "Shortcode Generator", 'my-calendar' ); ?></a></strong> | ||
<strong><a href="<?php echo admin_url( 'admin.php?page=my-calendar-help' ); ?>#mc-generator"><?php _e( 'Shortcode Generator', 'my-calendar' ); ?></a></strong> | ||
</li> | ||
<li> | ||
<a href="<?php echo admin_url( "admin.php?page=my-calendar-help" ); ?>#get-support"><?php _e( "Get Support", 'my-calendar' ); ?></a> | ||
<a href="<?php echo admin_url( 'admin.php?page=my-calendar-help' ); ?>#get-support"><?php _e( 'Get Support', 'my-calendar' ); ?></a> | ||
</li> | ||
<li> | ||
<div class="dashicons dashicons-editor-help" aria-hidden='true'></div> | ||
<a href="<?php echo admin_url( "admin.php?page=my-calendar-help" ); ?>"><?php _e( "My Calendar Help", 'my-calendar' ); ?></a> | ||
<a href="<?php echo admin_url( 'admin.php?page=my-calendar-help' ); ?>"><?php _e( 'My Calendar Help', 'my-calendar' ); ?></a> | ||
</li> | ||
<li> | ||
<div class="dashicons dashicons-yes" aria-hidden='true'></div> | ||
|
@@ -299,26 +311,26 @@ class="twitter-follow-button" data-size="small" data-related="joedolson">Follow | |
|
||
/** | ||
* Add My Calendar menu items to main admin menu | ||
* | ||
*/ | ||
function my_calendar_menu() { | ||
$icon_path = plugins_url( '/my-calendar/images' ); | ||
|
||
if ( function_exists( 'add_menu_page' ) ) { | ||
if ( get_option( 'mc_remote' ) != 'true' ) { | ||
if ( 'true' != get_option( 'mc_remote' ) ) { | ||
add_menu_page( __( 'My Calendar', 'my-calendar' ), __( 'My Calendar', 'my-calendar' ), 'mc_add_events', apply_filters( 'mc_modify_default', 'my-calendar' ), apply_filters( 'mc_modify_default_cb', 'my_calendar_edit' ), $icon_path . '/icon.png' ); | ||
} else { | ||
add_menu_page( __( 'My Calendar', 'my-calendar' ), __( 'My Calendar', 'my-calendar' ), 'mc_edit_settings', 'my-calendar', 'my_calendar_settings', $icon_path . '/icon.png' ); | ||
} | ||
} | ||
if ( function_exists( 'add_submenu_page' ) ) { | ||
add_action( "admin_head", 'my_calendar_write_js' ); | ||
add_action( 'admin_head', 'my_calendar_write_js' ); | ||
add_action( "admin_enqueue_scripts", 'my_calendar_add_styles' ); | ||
if ( 'true' == get_option( 'mc_remote' ) && function_exists( 'mc_remote_db' ) ) { | ||
// if we're accessing a remote site, remove these pages. | ||
// If we're accessing a remote site, remove these pages. | ||
} else { | ||
if ( isset( $_GET['event_id'] ) ) { | ||
$event_id = absint( $_GET['event_id'] ); | ||
// Translators: Title of event. | ||
$page_title = sprintf( __( 'Editing Event: %s', 'my-calendar' ), mc_get_data( 'event_title', $event_id ) ); | ||
} else { | ||
$page_title = __( 'Add New Event', 'my-calendar' ); | ||
|
@@ -341,24 +353,24 @@ function my_calendar_menu() { | |
} | ||
if ( function_exists( 'mcs_submissions' ) ) { | ||
$permission = apply_filters( 'mcs_submission_permissions', 'manage_options' ); | ||
add_action( "admin_head", 'my_calendar_sub_js' ); | ||
add_action( "admin_head", 'my_calendar_sub_styles' ); | ||
add_action( 'admin_head', 'my_calendar_sub_js' ); | ||
add_action( 'admin_head', 'my_calendar_sub_styles' ); | ||
add_submenu_page( 'my-calendar', __( 'My Calendar Pro Settings', 'my-calendar' ), __( 'My Calendar Pro', 'my-calendar' ), $permission, 'my-calendar-submissions', 'mcs_settings' ); | ||
// only show payments screen if enabled. | ||
if ( get_option( 'mcs_payments' ) == 'true' ) { | ||
// Only show payments screen if enabled. | ||
if ( 'true' == get_option( 'mcs_payments' ) ) { | ||
add_submenu_page( 'my-calendar', __( 'Payments Received', 'my-calendar' ), __( 'Payments', 'my-calendar' ), $permission, 'my-calendar-payments', 'mcs_sales_page' ); | ||
} | ||
} | ||
} | ||
|
||
add_shortcode( 'my_calendar', 'my_calendar_insert' ); | ||
add_shortcode( 'my_calendar_upcoming', 'my_calendar_insert_upcoming' ); | ||
add_shortcode( 'my_calendar_today', 'my_calendar_insert_today' ); | ||
add_shortcode( 'my_calendar_locations', 'my_calendar_locations' ); | ||
add_shortcode( 'my_calendar_categories', 'my_calendar_categories' ); | ||
add_shortcode( 'my_calendar_access', 'my_calendar_access' ); | ||
add_shortcode( 'mc_filters', 'my_calendar_filters' ); | ||
add_shortcode( 'my_calendar', 'my_calendar_insert' ); | ||
add_shortcode( 'my_calendar_upcoming', 'my_calendar_insert_upcoming' ); | ||
add_shortcode( 'my_calendar_today', 'my_calendar_insert_today' ); | ||
add_shortcode( 'my_calendar_locations', 'my_calendar_locations' ); | ||
add_shortcode( 'my_calendar_categories', 'my_calendar_categories' ); | ||
add_shortcode( 'my_calendar_access', 'my_calendar_access' ); | ||
add_shortcode( 'mc_filters', 'my_calendar_filters' ); | ||
add_shortcode( 'my_calendar_show_locations', 'my_calendar_show_locations_list' ); | ||
add_shortcode( 'my_calendar_event', 'my_calendar_show_event' ); | ||
add_shortcode( 'my_calendar_search', 'my_calendar_search' ); | ||
add_shortcode( 'my_calendar_now', 'my_calendar_now' ); | ||
add_shortcode( 'my_calendar_event', 'my_calendar_show_event' ); | ||
add_shortcode( 'my_calendar_search', 'my_calendar_search' ); | ||
add_shortcode( 'my_calendar_now', 'my_calendar_now' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters