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


PHP BaseController::exchange_factory方法代码示例

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


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

示例1: exchange_story_form_populate_storyteller_step_1

function exchange_story_form_populate_storyteller_step_1($form)
{
    /* Retrieve story form ID from options and verify */
    $story_form_id = get_option('options_story_update_form');
    if ($story_form_id && $form['id'] !== intval($story_form_id)) {
        return $form;
    }
    // Verify programme round token with collaboration id to ensure that we're only returning storytellers to people who came in with a programme_round token.
    $collaboration_id = get_query_var('update_id', false);
    $pr_reference = get_query_var('pr_ref', false);
    if (!$collaboration_id || !$pr_reference) {
        return $form;
    }
    $collaboration_obj = BaseController::exchange_factory($collaboration_id);
    if (!$collaboration_obj instanceof Collaboration) {
        return $form;
    }
    $programme_round_obj = $collaboration_obj->programme_round;
    if (!$programme_round_obj) {
        return $form;
    }
    $pr_token_from_cid = $programme_round_obj->controller->get_programme_round_token();
    if (empty($collaboration_obj->participants || $pr_token_from_cid !== $pr_reference)) {
        return $form;
    }
    foreach ($form['fields'] as $field) {
        $class = $field->cssClass;
        switch ($class) {
            case 'storyteller-select-step-1':
                $choices = array(array('text' => 'Form submitted via programme round token', 'value' => 'Form submitted via programme round token', 'isSelected' => true));
                $field['choices'] = $choices;
                break;
            case 'storyteller-select-step-2':
                $choices = array(array('text' => 'Select your name below', 'value' => 0, 'isSelected' => true));
                foreach ($collaboration_obj->participants as $participant) {
                    $choices[] = array('text' => $participant->name, 'value' => $participant->post_id, 'isSelected' => false);
                }
                $field['choices'] = $choices;
                break;
            default:
                break;
        }
    }
    return $form;
}
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:45,代码来源:admin-gravity.php

示例2: exchange_create_link

/**
 * Create link (or simply an opening tag)
 *
 * @param $object mixed Exchange object, term or ID
 * @param bool @with_text Optional. Add object title as link text, or simply open tag.
 * @return string Anchor tag with appropriate attributes and / or title.
 */
function exchange_create_link($obj, $with_text = true, $class = '')
{
    // Turn post_id into object
    if (is_numeric($obj) && exchange_post_exists($obj)) {
        $obj = BaseController::exchange_factory($obj);
    }
    if ($obj instanceof Exchange) {
        $url = $obj->link;
        $title = $obj->title;
        $label = $obj->title;
        $cat = 'story';
    } elseif ($obj instanceof WP_Term) {
        $url = get_term_link($obj);
        $title = $obj->name;
        $label = $obj->name;
    }
    $button_classes = array('griditem__button button--small');
    if (in_array($class, $button_classes, true)) {
        if (empty($obj->category)) {
            $label = strtoupper(__('Read more', 'exchange'));
        } else {
            $cat = $obj->category->slug;
            $labels = $GLOBALS['EXCHANGE_PLUGIN_CONFIG']['CATEGORIES']['button_labels'];
            if (array_key_exists($cat, $labels)) {
                $label = strtoupper(sprintf($labels[$cat], $cat));
            } else {
                $label = strtoupper(sprintf($labels['default'], $cat));
            }
            $class .= ' button--' . $cat;
        }
    }
    if (!empty($url) && !empty($title)) {
        $output = '<a class="' . $class . '" href="' . $url . '" title="' . sprintf(esc_html__('Navigate to %s', EXCHANGE_PLUGIN), esc_attr($title)) . '">';
        if ($with_text) {
            $output .= $label . '</a>';
        }
        return $output;
    } else {
        return false;
    }
}
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:48,代码来源:public.php

示例3: exchange_token_form_callback

function exchange_token_form_callback()
{
    $results = '';
    if (empty(check_ajax_referer('exchange-token-form-nonce', 'security', false))) {
        echo '<div class="loader-pointer section__helper">' . __('Whoa... where did YOU come from?', EXCHANGE_PLUGIN) . '</div>';
        wp_die();
    }
    if (!empty($_POST['prid']) && !empty($_POST['update_id']) && !empty($_POST['token'])) {
        $pr_obj = BaseController::exchange_factory($_POST['prid'], 'token-form');
        $pr_token = $_POST['token'];
        $c_obj = BaseController::exchange_factory($_POST['update_id'], 'token-form');
        $story_page = get_option('options_story_update_form_page');
        $s_obj = get_post($story_page);
        if (!$pr_obj instanceof Programme_Round) {
            echo '<div class="loader-pointer section__helper">' . __('We could not find the right data. Are you sure you have the right link?') . '</div>';
            wp_die();
        }
        // Create array for griditems.
        $simplegrid = new SimpleGrid();
        if ($s_obj instanceof WP_Post) {
            $simplegrid->add_grid_item($pr_obj->create_token_form_cta($s_obj, $pr_token, $c_obj));
        }
        if ($c_obj instanceof Collaboration) {
            $simplegrid->add_grid_item($pr_obj->create_token_form_cta($c_obj, $pr_token));
        }
        if (!empty($c_obj->participants)) {
            foreach ($c_obj->participants as $p) {
                $simplegrid->add_grid_item($pr_obj->create_token_form_cta($p, $pr_token));
            }
        }
        // echo '<pre>' . print_r( $simplegrid, true ) . '</pre>';
        // wp_die();
        echo $simplegrid->embed();
        wp_die();
    } else {
        echo '<div class="loader-pointer section__helper">' . __('We did not receive the request correctly. Make sure you\'ve selected your collaboration and try again!') . '</div>';
        wp_die();
    }
}
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:39,代码来源:tokens.php

示例4: exchange_add_update_form_link

function exchange_add_update_form_link($post_id, $post_obj)
{
    $type = $post_obj->post_type;
    if (!in_array($type, $GLOBALS['EXCHANGE_PLUGIN_CONFIG']['POST_TYPES']['available-for-form-updates'])) {
        return;
    }
    $update = false;
    // Gather token / form info for token verification.
    $form_id = get_option('options_' . $type . '_update_form');
    $form_link = get_field($type . '_update_form_link', $post_id);
    $field = $GLOBALS['EXCHANGE_PLUGIN_CONFIG']['ACF']['fields'][$type . '-update-link'];
    if ('participant' === $type) {
        $coll = CollaborationController::get_collaboration_by_participant_id($post_id);
    } elseif ('collaboration' === $type) {
        $coll = BaseController::exchange_factory($post_id);
    }
    if (!$coll instanceof Collaboration) {
        return;
    }
    if ($coll->programme_round instanceof Programme_Round) {
        $pr_token = $coll->programme_round->controller->get_programme_round_token();
    }
    if (!isset($pr_token)) {
        return;
    }
    // See if anything needs to be changed.
    $form_token = sha1($pr_token . $form_id . $post_id);
    if (!empty($form_link)) {
        $parts = parse_url($form_link);
        parse_str($parts['query'], $query);
        if ($query['update_token'] !== $form_token || $query['update_id'] !== $post_id) {
            $update = true;
        } else {
            return;
        }
    }
    // Update or save the link to the post.
    $update_page_id = get_option('options_' . $type . '_update_form_page');
    $update_page_url = get_permalink($update_page_id);
    $link = $update_page_url . '?update_token=' . $form_token . '&update_id=' . $post_id;
    if ($update) {
        update_post_meta($post_id, $type . '_update_form_link', $link);
    } else {
        update_field($field, $link, $post_id);
    }
}
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:46,代码来源:admin-acf.php

示例5: map_full_story

 /**
  * Return story object with properties taken from ACF Fields.
  *
  * @since 0.1.0
  * @access public
  * @return void;
  **/
 public function map_full_story()
 {
     // Retrieve post_id variable from basic mapping.
     $post_id = $this->container->post_id;
     // Set language global to language category
     if (isset($this->container->language)) {
         $GLOBALS['story_language'] = $this->container->language->name;
     }
     // // Throw Exception when the input is not a valid story post type object.
     // if ( ! ( $post_id >= 1 ) ) {
     // 	unset( $this->container );
     // 	throw new Exception( 'This is not a valid post' );
     // }
     // Get related
     $curation = get_post_meta($post_id, 'related_content_auto_select', true);
     if (!$curation) {
         $related_content = $this->get_related_grid_content_by_tags();
     } else {
         $related_content = get_post_meta($post_id, 'related_content', true);
     }
     if (is_array($related_content) && count($related_content) > 0) {
         $this->set_related_grid_content($related_content);
     }
     //Set sections.
     if (function_exists('get_field')) {
         $acf_sections = get_field('sections', $post_id);
         if (!empty($acf_sections)) {
             $this->set_sections($acf_sections);
         }
     }
     // $acf_section_count = get_post_meta( $post_id, 'sections', true );
     // var_dump( $acf_section_count );
     // if ( ! empty( $acf_section_count ) ) {
     // 	$post_custom = get_post_custom( $post_id );
     // 	var_dump( $post_custom );
     // }
     // for ( $i = 0; $i < $acf_section_count; $i++ ) {
     // 	$acf_section_contents = get_post_meta( $post_id, 'sections_' . $i . '_contents', true );
     // 	var_dump( $acf_section_contents );
     // 	if ( empty( $acf_section_contents ) || ! is_array( $acf_section_contents ) ) {
     // 		continue;
     // 	}
     // 	$contents_length = count( $acf_section_contents );
     // 	for( $j = 0; $j < $contents_length; $j++ ) {
     // 		switch( $acf_section_contents[ $j ] ) {
     // 			case 'has_story_elements' :
     // 				$meta_name = 'sections_' . $i . '_contents_' . $j . '_story_elements';
     // 				$acf_story_elements = get_post_meta( $post_id, $meta_name, true );
     // 				var_dump( $meta_name );
     // 				var_dump( $acf_story_elements );
     // 				break;
     // 			default :
     // 				var_dump( $acf_sections_items[ $j ] );
     // 				break;
     // 		}
     // 	}
     // }
     // throw new Exception("Testing {1:What are we testing?}");
     // Set header image.
     $this->set_header_image('story__header');
     // Set participant as storyteller
     $acf_storyteller = get_post_meta($post_id, 'storyteller', true);
     if (is_numeric($acf_storyteller)) {
         $storyteller = BaseController::exchange_factory($acf_storyteller);
         if ($storyteller instanceof Participant) {
             $this->container->storyteller = $storyteller;
         }
     }
     if (!empty($this->container->storyteller)) {
         $this->set_byline();
     } else {
         $this->set_custom_byline();
     }
     $this->set_gallery();
 }
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:82,代码来源:class-controller-story.php

示例6: _e

<h4 class="share-cta-header share-cta-story"><?php 
_e('Do you have a Tandem story you would like to share?', 'exchange');
?>
</h4>

<div class="button-wrapper">
<?php 
$story_form_page = get_option('options_story_update_form_page');
if (!empty($story_form_page)) {
    $exchange_form = BaseController::exchange_factory($story_form_page);
    if ($exchange_form instanceof Exchange) {
        echo exchange_create_link($exchange_form, false, 'button--large button--share-cta') . __('Share your story', 'exchange') . '</a>';
    }
}
?>
</div><!-- button-wrapper -->
开发者ID:retrorism,项目名称:exchange,代码行数:16,代码来源:content-story-share-cta.php

示例7: process_token

 /**
  * Process an update token to return a gravity form
  *
  * @param int $form_id Gravity Forms ID to check against
  * @return return $form_id
  *
  * @TODO add available post types to globals
  */
 private function process_token($form_id)
 {
     parse_str($_SERVER['QUERY_STRING']);
     $form_id_arr = $this->update_form_ids();
     if (empty($form_id)) {
         return;
     }
     if (!in_array(strval($form_id), $form_id_arr, true)) {
         return;
     }
     if (isset($update_id) && isset($update_token) && is_numeric($update_id) && in_array(get_post_type($update_id), $GLOBALS['EXCHANGE_PLUGIN_CONFIG']['POST_TYPES']['available-for-form-updates'], true)) {
         $exchange = BaseController::exchange_factory($update_id);
     }
     if (!$exchange instanceof Exchange) {
         return;
     }
     switch ($exchange->type) {
         case 'collaboration':
             $programme_round_obj = $exchange->programme_round;
             break;
         case 'participant':
             $exchange->controller->set_collaboration();
             if (is_object($exchange->collaboration)) {
                 $programme_round_obj = $exchange->collaboration->programme_round;
             }
             break;
         default:
             return;
     }
     if (!$programme_round_obj instanceof Programme_Round) {
         return;
     } else {
         $pr_update_token = $programme_round_obj->controller->get_programme_round_token();
     }
     if ($pr_update_token) {
         $verifications = array();
         foreach ($form_id_arr as $id) {
             /* The update tokens are generated by hashing the programme round token with the form id and post id */
             $verifications[] = sha1($pr_update_token . $id . $update_id);
         }
         if (in_array($update_token, $verifications)) {
             $update_string = ' update="' . $update_id . '" ';
             return $update_string;
         }
     }
 }
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:54,代码来源:class-section.php

示例8: get_header

<?php

get_header();
?>

<main id="main" class="archive__wrapper" role="main">

	<div class="main-inner">

		<?php 
$args = array('name' => 'stories', 'post_type' => 'page', 'post_status' => 'private', 'numberposts' => 1);
$get_stories_page = get_posts($args);
if ($get_stories_page) {
    $exchange = BaseController::exchange_factory($get_stories_page[0]);
    include_once get_stylesheet_directory() . '/parts/content-page-header.php';
    include_once get_stylesheet_directory() . '/parts/loop-featured-stories.php';
    ?>

		<?php 
} else {
    ?>

			<?php 
    get_template_part('parts/content', 'archive-header');
    ?>

		<?php 
}
?>

		<?php 
开发者ID:retrorism,项目名称:exchange,代码行数:31,代码来源:archive-story.php

示例9: create_grid_item_from_layout

 /**
  * Create grid item from ACF Layout
  *
  * Creates grid item with post_item data, add modifiers when necessary.
  *
  * @param integer $item Post object to be represented by grid item.
  */
 protected function create_grid_item_from_layout($item)
 {
     if (!isset($item['acf_fc_layout'])) {
         return;
     }
     $item_mods = array();
     $layout = $item['acf_fc_layout'];
     switch ($layout) {
         case 'grid_exchange_story':
         case 'grid_exchange_collaboration':
         case 'grid_exchange_programme_round':
             if (!is_numeric($item['grid_exchange_object'])) {
                 if (is_array($item['grid_exchange_object']) && is_int($item['grid_exchange_object'][0])) {
                     $object_id = $item['grid_exchange_object'][0];
                 } else {
                     return;
                 }
             } else {
                 $object_id = intval($item['grid_exchange_object']);
             }
             if (empty($object_id)) {
                 return;
             }
             $object = BaseController::exchange_factory($object_id, 'griditem');
             $item_mods = self::add_grid_modifiers($object);
             break;
         case 'grid_paragraph':
             if ('grid_paragraph' === $layout && empty($item['text'])) {
                 return;
             }
         case 'grid_pull_quote':
             if ('grid_pull_quote' === $layout && empty($item['pquote_text'])) {
                 return;
             }
         case 'grid_image':
             if ('grid_image' === $layout && empty($item['image'])) {
                 return;
             }
             $pattern_type = str_replace('grid_', '', $layout);
             $object = BasePattern::pattern_factory($item, $pattern_type, 'griditem', true);
             $item_mods['type'] = 'pattern';
             $item_mods['pattern_type'] = $pattern_type;
             break;
         default:
             return;
     }
     if (!empty($item['grid_width'])) {
         $item_mods['grid_width'] = $item['grid_width'];
         $num = $this->get_grid_width_num($item['grid_width']);
         if (isset($num) & is_int($num)) {
             $item_mods['grid_width_num'] = $num;
         }
     }
     $grid_item = new GridItem($object, $this->element, $item_mods);
     return $grid_item;
 }
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:63,代码来源:class-grid-base.php

示例10: get_header

get_header();
?>

<main id="main" class="archive__wrapper  " role="main">

	<div class="main-inner">

		<?php 
$args = array('name' => 'collaborations', 'post_type' => 'page', 'post_status' => 'private', 'numberposts' => 1);
$get_collaborations_page = get_posts($args);
if ($get_collaborations_page) {
    ?>

			<?php 
    $exchange = BaseController::exchange_factory($get_collaborations_page[0]);
    include_once get_stylesheet_directory() . '/parts/content-page-header.php';
    ?>

		<?php 
} else {
    ?>

			<?php 
    get_template_part('parts/content', 'archive-header');
    ?>

		<?php 
}
?>
开发者ID:retrorism,项目名称:exchange,代码行数:29,代码来源:archive-collaboration.php

示例11: _e

if (empty($pr)) {
    ?>

					<div class="callout"><?php 
    _e('There seems to be a problem with your token. Please get in touch with the Tandem Team', EXCHANGE_PLUGIN);
    ?>
</div>

				</div>

			<?php 
} else {
    ?>

				<?php 
    $exchange_pr_obj = BaseController::exchange_factory($pr);
    if (!$exchange_pr_obj instanceof Programme_Round) {
        ?>

					<div class="callout"><?php 
        _e('There seems to be a problem with your token. Please get in touch with the Tandem Team.', EXCHANGE_PLUGIN);
        ?>
</div>

				</div>

				<?php 
    } else {
        ?>

					<p><?php 
开发者ID:retrorism,项目名称:exchange,代码行数:31,代码来源:content-token-form.php

示例12: exchange_location_tags_by_participants

function exchange_location_tags_by_participants()
{
    $result = array();
    $collab_args = array('post_type' => 'collaboration', 'posts_per_page' => -1, 'post_status' => 'draft');
    $query = new WP_Query($collab_args);
    $collabs = $query->posts;
    if (!empty($collabs)) {
        foreach ($collabs as $collab) {
            $cid = get_field('collaboration_id', $collab->ID);
            $locations = array();
            $arr = array();
            $exchange = BaseController::exchange_factory($collab);
            foreach ($exchange->participants as $p) {
                if (!empty($p->org_city)) {
                    $locations[] = $p->org_city;
                    var_dump($p->org_city);
                }
            }
            if (!empty($locations)) {
                $arr['location'] = $locations;
                add_term_to_cid($cid, $arr);
            }
        }
    }
}
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:25,代码来源:import_projects.php

示例13: get_template_directory

<section class="story__section">
	<div class="section-inner">
		<figure class="section__slice section__image">
			<div id="programmes">
			<?php 
$img_root = get_template_directory() . '/assets/images/';
global $post;
$all_pages = BaseController::get_all_from_type('page');
$programmes = get_page_children($post->ID, $all_pages);
foreach ($programmes as $page_obj) {
    $anchor = '<a href="#">';
    if (!$page_obj instanceof WP_Post || 'publish' !== $page_obj->post_status) {
        continue;
    } else {
        $anchor = exchange_create_link(BaseController::exchange_factory($page_obj), false);
        $slug = array_search($page_obj->post_title, $GLOBALS['EXCHANGE_PLUGIN_CONFIG']['IMAGES']['programme-logos']);
        if (!empty($slug)) {
            echo $anchor . exchange_build_svg($img_root . 'svg/T_logo_' . $slug . '_WEB.svg', true) . '</a>';
        }
    }
}
?>
			</div>
			<?php 
if (class_exists('Caption')) {
    $caption_text = '<p>Building it together. Illustration copyright &copy; Erica Brisson, 2014-15</p>';
    $modifiers = array('classes' => array('text-right'));
    $caption = new Caption($caption_text, 'image');
    $caption->publish();
}
?>
开发者ID:retrorism,项目名称:exchange,代码行数:31,代码来源:content-page-programmes.php

示例14: esc_attr

		<div class="featured-stories featured-stories<?php 
    echo esc_attr($three_plus);
    ?>
">

			<section class="section--has-grid section--featured-grid">

				<div class="section-inner">

					<div class="row" data-equalizer>

					<?php 
    $length = count($featured_stories);
    for ($i = 0; $i < $length; $i++) {
        $griditem = BaseController::exchange_factory($featured_stories[$i], 'griditem');
        if (0 === $i && 2 !== $length) {
            $modifiers = array('grid_width' => 'grid_full', 'grid_width_num' => 12);
        } else {
            if (3 === $length) {
                $modifiers = array('grid_width' => 'grid_half', 'grid_width_num' => 6);
            } elseif (4 === $length) {
                $modifiers = array('grid_width' => 'grid_third', 'grid_width_num' => 4);
            } elseif (2 === $length) {
                $modifiers = array('grid_width' => 'grid_half', 'grid_width_num' => 6);
            }
        }
        if (1 === $i && 2 < $length) {
            echo '</div><!-- end row --><div class="row" data-equalizer>';
        }
        Exchange::publish_grid_featured($griditem, 'featuredgrid', $modifiers);
开发者ID:retrorism,项目名称:exchange,代码行数:30,代码来源:loop-featured-stories.php

示例15: prepare_map_marker

 /**
  * Prepare map marker.
  * @param array $marker_location Array with lat and long
  * @return string array $marker_label Array with title and possibly page ID as link.
  */
 protected function prepare_map_marker($marker_location, $marker_label)
 {
     $marker = array('message' => $marker_label['title'], 'lat' => $marker_location['lat'], 'lng' => $marker_location['lng']);
     if (!empty($marker_label['linked_object'])) {
         // Create link from object
         $object = BaseController::exchange_factory($marker_label['linked_object']);
         $link = exchange_create_link($object, false);
     }
     if (isset($link)) {
         $marker['message'] = $link . $marker_label['title'] . '</a>';
     }
     return $marker;
 }
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:18,代码来源:class-map-base.php


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