本文整理汇总了PHP中GVCommon::get_all_views方法的典型用法代码示例。如果您正苦于以下问题:PHP GVCommon::get_all_views方法的具体用法?PHP GVCommon::get_all_views怎么用?PHP GVCommon::get_all_views使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GVCommon
的用法示例。
在下文中一共展示了GVCommon::get_all_views方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form
/**
* @inheritDoc
*/
public function form($instance)
{
// @todo Make compatible with Customizer
if ($this->is_preview()) {
$warning = sprintf(esc_html__('This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview'), '<a href="' . admin_url('widgets.php') . '">', '</a>');
echo wpautop(GravityView_Admin::get_floaty() . $warning);
return;
}
$defaults = array('title' => '', 'view_id' => 0, 'post_id' => '', 'search_fields' => '');
$instance = wp_parse_args((array) $instance, $defaults);
$title = $instance['title'];
$view_id = $instance['view_id'];
$post_id = $instance['post_id'];
$search_fields = $instance['search_fields'];
$views = GVCommon::get_all_views();
// If there are no views set up yet, we get outta here.
if (empty($views)) {
?>
<div id="select_gravityview_view">
<div class="wrap"><?php
echo GravityView_Post_Types::no_views_text();
?>
</div>
</div>
<?php
return;
}
?>
<p><label for="<?php
echo $this->get_field_id('title');
?>
"><?php
_e('Title:', 'gravityview');
?>
<input class="widefat" id="<?php
echo $this->get_field_id('title');
?>
" name="<?php
echo $this->get_field_name('title');
?>
" type="text" value="<?php
echo esc_attr($title);
?>
" /></label></p>
<?php
/**
* Display errors generated for invalid embed IDs
* @see GravityView_View_Data::is_valid_embed_id
*/
if (isset($instance['updated']) && empty($instance['view_id'])) {
?>
<div class="error inline hide-on-view-change">
<p><?php
esc_html_e('Please select a View to search.', 'gravityview');
?>
</p>
</div>
<?php
unset($error);
}
?>
<p>
<label for="gravityview_view_id"><?php
_e('View:', 'gravityview');
?>
</label>
<select id="gravityview_view_id" name="<?php
echo $this->get_field_name('view_id');
?>
" class="widefat">
<option value=""><?php
esc_html_e('— Select a View —', 'gravityview');
?>
</option>
<?php
foreach ($views as $view_option) {
$title = empty($view_option->post_title) ? __('(no title)', 'gravityview') : $view_option->post_title;
echo '<option value="' . $view_option->ID . '" ' . selected(esc_attr($view_id), $view_option->ID, false) . '>' . esc_html(sprintf('%s #%d', $title, $view_option->ID)) . '</option>';
}
?>
</select>
</p>
<?php
/**
* Display errors generated for invalid embed IDs
* @see GravityView_View_Data::is_valid_embed_id
*/
if (!empty($instance['error_post_id'])) {
?>
<div class="error inline">
<p><?php
echo $instance['error_post_id'];
//.........这里部分代码省略.........