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


PHP p2p_type函数代码示例

本文整理汇总了PHP中p2p_type函数的典型用法代码示例。如果您正苦于以下问题:PHP p2p_type函数的具体用法?PHP p2p_type怎么用?PHP p2p_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: response_message

 protected function response_message($data)
 {
     if (!is_user_logged_in()) {
         $data['redirect'] = esc_url($_POST['current_url']);
         $data['status'] = 'error';
         $data['notice'] = sprintf(__('You must <a href="%1$s">login</a> to be able to favorite listings.', APP_TD), wp_login_url($data['redirect']));
         return $data;
     }
     $p2p = p2p_type(APP_FAVORITES_CONNECTION);
     $user_id = get_current_user_id();
     $post_id = (int) $_POST['item_id'];
     if ('add' == $_POST[$this->action_var]) {
         $date = current_time('mysql');
         $data['status'] = $p2p->connect($post_id, $user_id, array('date' => $date));
         $message = __("Added '%s' to your favorites.", APP_TD);
         $data['notice'] = sprintf($message, get_the_title($post_id));
     } else {
         $data['status'] = $p2p->disconnect($post_id, $user_id);
         $message = __("Removed '%s' from your favorites.", APP_TD);
         $data['notice'] = sprintf($message, get_the_title($post_id));
     }
     if (is_wp_error($p2p)) {
         $data['status'] = 'error';
         $message = __("Could not add '%s' to favorites at this time.", APP_TD);
         $data['notice'] = sprintf($message, get_the_title($post_id));
     }
     return $data;
 }
开发者ID:kalushta,项目名称:darom,代码行数:28,代码来源:class-ajax-view-favorites.php

示例2: appthemes_upgrade_item_addons

/**
 * Upgrades orders using the old item structure
 * @return void
 */
function appthemes_upgrade_item_addons()
{
    // Get All Orders
    $posts = new WP_Query(array('post_type' => APPTHEMES_ORDER_PTYPE, 'nopaging' => true));
    foreach ($posts->posts as $order) {
        $connected = new WP_Query(array('connected_type' => APPTHEMES_ORDER_CONNECTION, 'connected_from' => $order->ID));
        // Get all items
        foreach ($connected->posts as $post) {
            $post_id = $post->ID;
            // Get all addons
            $meta = p2p_get_meta($post->p2p_id);
            // Don't upgrade new items
            if (isset($meta['type'])) {
                continue;
            }
            if (isset($meta['addon'])) {
                foreach ($meta['addon'] as $addon) {
                    // Add an item for each addon
                    $p2p_id = p2p_type(APPTHEMES_ORDER_CONNECTION)->connect($order->ID, $post_id);
                    // Add meta data
                    p2p_add_meta($p2p_id, 'type', $addon);
                    p2p_add_meta($p2p_id, 'price', $meta[$addon][0]);
                }
            }
            // Add an item for the regular item
            $p2p_id = p2p_type(APPTHEMES_ORDER_CONNECTION)->connect($order->ID, $post_id);
            p2p_add_meta($p2p_id, 'type', 'regular');
            // value of VA_ITEM_REGULAR, since upgrade is only Vantage-applicable
            p2p_add_meta($p2p_id, 'price', $meta['price'][0]);
            // Delete the old item
            p2p_delete_connection($post->p2p_id);
        }
    }
}
开发者ID:TopLineMediaTeam,项目名称:horseshow,代码行数:38,代码来源:order-upgrade.php

示例3: widget

 function widget($args, $instance)
 {
     if (!is_singular()) {
         return;
     }
     $instance = array_merge($this->defaults, $instance);
     $post_id = get_queried_object_id();
     $ctype = p2p_type($instance['ctype']);
     if (!$ctype) {
         return;
     }
     $directed = $ctype->find_direction($post_id);
     if (!$directed) {
         return;
     }
     if ('related' == $instance['listing']) {
         $connected = $ctype->get_related($post_id);
         $title = sprintf(__('Related %s', P2P_TEXTDOMAIN), $directed->get_current('side')->get_title());
     } else {
         $connected = $directed->get_connected($post_id);
         $title = $directed->get_current('title');
     }
     if (!$connected->have_posts()) {
         return;
     }
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     extract($args);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     p2p_list_posts($connected);
     echo $after_widget;
 }
开发者ID:netconstructor,项目名称:wp-posts-to-posts,代码行数:34,代码来源:widget.php

示例4: expand_connected_type

 function expand_connected_type(&$q)
 {
     if (!isset($q['connected_type'])) {
         return;
     }
     $ctype = p2p_type(_p2p_pluck($q, 'connected_type'));
     if (!$ctype) {
         return false;
     }
     if (isset($q['connected_direction'])) {
         $directed = $ctype->set_direction(_p2p_pluck($q, 'connected_direction'));
     } else {
         if ('any' == $q['connected_items']) {
             $post_type = isset($q['post_type']) ? $q['post_type'] : 'post';
         } else {
             $post_type = $q['connected_items'];
         }
         $directed = P2P_Query::find_direction($ctype, $post_type, 'post');
     }
     if (!$directed) {
         trigger_error("Can't determine direction", E_USER_WARNING);
         return false;
     }
     $q = $directed->get_connected_args($q);
     return true;
 }
开发者ID:netconstructor,项目名称:wp-posts-to-posts,代码行数:26,代码来源:query-post.php

示例5: _p2p_get_list

/** @internal */
function _p2p_get_list($args)
{
    extract($args);
    $ctype = p2p_type($ctype);
    if (!$ctype) {
        trigger_error(sprintf("Unregistered connection type '%s'.", $ctype), E_USER_WARNING);
        return '';
    }
    $directed = $ctype->find_direction($item);
    if (!$directed) {
        return '';
    }
    $extra_qv = array('p2p:per_page' => -1, 'p2p:context' => $context);
    $connected = $directed->{$method}($item, $extra_qv, 'abstract');
    switch ($mode) {
        case 'inline':
            $args = array('separator' => ', ');
            break;
        case 'ol':
            $args = array('before_list' => '<ol id="' . $ctype->name . '_list">', 'after_list' => '</ol>');
            break;
        case 'ul':
        default:
            $args = array('before_list' => '<ul id="' . $ctype->name . '_list">', 'after_list' => '</ul>');
            break;
    }
    $args['echo'] = false;
    return apply_filters("p2p_{$context}_html", $connected->render($args), $connected, $directed, $mode);
}
开发者ID:hscale,项目名称:webento,代码行数:30,代码来源:extra.php

示例6: sc_session_loop

/**
 * Session Loop
 *
 */
function sc_session_loop($args = array())
{
    $loop = new WP_Query($args);
    if ($loop->have_posts()) {
        while ($loop->have_posts()) {
            $loop->the_post();
            global $post;
            echo '<div class="session">';
            echo '<div class="left">';
            echo '<h3>' . esc_attr(get_post_meta($post->ID, 'sc_session_time', true)) . '</h3>';
            echo wpautop(get_post_meta($post->ID, 'sc_session_location', true));
            echo '</div>';
            echo '<div class="right">';
            echo '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
            $content = get_the_content();
            if (function_exists('p2p_list_posts')) {
                $connected = p2p_type('sessions_to_speakers')->get_connected($post->ID);
                p2p_list_posts($connected, array('before_list' => '<p>by ', 'after_list' => '</p>', 'before_item' => '', 'after_item' => ' '));
            }
            echo $content;
            echo '</div>';
            echo '</div>';
        }
    }
    wp_reset_query();
}
开发者ID:hscale,项目名称:webento,代码行数:30,代码来源:template-schedule.php

示例7: query_and_render

 static function query_and_render($args)
 {
     $ctype = p2p_type($args['ctype']);
     if (!$ctype) {
         trigger_error(sprintf("Unregistered connection type '%s'.", $ctype), E_USER_WARNING);
         return '';
     }
     $directed = $ctype->find_direction($args['item']);
     if (!$directed) {
         return '';
     }
     $context = $args['context'];
     $extra_qv = array('p2p:per_page' => -1, 'p2p:context' => $context);
     $connected = call_user_func(array($directed, $args['method']), $args['item'], $extra_qv, 'abstract');
     switch ($args['mode']) {
         case 'inline':
             $render_args = array('separator' => ', ');
             break;
         case 'ol':
             $render_args = array('before_list' => '<ol id="' . $ctype->name . '_list">', 'after_list' => '</ol>');
             break;
         case 'ul':
         default:
             $render_args = array('before_list' => '<ul id="' . $ctype->name . '_list">', 'after_list' => '</ul>');
             break;
     }
     $render_args['echo'] = false;
     $html = self::render($connected, $render_args);
     return apply_filters("p2p_{$context}_html", $html, $connected, $directed, $args['mode']);
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:30,代码来源:list-renderer.php

示例8: create_from_qv

 /**
  * Create instance from mixed query vars
  *
  * @param array Query vars to collect parameters from
  * @return:
  * - null means ignore current query
  * - WP_Error instance if the query is invalid
  * - P2P_Query instance on success
  */
 public static function create_from_qv(&$q, $object_type)
 {
     $shortcuts = array('connected' => 'any', 'connected_to' => 'to', 'connected_from' => 'from');
     foreach ($shortcuts as $key => $direction) {
         if (!empty($q[$key])) {
             $q['connected_items'] = _p2p_pluck($q, $key);
             $q['connected_direction'] = $direction;
         }
     }
     if (!isset($q['connected_type'])) {
         if (isset($q['connected_items'])) {
             return new WP_Error('no_connection_type', "Queries without 'connected_type' are no longer supported.");
         }
         return;
     }
     $ctypes = (array) _p2p_pluck($q, 'connected_type');
     if (isset($q['connected_direction'])) {
         $directions = (array) _p2p_pluck($q, 'connected_direction');
     } else {
         $directions = array();
     }
     $item = isset($q['connected_items']) ? $q['connected_items'] : 'any';
     $p2p_types = array();
     foreach ($ctypes as $i => $p2p_type) {
         $ctype = p2p_type($p2p_type);
         if (!$ctype) {
             continue;
         }
         if (isset($directions[$i])) {
             $directed = $ctype->set_direction($directions[$i]);
         } else {
             $directed = $ctype->find_direction($item, true, $object_type);
         }
         if (!$directed) {
             continue;
         }
         $p2p_types[] = $directed;
     }
     if (empty($p2p_types)) {
         return new WP_Error('no_direction', "Could not find direction(s).");
     }
     if (1 == count($p2p_types)) {
         $directed = $p2p_types[0];
         if ($orderby_key = $directed->get_orderby_key()) {
             $q = wp_parse_args($q, array('connected_orderby' => $orderby_key, 'connected_order' => 'ASC', 'connected_order_num' => true));
         }
         $q = array_merge_recursive($q, array('connected_meta' => $directed->data));
         $q = $directed->get_final_qv($q, 'opposite');
         $q = apply_filters('p2p_connected_args', $q, $directed, $item);
     }
     $p2p_q = new P2P_Query();
     $p2p_q->ctypes = $p2p_types;
     $p2p_q->items = $item;
     foreach (array('meta', 'orderby', 'order_num', 'order') as $key) {
         $p2p_q->{$key} = isset($q["connected_{$key}"]) ? $q["connected_{$key}"] : false;
     }
     $p2p_q->query = isset($q['connected_query']) ? $q['connected_query'] : array();
     return $p2p_q;
 }
开发者ID:hscale,项目名称:webento,代码行数:68,代码来源:query.php

示例9: sfhiv_event_get_groups

function sfhiv_event_get_groups($posts, $query)
{
    if (is_admin() || $query->query_vars['post_type'] != 'sfhiv_event') {
        return $posts;
    }
    p2p_type('group_events')->each_connected($query, array('post_type' => 'sfhiv_group'), 'groups');
    return $query->posts;
}
开发者ID:nickdotreid,项目名称:SFHIV-Wordpress-Models-Plugin,代码行数:8,代码来源:sfhiv_events.php

示例10: sfhiv_service_provider_load_services

function sfhiv_service_provider_load_services($posts, $query)
{
    if (is_admin() || $query->query_vars['post_type'] != 'sfhiv_provider') {
        return $posts;
    }
    p2p_type('provider_services')->each_connected($query, array(), 'services');
    return $posts;
}
开发者ID:nickdotreid,项目名称:SFHIV-Wordpress-Models-Plugin,代码行数:8,代码来源:sfhiv_services.php

示例11: sfhiv_service_hours_load_related_locations

function sfhiv_service_hours_load_related_locations($posts, $query)
{
    if (is_admin() || $query->query_vars['post_type'] != 'sfhiv_service_hour') {
        return $posts;
    }
    p2p_type('related_location')->each_connected($query, array(), 'locations');
    return $posts;
}
开发者ID:nickdotreid,项目名称:SFHIV-Wordpress-Models-Plugin,代码行数:8,代码来源:sfhiv_service_hours.php

示例12: add_item

 public function add_item($post_id, $price, $addons = array())
 {
     $p2p_id = p2p_type(APPTHEMES_ORDER_CONNECTION)->connect($this->id, $post_id);
     p2p_add_meta($p2p_id, 'price', $price, true);
     $item = array('price' => $price, 'post' => get_post($post_id), 'addons' => array());
     foreach ($addons as $addon_id => $addon_price) {
         $item['addons'][] = $this->add_addon($p2p_id, $addon_id, $addon_price);
     }
     $this->items[] = $item;
     $this->refresh_total();
 }
开发者ID:ugurbastan,项目名称:swe-574-group4,代码行数:11,代码来源:order-class.php

示例13: setup_example

 function setup_example()
 {
     $ctype = p2p_type('actor_movie');
     $data = array('Nicholas Cage' => array('Lord Of War', 'Adaptation'), 'Jude Law' => array('Sherlock Holmes'), 'Brad Pitt' => array('7 Years In Tibet'), 'Natalie Portam' => array('Black Swan'), 'Charlize Theron' => array());
     foreach ($data as $actor_name => $movies) {
         $actor_id = self::make_post('actor', $actor_name);
         foreach ($movies as $movie_title) {
             $movie_id = self::make_post('movie', $movie_title);
             $ctype->connect($actor_id, $movie_id);
         }
     }
 }
开发者ID:netconstructor,项目名称:wp-posts-to-posts,代码行数:12,代码来源:debug.php

示例14: filter

 function filter($object_type, $post_type)
 {
     foreach ($this->queue as $p2p_type => $args) {
         $ctype = p2p_type($p2p_type);
         $directions = self::determine_directions($ctype, $object_type, $post_type, $args->show);
         $title = self::get_title($directions, $ctype);
         foreach ($directions as $direction) {
             $key = 'to' == $direction ? 'to' : 'from';
             $directed = $ctype->set_direction($direction);
             $this->add_item($directed, $object_type, $post_type, $title[$key]);
         }
     }
 }
开发者ID:Olaw2jr,项目名称:wp-posts-to-posts,代码行数:13,代码来源:factory.php

示例15: setup_example

 /**
  * Set up the example connections.
  *
  * @subcommand setup-example
  */
 function setup_example()
 {
     $ctype = p2p_type('actor_movie');
     $data = array('Nicholas Cage' => array('Lord Of War', 'Adaptation'), 'Jude Law' => array('Sherlock Holmes'), 'Brad Pitt' => array('7 Years In Tibet', 'Fight Club'), 'Natalie Portman' => array('Black Swan', 'Thor'), 'Matt Damon' => array('The Talented Mr. Ripley'), 'Charlize Theron' => array());
     foreach ($data as $actor_name => $movies) {
         $actor = self::titled_post('actor', $actor_name);
         foreach ($movies as $movie_title) {
             $movie = self::titled_post('movie', $movie_title);
             $ctype->connect($actor, $movie);
         }
     }
     WP_CLI::success("Set up the actors and movies example.");
 }
开发者ID:hscale,项目名称:webento,代码行数:18,代码来源:command.php


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