本文整理汇总了PHP中wpv_do_shortcode函数的典型用法代码示例。如果您正苦于以下问题:PHP wpv_do_shortcode函数的具体用法?PHP wpv_do_shortcode怎么用?PHP wpv_do_shortcode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpv_do_shortcode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpv_shortcode_wpv_if
/**
* Views-Shortcode: wpv-if
*
* Description: Conditional shortcode to be used to display a specific area
* based on a custom field condition. \n
* Supported actions and symbols:\n
* Integer and floating-point numbers \n
* Math operators: +, -, *, / \n
* Comparison operators: <, >, =, <=, >=, != \n
* Boolean operators: AND, OR, NOT \n
* Nested expressions - several levels of parentheses \n
* Variables defined as shortcode parameters starting with a dollar sign \n
* empty() function that checks for empty or non-existing fields
*
* Parameters:
* 'condition' => Define expected result from evaluate - either true or false
* 'evaluate' => Evaluate expression with fields involved, sample use: "($field1 > $field2) AND !empty($field3)"
* 'debug' => Enable debug to display error messages in the shortcode
* 'fieldX' => Define fields to be taken into account during evaluation
*
* Example usage:
* [wpv-if evaluate="boolean condition"]
* Execute code for true
* [/wpv-if]
* Sing a variable and comparing its value to a constant
* [wpv-if f1="wpcf-condnum1" evaluate="$f1 = 1" debug="true"]Number1=1[/wpv-if]
* Two numeric variables in a mathematical expression with boolean operators
* [wpv-if f1="wpcf-condnum1" f2="wpcf-condnum2" evaluate="(2 < 3 AND (((3+$f2)/2) > 3 OR NOT($f1 > 3)))" debug="true"]Visible block[/wpv-if]
* Compare custom field with a value
* [wpv-if f1="wpcf-condstr1" evaluate="$f1 = 'My text'" debug="true"]Text1='My text' [/wpv-if]
* Display condition if evaluates to false (use instead of else-if)
* [wpv-if condition="false" evaluate="2 > 3"] 2 > 3 [/wpv-if]
* Custom function support
* [wpv-if evaluate="my_func() = '1'"]my_func returns 1[/wpv-if]
*
* Link:
* <a href="http://wp-types.com/documentation/user-guides/conditional-html-output-in-views/?utm_source=viewsplugin&utm_campaign=views&utm_medium=views-conditional-help-link&utm_term=Conditional HTML output in Views">Conditional HTML output in Views</a>
*
* Note:
*
*/
function wpv_shortcode_wpv_if($args, $content)
{
$result = wpv_condition($args);
extract(shortcode_atts(array('evaluate' => FALSE, 'debug' => FALSE, 'condition' => TRUE), $args));
$condition = $condition == 'true' || $condition === TRUE ? true : false;
// show the view area if condition corresponds to the evaluate returned result 1=1 or 0=0
if ($result === true && $condition || $result === false && !$condition) {
$out = wpv_do_shortcode($content);
apply_filters('wpv_shortcode_debug', 'wpv-if', json_encode($args), '', 'Conditional output: evaluated to true', $out);
return $out;
} else {
// output empty string or the error message if debug is true
// empty for different condition and evaluate result
if ($result === false && $condition || $result === true && !$condition) {
apply_filters('wpv_shortcode_debug', 'wpv-if', json_encode($args), '', 'Conditional output: evaluated to false');
return '';
} else {
if ($debug) {
return $result;
} else {
return '';
}
apply_filters('wpv_shortcode_debug', 'wpv-if', json_encode($args), '', 'Conditional output: error', $result);
}
}
}
开发者ID:supahseppe,项目名称:path-of-gaming,代码行数:67,代码来源:wpv-condition.php
示例2: wpv_filter_meta_html
function wpv_filter_meta_html($atts)
{
extract(shortcode_atts(array(), $atts));
global $WP_Views;
$view_settings = $WP_Views->get_view_settings();
if (isset($view_settings['filter_meta_html'])) {
return wpv_do_shortcode($view_settings['filter_meta_html']);
} else {
return '';
}
}
开发者ID:davilode83,项目名称:occupysandy.net,代码行数:11,代码来源:wpv-filter-meta-html-embedded.php
示例3: wpv_filter_meta_html
function wpv_filter_meta_html($atts)
{
extract(shortcode_atts(array(), $atts));
global $WP_Views;
$view_settings = $WP_Views->get_view_settings();
if (isset($view_settings['filter_meta_html'])) {
$content = wpml_content_fix_links_to_translated_content($view_settings['filter_meta_html']);
return wpv_do_shortcode($content);
} else {
return '';
}
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:12,代码来源:wpv-filter-meta-html-embedded.php
示例4: wpv_for_each_shortcode
function wpv_for_each_shortcode($atts, $value)
{
extract(shortcode_atts(array('field' => ''), $atts));
if ($field == '') {
return wpv_do_shortcode($value);
}
$out = '';
global $post, $wpv_for_each_index;
if (!empty($post)) {
$meta = get_post_meta($post->ID, $field);
if (!$meta) {
return $value;
}
// iterate through the items and set the for-each index
$wpv_for_each_index[] = 0;
for ($i = 0; $i < count($meta); $i++) {
// set the for-each index and output
$wpv_for_each_index[count($wpv_for_each_index) - 1] = $i;
$out .= wpv_do_shortcode($value);
}
array_pop($wpv_for_each_index);
}
return $out;
}
开发者ID:davilode83,项目名称:occupysandy.net,代码行数:24,代码来源:wpv-shortcodes.php
示例5: wpv_shortcode_wpv_filter_controls
function wpv_shortcode_wpv_filter_controls($atts, $value)
{
/**
*
* This is a do nothing shortcode. It's just a place holder for putting the
* wpv-control shortcodes and allows for easier editing inside the meta HTML
*
* This shortcode now has a function: when hide="true"
* it does not display the wpv-control shortcodes
* This is usefull if you need to show pagination controls but not filter controls
* For View Forms, this hide parameter is overriden and controls are always shown
*/
$value = str_replace("<!-- ADD USER CONTROLS HERE -->", '', $value);
if (isset($atts['hide']) && $atts['hide'] == 'true') {
return '';
} else {
return wpv_do_shortcode($value);
}
}
开发者ID:javierdlahoz,项目名称:paella-development,代码行数:19,代码来源:wpv-filter-embedded.php
示例6: render_view
//.........这里部分代码省略.........
}
global $WPV_settings;
if (isset($WPV_settings->wpv_debug_mode) && !empty($WPV_settings->wpv_debug_mode)) {
$WPVDebug->add_log('items_count', count($items));
}
// The actual loop - render all items
$loop = '';
for ($i = 0; $i < count($items); $i++) {
$WPVDebug->set_index();
$index = $i;
if (isset($args['wrap'])) {
$index %= $args['wrap'];
}
// [wpv-item index=xx] uses base 1
$index++;
$index = strval($index);
if ($view_settings['query_type'][0] == 'posts') {
$post = clone $items[$i];
$authordata = new WP_User($post->post_author);
$id = $post->ID;
$temp_variables = $this->variables;
$this->variables = array();
do_action('wpv-before-display-post', $post, $view_id);
} elseif ($view_settings['query_type'][0] == 'taxonomy') {
$this->taxonomy_data['term'] = $items[$i];
do_action('wpv-before-display-taxonomy', $items[$i], $view_id);
} elseif ($view_settings['query_type'][0] == 'users') {
$user_id = $items[$i]->ID;
$user_meta = get_user_meta($user_id);
$items[$i]->meta = $user_meta;
$this->users_data['term'] = $items[$i];
do_action('wpv-before-display-user', $items[$i], $view_id);
}
$WPVDebug->add_log($view_settings['query_type'][0], $items[$i]);
// first output the "all" index.
$shortcodes_output = wpv_do_shortcode($item_indexes['all']);
$loop .= $shortcodes_output;
$WPVDebug->add_log_item('shortcodes', $item_indexes['all']);
$WPVDebug->add_log_item('output', $shortcodes_output);
/* Select a template for this item based on it's index.
* Note: It is possible that we won't be rendering this item's content if the index 'other'
* isn't set and there is no other match. */
$selected_index = null;
if (isset($item_indexes[$index])) {
$selected_index = $index;
} elseif (isset($item_indexes['odd']) && $index % 2 == 1) {
$selected_index = 'odd';
} elseif (isset($item_indexes['even']) && $index % 2 == 0) {
$selected_index = 'even';
} elseif (isset($item_indexes['other'])) {
$selected_index = 'other';
}
// Output the item with appropriate template (if we found one)
if (null !== $selected_index) {
$shortcodes_output = wpv_do_shortcode($item_indexes[$selected_index]);
$loop .= $shortcodes_output;
$WPVDebug->add_log_item('shortcodes', $item_indexes[$selected_index]);
$WPVDebug->add_log_item('output', $shortcodes_output);
}
// Do wpv-after-display-* action after displaying the item
if ($view_settings['query_type'][0] == 'posts') {
do_action('wpv-after-display-post', $post, $view_id);
$this->variables = $temp_variables;
} elseif ($view_settings['query_type'][0] == 'taxonomy') {
do_action('wpv-after-display-taxonomy', $items[$i], $view_id);
} elseif ($view_settings['query_type'][0] == 'users') {
do_action('wpv-after-display-user', $items[$i], $view_id);
}
}
// see if we should pad the remaining items.
if (isset($args['wrap']) && isset($args['pad'])) {
while ($i % $args['wrap'] && $args['pad']) {
$index = $i;
$index %= $args['wrap'];
if ($index == $args['wrap'] - 1) {
$loop .= wpv_do_shortcode($item_indexes['pad-last']);
} else {
$loop .= wpv_do_shortcode($item_indexes['pad']);
}
$i++;
}
}
$WPVDebug->clean_index();
$out .= str_replace($matches[0], $loop, $post_content);
// restore original $post
$post = isset($tmp_post) && $tmp_post instanceof WP_Post ? clone $tmp_post : null;
$authordata = isset($tmp_authordata) && is_object($tmp_authordata) ? clone $tmp_authordata : null;
$id = $tmp_id;
}
} else {
$out .= sprintf('<!- %s ->', __('View not found', 'wpv-views'));
}
} else {
if ($processed_views[$view_caller_id][$hash] !== true) {
// use output from cache
$out .= $processed_views[$view_caller_id][$hash];
}
}
return $out;
}
开发者ID:javierdlahoz,项目名称:paella-development,代码行数:101,代码来源:wpv.class.php
示例7: the_excerpt_for_archives
/**
* Handle the_excerpt filter when it's used in an archive loop
*
*/
function the_excerpt_for_archives($content) {
global $WPV_settings, $post, $wp_query;
static $archive_type_has_been_checked = false;
static $taxonomy_loop = null;
static $archive_loop = null;
if ( !$archive_type_has_been_checked ) {
$archive_type_has_been_checked = true;
if ( is_archive() ) {
/* Taxonomy archives. */
if ( is_tax() || is_category() || is_tag() ) {
$term = $wp_query->get_queried_object();
$taxonomy_loop = 'views_template_loop_' . $term->taxonomy;
} else if (is_post_type_archive($post->post_type)) {
$archive_loop = 'views_template_archive_for_' . $post->post_type;
}
}
}
if ( $taxonomy_loop && isset( $WPV_settings[$taxonomy_loop] ) ) {
// this is a taxonomy loop. Get the Content Template using the_content function
$content = wpv_do_shortcode( $this->the_content( $content ) );
} else if ( $archive_loop && isset( $WPV_settings[$archive_loop] ) ) {
// this is an archive loop. Get the Content Template using the_content function
$content = wpv_do_shortcode( $this->the_content( $content ) );
}
return $content;
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:38,代码来源:wpv-template.class.php
示例8: widget
function widget($args, $instance)
{
global $WP_Views;
extract($args);
$instance = wp_parse_args((array) $instance, array('title' => '', 'view' => false, 'target_id' => false));
if ($instance['view'] && $instance['target_id']) {
$WP_Views->set_widget_view_id($instance['view']);
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
$atts = array();
$atts['id'] = $instance['view'];
$atts['target_id'] = $instance['target_id'];
$out = $WP_Views->short_tag_wpv_view_form($atts);
$out = wpv_do_shortcode($out);
$post_type_object = get_post_type_object('view');
if (current_user_can($post_type_object->cap->edit_post, $instance['view'])) {
$out .= widget_view_link($instance['view']);
}
echo $out;
echo $after_widget;
$WP_Views->set_widget_view_id(0);
}
}
开发者ID:supahseppe,项目名称:path-of-gaming,代码行数:26,代码来源:wpv-widgets.php
示例9: wpv_pager_next_page_shortcode
function wpv_pager_next_page_shortcode($atts, $value)
{
extract(shortcode_atts(array(), $atts));
global $WP_Views;
$page = $WP_Views->get_current_page_number();
$view_settings = $WP_Views->get_view_settings();
$display = false;
if ($view_settings['pagination']['mode'] == 'rollover') {
$display = true;
} else {
if ($page < $WP_Views->get_max_pages()) {
$display = true;
}
}
if ($display) {
$page++;
$value = wpv_do_shortcode($value);
// TODO remove
// return '<a href="#" onclick="return wpv_pager_click_' . $WP_Views->get_view_count() . '(\'' . $page. '\')">' . $value . '</a>';
$ajax = $view_settings['ajax_pagination'][0] == 'enable' ? 'true' : 'false';
$effect = isset($view_settings['ajax_pagination']['style']) ? $view_settings['ajax_pagination']['style'] : 'fade';
$stop_rollover = 'false';
if ($view_settings['pagination']['mode'] == 'rollover') {
$ajax = 'true';
$effect = $view_settings['rollover']['effect'];
$stop_rollover = 'true';
if ($effect == 'slideright') {
$effect = 'slideleft';
}
if ($effect == 'slideup') {
$effect = 'slidedown';
}
}
$cache_pages = $view_settings['pagination']['cache_pages'];
$preload_pages = $view_settings['pagination']['preload_pages'];
$spinner = $view_settings['pagination']['spinner'];
$spinner_image = $view_settings['pagination']['spinner_image'];
$callback_next = $view_settings['pagination']['callback_next'];
if ($page <= 0) {
$page = $WP_Views->get_max_pages();
} else {
if ($page > $WP_Views->get_max_pages()) {
$page = 1;
}
}
return '<a href="#" class="wpv-filter-next-link" onclick="return wpv_pagination_replace_view(' . $WP_Views->get_view_count() . ',' . $page . ', ' . $ajax . ', \'' . $effect . '\',' . $WP_Views->get_max_pages() . ', ' . $cache_pages . ', ' . $preload_pages . ', \'' . $spinner . '\', \'' . $spinner_image . '\', \'' . $callback_next . '\', ' . $stop_rollover . ')">' . $value . '</a>';
} else {
return '';
}
}
开发者ID:davilode83,项目名称:occupysandy.net,代码行数:50,代码来源:wpv-pagination-embedded.php
示例10: CRED_User_build
private function CRED_User_build()
{
// get refs here
$out_ =& $this->out_;
$formHelper = $this->_formHelper;
$shortcodeParser = $this->_shortcodeParser;
$zebraForm = $this->_zebraForm;
$zebraForm->out_ =& $out_;
$zebraForm->_shortcodeParser = $shortcodeParser;
$zebraForm->_formHelper = $formHelper;
$zebraForm->_formData = $this->_formData;
$zebraForm->_post_ID = $this->_post_ID;
if ($zebraForm->preview) {
$preview_content = $this->_content;
}
// remove any HTML comments before parsing, allow to comment-out parts
$this->_content = $shortcodeParser->removeHtmlComments($this->_content);
// do WP shortcode here for final output, moved here to avoid replacing post_content
// call wpv_do_shortcode instead to fix render wpv shortcodes inside other shortcodes
$this->_content = apply_filters('cred_content_before_do_shortcode', $this->_content);
//New CRED shortcode to retrieve current container post_id
if (isset(StaticClass::$_cred_container_id)) {
$this->_content = str_replace("[cred-container-id]", StaticClass::$_cred_container_id, $this->_content);
}
//_pre($this->_content);
if (function_exists('wpv_do_shortcode')) {
$this->_content = wpv_do_shortcode($this->_content);
} else {
$this->_content = do_shortcode($this->_content);
}
// parse all shortcodes internally
$shortcodeParser->remove_all_shortcodes();
$shortcodeParser->add_shortcode('creduserform', array(&$zebraForm, 'cred_user_form_shortcode'));
$this->_content = $shortcodeParser->do_shortcode($this->_content);
$shortcodeParser->remove_shortcode('creduserform', array(&$zebraForm, 'cred_user_form_shortcode'));
// add any custom attributes eg class
/* if (
isset($zebraForm->form_properties['attributes'])
&& is_array($zebraForm->form_properties['attributes'])
&& !empty($zebraForm->form_properties['attributes'])
)
$zebraForm->form_properties['attributes']=array_merge($zebraForm->form_properties['attributes'],
$this->_attributes);
else
$zebraForm->form_properties['attributes']=$this->_attributes; */
// render any external third-party shortcodes first (enables using shortcodes as values to cred shortcodes)
$zebraForm->_form_content = do_shortcode($zebraForm->_form_content);
// build shortcodes, (backwards compatibility, render first old shortcode format with dashes)
$shortcodeParser->add_shortcode('cred-field', array(&$zebraForm, 'cred_field_shortcodes'));
$shortcodeParser->add_shortcode('cred-generic-field', array(&$zebraForm, 'cred_generic_field_shortcodes'));
$shortcodeParser->add_shortcode('cred-show-group', array(&$zebraForm, 'cred_conditional_shortcodes'));
// build shortcodes, render new shortcode format with underscores
$shortcodeParser->add_shortcode('cred_field', array(&$zebraForm, 'cred_field_shortcodes'));
$shortcodeParser->add_shortcode('cred_generic_field', array(&$zebraForm, 'cred_generic_field_shortcodes'));
$shortcodeParser->add_shortcode('cred_show_group', array(&$zebraForm, 'cred_conditional_shortcodes'));
$out_['child_groups'] = array();
//$this->_form_content=$shortcodeParser->do_recursive_shortcode('cred-show-group', $this->_form_content);
$zebraForm->_form_content = $shortcodeParser->do_recursive_shortcode('cred_show_group', $zebraForm->_form_content);
$out_['child_groups'] = array();
/* Watch out for Toolset forms library in commons outputting HTML before header()
* In the do_shortcode parser
* https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/185336518/comments#282283111
*/
$zebraForm->_form_content = $shortcodeParser->do_shortcode($zebraForm->_form_content);
$shortcodeParser->remove_shortcode('cred_show_group', array(&$zebraForm, 'cred_conditional_shortcodes'));
$shortcodeParser->remove_shortcode('cred_generic_field', array(&$zebraForm, 'cred_generic_field_shortcodes'));
$shortcodeParser->remove_shortcode('cred_field', array(&$zebraForm, 'cred_field_shortcodes'));
$shortcodeParser->remove_shortcode('cred-show-group', array(&$zebraForm, 'cred_conditional_shortcodes'));
$shortcodeParser->remove_shortcode('cred-generic-field', array(&$zebraForm, 'cred_generic_field_shortcodes'));
$shortcodeParser->remove_shortcode('cred-field', array(&$zebraForm, 'cred_field_shortcodes'));
// add some auxilliary fields to form
// add nonce hidden field
//$nonceobj=$zebraForm->add('hidden', StaticClass::NONCE, wp_create_nonce($zebraForm->form_properties['name']), array('style'=>'display:none;'));
if (is_user_logged_in()) {
$nonceobj = $zebraForm->add2form_content('hidden', StaticClass::NONCE, wp_create_nonce($zebraForm->form_properties['name']), array('style' => 'display:none;'));
}
//$out_['nonce_field']=$nonce_field;
// add post_id hidden field
if ($this->_post_ID) {
$post_id_obj = $zebraForm->add2form_content('hidden', StaticClass::PREFIX . 'post_id', $this->_post_ID, array('style' => 'display:none;'));
//$out_['post_id_field']=$post_id_obj->attributes['id'];
}
if (isset(StaticClass::$_cred_container_id)) {
$cred_container_id_obj = $zebraForm->add2form_content('hidden', StaticClass::PREFIX . 'cred_container_id', StaticClass::$_cred_container_id, array('style' => 'display:none;'));
}
// add to form
$_fields = $this->_formData->getFields();
$form_type = $_fields['form_settings']->form['type'];
$form_id = $this->_formData->getForm()->ID;
$form_count = $out_['count'];
$post_type = $_fields['form_settings']->post['post_type'];
//$post_type=$this->_postType;
if ($zebraForm->preview) {
// add temporary content for form preview
//$obj=$zebraForm->add('textarea', StaticClass::PREFIX.'form_preview_content', $preview_content, array('style'=>'display:none;'));
$zebraForm->add2form_content('textarea', StaticClass::PREFIX . 'form_preview_content', $preview_content, array('style' => 'display:none;'));
// add temporary content for form preview (not added automatically as there is no shortcode to render this)
//$this->_form_content.=$obj->toHTML();
// hidden fields are rendered automatically
//$obj=$zebraForm->add('hidden',StaticClass::PREFIX.'form_preview_post_type', $post_type, array('style'=>'display:none;'));
//.........这里部分代码省略.........
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:101,代码来源:Form_Builder.php
示例11: wpv_pager_next_page_shortcode
function wpv_pager_next_page_shortcode($atts, $value)
{
extract(shortcode_atts(array(), $atts));
global $WP_Views;
$page = $WP_Views->get_current_page_number();
$view_settings = $WP_Views->get_view_settings();
$display = false;
if ($view_settings['pagination']['mode'] == 'rollover') {
$display = true;
} else {
if ($page < $WP_Views->get_max_pages()) {
$display = true;
}
}
if ($WP_Views->get_max_pages() <= 1.0) {
// only 1 page so we display nothing.
$display = false;
}
if ($display) {
$page++;
$value = wpv_do_shortcode($value);
$ajax = $view_settings['ajax_pagination'][0] == 'enable' ? 'true' : 'false';
$effect = isset($view_settings['ajax_pagination']['style']) ? $view_settings['ajax_pagination']['style'] : 'fade';
$stop_rollover = 'false';
if ($view_settings['pagination']['mode'] == 'rollover') {
$ajax = 'true';
$effect = $view_settings['rollover']['effect'];
$stop_rollover = 'true';
if ($effect == 'slideright') {
$effect = 'slideleft';
}
if ($effect == 'slideup') {
$effect = 'slidedown';
}
}
$cache_pages = $view_settings['pagination']['cache_pages'];
$preload_pages = $view_settings['pagination']['preload_pages'];
$spinner = $view_settings['pagination']['spinner'];
$spinner_image = $view_settings['pagination']['spinner_image'];
// $spinner_image might contain SSL traces, adjust if needed
if (!is_ssl()) {
$spinner_image = str_replace('https://', 'http://', $spinner_image);
}
$callback_next = $view_settings['pagination']['callback_next'];
// adjust pages when reaching beyond the last or first
if ($page <= 0) {
$page = $WP_Views->get_max_pages();
} else {
if ($page > $WP_Views->get_max_pages()) {
$page = 1;
}
}
return '<a href="#" data-viewnumber="' . $WP_Views->get_view_count() . '" data-page="' . $page . '" data-ajax="' . $ajax . '" data-effect="' . $effect . '" data-maxpages="' . $WP_Views->get_max_pages() . '" data-cachepages="' . $cache_pages . '" data-preloadimages="' . $preload_pages . '" dapa-spinner="' . $spinner . '" data-spinnerimage="' . $spinner_image . '" data-callbacknext="' . $callback_next . '" data-stoprollover="' . $stop_rollover . '" class="wpv-filter-next-link js-wpv-pagination-next-link">' . $value . '</a>';
} else {
return '';
}
}
开发者ID:supahseppe,项目名称:path-of-gaming,代码行数:57,代码来源:wpv-pagination-embedded.php
示例12: wpv_shortcode_wpv_if
/**
* Views-Shortcode: wpv-if
*
* Description: Conditional shortcode to be used to display a specific area
* based on a custom field condition. \n
* Supported actions and symbols:\n
* Integer and floating-point numbers \n
* Math operators: +, -, *, / \n
* Comparison operators: <, >, =, <=, >=, != \n
* Boolean operators: AND, OR, NOT \n
* Nested expressions - several levels of parentheses \n
* Variables defined as shortcode parameters starting with a dollar sign \n
* empty() function that checks for empty or non-existing fields
*
* Parameters:
* 'condition' => Define expected result from evaluate - either true or false
* 'evaluate' => Evaluate expression with fields involved, sample use: "($field1 > $field2) AND !empty($field3)"
* 'debug' => Enable debug to display error messages in the shortcode
* 'fieldX' => Define fields to be taken into account during evaluation
*
* Example usage:
* [wpv-if evaluate="boolean condition"]
* Execute code for true
* [/wpv-if]
* Sing a variable and comparing its value to a constant
* [wpv-if f1="wpcf-condnum1" evaluate="$f1 = 1" debug="true"]Number1=1[/wpv-if]
* Two numeric variables in a mathematical expression with boolean operators
* [wpv-if f1="wpcf-condnum1" f2="wpcf-condnum2" evaluate="(2 < 3 AND (((3+$f2)/2) > 3 OR NOT($f1 > 3)))" debug="true"]Visible block[/wpv-if]
* Compare custom field with a value
* [wpv-if f1="wpcf-condstr1" evaluate="$f1 = 'My text'" debug="true"]Text1='My text' [/wpv-if]
* Display condition if evaluates to false (use instead of else-if)
* [wpv-if condition="false" evaluate="2 > 3"] 2 > 3 [/wpv-if]
* Custom function support
* [wpv-if evaluate="my_func() = '1'"]my_func returns 1[/wpv-if]
*
* Link:
* <a href="http://wp-types.com/documentation/user-guides/conditional-html-output-in-views/?utm_source=viewsplugin&utm_campaign=views&utm_medium=views-conditional-help-link&utm_term=Conditional HTML output in Views">Conditional HTML output in Views</a>
*
* Note:
*
*/
function wpv_shortcode_wpv_if( $args, $content ) {
$evaluation_result = wpv_condition_manage_and_evaluate( $args );
extract(
shortcode_atts(
array(
'evaluate' => false,
'debug' => false,
'condition' => true
),
$args
)
);
$condition = ( $condition == 'true' || $condition === TRUE ) ? true : false;
$out = '';
if (
(
$evaluation_result['result'] === true
&& $condition
)
|| (
$evaluation_result['result'] === false
&& ! $condition
)
) {
if ( strpos( $content, 'wpv-b64-' ) === 0) {
$content = substr( $content, 7 );
$content = base64_decode( $content );
}
$out = wpv_do_shortcode( $content );
apply_filters('wpv_shortcode_debug','wpv-if', json_encode( $args ), '', 'Conditional output: evaluated to true', $out );
} else {
$out = '';
if (
(
$evaluation_result['result'] === false
&& $condition
)
|| (
$evaluation_result['result'] === true
&& ! $condition
)
) {
apply_filters('wpv_shortcode_debug','wpv-if', json_encode( $args ), '', 'Conditional output: evaluated to false');
} else {
apply_filters('wpv_shortcode_debug','wpv-if', json_encode( $args ), '', 'Conditional output: error', $evaluation_result['debug'] );
}
}
if (
$debug
&& current_user_can( 'manage_options' )
) {
$out .= '<pre>' . $evaluation_result['debug'] . '</pre>';
}
return $out;
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:100,代码来源:wpv-condition.php
示例13: wpv_archive_pager_next_page_shortcode
function wpv_archive_pager_next_page_shortcode( $atts, $value ) {
return get_previous_posts_link( wpv_do_shortcode( $value ) );
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:3,代码来源:wpv-archive-loop.php
示例14: wpv_for_each_shortcode
/**
* Views-Shortcode: wpv-for-each
*
* Description: Iterate through multple items in a post meta field and output the enclosed text for each item
*
* Parameters:
* 'field' => The name of post meta field.
*
* Example usage:
* Output the field values as an ordered list
* <ol>[wpv-for-each field="my-field"]<li>[wpv-post-field name="my-field"]</li>[/wpv-for-each]<ol>
*
* Link:
*
* Note:
* <a href="#wpv-if">wpv-if</a> shortcode won't work inside a wpv-for-each shortcode
*/
function wpv_for_each_shortcode($atts, $value)
{
extract(shortcode_atts(array('field' => '', 'start' => 1, 'end' => null), $atts));
if (strpos($value, 'wpv-b64-') === 0) {
$value = substr($value, 7);
$value = base64_decode($value);
}
if ($field == '') {
return wpv_do_shortcode($value);
}
$out = '';
global $post;
if (!empty($post)) {
$meta = get_post_meta($post->ID, $field);
if (!$meta) {
// return $value; // old behaviour
// This happens when there is no meta with that key asociated with that post, so return nothing
// From 1.4
return '';
}
// When the metavalue for this key is empty, $meta is an array with just an empty first element
// In that case, return nothing either
// From 1.4
if (is_array($meta) && count($meta) == 1 && empty($meta[0])) {
return '';
}
$start = (int) $start;
$start = $start - 1;
if (is_null($end)) {
$end = count($meta);
}
$end = (int) $end;
if ($start < 0) {
$start = 0;
}
if ($end > count($meta)) {
$end = count($meta);
}
$inner_loopers = "/\\[(wpv-post-field|types).*?\\]/i";
$counts = preg_match_all($inner_loopers, $value, $matches);
$value_arr = array();
for ($i = $start; $i < $end; $i++) {
// Set indexes in the wpv-post-field shortcode
if ($counts > 0) {
$new_value = $value;
foreach ($matches[0] as $index => $match) {
// execute shortcode content and replace
$shortcode = $matches[1][$index];
$apply_index = wpv_should_apply_index_for_each_field($shortcode, $match, $field);
if ($apply_index) {
$resolved_match = str_replace('[' . $shortcode . ' ', '[' . $shortcode . ' index="' . $i . '" ', $match);
$new_value = str_replace($match, $resolved_match, $new_value);
}
}
$value_arr[] = $new_value;
} else {
$value_arr[] = $value;
}
}
$out .= implode('', $value_arr);
}
apply_filters('wpv_shortcode_debug', 'wpv-for-each', json_encode($atts), '', 'Data received from cache.', $out);
return $out;
}
开发者ID:javierdlahoz,项目名称:paella-development,代码行数:81,代码来源:wpv-shortcodes.php
示例15: wpv_shortcode_wpv_filter_spinner
function wpv_shortcode_wpv_filter_spinner( $atts, $value ) {
extract(
shortcode_atts(array(
'container' => 'span',
'class' => '',
'position' => 'before',
'spinner' => '',
'style' => ''
), $atts)
);
if (
empty( $spinner )
&& ! empty( $position )
&& $position != 'none'
) {
// Keep the spinner coming from the View settings for backward compatibility
global $WP_Views;
$view_settings = $WP_Views->get_view_settings();
if (
isset( $view_settings['dps'] )
&& isset( $view_settings['dps']['spinner'] )
&& $view_settings['dps']['spinner'] != 'none'
) {
if ( $view_settings['dps']['spinner'] == 'custom' ) {
if ( isset( $view_settings['dps']['spinner_image_uploaded'] ) ) {
$spinner = $view_settings['dps']['spinner_image_uploaded'];
}
} else if ( $view_settings['dps']['spinner'] == 'inhouse' ) {
if ( isset( $view_settings['dps']['spinner_image'] ) ) {
$spinner = $view_settings['dps']['spinner_image'];
}
}
}
}
// $spinner_image might contain SSL traces, adjust if needed
if ( !is_ssl() ) {
$spinner = str_replace( 'https://', 'http://', $spinner );
}
if ( ! empty( $style ) ) {
$style = '; '. esc_attr( $style );
}
$return = '<' . $container . ' style="display:none'. $style .'" class="js-wpv-dps-spinner';
if ( !empty( $class ) ) {
$return .= ' ' . $class;
}
$return .= '">';
if ( ! empty( $position ) && ! empty( $spinner ) && $position == 'before' ) {
$return .= '<img src="' . $spinner . '" />';
}
$return .= wpv_do_shortcode( $value );
if ( ! empty( $position ) && ! empty( $spinner ) && $position == 'after' ) {
$return .= '<img src="' . $spinner . '" />';
}
$return .= '</' . $container . '>';
return $return;
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:60,代码来源:wpv-filter-embedded.php
示例16: wpv_for_each_shortcode
function wpv_for_each_shortcode($atts, $value)
{
extract(shortcode_atts(array('field' => ''), $atts));
if ($field == '') {
return wpv_do_shortcode($value);
}
$out = '';
global $post, $wpv_for_each_index;
if (!empty($post)) {
$meta = get_post_meta($post->ID, $field);
if (!$meta) {
// return $value; // old behaviour
// This happens when there is no meta with that key asociated with that post, so return nothing
// From 1.4
return '';
}
// When the metavalue for this key is empty, $meta is an array with just an empty first element
// In that case, return nothing either
// From 1.4
if (is_array($meta) && count($meta) == 1 && empty($meta[0])) {
return '';
}
// iterate through the items and set the for-each index
$wpv_for_each_index[] = 0;
for ($i = 0; $i < count($meta); $i++) {
// set the for-each index and output
$wpv_for_each_index[count($wpv_for_each_index) - 1] = $i;
$out .= wpv_do_shortcode($value);
}
array_pop($wpv_for_each_index);
}
apply_filters('wpv_shortcode_debug', 'wpv-for-each', json_encode($atts), '', 'Data received from cache.', $out);
return $out;
}
开发者ID:javierdlahoz,项目名称:paella-development,代码行数:34,代码来源:wpv-shortcodes.php
示例17: render_view
//.........这里部分代码省略.........
if ($archive_query) {
$this->post_query = $archive_query;
} else {
$this->post_query = wpv_filter_get_posts($view_id);
}
$items = $this->post_query->posts;
$wplogger->log('Found ' . count($items) . ' posts');
if ($wplogger->isMsgVisible(WPLOG_DEBUG)) {
// simplify the output
$out_items = array();
foreach ($items as $item) {
$out_items[] = array('ID' => $item->ID, 'post_title' => $item->post_title);
}
$wplogger->log($out_items, WPLOG_DEBUG);
}
}
// save original post
global $post, $authordata, $id;
$tmp_post = isset($post) ? clone $post : null;
if ($authordata) {
$tmp_authordata = clone $authordata;
} else {
$tmp_authordata = null;
}
$tmp_id = $id;
if ($view_settings['query_type'][0] == 'taxonomy') {
$items = $this->taxonomy_query($view_settings);
$wplogger->log($items, WPLOG_DEBUG);
// taxonomy views can be recursive so remove from
// the processed array
//unset($processed_views[$view_caller_id][$hash]);
}
$loop = '';
for ($i = 0; $i < count($items); $i++) {
$index = $i;
if (isset($args['wrap'])) {
$index %= $args['wrap'];
}
$index++;
// [wpv-item index=xx] uses base 1
$index = strval($index);
if ($view_settings['query_type'][0] == 'posts') {
$post = clone $items[$i];
$authordata = new WP_User($post->post_author);
$id = $post->ID;
$temp_variables = $this->variables;
$this->variables = array();
do_action('wpv-before-display-post', $post, $view_id);
}
if ($view_settings['query_type'][0] == 'taxonomy') {
$this->taxonomy_data['term'] = $items[$i];
}
// first output the "all" index.
$loop .= wpv_do_shortcode($item_indexes['all']);
// Output each index we find
// otherwise output 'other'
if (isset($item_indexes[$index])) {
$loop .= wpv_do_shortcode($item_indexes[$index]);
} elseif (isset($item_indexes['other'])) {
$loop .= wpv_do_shortcode($item_indexes['other']);
}
if ($view_settings['query_type'][0] == 'posts') {
do_action('wpv-after-display-post', $post, $view_id);
$this->variables = $temp_variables;
}
}
// see if we should pad the remaining items.
if (isset($args['wrap']) && isset($args['pad'])) {
while ($i % $args['wrap'] && $args['pad']) {
$index = $i;
$index %= $args['wrap'];
if ($index == $args['wrap'] - 1) {
$loop .= wpv_do_shortcode($item_indexes['pad-last']);
} else {
$loop .= wpv_do_shortcode($item_indexes['pad']);
}
|
请发表评论