本文整理汇总了PHP中papi_render_html_tag函数的典型用法代码示例。如果您正苦于以下问题:PHP papi_render_html_tag函数的具体用法?PHP papi_render_html_tag怎么用?PHP papi_render_html_tag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了papi_render_html_tag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: html
/**
* Render property html.
*/
public function html()
{
$settings = $this->get_settings();
$value = papi_cast_string_value($this->get_value());
$options_html = [];
// Override selected setting with
// database value if not empty.
if (!papi_is_empty($value)) {
$settings->selected = $value;
}
$classes = 'papi-fullwidth';
if ($settings->select2) {
$classes .= ' papi-component-select2';
}
if (!empty($settings->placeholder)) {
$options_html[] = papi_html_tag('option', ['value' => '', $settings->placeholder]);
}
// Create option html tags for all items.
foreach ($this->get_items() as $key => $value) {
$key = is_numeric($key) ? $value : $key;
if (papi_is_empty($key)) {
continue;
}
$options_html[] = papi_html_tag('option', ['selected' => $value === $settings->selected ? 'selected' : null, 'value' => $value, papi_convert_to_string($key)]);
}
papi_render_html_tag('select', ['class' => $classes, 'data-allow-clear' => true, 'data-placeholder' => $settings->placeholder, 'data-width' => '100%', 'id' => $this->html_id(), 'name' => $this->html_name(), $options_html]);
}
示例2: html
/**
* Render property html.
*/
public function html()
{
$settings = $this->get_settings();
$value = $this->get_value();
$settings_json = ['i18n' => ['previousMonth' => __('Previous Month', 'papi'), 'nextMonth' => __('Next Month', 'papi'), 'midnight' => __('Midnight', 'papi'), 'months' => [__('January', 'papi'), __('February', 'papi'), __('March', 'papi'), __('April', 'papi'), __('May', 'papi'), __('June', 'papi'), __('July', 'papi'), __('August', 'papi'), __('September', 'papi'), __('October', 'papi'), __('November', 'papi'), __('December', 'papi')], 'noon' => __('Noon', 'papi'), 'weekdays' => [__('Sunday', 'papi'), __('Monday', 'papi'), __('Tuesday', 'papi'), __('Wednesday', 'papi'), __('Thursday', 'papi'), __('Friday', 'papi'), __('Saturday', 'papi')], 'weekdaysShort' => [__('Sun', 'papi'), __('Mon', 'papi'), __('Tue', 'papi'), __('Wed', 'papi'), __('Thu', 'papi'), __('Fri', 'papi'), __('Sat', 'papi')]]];
// Remove i18n setting if it exists.
if (isset($settings->i18n)) {
unset($settings->i18n);
}
// Remove default time format if show time is false.
if (isset($settings->show_time) && !$settings->show_time && isset($settings->format)) {
$settings->format = trim(str_replace('hh:mm:ss', '', $settings->format));
}
// Convert all sneak case key to camel case.
foreach ((array) $settings as $key => $val) {
if (!is_string($key)) {
continue;
}
if ($key = papi_camel_case($key)) {
$settings_json[$key] = $val;
}
}
// Papi has `use24Hours` as key and Pikaday has `use24hour`.
// This code will fix it.
if (isset($settings_json['use24Hours'])) {
$settings_json['use24hour'] = $settings_json['use24Hours'];
unset($settings_json['use24Hours']);
}
papi_render_html_tag('input', ['class' => 'papi-property-datetime', 'data-settings' => (object) $settings_json, 'id' => $this->html_id(), 'name' => $this->html_name(), 'type' => 'text', 'value' => $value]);
}
示例3: html
/**
* Render property html.
*/
public function html()
{
$options = $this->get_options();
papi_render_html_tag('div', ['class' => 'papi-property-divider', 'data-papi-rule' => $this->html_name(), sprintf('<h3><span>%s</span></h3>', $options->title)]);
if (!papi_is_empty($options->description)) {
echo sprintf('<p>%s</p>', $options->description);
}
}
示例4: html
/**
* Render property html.
*/
public function html()
{
$settings = $this->get_settings();
papi_render_html_tag('input', ['class' => $settings->mediauploader ? 'papi-url-media-input' : null, 'id' => $this->html_id(), 'name' => $this->html_name(), 'type' => 'url', 'value' => $this->get_value()]);
if ($settings->mediauploader) {
echo ' ';
papi_render_html_tag('input', ['class' => 'button papi-url-media-button', 'data-papi-action' => 'mediauploader', 'id' => $this->html_id(), 'name' => $this->html_name() . '_button', 'type' => 'button', 'value' => __('Select file', 'papi')]);
}
}
示例5: html
/**
* Render property html.
*/
public function html()
{
$options = $this->get_options();
$text = '';
$options->description = $options->slug;
if (!papi_is_empty($options->description)) {
$text = sprintf('<p>%s</p>', $options->description);
}
papi_render_html_tag('div', ['class' => 'papi-property-divider', 'data-papi-rule' => esc_attr($this->html_name()), sprintf('<h3><span>%s</span></h3>%s', esc_html($options->title), $text)]);
}
示例6: html
/**
* Render property html.
*/
public function html()
{
$settings = $this->get_settings();
$html = papi_maybe_get_callable_value($settings->html);
if ($settings->save) {
$value = $this->get_value();
if (!empty($value) && is_string($value)) {
$html = $value;
}
papi_render_html_tag('input', ['name' => esc_attr($this->html_name()), 'type' => 'hidden', 'value' => $html]);
}
papi_render_html_tag('div', ['data-papi-rule' => esc_attr($this->html_name()), 'class' => 'property-html', $html]);
}
示例7: html
/**
* Render property html.
*/
public function html()
{
$settings = $this->get_settings();
$value = $this->get_value();
// If range type is used change the default values if empty.
if ($settings->type === 'range') {
$settings->max = papi_is_empty($settings->max) ? 100 : $settings->max;
$settings->min = papi_is_empty($settings->min) ? 0 : $settings->min;
$settings->step = papi_is_empty($settings->step) ? 1 : $settings->step;
}
if ($settings->min !== 0 && $value < $settings->min) {
$value = $settings->min;
}
papi_render_html_tag('input', ['id' => $this->html_id(), 'max' => $settings->max, 'min' => $settings->min, 'name' => $this->html_name(), 'step' => $settings->step, 'type' => $settings->type, 'value' => $value]);
}
示例8: html
/**
* Render property html.
*/
public function html()
{
$settings = $this->get_settings();
$value = papi_cast_string_value($this->get_value());
// Override selected setting with
// database value if not null.
if (!papi_is_empty($value)) {
$settings->selected = $value;
}
foreach ($settings->items as $key => $value) {
$key = is_numeric($key) ? $value : $key;
papi_render_html_tag('label', ['class' => 'light', 'for' => $this->html_id($key), papi_render_html_tag('input', ['id' => $this->html_id($key), 'name' => $this->html_name(), 'type' => 'radio', 'checked' => $value === $settings->selected ? 'checked' : null, 'value' => $value]), papi_convert_to_string($key)]);
papi_render_html_tag('br');
}
}
示例9: add_form_fields
/**
* Add form fields to edit tags page.
*/
public function add_form_fields()
{
$html_name = esc_attr(papi_get_page_type_key());
$taxonomy = papi_get_qs('taxonomy');
$taxonomy_object = get_taxonomy($taxonomy);
// Get only the taxonomy types that has the taxonomy.
$taxonomy_types = array_filter($this->taxonomy_types, function ($taxonomy_type) use($taxonomy) {
return in_array($taxonomy, $taxonomy_type->taxonomy, true) && $taxonomy_type->display($taxonomy);
});
$taxonomy_types = array_values($taxonomy_types);
// Do not display empty select if no taxonomy types.
if (empty($taxonomy_types)) {
return;
}
// Prepare taxonomy types with standard taxonomy type.
$taxonomy_types = $this->prepare_taxonomy_types($taxonomy_types);
// Render a dropdown if more than one taxonomy types
// exists on the taxonomy.
if (count($taxonomy_types) > 1) {
?>
<div class="form-field">
<label for="<?php
echo esc_attr($html_name);
?>
">
<?php
echo esc_html(sprintf(__('%s type', 'papi'), $taxonomy_object->labels->singular_name));
?>
</label>
<select name="<?php
echo esc_attr($html_name);
?>
" id="<?php
echo esc_attr($html_name);
?>
" data-papi-page-type-key="true">
<?php
foreach ($taxonomy_types as $taxonomy_type) {
papi_render_html_tag('option', ['data-redirect' => $taxonomy_type->redirect_after_create, 'value' => esc_attr($taxonomy_type->get_id()), esc_html($taxonomy_type->name)]);
}
?>
</select>
</div>
<?php
} else {
papi_render_html_tag('input', ['data-redirect' => $taxonomy_types[0]->redirect_after_create, 'data-papi-page-type-key' => true, 'name' => esc_attr($html_name), 'type' => 'hidden', 'value' => esc_attr($taxonomy_types[0]->get_id())]);
}
}
示例10: html
/**
* Render property html.
*/
public function html()
{
$settings = $this->get_settings();
$value = papi_cast_string_value($this->get_value());
// Override selected setting with
// database value if not null.
if (!papi_is_empty($value)) {
$settings->selected = $value;
}
echo '<div class="papi-property-radio">';
foreach ($settings->items as $key => $value) {
$key = is_numeric($key) ? $value : $key;
papi_render_html_tag('p', [papi_html_tag('label', ['class' => 'light', 'for' => esc_attr($this->html_id($key)), papi_html_tag('input', ['id' => esc_attr($this->html_id($key)), 'name' => esc_attr($this->html_name()), 'type' => 'radio', 'checked' => $value === $settings->selected, 'value' => $value]), esc_html(papi_convert_to_string($key))])]);
}
echo '</div>';
}
示例11: html
/**
* Render property html.
*/
public function html()
{
$layout = $this->get_setting('layout');
$labels = $this->get_labels();
$post_types = $this->get_post_types();
$render_label = count($post_types) > 1;
$advanced = $render_label && $layout === 'advanced';
$single = $render_label && $layout !== 'advanced';
$classes = count($post_types) > 1 ? '' : 'papi-fullwidth';
$settings = $this->get_settings();
$value = $this->get_value();
$value = is_object($value) ? $value->ID : 0;
$selected_label = array_shift($labels);
$selected_post_type = get_post_type($value) ?: '';
$posts = $this->get_posts($selected_post_type);
if ($settings->select2) {
$classes .= ' papi-component-select2';
}
?>
<div class="papi-property-post <?php
echo $advanced ? 'advanced' : '';
?>
">
<?php
if ($advanced) {
?>
<table class="papi-table">
<tr>
<td>
<label for="<?php
echo esc_attr($this->html_id());
?>
_post_type">
<?php
echo esc_html($settings->labels['select_post_type']);
?>
</label>
</td>
<td>
<select
id="<?php
echo esc_attr($this->html_id());
?>
_post_type"
class="<?php
echo esc_attr($classes);
?>
papi-property-post-left"
data-select-item="<?php
echo esc_attr($settings->labels['select_item']);
?>
"
data-post-query='<?php
echo esc_attr(papi_maybe_json_encode($settings->query));
?>
'
data-width="100%"
>
<?php
foreach ($labels as $post_type => $label) {
papi_render_html_tag('option', ['value' => $post_type, 'selected' => $post_type === $selected_post_type, $label]);
if ($selected) {
$selected_label = $label;
}
}
?>
</select>
</td>
</tr>
<tr>
<td>
<label for="<?php
echo esc_attr($this->html_id());
?>
_posts">
<?php
echo esc_html(sprintf($settings->labels['select_item'], $selected_label));
?>
</label>
</td>
<td>
<?php
}
?>
<select
class="<?php
echo esc_attr($classes);
?>
papi-property-post-right"
id="<?php
echo esc_attr($this->html_id());
?>
_posts"
name="<?php
echo esc_attr($this->html_name());
//.........这里部分代码省略.........
示例12: esc_html
echo esc_html(implode(', ', $post_types));
?>
</td>
<td>
<?php
if (empty($page_type->template)) {
_e('Page Type has no template file', 'papi');
} else {
if (!current_user_can('edit_themes') || defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT) {
echo esc_html($page_type->template);
} else {
$theme_dir = get_template_directory();
$theme_name = basename($theme_dir);
$url = admin_url('theme-editor.php?file=' . $page_type->template . '&theme=' . $theme_name);
if (file_exists($theme_dir . '/' . $page_type->template)) {
papi_render_html_tag('a', ['href' => esc_attr($url), esc_html($page_type->template)]);
} else {
_e('Template file does not exist', 'papi');
}
}
}
?>
</td>
<td>
<?php
echo esc_html(papi_get_number_of_pages($page_type->get_id()));
?>
</td>
</tr>
<?php
}
示例13: render_repeater
/**
* Render repeater html.
*
* @param stdClass $options
*/
protected function render_repeater($options)
{
?>
<div class="papi-property-repeater papi-property-repeater-top" data-limit="<?php
echo esc_attr($this->get_setting('limit'));
?>
">
<table class="papi-table">
<?php
$this->render_repeater_head();
?>
<tbody class="repeater-tbody">
<?php
$this->render_repeater_rows();
?>
</tbody>
</table>
<div class="bottom">
<?php
papi_render_html_tag('button', ['class' => 'button button-primary', 'data-papi-json' => sprintf('%s_repeater_json', $options->slug), 'type' => 'button', esc_html($this->get_setting('add_new_label'))]);
?>
</div>
<?php
/* Default repeater value */
?>
<input type="hidden" data-papi-rule="<?php
echo esc_attr($options->slug);
?>
" name="<?php
echo esc_attr($options->slug);
?>
[]" />
</div>
<?php
}
示例14: html
/**
* Render property html.
*/
public function html()
{
$css_classes = '';
$labels = $this->get_labels();
$settings = $this->get_settings();
$slug = $this->html_name();
$value = papi_to_array($this->get_value());
// Keep only valid objects.
$value = array_filter($value, function ($item) {
return is_object($item) && isset($item->id) && !empty($item->id);
});
$show_button = empty($value);
if ($settings->multiple) {
$css_classes .= ' multiple ';
$slug .= '[]';
$show_button = true;
}
?>
<div class="papi-property-file <?php
echo esc_attr($css_classes);
?>
" data-file-type="<?php
echo esc_attr($this->file_type);
?>
">
<p class="papi-file-select <?php
echo $show_button ? '' : 'papi-hide';
?>
">
<?php
if (!$settings->multiple) {
echo esc_html($labels['no_file']) . ' ';
}
papi_render_html_tag('input', ['name' => esc_attr($slug), 'type' => 'hidden', 'value' => '']);
papi_render_html_tag('button', ['data-slug' => esc_attr($slug), 'class' => 'button', 'type' => 'button', esc_html($labels['add'])]);
?>
</p>
<div class="attachments">
<?php
if (is_array($value)) {
foreach ($value as $file) {
$url = wp_get_attachment_thumb_url($file->id);
if (empty($url)) {
$url = wp_mime_type_icon($file->id);
}
?>
<div class="attachment">
<a class="check" href="#">×</a>
<div class="attachment-preview">
<div class="thumbnail">
<div class="centered">
<?php
papi_render_html_tag('img', ['alt' => esc_attr($file->alt), 'src' => esc_attr($url)]);
papi_render_html_tag('input', ['name' => esc_attr($slug), 'type' => 'hidden', 'value' => esc_attr($file->id)]);
?>
</div>
<?php
if ($this->file_type === 'file') {
?>
<div class="filename">
<div><?php
echo esc_html(basename($file->file));
?>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
<?php
}
}
?>
</div>
<div class="clear"></div>
</div>
<?php
}
示例15: render_repeater
/**
* Render repeater html.
*
* @param object $options
*/
protected function render_repeater($options)
{
$layouts = $this->get_settings_layouts();
?>
<div class="papi-property-flexible papi-property-repeater-top" data-limit="<?php
echo esc_attr($this->get_setting('limit'));
?>
">
<table class="papi-table">
<tbody class="repeater-tbody flexible-tbody">
<?php
$this->render_repeater_row();
?>
</tbody>
</table>
<div class="bottom">
<div class="flexible-layouts-btn-wrap">
<div class="flexible-layouts papi-hide">
<div class="flexible-layouts-arrow"></div>
<ul>
<?php
foreach ($layouts as $layout) {
papi_render_html_tag('li', [papi_html_tag('a', ['data-layout' => esc_html($layout['slug']), 'data-papi-json' => sprintf('%s_repeater_json', $options->slug), 'href' => '#', 'role' => 'button', 'tabindex' => 0, esc_html($layout['title'])])]);
}
?>
</ul>
</div>
<?php
papi_render_html_tag('button', ['class' => 'button button-primary', 'type' => 'button', esc_html($this->get_setting('add_new_label'))]);
?>
</div>
</div>
<?php
/* Default repeater value */
?>
<input type="hidden" data-papi-rule="<?php
echo esc_attr($options->slug);
?>
" name="<?php
echo esc_attr($this->get_slug());
?>
[]" />
</div>
<?php
}