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; }
/** * 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); } } }
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; }
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; }
/** @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); }
/** * 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(); }
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']); }
/** * 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; }
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; }
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; }
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; }
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(); }
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); } } }
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]); } } }
/** * 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."); }
/** @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'); $args = array('before_list' => '<ul id="' . $ctype->name . '_list">', 'echo' => false); if ('ol' == $mode) { _p2p_append($args, array('before_list' => '<ol id="' . $ctype->name . '_list">', 'after_list' => '</ol>')); } return apply_filters("p2p_{$context}_html", $connected->render($args), $connected, $directed); }
private static function expand_ctypes($item, $directions, $object_type, $ctypes) { $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; } return $p2p_types; }
function add_columns() { $screen = get_current_screen(); if ('edit' != $screen->base) { return; } $post_type = $screen->post_type; foreach (self::$column_args as $p2p_type => $column_args) { $ctype = p2p_type($p2p_type); $directed = $ctype->find_direction($post_type); if (!$directed) { continue; } if (!('any' == $column_args || $directed->get_direction() == $column_args)) { continue; } $column = new P2P_Column($directed); $column->styles(); add_filter("manage_{$screen->id}_columns", array($column, 'add_column')); add_action("manage_{$post_type}_posts_custom_column", array($column, 'display_column'), 10, 2); } }
function related_papers() { ob_start(); $connected = new WP_Query(array('connected_type' => 'issue_to_paper', 'connected_items' => get_queried_object(), 'nopaging' => yes, 'post_type' => 'paper')); //get related objects $current = new WP_Query(array('post_type' => 'paper', 'p' => get_the_ID(), 'posts_per_page' => 1)); //echo '<pre>'; var_dump($current); echo '</pre>'; $papers = p2p_type('issue_to_paper')->get_related(get_queried_object()); $result = new WP_Query(); // start putting the contents in the new object $result->posts = array_merge($papers->posts, $current->posts); $result->post_count = count($result->posts); if ($result->have_posts()) { ?> <?php while ($result->have_posts()) { $result->the_post(); ?> <li><a href="<?php the_permalink(); ?> "> <?php if (get_field('short_title')) { the_field('short_title'); } else { the_title(); } ?> </a></li><?php } } wp_reset_postdata(); $contents = ob_get_contents(); ob_end_clean(); return $contents; }
/** * Sets 'p2p_type' => array( connection_type => direction ) * * @return: * null means ignore current query * false means trigger 404 * true means proceed */ static function expand_connected_type(&$q, $item, $object_type) { if (!isset($q['connected_type'])) { return; } $ctypes = (array) _p2p_pluck($q, 'connected_type'); if (isset($q['connected_direction'])) { $directions = (array) _p2p_pluck($q, 'connected_direction'); } else { $directions = array(); } $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 = self::find_direction($ctype, $item, $object_type); } if (!$directed) { continue; } $p2p_types[$p2p_type] = $directed->get_direction(); } if (empty($p2p_types)) { return false; } if (1 == count($p2p_types)) { $q = $directed->get_connected_args($q); } else { $q['p2p_type'] = $p2p_types; } return true; }
function page_content() { $data = array('columns' => array(__('Name', P2P_TEXTDOMAIN), __('Information', P2P_TEXTDOMAIN), __('Connections', P2P_TEXTDOMAIN))); $connection_counts = $this->get_connection_counts(); if (empty($connection_counts)) { $data['has-rows'] = false; $data['no-rows'] = __('No connection types registered.', P2P_TEXTDOMAIN); $data['no-rows2'] = sprintf(__('To register a connection type, see <a href="%s">the wiki</a>.', P2P_TEXTDOMAIN), 'https://github.com/scribu/wp-posts-to-posts/wiki/'); } else { $data['has-rows'] = array(true); foreach ($connection_counts as $p2p_type => $count) { $row = array('p2p_type' => $p2p_type, 'count' => number_format_i18n($count)); $ctype = p2p_type($p2p_type); if ($ctype) { $row['desc'] = $ctype->get_desc(); } else { $row['desc'] = __('Convert to registered connection type:', P2P_TEXTDOMAIN) . scbForms::form_wrap($this->get_dropdown($p2p_type), $this->nonce); $row['class'] = 'error'; } $data['rows'][] = $row; } } echo P2P_Mustache::render('connection-types', $data); }
function rotary_toggleparticipants() { // By default, let's start with an error message $response = array('status' => 'error', 'message' => 'Invalid nonce'); $current_user = wp_get_current_user(); $going = 'no'; // Next, check to see if the nonce is valid if (isset($_GET['nonce']) && wp_verify_nonce($_GET['nonce'], 'rotary-participant-nonce')) { // Update our message / status since our request was successfully processed $response['status'] = 'success'; //toggle value if ('' == $_GET['participate']) { $going = 'yes'; p2p_type('projects_to_users')->connect($_GET['postid'], $current_user->ID, array('date' => current_time('mysql'))); } else { p2p_type('projects_to_users')->disconnect($_GET['postid'], $current_user->ID, array('date' => current_time('mysql'))); } $response['message'] = $going; } // Return our response to the script in JSON format header('Content: application/json'); echo json_encode($response); die; }
/** * Prepares the list of gigs for displaying. * * Modifies the query based on the current view and screen options and * begins setting up columns. * * @since 1.0.0 */ function prepare_items() { global $wp_query; $screen = get_current_screen(); $per_page = get_user_option('toplevel_page_audiotheme_gigs_per_page'); $per_page = empty($per_page) ? 20 : $per_page; // Set up column headers. $columns = $this->get_columns(); $hidden = get_hidden_columns($screen->id); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); // Compile the WP_Query args based on the current view and user options. $args = array('post_type' => 'audiotheme_gig', 'order' => isset($_REQUEST['order']) && 'asc' === strtolower($_REQUEST['order']) ? 'asc' : 'desc', 'post_status' => isset($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'publish,draft', 'posts_per_page' => $per_page); if (empty($_REQUEST['m']) && ('upcoming' === $this->current_view || 'past' === $this->current_view)) { $args['meta_query'][] = array('key' => '_audiotheme_gig_datetime', 'value' => isset($_REQUEST['gig_date']) ? urldecode($_REQUEST['gig_date']) : current_time('mysql'), 'compare' => isset($_REQUEST['compare']) ? urldecode($_REQUEST['compare']) : '>=', 'type' => 'DATETIME'); // Sort upcoming in ascending order by default. $args['order'] = 'upcoming' === $this->current_view && !isset($_REQUEST['order']) ? 'asc' : $args['order']; } elseif (!empty($_REQUEST['m'])) { $m = absint(substr($_REQUEST['m'], 4)); $y = absint(substr($_REQUEST['m'], 0, 4)); $start = sprintf('%s-%s-01 00:00:00', $y, zeroise($m, 2)); $end = sprintf('%s 23:59:59', date('Y-m-t', mktime(0, 0, 0, $m, 1, $y))); $args['meta_query'][] = array('key' => '_audiotheme_gig_datetime', 'value' => array($start, $end), 'compare' => 'BETWEEN', 'type' => 'DATETIME'); $args['order'] = isset($_REQUEST['order']) ? $args['order'] : 'asc'; } if (!empty($_REQUEST['venue'])) { $args['connected_type'] = 'audiotheme_venue_to_gig'; $args['connected_items'] = absint($_REQUEST['venue']); } if (isset($_REQUEST['orderby'])) { switch ($_REQUEST['orderby']) { case 'title': $args['orderby'] = 'title'; break; case 'venue': // Handled after the query is run. break; default: $args['meta_key'] = '_audiotheme_' . $_REQUEST['orderby']; $args['orderby'] = 'meta_value'; break; } } else { $args['meta_key'] = '_audiotheme_gig_datetime'; $args['orderby'] = 'meta_value'; } if (isset($_REQUEST['s'])) { $args['s'] = $_REQUEST['s']; } $args['paged'] = $this->get_pagenum(); // Run the query and fetch the connected venues. $items = array(); $wp_query = new WP_Query($args); p2p_type('audiotheme_venue_to_gig')->each_connected($wp_query); if (isset($wp_query->posts) && count($wp_query->posts)) { foreach ($wp_query->posts as $post) { $items[$post->ID] = get_audiotheme_gig($post->ID); } // Sort by venue. if (!empty($_GET['orderby']) && 'venue' === $_GET['orderby']) { $items = audiotheme_sort_objects($items, array('venue', 'name'), $args['order'], true, 'gig_datetime'); } } $this->items = $items; $this->set_pagination_args(array('total_items' => $wp_query->found_posts, 'per_page' => $per_page, 'total_pages' => $wp_query->max_num_pages)); }
/** * After import has run, go back and connect all the posts. */ public function wp_parser_ending_import() { if (defined('WP_CLI') && WP_CLI) { WP_CLI::log('Removing current relationships...'); } p2p_delete_connections('functions_to_functions'); p2p_delete_connections('functions_to_methods'); p2p_delete_connections('functions_to_hooks'); p2p_delete_connections('methods_to_functions'); p2p_delete_connections('methods_to_methods'); p2p_delete_connections('methods_to_hooks'); if (defined('WP_CLI') && WP_CLI) { WP_CLI::log('Setting up relationships...'); } // Iterate over post types being related FROM: functions, methods, and hooks foreach ($this->post_types as $from_type) { // Iterate over relationships for each post type foreach ((array) @$this->relationships[$from_type] as $from_id => $to_types) { // Iterate over slugs for each post type being related TO foreach ($to_types as $to_type => $to_slugs) { // Convert slugs to IDs. if (empty($this->slugs_to_ids[$to_type])) { // TODO why might this be empty? test class-IXR.php continue; } $this->relationships[$from_type][$from_id][$to_type] = $this->get_ids_for_slugs($to_slugs, $this->slugs_to_ids[$to_type]); } } } // Repeat loop over post_types and relationships now that all slugs have been mapped to IDs foreach ($this->post_types as $from_type) { foreach ((array) @$this->relationships[$from_type] as $from_id => $to_types) { // Connect Functions if ($from_type == $this->post_types['function']) { foreach ($to_types as $to_type => $to_slugs) { // ...to Functions if ($this->post_types['function'] == $to_type) { foreach ($to_slugs as $to_slug => $to_id) { $to_id = intval($to_id, 10); if (0 != $to_id) { p2p_type('functions_to_functions')->connect($from_id, $to_id, array('date' => current_time('mysql'))); } } } // ...to Methods if ($this->post_types['method'] == $to_type) { foreach ($to_slugs as $to_slug => $to_id) { $to_id = intval($to_id, 10); if (0 != $to_id) { p2p_type('functions_to_methods')->connect($from_id, $to_id, array('date' => current_time('mysql'))); } } } // ...to Hooks if ($this->post_types['hook'] == $to_type) { foreach ($to_slugs as $to_slug => $to_id) { $to_id = intval($to_id, 10); if (0 != $to_id) { p2p_type('functions_to_hooks')->connect($from_id, $to_id, array('date' => current_time('mysql'))); } } } } } // Connect Methods if ($from_type === $this->post_types['method']) { foreach ($to_types as $to_type => $to_slugs) { // ...to Functions if ($this->post_types['function'] === $to_type) { foreach ($to_slugs as $to_slug => $to_id) { $to_id = intval($to_id, 10); if (0 != $to_id) { p2p_type('methods_to_functions')->connect($from_id, $to_id, array('data' => current_time('mysql'))); } } } // ...to Methods if ($this->post_types['method'] === $to_type) { foreach ($to_slugs as $to_slug => $to_id) { $to_id = intval($to_id, 10); if (0 != $to_id) { p2p_type('methods_to_methods')->connect($from_id, $to_id, array('data' => current_time('mysql'))); } } } // ...to Hooks if ($this->post_types['hook'] === $to_type) { foreach ($to_slugs as $to_slug => $to_id) { $to_id = intval($to_id, 10); if (0 != $to_id) { p2p_type('methods_to_hooks')->connect($from_id, $to_id, array('data' => current_time('mysql'))); } } } } } } } }
<h3 class="mtop40">We're here to help. <span>1.800.759.2248</span></h3> <?php } else { ?> <h3>We're here to help. <span>1.800.759.2248</span></h3> <?php } ?> </div> <nav id="main-nav"> <?php // Load the appropriate "Mega Menu" for each of the three main States and the FAQs if (is_singular('faq')) { // Check posts2posts to see if this post is connected $p2p_florida = p2p_type('state_to_faq')->get_p2p_id($post->ID, incnow_get_state('FL')); $p2p_nevada = p2p_type('state_to_faq')->get_p2p_id($post->ID, incnow_get_state('NV')); // Florida if ($p2p_florida) { //get_template_part( 'partials/menu-header', 'florida' ); wp_nav_menu(array('container' => 'false', 'menu' => 'header-main-florida')); // Nevada } elseif ($p2p_nevada) { //get_template_part( 'partials/menu-header', 'florida' ); wp_nav_menu(array('container' => 'false', 'menu' => 'header-main-nevada')); // Delaware / Catchall } else { wp_nav_menu(array('container' => 'false', 'menu' => 'header-main-delaware')); } } else { if (is_page('states')) { // if it's our new states page we don't want the extra navigation
<?php get_header(); the_post(); ?> <div class="row"> <?php get_sidebar('conferences'); ?> <div class="content"> <?php get_template_part('page', 'article'); ?> <?php $talks = p2p_type('talk_to_schedule')->get_connected(get_the_id()); ?> <?php p2p_list_posts($talks, array('template' => 'single-talk-embed.php', 'before_list' => '', 'after_list' => '', 'before_item' => '', 'after_item' => '')); ?> </div> </div> <?php get_footer();
/** * Get a sensible title for the current item (usually the arguments array for a column) * * @param array $item An array of arguments * @return string The item title */ protected function get_item_title(array $item) { if (isset($item['taxonomy'])) { if ($tax = get_taxonomy($item['taxonomy'])) { if (!empty($tax->exclusive)) { return $tax->labels->singular_name; } else { return $tax->labels->name; } } else { return $item['taxonomy']; } } else { if (isset($item['post_field'])) { return ucwords(trim(str_replace(array('post_', '_'), ' ', $item['post_field']))); } else { if (isset($item['meta_key'])) { return ucwords(trim(str_replace(array('_', '-'), ' ', $item['meta_key']))); } else { if (isset($item['connection']) and isset($item['value'])) { return ucwords(trim(str_replace(array('_', '-'), ' ', $item['value']))); } else { if (isset($item['connection'])) { if (function_exists('p2p_type') and p2p_connection_exists($item['connection'])) { $ctype = p2p_type($item['connection']); $other = 'from' == $ctype->direction_from_types('post', $this->cpt->post_type) ? 'to' : 'from'; return $ctype->side[$other]->get_title(); } else { return $item['connection']; } } } } } } }
?> ">Översättning</a> <i class="fa fa-angle-right"></i> <a href="<?php echo esc_url(home_url('/oversattningsvaliderare/')); ?> ">Översättningsvaliderare</a> <i class="fa fa-angle-right"></i> <?php printf(__('Sökresultat för "%s"', 'wpsvse'), '<span>' . get_search_query() . '</span>'); ?> </p> <?php if ($wp_query->have_posts()) { ?> <?php // Find connected pages (for all posts) p2p_type('translator_to_projects')->each_connected($wp_query); ?> <?php while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php get_template_part('content', 'translators'); ?> <?php } ?>
static function connect_posts($type, $from_id, $to_id, $data = array()) { p2p_type($type)->connect($from_id, $to_id, $data); }
get_header(); ?> <div id="post-<?php the_ID(); ?> " <?php post_class(); ?> > <div class="site-content container pt pb clearfix"> <article id="primary-wrapper" class="column eight"> <?php global $wp_query; p2p_type('players_to_teams')->each_connected($wp_query, array('order' => 'ASC'), 'teams'); ?> <?php if (have_posts()) { the_post(); ?> <?php $teams = $post->teams; $player_name = get_the_title(); ?> <div class="inner"> <div class="post-blog">