本文整理汇总了PHP中gravityview_sanitize_html_class函数的典型用法代码示例。如果您正苦于以下问题:PHP gravityview_sanitize_html_class函数的具体用法?PHP gravityview_sanitize_html_class怎么用?PHP gravityview_sanitize_html_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gravityview_sanitize_html_class函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_frontend
public function render_frontend($widget_args, $content = '', $context = '')
{
if (!$this->pre_render_frontend()) {
return;
}
if (!empty($widget_args['title'])) {
echo $widget_args['title'];
}
// Make sure the class is loaded in DataTables
if (!class_exists('GFFormDisplay')) {
include_once GFCommon::get_base_path() . '/form_display.php';
}
$widget_args['content'] = trim(rtrim($widget_args['content']));
// No custom content
if (empty($widget_args['content'])) {
do_action('gravityview_log_debug', sprintf('%s[render_frontend]: No content.', get_class($this)));
return;
}
// Add paragraphs?
if (!empty($widget_args['wpautop'])) {
$widget_args['content'] = wpautop($widget_args['content']);
}
// Enqueue scripts needed for Gravity Form display, if form shortcode exists.
// Also runs `do_shortcode()`
$content = GFCommon::gform_do_shortcode($widget_args['content']);
// Add custom class
$class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
$class = gravityview_sanitize_html_class($class);
echo '<div class="gv-widget-custom-content ' . $class . '">' . $content . '</div>';
}
示例2: render_frontend
public function render_frontend($widget_args, $content = '', $context = '')
{
$gravityview_view = GravityView_View::getInstance();
if (!$this->pre_render_frontend()) {
return;
}
if (!empty($widget_args['title'])) {
echo $widget_args['title'];
}
$offset = $gravityview_view->paging['offset'];
$page_size = $gravityview_view->paging['page_size'];
$total = $gravityview_view->total_entries;
if (empty($total)) {
do_action('gravityview_log_debug', sprintf('%s[render_frontend]: No entries.', get_class($this)));
return;
}
// displaying info
if ($total == 0) {
$first = $last = 0;
} else {
$first = empty($offset) ? 1 : $offset + 1;
$last = $offset + $page_size > $total ? $total : $offset + $page_size;
}
/**
* Modify the displayed pagination numbers
* @param array $counts Array with $first, $last, $total
* @var array array with $first, $last, $total numbers in that order.
*/
list($first, $last, $total) = apply_filters('gravityview_pagination_counts', array($first, $last, $total));
$class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
$class = gravityview_sanitize_html_class($class);
$output = '<div class="gv-widget-pagination ' . $class . '"><p>' . sprintf(__('Displaying %1$s - %2$s of %3$s', 'gravityview'), $first, $last, $total) . '</p></div>';
echo apply_filters('gravityview_pagination_output', $output, $first, $last, $total);
}
示例3: render_frontend
public function render_frontend($widget_args, $content = '', $context = '')
{
$gravityview_view = GravityView_View::getInstance();
if (!$this->pre_render_frontend()) {
return;
}
$page_size = $gravityview_view->paging['page_size'];
$total = $gravityview_view->total_entries;
$atts = shortcode_atts(array('show_all' => !empty($this->settings['show_all']['default'])), $widget_args, 'gravityview_widget_page_links');
// displaying info
$curr_page = empty($_GET['pagenum']) ? 1 : intval($_GET['pagenum']);
$page_link_args = array('base' => add_query_arg('pagenum', '%#%', gv_directory_link()), 'format' => '&pagenum=%#%', 'add_args' => array(), 'prev_text' => '«', 'next_text' => '»', 'type' => 'list', 'end_size' => 1, 'mid_size' => 2, 'total' => empty($page_size) ? 0 : ceil($total / $page_size), 'current' => $curr_page, 'show_all' => !empty($atts['show_all']));
/**
* @filter `gravityview_page_links_args` Filter the pagination options
* @since 1.1.4
* @param array $page_link_args Array of arguments for the `paginate_links()` function. [Read more about `paginate_links()`](http://developer.wordpress.org/reference/functions/paginate_links/)
*/
$page_link_args = apply_filters('gravityview_page_links_args', $page_link_args);
$page_links = paginate_links($page_link_args);
if (!empty($page_links)) {
$class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
$class = gravityview_sanitize_html_class($class);
echo '<div class="gv-widget-page-links ' . $class . '">' . $page_links . '</div>';
} else {
do_action('gravityview_log_debug', 'GravityView_Widget_Page_Links[render_frontend] No page links; paginate_links() returned empty response.');
}
}
示例4: render_frontend
public function render_frontend($widget_args, $content = '', $context = '')
{
$gravityview_view = GravityView_View::getInstance();
if (!$this->pre_render_frontend()) {
return;
}
if (!empty($widget_args['title'])) {
echo $widget_args['title'];
}
$pagination_counts = $gravityview_view->getPaginationCounts();
$total = $first = $last = null;
$output = '';
if (!empty($pagination_counts)) {
$first = $pagination_counts['first'];
$last = $pagination_counts['last'];
$total = $pagination_counts['total'];
$class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
$class = gravityview_sanitize_html_class($class);
$output = '<div class="gv-widget-pagination ' . $class . '"><p>' . sprintf(__('Displaying %1$s - %2$s of %3$s', 'gravityview'), number_format_i18n($first), number_format_i18n($last), number_format_i18n($total)) . '</p></div>';
}
/**
* @filter `gravityview_pagination_output` Modify the pagination widget output
* @param string $output HTML output
* @param int $first First entry #
* @param int $last Last entry #
* @param int $total Total entries #
*/
echo apply_filters('gravityview_pagination_output', $output, $first, $last, $total);
}
示例5: admin_notice
/**
* Outputs the admin notices generated by the plugin
*
* @uses GVCommon::has_cap()
* @since 1.12
*
* @return void
*/
public function admin_notice()
{
/**
* @filter `gravityview/admin/notices` Modify the notices displayed in the admin
* @since 1.12
*/
$notices = apply_filters('gravityview/admin/notices', self::$admin_notices);
if (empty($notices) || !$this->check_show_multisite_notices()) {
return;
}
//don't display a message if use has dismissed the message for this version
// TODO: Use get_user_meta instead of get_transient
self::$dismissed_notices = isset($_GET['show-dismissed-notices']) ? array() : (array) get_transient('gravityview_dismissed_notices');
$output = '';
foreach ($notices as $notice) {
// If the user doesn't have the capability to see the warning
if (isset($notice['cap']) && false === GVCommon::has_cap($notice['cap'])) {
do_action('gravityview_log_debug', 'Notice not shown because user does not have the capability to view it.', $notice);
continue;
}
if (true === $this->is_notice_dismissed($notice)) {
do_action('gravityview_log_debug', 'Notice not shown because the notice has already been dismissed.', $notice);
continue;
}
$output .= '<div id="message" style="position:relative" class="notice ' . gravityview_sanitize_html_class($notice['class']) . '">';
// Too cute to leave out.
$output .= gravityview_get_floaty();
if (!empty($notice['title'])) {
$output .= '<h3>' . esc_html($notice['title']) . '</h3>';
}
$message = isset($notice['message']) ? $notice['message'] : '';
if (!empty($notice['dismiss'])) {
$dismiss = esc_attr($notice['dismiss']);
$url = esc_url(add_query_arg(array('gv-dismiss' => wp_create_nonce('dismiss'), 'notice' => $dismiss)));
$align = is_rtl() ? 'alignleft' : 'alignright';
$message .= '<a href="' . $url . '" data-notice="' . $dismiss . '" class="' . $align . ' button button-link">' . esc_html__('Dismiss', 'gravityview') . '</a></p>';
}
$output .= wpautop($message);
$output .= '<div class="clear"></div>';
$output .= '</div>';
}
echo $output;
unset($output, $align, $message, $notices);
//reset the notices handler
self::$admin_notices = array();
}
示例6: field_class
/**
* Fetch Field class
*
* @access public
* @static
* @param mixed $field
* @return string
*/
public static function field_class($field, $form = NULL, $entry = NULL)
{
$gravityview_view = GravityView_View::getInstance();
$classes = array();
if (!empty($field['custom_class'])) {
$custom_class = $field['custom_class'];
if (!empty($entry)) {
// We want the merge tag to be formatted as a class. The merge tag may be
// replaced by a multiple-word value that should be output as a single class.
// "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
add_filter('gform_merge_tag_filter', 'sanitize_html_class');
$custom_class = self::replace_variables($custom_class, $form, $entry);
// And then we want life to return to normal
remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
}
// And now we want the spaces to be handled nicely.
$classes[] = gravityview_sanitize_html_class($custom_class);
}
if (!empty($field['id'])) {
if (!empty($form) && !empty($form['id'])) {
$form_id = '-' . $form['id'];
} else {
$form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : '';
}
$classes[] = 'gv-field' . $form_id . '-' . $field['id'];
}
return esc_attr(implode(' ', $classes));
}
示例7: admin_notice
/**
* Outputs the admin notices generated by the plugin
*
* @since 1.12
*
* @return void
*/
public function admin_notice()
{
/**
* Modify the notices displayed
* @since 1.12
*/
$notices = apply_filters('gravityview/admin/notices', self::$admin_notices);
if (empty($notices) || !$this->check_show_multisite_notices()) {
return;
}
//don't display a message if use has dismissed the message for this version
self::$dismissed_notices = isset($_GET['show-dismissed-notices']) ? array() : (array) get_transient('gravityview_dismissed_notices');
foreach ($notices as $notice) {
if (false === $this->_maybe_show_notice($notice)) {
continue;
}
echo '<div id="message" class="notice ' . gravityview_sanitize_html_class($notice['class']) . '">';
// Too cute to leave out.
echo gravityview_get_floaty();
if (!empty($notice['title'])) {
echo '<h3>' . esc_html($notice['title']) . '</h3>';
}
echo wpautop($notice['message']);
if (!empty($notice['dismiss'])) {
$dismiss = esc_attr($notice['dismiss']);
$url = esc_url(add_query_arg(array('gv-dismiss' => wp_create_nonce('dismiss'), 'notice' => $dismiss)));
echo wpautop('<a href="' . $url . '" data-notice="' . $dismiss . '" class="button-small button button-secondary">' . esc_html__('Dismiss', 'gravityview') . '</a>');
}
echo '<div class="clear"></div>';
echo '</div>';
}
//reset the notices handler
self::$admin_notices = array();
}
示例8: merge_field_properties
/**
* Override GF Form field properties with the ones defined on the View
* @param GF_Field $field GF Form field object
* @param array $setting GV field options
* @since 1.5
* @return array
*/
private function merge_field_properties($field, $field_setting)
{
$return_field = $field;
if (empty($field_setting['show_label'])) {
$return_field->label = '';
} elseif (!empty($field_setting['custom_label'])) {
$return_field->label = $field_setting['custom_label'];
}
if (!empty($field_setting['custom_class'])) {
$return_field->cssClass .= ' ' . gravityview_sanitize_html_class($field_setting['custom_class']);
}
/**
* Normalize page numbers - avoid conflicts with page validation
* @since 1.6
*/
$return_field->pageNumber = 1;
return $return_field;
}
示例9: generate_notice
/**
* Display updated/error notice
*
* @param string $notice text/HTML of notice
* @param string $class CSS class for notice (`updated` or `error`)
*
* @return string
*/
public static function generate_notice($notice, $class = '')
{
return '<div class="gv-notice ' . gravityview_sanitize_html_class($class) . '">' . $notice . '</div>';
}
示例10: renderZone
/**
* Render an output zone, as configured in the Admin
*
* @param string $zone The zone name, like 'footer-left'
* @param array $atts
*
* @return string|null
*/
public function renderZone($zone = '', $atts = array())
{
if (empty($zone)) {
do_action('gravityview_log_error', 'GravityView_View[renderZone] No zone defined.');
return NULL;
}
$defaults = array('slug' => $this->getTemplatePartSlug(), 'context' => $this->getContext(), 'entry' => $this->getCurrentEntry(), 'form' => $this->getForm(), 'hide_empty' => $this->getAtts('hide_empty'));
$final_atts = wp_parse_args($atts, $defaults);
$output = '';
$final_atts['zone_id'] = "{$final_atts['context']}_{$final_atts['slug']}-{$zone}";
$fields = $this->getField($final_atts['zone_id']);
// Backward compatibility
if ('table' === $this->getTemplatePartSlug()) {
/**
* Modify the fields displayed in the table
* @var array
*/
$fields = apply_filters("gravityview_table_cells", $fields, $this);
}
if (empty($fields)) {
return NULL;
}
$field_output = '';
foreach ($fields as $field) {
$final_atts['field'] = $field;
$field_output .= gravityview_field_output($final_atts);
}
/**
* If a zone has no field output, choose whether to show wrapper
* False by default to keep backward compatibility
* @since 1.7.6
* @param boolean $hide_empty_zone Default: false
*/
if (empty($field_output) && apply_filters('gravityview/render/hide-empty-zone', false)) {
return NULL;
}
if (!empty($final_atts['wrapper_class'])) {
$output .= '<div class="' . gravityview_sanitize_html_class($final_atts['wrapper_class']) . '">';
}
$output .= $field_output;
if (!empty($final_atts['wrapper_class'])) {
$output .= '</div>';
}
echo $output;
return $output;
}
示例11: get_search_class
/**
* Get the search class for a search form
*
* @since 1.5.4
*
* @return string Sanitized CSS class for the search form
*/
public static function get_search_class($custom_class = '')
{
$gravityview_view = GravityView_View::getInstance();
$search_class = 'gv-search-' . $gravityview_view->search_layout;
if (!empty($custom_class)) {
$search_class .= ' ' . $custom_class;
}
/**
* @filter `gravityview_search_class` Modify the CSS class for the search form
* @param string $search_class The CSS class for the search form
*/
$search_class = apply_filters('gravityview_search_class', $search_class);
// Is there an active search being performed? Used by fe-views.js
$search_class .= GravityView_frontend::getInstance()->isSearch() ? ' gv-is-search' : '';
return gravityview_sanitize_html_class($search_class);
}
示例12: render_widget_hooks
/**
*
* @param $view_id
*/
public function render_widget_hooks($view_id)
{
if (empty($view_id) || 'single' == gravityview_get_context()) {
do_action('gravityview_log_debug', __METHOD__ . ' - Not rendering widgets; single entry');
return;
}
$view_data = gravityview_get_current_view_data($view_id);
// get View widget configuration
$widgets = (array) $view_data['widgets'];
switch (current_filter()) {
default:
case 'gravityview_before':
$zone = 'header';
break;
case 'gravityview_after':
$zone = 'footer';
break;
}
/**
* Filter widgets not in the current zone
* @since 1.16
*/
foreach ($widgets as $key => $widget) {
// The widget isn't in the current zone
if (false === strpos($key, $zone)) {
unset($widgets[$key]);
}
}
/**
* Prevent output if no widgets to show.
* @since 1.16
*/
if (empty($widgets)) {
do_action('gravityview_log_debug', sprintf('No widgets for View #%s', $view_id));
return;
}
// Prevent being called twice
if (did_action($zone . '_' . $view_id . '_widgets')) {
do_action('gravityview_log_debug', sprintf('%s - Not rendering %s; already rendered', __METHOD__, $zone . '_' . $view_id . '_widgets'));
return;
}
$rows = GravityView_Plugin::get_default_widget_areas();
// TODO: Move to sep. method, use an action instead
wp_enqueue_style('gravityview_default_style');
$default_css_class = 'gv-grid gv-widgets-' . $zone;
if (0 === GravityView_View::getInstance()->getTotalEntries()) {
$default_css_class .= ' gv-widgets-no-results';
}
/**
* @filter `gravityview/widgets/wrapper_css_class` The CSS class applied to the widget container `<div>`.
* @since 1.16.2
* @param string $css_class Default: `gv-grid gv-widgets-{zone}` where `{zone}` is replaced by the current `$zone` value. If the View has no results, adds ` gv-widgets-no-results`
* @param string $zone Current widget zone, either `header` or `footer`
* @param array $widgets Array of widget configurations for the current zone, as set by `gravityview_get_current_view_data()['widgets']`
*/
$css_class = apply_filters('gravityview/widgets/wrapper_css_class', $default_css_class, $zone, $widgets);
$css_class = gravityview_sanitize_html_class($css_class);
// TODO Convert to partials
?>
<div class="<?php
echo $css_class;
?>
">
<?php
foreach ($rows as $row) {
foreach ($row as $col => $areas) {
$column = $col == '2-2' ? '1-2 gv-right' : $col . ' gv-left';
?>
<div class="gv-grid-col-<?php
echo esc_attr($column);
?>
">
<?php
if (!empty($areas)) {
foreach ($areas as $area) {
if (!empty($widgets[$zone . '_' . $area['areaid']])) {
foreach ($widgets[$zone . '_' . $area['areaid']] as $widget) {
do_action("gravityview_render_widget_{$widget['id']}", $widget);
}
}
}
}
?>
</div>
<?php
}
// $row
?>
<?php
}
// $rows
?>
</div>
<?php
/**
//.........这里部分代码省略.........
示例13: test_gravityview_sanitize_html_class
/**
* @covers ::gravityview_sanitize_html_class()
*/
public function test_gravityview_sanitize_html_class()
{
$classes = array('example' => gravityview_sanitize_html_class('example'), 'example-dash' => gravityview_sanitize_html_class('example-dash'), 'example dash' => gravityview_sanitize_html_class('example dash'), 'example dash bar' => gravityview_sanitize_html_class(array('example', 'dash', 'bar')), 'example-dash bar' => gravityview_sanitize_html_class(array('example-dash', 'bar')), 'Foo Bar0' => gravityview_sanitize_html_class(array('Foo', 'Bar0')), 'Foo Bar2_-' => gravityview_sanitize_html_class('Foo Bar2!_-'));
foreach ($classes as $expected => $formatted) {
$this->assertEquals($expected, $formatted);
}
}