当前位置: 首页>>代码示例>>PHP>>正文


PHP EM_Object::get_taxonomies方法代码示例

本文整理汇总了PHP中EM_Object::get_taxonomies方法的典型用法代码示例。如果您正苦于以下问题:PHP EM_Object::get_taxonomies方法的具体用法?PHP EM_Object::get_taxonomies怎么用?PHP EM_Object::get_taxonomies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EM_Object的用法示例。


在下文中一共展示了EM_Object::get_taxonomies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: em_ical_item

/**
 * Generates an ics file for a single event 
 */
function 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: inline; 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;
        }
    }
}
开发者ID:Olaf1989,项目名称:Cakes-and-more,代码行数:51,代码来源:em-ical.php

示例2: rewrite_rules_array


//.........这里部分代码省略.........
             $child_posts = $wpdb->get_results("SELECT ID, post_name FROM {$wpdb->posts} WHERE post_parent={$events_page->ID} AND post_type='page' AND post_status='publish'");
             foreach ($child_posts as $child_post) {
                 $em_rules[$events_page->post_name . '/' . urldecode($child_post->post_name) . '/?$'] = 'index.php?page_id=' . $child_post->ID;
                 //single event booking form with slug    //check if child page has children
                 $grandchildren = $wpdb->get_results("SELECT ID, post_name FROM {$wpdb->posts} WHERE post_parent={$child_post->ID} AND post_type='page' AND post_status='publish'");
                 if (count($grandchildren) != 0) {
                     foreach ($grandchildren as $grandchild) {
                         $em_rules[$events_slug . urldecode($child_post->post_name) . '/' . urldecode($grandchild->post_name) . '/?$'] = 'index.php?page_id=' . $grandchild->ID;
                     }
                 }
             }
         }
         //global links hard-coded
         if (EM_MS_GLOBAL && !get_site_option('dbem_ms_global_events_links', true)) {
             //MS Mode has slug also for global links
             $em_rules[$events_slug . get_site_option('dbem_ms_events_slug', EM_EVENT_SLUG) . '/(.+)$'] = 'index.php?pagename=' . $events_slug . '&em_redirect=1&event_slug=$matches[1]';
             //single event from subsite
         }
         //add redirection for backwards compatability
         $em_rules[$events_slug . EM_EVENT_SLUG . '/(.+)$'] = 'index.php?pagename=' . $events_slug . '&em_redirect=1&event_slug=$matches[1]';
         //single event
         $em_rules[$events_slug . EM_LOCATION_SLUG . '/(.+)$'] = 'index.php?pagename=' . $events_slug . '&em_redirect=1&location_slug=$matches[1]';
         //single location page
         $em_rules[$events_slug . EM_CATEGORY_SLUG . '/(.+)$'] = 'index.php?pagename=' . $events_slug . '&em_redirect=1&category_slug=$matches[1]';
         //single category page slug
         //add a rule that ensures that the events page is found and used over other pages
         $em_rules[trim($events_slug, '/') . '/?$'] = 'index.php?pagename=' . trim($events_slug, '/');
     } else {
         $events_slug = EM_POST_TYPE_EVENT_SLUG;
         $em_rules[$events_slug . '/(\\d{4}-\\d{2}-\\d{2})$'] = 'index.php?post_type=' . EM_POST_TYPE_EVENT . '&calendar_day=$matches[1]';
         //event calendar date search
         if (get_option('dbem_rsvp_enabled')) {
             if (!get_option('dbem_my_bookings_page') || !is_object(get_post(get_option('dbem_my_bookings_page')))) {
                 //only added if bookings page isn't assigned
                 $em_rules[$events_slug . '/my\\-bookings$'] = 'index.php?post_type=' . EM_POST_TYPE_EVENT . '&bookings_page=1';
                 //page for users to manage bookings
             }
         }
         //check for potentially conflicting posts with the same slug as events
         $conflicting_posts = get_posts(array('name' => EM_POST_TYPE_EVENT_SLUG, 'post_type' => 'any', 'numberposts' => 0));
         if (count($conflicting_posts) > 0) {
             //won't apply on homepage
             foreach ($conflicting_posts as $conflicting_post) {
                 //make sure we hard-code rewrites for child pages of events
                 $child_posts = get_posts(array('post_type' => 'any', 'post_parent' => $conflicting_post->ID, 'numberposts' => 0));
                 foreach ($child_posts as $child_post) {
                     $em_rules[EM_POST_TYPE_EVENT_SLUG . '/' . urldecode($child_post->post_name) . '/?$'] = 'index.php?page_id=' . $child_post->ID;
                     //single event booking form with slug
                     //check if child page has children
                     $grandchildren = get_pages('child_of=' . $child_post->ID);
                     if (count($grandchildren) != 0) {
                         foreach ($grandchildren as $grandchild) {
                             $em_rules[$events_slug . urldecode($child_post->post_name) . '/' . urldecode($grandchild->post_name) . '/?$'] = 'index.php?page_id=' . $grandchild->ID;
                         }
                     }
                 }
             }
         }
     }
     $em_rules = apply_filters('em_rewrite_rules_array_events', $em_rules, $events_slug);
     //make sure there's no page with same name as archives, that should take precedence as it can easily be deleted wp admin side
     $em_query = new WP_Query(array('pagename' => EM_POST_TYPE_EVENT_SLUG));
     if ($em_query->have_posts()) {
         $em_rules[trim(EM_POST_TYPE_EVENT_SLUG, '/') . '/?$'] = 'index.php?pagename=' . trim(EM_POST_TYPE_EVENT_SLUG, '/');
         wp_reset_postdata();
     }
     //make sure there's no page with same name as archives, that should take precedence as it can easily be deleted wp admin side
     $em_query = new WP_Query(array('pagename' => EM_POST_TYPE_LOCATION_SLUG));
     if ($em_query->have_posts()) {
         $em_rules[trim(EM_POST_TYPE_LOCATION_SLUG, '/') . '/?$'] = 'index.php?pagename=' . trim(EM_POST_TYPE_LOCATION_SLUG, '/');
         wp_reset_postdata();
     }
     //If in MS global mode and locations are linked on same site
     if (EM_MS_GLOBAL && !get_site_option('dbem_ms_global_locations_links', true)) {
         $locations_page_id = get_option('dbem_locations_page');
         $locations_page = get_post($locations_page_id);
         if (is_object($locations_page)) {
             $locations_slug = preg_replace('/\\/$/', '', str_replace(trailingslashit(home_url()), '', get_permalink($locations_page_id)));
             $locations_slug_slashed = !empty($locations_slug) ? trailingslashit($locations_slug) : $locations_slug;
             $em_rules[$locations_slug . '/' . get_site_option('dbem_ms_locations_slug', EM_LOCATION_SLUG) . '/(.+)$'] = 'index.php?pagename=' . $locations_slug_slashed . '&location_slug=$matches[1]';
             //single event booking form with slug
         }
     }
     //add ical CPT endpoints
     $em_rules[EM_POST_TYPE_EVENT_SLUG . "/([^/]+)/ical/?\$"] = 'index.php?' . EM_POST_TYPE_EVENT . '=$matches[1]&ical=1';
     if (get_option('dbem_locations_enabled')) {
         $em_rules[EM_POST_TYPE_LOCATION_SLUG . "/([^/]+)/ical/?\$"] = 'index.php?' . EM_POST_TYPE_LOCATION . '=$matches[1]&ical=1';
     }
     //add ical taxonomy endpoints
     $taxonomies = EM_Object::get_taxonomies();
     foreach ($taxonomies as $tax_arg => $taxonomy_info) {
         //set the dynamic rule for this taxonomy
         $em_rules[$taxonomy_info['slug'] . "/([^/]+)/ical/?\$"] = 'index.php?' . $taxonomy_info['query_var'] . '=$matches[1]&ical=1';
     }
     //add RSS location CPT endpoint
     if (get_option('dbem_locations_enabled')) {
         $em_rules[EM_POST_TYPE_LOCATION_SLUG . "/([^/]+)/rss/?\$"] = 'index.php?' . EM_POST_TYPE_LOCATION . '=$matches[1]&rss=1';
     }
     return $em_rules + $rules;
 }
开发者ID:pcco,项目名称:portal-redesign,代码行数:101,代码来源:em-permalinks.php


注:本文中的EM_Object::get_taxonomies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。