, Nick Young * @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 = '
[event-title]
' . "\n"; $content .= '
' . __( 'Starts:', 'gce' ) . ' [start-time]
' . "\n"; $content .= '
' . __( 'Ends:', 'gce' ) . ' [end-date] - [end-time]
' . "\n"; $content .= '[if-location]
' . __( 'Location:', 'gce' ) . ' [location]
[/if-location]' . "\n"; $content .= '[if-description]
' . __( 'Description:', 'gce' ) . ' [description]
[/if-description]' . "\n"; $content .= '
[link newwindow="true"]' . __( 'More details...', 'gce' ) . '[/link]
' . "\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:', 'gce' ) ); add_post_meta( $post->ID, 'gce_display_end', 'time-date' ); add_post_meta( $post->ID, 'gce_display_end_text', __( 'Ends:', 'gce' ) ); add_post_meta( $post->ID, 'gce_display_separator', ', ' ); add_post_meta( $post->ID, 'gce_display_location_text', __( 'Location:', 'gce' ) ); add_post_meta( $post->ID, 'gce_display_description_text', __( 'Description:', 'gce' ) ); add_post_meta( $post->ID, 'gce_display_link', 1 ); add_post_meta( $post->ID, 'gce_display_link_text', __( 'More Details', 'gce' ) ); } 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 = '
' . '' . __( 'Clear Cache', 'gce' ) . '' . '
'; echo $html; } } add_action( 'post_submitbox_start', 'gce_add_cache_button' );