/**
  * Outputs the HTML for this widget.
  *
  * @param array  An array of standard parameters for widgets in this theme 
  * @param array  An array of settings for this widget instance 
  * @return void Echoes it's output
  **/
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $count = esc_attr($instance['count']);
     $count = 0 < $count && $count < 10 ? $count : 2;
     $loop = new WP_Query(array('post_type' => 'event', 'posts_per_page' => $count, 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => '_event_start', 'meta_query' => array(array('key' => '_event_end', 'value' => time(), 'compare' => '>'))));
     if ($loop->have_posts()) {
         echo $before_widget;
         if ($instance['title']) {
             echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title;
         }
         echo '<ul>';
         while ($loop->have_posts()) {
             $loop->the_post();
             global $post;
             $output = '<span class="meta">' . date(get_option('date_format'), get_post_meta(get_the_ID(), '_event_start', true)) . '</span> <a href="' . get_permalink() . '">' . get_the_title() . '</a>';
             $read_more = apply_filters('em4wp_events_manager_upcoming_widget_output', $output, $post);
             if ($read_more) {
                 echo '<li>' . $read_more . '</li>';
             }
         }
         if ($instance['more_text']) {
             echo '<li><a href="' . get_post_type_archive_link('event') . '">' . esc_attr($instance['more_text']) . '</a></li>';
         }
         echo '</ul>';
         echo $after_widget;
     }
     wp_reset_postdata();
 }
Example #2
0
 /**
  * User's questions list loop.
  */
 static function profile_questions_loop()
 {
     global $dwqa_options;
     $submit_question_link = get_post_type_archive_link(CMA_AnswerThread::POST_TYPE);
     $questions = get_posts(array('posts_per_page' => -1, 'author' => bp_displayed_user_id(), 'post_type' => CMA_AnswerThread::POST_TYPE));
     include CMA_PATH . '/views/frontend/buddypress/user-questions-loop.phtml';
 }
/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 *
 * @return void
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    // When default permalinks are enabled, redirect shop page to post type archive url
    if (!empty($_GET['page_id']) && get_option('permalink_structure') == "" && $_GET['page_id'] == wc_get_page_id('shop')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && sizeof(WC()->cart->get_cart()) == 0 && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        wp_redirect(get_permalink(wc_get_page_id('cart')));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        wp_redirect(str_replace('&amp;', '&', wp_logout_url(get_permalink(wc_get_page_id('myaccount')))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && $wp_query->found_posts == 1) {
        $product = wc_get_product($wp_query->post);
        if ($product->is_visible()) {
            wp_safe_redirect(get_permalink($product->id), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
Example #4
0
 function widget($args, $instance)
 {
     global $wp_query;
     $facets = elasticsearch\Faceting::all();
     $url = null;
     if (is_category() || is_tax()) {
         $url = get_term_link($wp_query->queried_object);
     } elseif (is_tag()) {
         $url = get_tag_link($wp_query->queried_object->term_id);
     } elseif (is_archive()) {
         $url = get_post_type_archive_link($wp_query->queried_object->query_var);
     } elseif (is_search()) {
         $url = home_url('/');
     }
     foreach ($facets as $type => $facet) {
         if (count($facet['selected']) > 0) {
             $name = $type;
             if (taxonomy_exists($type)) {
                 $name = get_taxonomy($type)->label;
             }
             echo '<aside id="facet-' . $type . '-selected" class="widget facets facets-selected">';
             echo '<h3 class="widget-title">' . $name . '</h3>';
             echo '<ul>';
             foreach ($facet['selected'] as $option) {
                 $url = elasticsearch\Faceting::urlRemove($url, $type, $option['slug']);
                 echo '<li id="facet-' . $type . '-' . $option['slug'] . '" class="facet-item">';
                 echo '<a href="' . $url . '">' . $option['name'] . '</a>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</aside>';
         }
     }
 }
Example #5
0
 function post_type_link($link, $post)
 {
     if ($post->post_type === 'handbook' && $post->post_name === 'handbook') {
         return get_post_type_archive_link('handbook');
     }
     return $link;
 }
/**
 * When default permalinks are enabled, redirect shop page to post type archive url
 **/
function woocommerce_shop_page_archive_redirect()
{
    if (isset($_GET['page_id']) && get_option('permalink_structure') == "" && $_GET['page_id'] == get_option('woocommerce_shop_page_id')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    }
}
Example #7
0
    /**
     * The description of the section.
     *
     * @param array $args
     */
    public function section_description($args)
    {
        if (is_array($args) && isset($args['id'])) {
            switch ($args['id']) {
                case 'ib_educator_pages':
                    ?>
					<table class="form-table">
						<tbody>
							<tr>
								<th scope="row"><?php 
                    _e('Courses Archive', 'ibeducator');
                    ?>
</th>
								<td>
									<?php 
                    $archive_link = get_post_type_archive_link('ib_educator_course');
                    if ($archive_link) {
                        echo '<a href="' . esc_url($archive_link) . '" target="_blank">' . esc_url($archive_link) . '</a>';
                    }
                    ?>
								</td>
							</tr>
						</tbody>
					</table>
					<?php 
                    break;
            }
        }
    }
Example #8
0
/**
 * Return the HTML link of the translation of a post.
 *
 * @param $post_id integer id of post.
 * @param $language string language of translation. If it is null or invalid, current language loaded in the page is used.
 * @param $label string inner text of the link.
 * @param $class string text to include as class parameter in the link
 *
 * @return string the HTML link of the translation link of a post.
 */
function uls_get_link($post_id = null, $language = null, $label = null, $class = 'uls-link')
{
    if ($post_id == null) {
        if (is_home()) {
            $url = get_home_url();
            $translation_url = uls_get_url_translated($url, $language);
        } else {
            if (is_archive()) {
                $url = get_post_type_archive_link(get_post_type());
                $translation_url = uls_get_url_translated($url, $language);
                $title = post_type_archive_title("", false);
            }
        }
    } else {
        $translation_id = uls_get_post_translation_id($post_id, $language);
        if (empty($translation_id)) {
            $translation_id = $post_id;
        }
        //set conversion of permalinks to false
        global $uls_permalink_convertion;
        $uls_permalink_convertion = false;
        $translation_url = uls_get_url_translated(get_permalink($translation_id), $language);
        //set conversion of permalinks to true again
        $uls_permalink_convertion = true;
        $title = get_the_title($translation_id);
    }
    // echo $translation_url;
    if (null == $label) {
        return '<a class="' . $class . '" href="' . $translation_url . '" >' . $title . '</a>';
    } else {
        return '<a class="' . $class . '" href="' . $translation_url . '" >' . $label . '</a>';
    }
}
function sfhiv_draw_taxonomy_query_menu($tax_name, $query, $args = array())
{
    if (!is_object_in_taxonomy($query->query_vars['post_type'], $tax_name)) {
        return;
    }
    if (!isset($args['include'])) {
        $query = sfhiv_remove_url_vars_from_query($query, array($tax_name));
        $query = sfhiv_unpage_query($query);
        $categories = sfhiv_get_taxonomy_in($query, $tax_name, 'ids');
        $args['include'] = implode(",", $categories);
        if (!isset($args['min_display'])) {
            $args['min_display'] = 2;
        }
        if (count($categories) < $args['min_display']) {
            return;
        }
    }
    if (!isset($args['base_link'])) {
        if (is_page() && mini_archive_on_page(get_the_ID())) {
            $args['base_link'] = get_permalink();
        } else {
            $args['base_link'] = get_post_type_archive_link($query->query_vars['post_type']);
        }
    }
    if (!isset($args['title_li'])) {
        $taxonomies = get_taxonomies(array('name' => $tax_name), 'objects');
        foreach ($taxonomies as $taxonomy) {
            $args['title_li'] = $taxonomy->label;
        }
    }
    $args = array_merge(array('taxonomy' => $tax_name, 'show_all_link' => true), $args);
    sfhiv_draw_taxonomy_menu($args);
}
 public function term_link($link, $term, $taxonomy)
 {
     $facets = FWP()->helper->get_facets();
     $taxes = $sources = array();
     $permalink = FWP()->helper->get_setting('term_permalink', 'slug');
     $permalink_type = FWP()->helper->get_setting('permalink_type', 'get');
     $term = 'term_id' == $permalink ? $term->term_id : $term->slug;
     if (empty($facets)) {
         return $link;
     }
     foreach ($facets as $facet) {
         if (isset($facet['source'])) {
             $sources[$facet['name']] = $facet['source'];
         }
     }
     if (empty($sources)) {
         return $link;
     }
     foreach ($sources as $name => $source) {
         $source = str_replace('tax/', '', $source);
         if ($taxonomy == $source) {
             $post_type = get_post_type_archive_link('job_listing');
             if ('get' == $permalink_type) {
                 $url = add_query_arg('fwp_' . $name, $term, $post_type);
             } else {
                 $url = $post_type . '#!/' . $name . '=' . $term;
             }
             return esc_url($url);
         }
     }
     return $link;
 }
Example #11
0
 function widget($args, $instance)
 {
     $out = $args['before_widget'];
     // And here do whatever you want
     $out .= $args['before_title'];
     $out .= $instance['title'];
     $out .= $args['after_title'];
     global $wpdb;
     $count_col = '';
     if ((bool) $instance['show_counts']) {
         $count_col = ", count( substring( TRIM( LEADING 'A ' FROM TRIM( LEADING 'AN ' FROM TRIM( LEADING 'THE ' FROM UPPER( {$wpdb->posts}.post_title ) ) ) ), 1, 1) ) as counts";
     }
     $querystr = "SELECT DISTINCT substring( TRIM( LEADING 'A ' FROM TRIM( LEADING 'AN ' FROM TRIM( LEADING 'THE ' FROM UPPER( {$wpdb->posts}.post_title ) ) ) ), 1, 1) as initial" . $count_col . " FROM {$wpdb->posts} WHERE {$wpdb->posts}.post_status = 'publish' AND {$wpdb->posts}.post_type = 'glossary' GROUP BY initial ORDER BY TRIM( LEADING 'A ' FROM TRIM( LEADING 'AN ' FROM TRIM( LEADING 'THE ' FROM UPPER( {$wpdb->posts}.post_title ) ) ) );";
     $pt_initials = $wpdb->get_results($querystr, ARRAY_A);
     $initial_arr = array();
     $base_url = get_post_type_archive_link('glossary');
     if (!$base_url) {
         $base_url = esc_url(home_url('/'));
         if (get_option('show_on_front') == 'page') {
             $base_url = esc_url(get_permalink(get_option('page_for_posts')));
         }
     }
     foreach ($pt_initials as $pt_rec) {
         $link = add_query_arg('az', $pt_rec['initial'], $base_url);
         $item = '<li><a href="' . $link . '">' . $pt_rec['initial'] . '</a></li>';
         if ((bool) $instance['show_counts']) {
             $item = '<li class="count"><a href="' . $link . '">' . $pt_rec['initial'] . ' <span>(' . $pt_rec['counts'] . ')</span>' . '</a></li>';
         }
         $initial_arr[] = $item;
     }
     $out .= '<ul>' . implode('', $initial_arr) . '</ul>';
     $out .= $args['after_widget'];
     echo $out;
 }
Example #12
0
File: CMA.php Project: hemangsk/TCB
 public static function getReferer()
 {
     global $wp_query;
     $isEditPage = function ($url) {
         return false;
     };
     $isTheSameHost = function ($a, $b) {
         return parse_url($a, PHP_URL_HOST) == parse_url($b, PHP_URL_HOST);
     };
     $canUseReferer = (!empty($_SERVER['HTTP_REFERER']) and $isTheSameHost($_SERVER['HTTP_REFERER'], site_url()) and !$isEditPage($_SERVER['HTTP_REFERER']));
     $canUseCurrentPost = (is_single() and !empty($wp_query->post) and $wp_query->post->post_type == CMA_Thread::POST_TYPE and $isEditPage($_GET));
     if (!empty($_GET['backlink'])) {
         // GET backlink param
         return base64_decode(urldecode($_GET['backlink']));
     } else {
         if (!empty($_POST['backlink'])) {
             // POST backlink param
             return $_POST['backlink'];
         } else {
             if ($canUseReferer) {
                 // HTTP referer
                 return $_SERVER['HTTP_REFERER'];
             } else {
                 if ($canUseCurrentPost) {
                     // Question permalink
                     return get_permalink($wp_query->post->ID);
                 } else {
                     // CMA index page
                     return get_post_type_archive_link(CMA_Thread::POST_TYPE);
                 }
             }
         }
     }
 }
Example #13
0
 /**
  * Registering a post type
  *
  * @param string $type slug of the type
  * @param string $singular singular name
  * @param string $plural plural name
  * @param array $config can override the defaults of this function (array_merge)
  */
 public static function registerPostType($type, $singular, $plural, $config = array())
 {
     $labels = array('name' => $plural, 'singular_name' => $singular, 'add_new' => 'Erstellen', 'add_new_item' => $singular . ' erfassen', 'edit_item' => 'Bearbeite ' . $singular, 'new_item' => 'Neues ' . $singular, 'view_item' => $singular . ' ansehen', 'search_items' => $singular . ' suchen', 'not_found' => 'Keine ' . $plural . ' gefunden', 'not_found_in_trash' => 'Keine ' . $plural . ' im Papierkorb gefunden', 'parent_item_colon' => '');
     $defaults = array('labels' => $labels, 'public' => true, 'has_archive' => true, 'plural_view_adminbar' => false);
     $arguments = array_merge_recursive_distinct($defaults, $config);
     if (isset($arguments['plural_view_adminbar']) && $arguments['plural_view_adminbar']) {
         add_action('admin_bar_menu', function ($wp_admin_bar) use($type, $arguments) {
             $object = get_queried_object();
             if ($object->name == $type) {
                 $title = $object->labels->menu_name;
                 if (is_admin()) {
                     $url = get_post_type_archive_link($type);
                 } else {
                     $url = get_admin_url(null, 'edit.php?post_type=' . $type);
                 }
             }
             if ($object->post_type == $type) {
                 if (!is_admin()) {
                     $url = get_edit_post_link($object->ID);
                     $title = $arguments['labels']['edit_item'];
                 }
             }
             // Add admin bar entry
             if ($url) {
                 $wp_admin_bar->add_node(array('id' => 'custom-button', 'title' => $title, 'href' => $url));
             }
         }, 95);
     }
     register_post_type($type, $arguments);
 }
Example #14
0
 public static function getArchiveUrl()
 {
     $url = get_post_type_archive_link((new static())->post_type);
     if (Filter::isUrl($url)) {
         return $url;
     }
 }
/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works
 **/
function woocommerce_redirects()
{
    global $woocommerce, $wp_query;
    // When default permalinks are enabled, redirect shop page to post type archive url
    if (isset($_GET['page_id']) && $_GET['page_id'] > 0 && get_option('permalink_structure') == "" && $_GET['page_id'] == woocommerce_get_page_id('shop')) {
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    }
    // When on the checkout with an empty cart, redirect to cart page
    if (is_page(woocommerce_get_page_id('checkout')) && sizeof($woocommerce->cart->get_cart()) == 0) {
        wp_redirect(get_permalink(woocommerce_get_page_id('cart')));
        exit;
    }
    // When on pay page with no query string, redirect to checkout
    if (is_page(woocommerce_get_page_id('pay')) && !isset($_GET['order'])) {
        wp_redirect(get_permalink(woocommerce_get_page_id('checkout')));
        exit;
    }
    // My account page redirects (logged out)
    if (!is_user_logged_in() && (is_page(woocommerce_get_page_id('edit_address')) || is_page(woocommerce_get_page_id('view_order')) || is_page(woocommerce_get_page_id('change_password')))) {
        wp_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
        exit;
    }
    // Redirect to the product page if we have a single product
    if (is_search() && is_post_type_archive('product') && get_option('woocommerce_redirect_on_single_search_result') == 'yes') {
        if ($wp_query->post_count == 1) {
            $product = new WC_Product($wp_query->post->ID);
            if ($product->is_visible()) {
                wp_safe_redirect(get_permalink($product->id), 302);
            }
            exit;
        }
    }
}
function station_shortcode_get_playlists_for_show($atts)
{
    extract(shortcode_atts(array('show' => '', 'limit' => -1), $atts));
    //don't return anything if we don't have a show
    if ($show == '') {
        return false;
    }
    $args = array('numberposts' => $limit, 'offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'playlist', 'post_status' => 'publish', 'meta_key' => 'playlist_show_id', 'meta_value' => $show);
    $playlists = get_posts($args);
    $output = '';
    $output .= '<div id="myplaylist-playlistlinks">';
    $output .= '<ul class="myplaylist-linklist">';
    foreach ($playlists as $playlist) {
        $output .= '<li><a href="';
        $output .= get_permalink($playlist->ID);
        $output .= '">' . $playlist->post_title . '</a></li>';
    }
    $output .= '</ul>';
    $playlist_archive = get_post_type_archive_link('playlist');
    $params = array('show_id' => $show);
    $playlist_archive = add_query_arg($params, $playlist_archive);
    $output .= '<a href="' . $playlist_archive . '">' . __('More Playlists', 'radio-station') . '</a>';
    $output .= '</div>';
    return $output;
}
 /**
  * Decide which template file to load
  */
 public function override_templates()
 {
     $this->queried_object = get_queried_object();
     if (is_post_type_archive(Plugin::POST_TYPE_NAME)) {
         // load template for a single page
         $custom_archive_page_id = $this->wpkb->get_option('custom_archive_page_id');
         if ($custom_archive_page_id > 0) {
             // if we're using a custom archive page, that one should be used
             $archive_link = get_permalink($custom_archive_page_id);
             if ($archive_link !== get_post_type_archive_link(Plugin::POST_TYPE_NAME)) {
                 wp_redirect($archive_link);
                 exit;
             }
         } else {
             add_filter('archive_template', array($this, 'set_archive_template'));
         }
     } elseif (is_tax(Plugin::TAXONOMY_CATEGORY_NAME)) {
         // choose "category" archive template to load
         add_filter('taxonomy_template', array($this, 'set_taxonomy_category_template'));
     } elseif (is_tax(Plugin::TAXONOMY_KEYWORD_NAME)) {
         // choose "keyword" archive template to load
         add_filter('taxonomy_template', array($this, 'set_taxonomy_keyword_template'));
     } elseif (is_singular(Plugin::POST_TYPE_NAME)) {
         // choose template to load for singular docs
         add_filter('single_template', array($this, 'set_single_template'));
         add_filter('wp_footer', array($this, 'print_js_helpers'));
         add_filter('wp_head', array($this, 'print_css_helpers'));
     }
 }
Example #18
0
/**
 * Build URL for time facet
 *
 * @param int $year
 * @param int $month
 * @param array $widget_instance
 *
 * @return string
 */
function _scifi_facets_time_url($year, $month, $widget_instance)
{
    global $wp_rewrite;
    $url = '';
    if ($month) {
        $month = sprintf('%02d', $month);
    }
    if (!empty($wp_rewrite->permalink_structure) && !empty($widget_instance['usepermalinks'])) {
        if (!empty($widget_instance['urlbase_custom'])) {
            $url = home_url($widget_instance['urlbase_custom']);
        } else {
            $post_type = empty($widget_instance['posttype']) ? get_query_var('post_type') : $widget_instance['posttype'];
            if ($post_type == 'post') {
                $url = home_url($wp_rewrite->front);
            } else {
                $url = get_post_type_archive_link($post_type);
            }
        }
        if (strpos($url, '%year%') !== FALSE || strpos($url, '%month%') !== FALSE || strpos($url, '%date%') !== FALSE) {
            $url = strtr($url, array('%year%' => $year, '%month%' => $month, '%date%' => $year . '/' . $month));
        } else {
            $url = $url . '/' . $year . '/' . $month;
        }
        $url = preg_replace('#[^\\:]\\/{2,}#', '/', trailingslashit($url));
    } else {
        $url = home_url(add_query_arg(array('year' => $year, 'month' => $month)));
    }
    return $url;
}
function enlightenment_project_types_filter($args = null)
{
    $args = array('container' => 'ul', 'container_class' => 'project-types-filter', 'term_tag' => 'li', 'term_class' => 'project-type', 'current_term_class' => 'current-project-type', 'sep' => '', 'echo' => true);
    $args = apply_filters('enlightenment_project_types_filter_args', $args);
    $terms = get_terms('jetpack-portfolio-type');
    $output = '';
    if (!empty($terms)) {
        $output .= enlightenment_open_tag($args['container'], $args['container_class']);
        if (is_tax('jetpack-portfolio-type')) {
            $output .= enlightenment_open_tag($args['term_tag'], $args['term_class']);
            $output .= sprintf('<a href="%1$s" rel="%2$s">%3$s</a>', get_post_type_archive_link('jetpack-portfolio'), 'jetpack-portfolio-type', __('All', 'enlightenment'));
            $output .= enlightenment_close_tag($args['term_tag']);
        }
        foreach ($terms as $term) {
            $class = $args['term_class'];
            $link = get_term_link($term, $term->taxonomy);
            $current_url = sprintf('%1$s%2$s%3$s', is_ssl() ? 'https://' : 'http://', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
            if ($link == $current_url) {
                $class .= ' ' . $args['current_term_class'];
            }
            $output .= enlightenment_open_tag($args['term_tag'], $class);
            $output .= sprintf('<a href="%1$s" rel="%2$s">%3$s</a>', $link, $term->taxonomy, $term->name);
            $output .= enlightenment_close_tag($args['term_tag']);
        }
        $output .= enlightenment_close_tag($args['container']);
    }
    $output = apply_filters('enlightenment_project_types_filter', $output);
    if (!$args['echo']) {
        return $output;
    }
    echo $output;
}
/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 */
function wc_template_redirect()
{
    global $wp_query, $wp;
    if (!empty($_GET['page_id']) && '' === get_option('permalink_structure') && wc_get_page_id('shop') == $_GET['page_id']) {
        // When default permalinks are enabled, redirect shop page to post type archive url
        wp_safe_redirect(get_post_type_archive_link('product'));
        exit;
    } elseif (is_page(wc_get_page_id('checkout')) && wc_get_page_id('checkout') !== wc_get_page_id('cart') && WC()->cart->is_empty() && empty($wp->query_vars['order-pay']) && !isset($wp->query_vars['order-received'])) {
        // When on the checkout with an empty cart, redirect to cart page
        wc_add_notice(__('Checkout is not available whilst your cart is empty.', 'woocommerce'), 'notice');
        wp_redirect(wc_get_page_permalink('cart'));
        exit;
    } elseif (isset($wp->query_vars['customer-logout'])) {
        // Logout
        wp_redirect(str_replace('&amp;', '&', wp_logout_url(wc_get_page_permalink('myaccount'))));
        exit;
    } elseif (is_search() && is_post_type_archive('product') && apply_filters('woocommerce_redirect_single_search_result', true) && 1 === absint($wp_query->found_posts)) {
        // Redirect to the product page if we have a single product
        $product = wc_get_product($wp_query->post);
        if ($product && $product->is_visible()) {
            wp_safe_redirect(get_permalink($product->get_id()), 302);
            exit;
        }
    } elseif (is_add_payment_method_page()) {
        // Ensure payment gateways are loaded early
        WC()->payment_gateways();
    } elseif (is_checkout()) {
        // Checkout pages handling
        // Buffer the checkout page
        ob_start();
        // Ensure gateways and shipping methods are loaded early
        WC()->payment_gateways();
        WC()->shipping();
    }
}
 /**
  * Generate the content of the widget.
  *
  * @param	array	args		The array of form elements
  * @param	array	instance	The current instance of the widget
  */
 public function widget_content($args, $instance)
 {
     extract($args, EXTR_SKIP);
     extract($instance);
     $count = (array) wp_count_posts('movie');
     $count = array('movies' => $count['publish'], 'imported' => $count['import-draft'], 'queued' => $count['import-queued'], 'draft' => $count['draft'], 'total' => 0);
     $count['total'] = array_sum($count);
     $count['collections'] = wp_count_terms('collection');
     $count['genres'] = wp_count_terms('genre');
     $count['actors'] = wp_count_terms('actor');
     $count = array_map('intval', $count);
     extract($count);
     $links = array();
     $links['%total%'] = sprintf('<a href="%s">%s</a>', get_post_type_archive_link('movie'), sprintf(_n('<strong>1</strong> movie', '<strong>%d</strong> movies', $movies, 'wpmovielibrary'), $movies));
     $links['%collections%'] = WPMOLY_Utils::get_taxonomy_permalink('collection', sprintf(_n('<strong>1</strong> collection', '<strong>%d</strong> collections', $collections, 'wpmovielibrary'), $collections));
     $links['%genres%'] = WPMOLY_Utils::get_taxonomy_permalink('genre', sprintf(_n('<strong>1</strong> genre', '<strong>%d</strong> genres', $genres, 'wpmovielibrary'), $genres));
     $links['%actors%'] = WPMOLY_Utils::get_taxonomy_permalink('actor', sprintf(_n('<strong>1</strong> actor', '<strong>%d</strong> actors', $actors, 'wpmovielibrary'), $actors));
     $title = $before_title . apply_filters('widget_title', $title) . $after_title;
     $description = esc_attr($description);
     $format = wpautop(wp_kses($format, array('ul', 'ol', 'li', 'p', 'span', 'em', 'i', 'p', 'strong', 'b', 'br')));
     $content = str_replace(array_keys($links), array_values($links), $format);
     $style = 'wpmoly-widget wpmoly-statistics';
     $attributes = array('content' => $content, 'description' => $description, 'style' => $style);
     $html = WPMovieLibrary::render_template('statistics-widget/statistics.php', $attributes, $require = 'always');
     return $before_widget . $title . $html . $after_widget;
 }
        /**
         * Front-end display of widget.
         * @param array $args     Widget arguments.
         * @param array $instance Saved values from database.
         */
        public function widget($args, $instance)
        {
            $title = apply_filters('widget_title', empty($instance['title']) ? __('Latest News', 'st-business-carry-over') : $instance['title'], $instance, $this->id_base);
            $number = isset($instance['number']) ? $instance['number'] : 3;
            $see_all_label = !empty($instance['see_all_label']) ? $instance['see_all_label'] : __('All Announcements', 'st-business-carry-over');
            echo $args['before_widget'];
            echo '<h3 class="widget-title">' . $title . '</h3>';
            /** 
             * loop through announcements 
             */
            $query_args = array('posts_per_page' => $number, 'post_type' => 'smartest_news', 'order' => 'DESC');
            $sbfnews = new WP_Query($query_args);
            if ($sbfnews->have_posts()) {
                ?>
				<ul>
				<?php 
                while ($sbfnews->have_posts()) {
                    $sbfnews->the_post();
                    ?>
					<li><a href="<?php 
                    echo get_permalink();
                    ?>
" title="<?php 
                    the_title_attribute();
                    ?>
"><?php 
                    echo get_the_title();
                    ?>
</a><br />
					<?php 
                    $datetime = get_the_date('Y-m-d');
                    printf('<time datetime="%s">%s</time>', $datetime, get_the_date());
                    ?>
					</li>
			 
				<?php 
                }
                ?>
				</ul>
				<?php 
                $li = '<a href="' . get_post_type_archive_link('smartest_news') . '">' . $see_all_label . '</a>';
                ?>
 <p><?php 
                printf(__('%s', 'st-business-carry-over'), $li);
                ?>
</p>

		<?php 
            } else {
                ?>
					<p><?php 
                _e('Coming soon.', 'st-business-carry-over');
                ?>
</p>		
		<?php 
            }
            wp_reset_postdata();
            echo $args['after_widget'];
        }
 function urlForToolName($shortName = '')
 {
     $url = get_post_type_archive_link('bfox_tool');
     if (!empty($shortName)) {
         $url = add_query_arg('tool', $shortName, $url);
     }
     return $url;
 }
/**
 * Handle redirects before content is output - hooked into template_redirect so is_page works.
 *
 * @return void
 */
function rh_template_redirect()
{
    // When default permalinks are enabled, redirect recipes page to post type archive url
    if (!empty($_GET['page_id']) && get_option('permalink_structure') == "" && $_GET['page_id'] == rh_get_page_id('recipes')) {
        wp_safe_redirect(get_post_type_archive_link('recipe'));
        exit;
    }
}
Example #25
0
 protected function has_archive()
 {
     $cpt = Types_Helper_Condition::get_post_type();
     if (!get_post_type_archive_link($cpt->name)) {
         return false;
     }
     return true;
 }
 public function __construct()
 {
     add_filter('nav_menu_css_class', array($this, 'cssClasses'), 10, 2);
     add_filter('nav_menu_item_id', '__return_null');
     $cpt = get_post_type();
     $this->cpt = in_array($cpt, get_post_types(array('_builtin' => false)));
     $this->archive = get_post_type_archive_link($cpt);
 }
/**
 * sensei_course_archive_next_link function.
 *
 * @access public
 * @param string $type (default: 'newcourses')
 * @return void
 */
function sensei_course_archive_next_link($type = 'newcourses')
{
    global $woothemes_sensei;
    $course_pagination_link = get_post_type_archive_link('course');
    $more_link_text = esc_html($woothemes_sensei->settings->settings['course_archive_more_link_text']);
    $html = '<div class="navigation"><div class="nav-next"><a href="' . esc_url(add_query_arg(array('paged' => '2', 'action' => $type), $course_pagination_link)) . '">' . sprintf(__('%1$s', 'woothemes-sensei'), $more_link_text) . ' <span class="meta-nav"></span></a></div><div class="nav-previous"></div></div>';
    return apply_filters('course_archive_next_link', $html);
}
Example #28
0
function jigoshop_shop_page_archive_redirect() {
	
	if ( isset($_GET['page_id']) && $_GET['page_id'] == get_option('jigoshop_shop_page_id') ) :
		wp_safe_redirect( get_post_type_archive_link('product') );
		exit;
	endif;
	
}
function rbp_redirect_partners_single_to_archive()
{
    if (!is_singular('portfolio')) {
        return;
    }
    wp_redirect(get_post_type_archive_link('portfolio'), 301);
    exit;
}
 /**
  * Get current page URL for layered nav items.
  * @return string
  */
 protected function get_page_base_url()
 {
     if (defined('SHOP_IS_ON_FRONT')) {
         $link = home_url();
     } elseif (is_post_type_archive('product') || is_page(wc_get_page_id('shop'))) {
         $link = get_post_type_archive_link('product');
     } else {
         $link = get_term_link(get_query_var('term'), get_query_var('taxonomy'));
     }
     // Min/Max
     if (isset($_GET['min_price'])) {
         $link = add_query_arg('min_price', wc_clean($_GET['min_price']), $link);
     }
     if (isset($_GET['max_price'])) {
         $link = add_query_arg('max_price', wc_clean($_GET['max_price']), $link);
     }
     // Orderby
     if (isset($_GET['orderby'])) {
         $link = add_query_arg('orderby', wc_clean($_GET['orderby']), $link);
     }
     // Search Arg
     if (get_search_query()) {
         $link = add_query_arg('s', get_search_query(), $link);
     }
     // Post Type Arg
     if (isset($_GET['post_type'])) {
         $link = add_query_arg('post_type', wc_clean($_GET['post_type']), $link);
     }
     return $link;
 }