This repository has been archived on 2026-10-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
aktiv-web/wp-content/plugins/google-calendar-events/includes/admin/admin-functions.php
T
2014-10-18 14:28:57 +02:00

87 lines
3.0 KiB
PHP

<?php
/**
* Admin helper functions
*
* @package GCE
* @author Phil Derksen <pderksen@gmail.com>, Nick Young <mycorpweb@gmail.com>
* @license GPL-2.0+
* @copyright 2014 Phil Derksen
*/
/**
* Function to clear the cache out
*
* @since 2.0.0
*/
function gce_clear_cache( $id ) {
delete_transient( 'gce_feed_' . $id );
add_settings_error( 'gce-notices', 'gce-cache-updated', __( 'Cache has been cleared for this feed.', 'gce' ), 'updated' );
}
/**
* Function that runs when a new Feed CPT is made
* Adds the default editor content for the event builder
* Adds default post meta options
*
* @since 2.0.0
*/
function gce_default_editor_content( $content, $post ) {
if( $post->post_type == 'gce_feed' ) {
$content = '<div class="gce-list-event gce-tooltip-event">[event-title]</div>' . "\n";
$content .= '<div><span>Starts:</span> [start-time]</div>' . "\n";
$content .= '<div><span>Ends:</span> [end-date] - [end-time]</div>' . "\n";
$content .= '[if-location]<div><span>Location:</span> [location]</div>[/if-location]' . "\n";
$content .= '[if-description]<div><span>Description:</span> [description]</div>[/if-description]' . "\n";
$content .= '<div>[link newwindow="true"]More details...[/link]</div>' . "\n";
// Default Post Meta Options
add_post_meta( $post->ID, 'gce_expand_recurring', 1 );
add_post_meta( $post->ID, 'gce_retrieve_from', 'today' );
add_post_meta( $post->ID, 'gce_retrieve_until', 'end_time' );
add_post_meta( $post->ID, 'gce_cache', 43200 );
add_post_meta( $post->ID, 'gce_paging', 1 );
add_post_meta( $post->ID, 'gce_list_max_num', 7 );
add_post_meta( $post->ID, 'gce_list_max_length', 'days' );
add_post_meta( $post->ID, 'gce_list_start_offset_num', '0' );
add_post_meta( $post->ID, 'gce_feed_start', '1' );
add_post_meta( $post->ID, 'gce_feed_start_interval', 'months' );
add_post_meta( $post->ID, 'gce_feed_end', '2' );
add_post_meta( $post->ID, 'gce_feed_end_interval', 'years' );
// Default Simple Display Options
add_post_meta( $post->ID, 'gce_display_start', 'time' );
add_post_meta( $post->ID, 'gce_display_start_text', 'Starts:' );
add_post_meta( $post->ID, 'gce_display_end', 'time-date' );
add_post_meta( $post->ID, 'gce_display_end_text', 'Ends:' );
add_post_meta( $post->ID, 'gce_display_separator', ', ' );
add_post_meta( $post->ID, 'gce_display_location_text', 'Location:' );
add_post_meta( $post->ID, 'gce_display_description_text', 'Description:' );
add_post_meta( $post->ID, 'gce_display_link', 1 );
add_post_meta( $post->ID, 'gce_display_link_text', 'More Details' );
}
return $content;
}
add_filter( 'default_content', 'gce_default_editor_content', 10, 2 );
function gce_add_cache_button() {
global $post;
if( $post->post_type == 'gce_feed' ) {
$html = '<div id="gce-clear-cache">' .
'<a href="' . add_query_arg( array( 'clear_cache' => true ) ) . '">' . __( 'Clear Cache', 'gce' ) . '</a>' .
'</div>';
echo $html;
}
}
add_action( 'post_submitbox_start', 'gce_add_cache_button' );