static function addURLParameter($url, $paramName, $paramValue) { $url_data = parse_url($url); if (!isset($url_data["query"])) { $url_data["query"] = ""; } $params = array(); parse_str($url_data['query'], $params); $params[$paramName] = $paramValue; $url_data['query'] = http_build_query($params); return rhc_supe_dom_renderer::build_url($url_data); }
function sc_rhc_static_upcoming_events($atts, $content = null, $code = "") { global $rhc_plugin; $uid = ++$this->uid; $atts = apply_filters('supe_atts', $atts, $uid); //-- if (!$this->sc_output_conditions_met($atts, $content, $code)) { return ''; } //-- //-- NOTE: Important! when adding parameters here, also add them to calendar_ajax::supe_get_events, also add it to the compact function below for this::get_events $shortcode_atts = shortcode_atts(array('uid' => $uid, 'test' => '', 'page' => '0', 'number' => '5', 'taxonomy' => '', 'terms' => '', 'template' => 'widget_upcoming_events.php', 'class' => 'rhc_supe_holder', 'prefix' => 'uew', 'parse_postmeta' => '', 'parse_taxonomy' => '0', 'parse_taxonomymeta' => '1', 'order' => 'ASC', 'date' => 'NOW', 'date_end' => '', 'horizon' => 'hour', 'allday' => '', 'no_events_message' => '', 'post_status' => 'publish', 'post_type' => '', 'author' => '', 'author_current' => '', 'do_shortcode' => '1', 'the_content' => '0', 'separator' => '', 'holder' => '1', 'dayspast' => '', 'premiere' => '0', 'auto' => '0', 'feed' => '', 'words' => '', 'render_images' => '', 'calendar_url' => '', 'loading_overlay' => '0', 'for_sidebar' => '0', 'post_id' => '', 'current_post' => '', 'rdate' => '', 'js_init_script' => '', 'vc_js_init_script' => '', 'nav' => ''), $atts); if ('1' == $shortcode_atts['auto']) { if (is_tax()) { $shortcode_atts['taxonomy'] = get_query_var('taxonomy'); $shortcode_atts['terms'] = get_query_var('term'); $atts['taxonomy'] = $shortcode_atts['taxonomy']; $atts['terms'] = $shortcode_atts['terms']; } else { if ($rhc_plugin->template_frontend->is_taxonomy) { $shortcode_atts['taxonomy'] = $rhc_plugin->template_frontend->taxonomy; $shortcode_atts['terms'] = $rhc_plugin->template_frontend->term_slug; $atts['taxonomy'] = $shortcode_atts['taxonomy']; $atts['terms'] = $shortcode_atts['terms']; } } } $default_events_source = $rhc_plugin->get_option('rhc-api-url', '', true); if ('' == trim($default_events_source)) { $default_events_source = site_url('/?rhc_action=supe_get_events'); //Compat fix: qtranslate plugin if (defined('QT_SUPPORTED_WP_VERSION') && function_exists('qtrans_getLanguage')) { $default_events_source .= '&lang=' . qtrans_getLanguage(); } } $shortcode_atts['ajaxurl'] = $default_events_source; //--- // if ('1' == $shortcode_atts['current_post']) { $shortcode_atts['post_id'] = get_the_ID(); } //file_put_contents( ABSPATH.'api.log', "post_id $post_id".print_r( $shortcode_atts,true) ); //--- $shortcode_atts = apply_filters('supe_shortcode_atts', $shortcode_atts, $atts); extract($shortcode_atts); //'feed', 'premiere', 'loading_method', 'template', 'post_type','calendar','venue','organizer','taxonomy','terms','auto','horizon','number','showimage','words','dayspast','fcdate_format','fctime_format','calendar_url','specific_date','specific_date_end' $templates = array('widget_upcoming_events.php', 'widget_upcoming_events_a.php', 'widget_upcoming_events_a_end.php', 'widget_upcoming_events_a_end_range.php', 'widget_upcoming_events_a1.php', 'widget_upcoming_events_agenda_b.php', 'widget_upcoming_events_agenda_b2.php', 'json', 'php'); if (!empty($content)) { if (isset($atts['custom_content_wrapper'])) { $content = sprintf($atts['custom_content_wrapper'], $content); } else { $content = sprintf('<div class="rhc-custom-template">%s</div>', $content); } } if (intval($author_current)) { $author = 'current'; } do_action('enqueue_frontend_only'); global $rhc_plugin; if ('0' != $rhc_plugin->get_option('original_ajax_enable', '', true)) { return __('This shortcode requires that the latest version of "Ajax events query version." is enabled.', 'rhc'); } $templates = apply_filters('rhc_allowed_widget_templates', $templates); if (false === strpos($template, 'widget_custom_') && !in_array($template, $templates)) { return ''; } $args = compact('page', 'number', 'parse_taxonomy', 'parse_taxonomymeta', 'order', 'date', 'date_end', 'dayspast', 'horizon', 'allday', 'post_status', 'post_type', 'author', 'premiere', 'auto', 'feed', 'post_id', 'current_post', 'rdate'); if (!empty($taxonomy) && !empty($terms)) { $args['taxonomy'] = $taxonomy; $args['terms'] = $terms; } if (!class_exists('rhc_supe_query')) { require 'class.rhc_supe_query.php'; } $events = false; //handle taxonomy //--- the following block is for supporting the same shortcodes inside a venue/organizer template page. if ($rhc_plugin->template_frontend->is_taxonomy) { $tmp_post_id = $post_id; if ('current' == $tmp_post_id) { $tmp_post_id = get_the_ID(); if ($tmp_post_id > 0) { switch ($rhc_plugin->template_frontend->taxonomy) { case RHC_VENUE: $option_name = 'venue_template_page_id'; break; case RHC_ORGANIZER: $option_name = 'organizer_template_page_id'; break; default: $option_name = 'taxonomy_template_page_id'; } $template_id = $rhc_plugin->get_option($option_name, 0, true); if (empty($template_id)) { //fallback to original. $template_id = $rhc_plugin->get_option('taxonomy_template_page_id', 0, true); } if ($template_id == $tmp_post_id) { //the template page is the target of this shortcode. if (property_exists($rhc_plugin->template_frontend, 'term')) { $tmp_taxonomy = get_taxonomy($rhc_plugin->template_frontend->taxonomy); if (is_object($tmp_taxonomy)) { $term = $rhc_plugin->template_frontend->term; $term->meta = array(); global $wpdb; $meta_fields = $wpdb->get_col("SELECT DISTINCT(meta_key) FROM `{$wpdb->prefix}taxonomymeta`;", 0); $meta_fields = is_array($meta_fields) ? $meta_fields : array(); if (count($meta_fields) > 0) { foreach ($meta_fields as $meta_field) { $value = get_term_meta($term->term_id, $meta_field, true); if (!empty($value)) { $term->meta[$meta_field] = $value; } } } $tmp_taxonomy->terms = array(); $tmp_taxonomy->terms[] = $term; $tmp_e = (object) array('ID' => $tmp_post_id, 'post_id' => $tmp_post_id, 'taxonomies' => array($tmp_taxonomy)); $events = array($tmp_e); //--- flag that a custom layout is used, template_frontend will use this to skip the built in layout. $rhc_plugin->template_frontend->is_custom_tax = true; } } } } } } //query regular events if (false === $events) { $supe_query = new rhc_supe_query(); $events = $supe_query->get_events($args, $atts); } //file_put_contents( ABSPATH.'api.log', print_r($rhc_plugin->template_frontend,true) ); //other output handling: if ($template == 'json') { return json_encode($events); } else { if ($template == 'php') { return $events; } } $custom_output = apply_filters('rhc_supe_custom_render', false, $events, $atts, $content); if (false !== $custom_output) { return $custom_output; } $do_shortcode = '1' == $do_shortcode ? true : false; if (empty($events)) { $output = sprintf('<div class="rhc-supe-no-events" data-css_clear="opacity" style="opacity:0;">%s</div>', $no_events_message); } else { if (!class_exists('rhc_supe_dom_renderer')) { require_once 'class.rhc_supe_dom_renderer.php'; } $re = new rhc_supe_dom_renderer(); $output = $re->render_events($events, $atts, $content, $do_shortcode, $this->uid, $render_images); } //$output.= $this->render_js( $atts ); if ('1' == $the_content) { $output = apply_filters('the_content', $output); } else { if ($do_shortcode) { $output = do_shortcode($output); } } if ($separator == 'eap') { $holder = ''; } $custom_output = apply_filters('rhc_supe_custom_output', false, $uid, $output, $atts, $shortcode_atts, compact('class', 'uid', 'page', 'number')); if (false !== $custom_output) { return $custom_output; } //-- wpbakery visual composer not loading when saving shortcode in frontend editor. if (isset($_REQUEST['vc_editable']) && !empty($vc_js_init_script)) { } else { $vc_js_init_script = ''; } $test_empty = trim($js_init_script . $vc_js_init_script); if (!empty($test_empty)) { $js_init_script = sprintf("<script type='text/javascript'>try{%s;%s;}catch(e){}</script>", $js_init_script, $vc_js_init_script); } $class .= ' rhc-side-' . intval($for_sidebar); if ('1' == $holder) { return sprintf("<div id=\"%s_%s\" class=\"%s\" data-page=\"%s\" data-number=\"%s\" data-atts=\"%s\"><div class=\"supe-head\"></div><div class=\"supe-body\">%s<div class=\"supe-item-holder\">%s</div></div><div class=\"rhc-clear\"></div><div class=\"supe-footer\"></div></div>%s", $prefix, $uid, $class, $page, $number, $this->encoded_atts($atts, $shortcode_atts), '1' == $loading_overlay ? '<div class="uew-loading"><div class="uew-loading-1"><div class="uew-loading-2 xspinner icon-xspinner-3"></div></div></div>' : '', $output, $js_init_script); } else { return $output . $js_init_script; } }