| Server IP : 104.21.21.239 / Your IP : 216.73.216.69 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/tgnew/wp-content/plugins/lcs-tg-custom/ |
Upload File : |
<?php
/*
Plugin Name: LCS Thought Gallery Custom Functions
Version: 1.0
Description: Extends various Thought Gallery functionality.
Author: LatCom Systems
Author URI: http://www.latcomsystems.com/
Copyright 2016 LatCom Systems
*/
if (!class_exists('lcs_page_templater')) :
class lcs_page_templater {
private static $instance;
protected $templates;
public static function get_instance() {
if( null == self::$instance ) {
self::$instance = new lcs_page_templater();
}
return self::$instance;
}
private function __construct() {
$this->templates = array();
add_filter(
'page_attributes_dropdown_pages_args',
array( $this, 'register_project_templates' )
);
add_filter(
'wp_insert_post_data',
array( $this, 'register_project_templates' )
);
add_filter(
'template_include',
array( $this, 'view_project_template')
);
$this->templates = array(
'lcs-todays-events.php' => 'LCS Todays Events',
);
}
public function register_project_templates( $atts ) {
$cache_key = 'page_templates-' . md5( get_theme_root() . '/' . get_stylesheet() );
$templates = wp_get_theme()->get_page_templates();
if ( empty( $templates ) ) {
$templates = array();
}
wp_cache_delete( $cache_key , 'themes');
$templates = array_merge( $templates, $this->templates );
wp_cache_add( $cache_key, $templates, 'themes', 1800 );
return $atts;
}
public function view_project_template( $template ) {
global $post;
if (!isset($this->templates[get_post_meta(
$post->ID, '_wp_page_template', true
)] ) ) {
return $template;
}
$file = plugin_dir_path(__FILE__). get_post_meta(
$post->ID, '_wp_page_template', true
);
if( file_exists( $file ) ) {
return $file;
}
else { echo $file; }
return $template;
}
}
endif;
add_action( 'plugins_loaded', array( 'lcs_page_templater', 'get_instance' ) );
/* overide event manager ical */
function lcs_em_ical()
{
//check if this is a calendar request for all events
//var_dump($_SERVER);
//echo '=='.substr($_SERVER['REQUEST_URI'], -6).'==';
if ( preg_match('/events.ics$/', $_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == '/?ical=1' || substr($_SERVER['REQUEST_URI'], -6) == '/ical/') {
header('Content-type: octet/stream; charset=utf-8');
header('Content-Disposition: attachment; filename="event.ics"');
//send headers
em_locate_template('templates/ical.php', true);
die();
}
}
//remove_action('init', 'em_ical');
//add_action('init', 'lcs_em_ical', 1);
function lcs_em_ical_item(){
global $wpdb, $wp_query, $wp_rewrite;
//check if we're outputting an ical feed
if( !empty($wp_query) && $wp_query->get('ical') ){
$execute_ical = false;
$filename = 'events';
$args = array();
//single event
if( $wp_query->get(EM_POST_TYPE_EVENT) ){
$event_id = $wpdb->get_var('SELECT event_id FROM '.EM_EVENTS_TABLE." WHERE event_slug='".$wp_query->get(EM_POST_TYPE_EVENT)."' AND event_status=1 LIMIT 1");
if( !empty($event_id) ){
$filename = $wp_query->get(EM_POST_TYPE_EVENT);
$args['event'] = $event_id;
}
//single location
}elseif( $wp_query->get(EM_POST_TYPE_LOCATION) ){
$location_id = $wpdb->get_var('SELECT location_id FROM '.EM_LOCATIONS_TABLE." WHERE location_slug='".$wp_query->get(EM_POST_TYPE_LOCATION)."' AND location_status=1 LIMIT 1");
if( !empty($location_id) ){
$filename = $wp_query->get(EM_POST_TYPE_LOCATION);
$args['location'] = $location_id;
}
//taxonomies
}else{
$taxonomies = EM_Object::get_taxonomies();
foreach($taxonomies as $tax_arg => $taxonomy_info){
$taxonomy_term = $wp_query->get($taxonomy_info['query_var']);
if( $taxonomy_term ){
$filename = $taxonomy_term;
$args[$tax_arg] = $taxonomy_term;
}
}
}
//only output the ical if we have a match from above
if( count($args) > 0 ){
//send headers and output ical
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="'.$filename.'.ics"');
em_locate_template('templates/ical.php', true, array('args'=>$args));
exit();
}else{
//no item exists, so redirect to original URL
$url_to_redirect = preg_replace("/ical\/$/",'', esc_url_raw(add_query_arg(array('ical'=>null))));
wp_redirect($url_to_redirect, '302');
exit();
}
}
}
remove_action('parse_query', 'em_ical_item');
add_action ( 'parse_query', 'lcs_em_ical_item', 1 );
add_action('init','lcs_ga_events_scripts');
function lcs_ga_events_scripts() {
wp_enqueue_script('jquery');
wp_enqueue_script('lcs_ga_events',plugins_url( '/js/ga-events.js', __FILE__) , array('jquery'), filemtime(plugin_dir_path(__FILE__).'js/ga-events.js'), false);
wp_enqueue_script('lcs_custom',plugins_url( '/js/custom.js', __FILE__) , array('jquery'), filemtime(plugin_dir_path(__FILE__).'js/custom.js'), false);
}
add_action('init','lcs_enqueue_styles');
function lcs_enqueue_styles() {
wp_enqueue_style('lcs_custom_css',plugins_url( '/css/custom.css', __FILE__) , array(), filemtime(plugin_dir_path(__FILE__).'css/custom.css'));
}
function lcs_mailchimp_sticky_button($atts, $content = '')
{
$submit_url = plugins_url( '/lcs-mailchimp-sticky-form.php', __FILE__);
$html = '';
$html .= '<div class="lcs_mailchimp_sticky_container">';
$html .= '<div class="lcs_mailchimp_sticky_header" onclick="lcs_toggle_mailchimp_sticky_form()">';
$html .= 'Discover More';
$html .= '</div>';
$html .= '<p>Get Thought Gallery newsletter via email.</p>';
$html .= '<div id="lcs_mailchimp_sticky_form_container">';
/*
*/
ob_start();
require_once('lcs-mailchimp-sticky-form.php');
$html .= ob_get_clean();
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="lcs_mailchimp_sticky_button" onclick="lcs_toggle_mailchimp_sticky_form()">';
$html .= '<img id="lcs_xmail_icon" src="'.plugins_url( '/img/xmail.png', __FILE__).'" alt="mailing list" />';
$html .= 'Discover More';
$html .= '</div>';
return $html;
}
add_shortcode( 'lcs_mailchimp_sticky_button', 'lcs_mailchimp_sticky_button' );
?>