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


PHP wp_validate_boolean函数代码示例

本文整理汇总了PHP中wp_validate_boolean函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_validate_boolean函数的具体用法?PHP wp_validate_boolean怎么用?PHP wp_validate_boolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: __construct

 public function __construct($args)
 {
     if (!is_array($args)) {
         return;
     }
     $this->post_id = null === $args['post_id'] ? null : (int) $args['post_id'];
     $this->size = isset($args['size']) ? sanitize_key($args['size']) : false;
     $this->crop = isset($args['crop']) ? wp_validate_boolean($args['crop']) : (bool) 0;
     $this->img_class = isset($args['img_class']) ? sanitize_html_class($args['img_class']) : '';
     $this->img_default = isset($args['default']) ? esc_url_raw($args['default']) : '';
     $this->img_src = isset($args['src']) && '' != $args['src'] ? esc_url_raw($args['src']) : '';
     $this->img_src = isset($args['full_src']) ? esc_url_raw($args['full_src']) : $this->img_src;
     $this->direct_src_external = '' != $this->img_src ? $this->img_src : '';
     $this->post = get_post($this->post_id);
     $this->attachment_id = intval(get_post_thumbnail_id($this->post_id));
     if (!is_admin()) {
         $image = $this->thumbnail_meta_data();
         if (0 == $this->attachment_id) {
             $this->attachment_id = $image['attachment_id'];
             if (!is_admin()) {
                 $this->img_src = $image['src'];
             }
             if (-1 == $this->attachment_id) {
                 $this->img_src_ext = $image['src'];
             }
         }
     }
     $this->attachment = get_post($this->attachment_id);
     add_filter('icon_dir', array($this, 'filter_icon_dir'));
 }
开发者ID:Jevuska,项目名称:extended-related-posts,代码行数:30,代码来源:class-extrp-thumbnail.php

示例2: wpqt_factory

/**
 * Instance factory for WP Qiita plugin
 *
 * @since v1.0.0
 *
 * @param boolean $set_global [optional] Default is true
 * @return void
 */
function wpqt_factory($set_global = true)
{
    if (wp_validate_boolean($set_global)) {
        global $wpqt;
        $wpqt = WpQiitaMain::instance();
    } else {
        return WpQiitaMain::instance();
    }
}
开发者ID:ka215,项目名称:wp-qiita,代码行数:17,代码来源:init.php

示例3: playlist_shortcode

 /**
  * Callback for the [_playlist] shortcode
  *
  * @uses wp_validate_boolean() from WordPress 4.0
  */
 public function playlist_shortcode($atts = array(), $content = '')
 {
     global $content_width;
     // Theme dependent content width
     $this->instance++;
     // Counter to activate the 'wp_playlist_scripts' action only once
     $atts = shortcode_atts(array('type' => 'audio', 'style' => 'light', 'tracklist' => 'true', 'tracknumbers' => 'true', 'images' => 'true', 'artists' => 'true', 'current' => 'true', 'autoplay' => 'false', 'class' => 'wpse-playlist', 'width' => '', 'height' => '', 'outer' => '20', 'default_width' => '640', 'default_height' => '380'), $atts, 'wpse_playlist_shortcode');
     // Autoplay:
     $autoplay = wp_validate_boolean($atts['autoplay']) ? 'autoplay="yes"' : '';
     // Nested shortcode support:
     $this->type = in_array($atts['type'], $this->types, TRUE) ? esc_attr($atts['type']) : 'audio';
     // Enqueue default scripts and styles for the playlist.
     1 === $this->instance && do_action('wp_playlist_scripts', esc_attr($atts['type']), esc_attr($atts['style']));
     //----------
     // Height & Width - Adjusted from the WordPress core
     //----------
     $width = esc_attr($atts['width']);
     if (empty($width)) {
         $width = empty($content_width) ? intval($atts['default_width']) : $content_width - intval($atts['outer']);
     }
     $height = esc_attr($atts['height']);
     if (empty($height) && intval($atts['default_height']) > 0) {
         $height = empty($content_width) ? intval($atts['default_height']) : round(intval($atts['default_height']) * $width / intval($atts['default_width']));
     }
     //----------
     // Output
     //----------
     $html = '';
     // Start div container:
     $html .= sprintf('<div class="wp-playlist wp-%s-playlist wp-playlist-%s ' . esc_attr($atts['class']) . '">', $this->type, esc_attr($atts['style']));
     // Current audio item:
     if ($atts['current'] && 'audio' === $this->type) {
         $html .= '<div class="wp-playlist-current-item"></div>';
     }
     // Video player:
     if ('video' === $this->type) {
         $html .= sprintf('<video controls="controls" ' . $autoplay . ' preload="none" width="%s" height="%s"></video>', $width, $height);
     } else {
         $html .= sprintf('<audio controls="controls" ' . $autoplay . ' preload="none" width="%s" style="visibility: hidden"></audio>', $width);
     }
     // Next/Previous:
     $html .= '<div class="wp-playlist-next"></div><div class="wp-playlist-prev"></div>';
     // JSON
     $html .= sprintf('
         <script class="wp-playlist-script" type="application/json">{
             "type":"%s",
             "tracklist":%s,
             "tracknumbers":%s,
             "images":%s,
             "artists":%s,
             "tracks":[%s]
         }</script>', esc_attr($atts['type']), wp_validate_boolean($atts['tracklist']) ? 'true' : 'false', wp_validate_boolean($atts['tracknumbers']) ? 'true' : 'false', wp_validate_boolean($atts['images']) ? 'true' : 'false', wp_validate_boolean($atts['artists']) ? 'true' : 'false', $this->get_tracks_from_content($content));
     // Close div container:
     $html .= '</div>';
     return $html;
 }
开发者ID:dartokloning,项目名称:wpse-playlist,代码行数:61,代码来源:class.playlist.php

示例4: extrp_bail_noimage

function extrp_bail_noimage()
{
    global $extrp_settings, $extrp_sanitize;
    $extrp_noimage = [];
    $args = array('post_id' => null, 'src' => esc_url_raw(EXTRP_URL_PLUGIN_IMAGES . 'default.png'), 'size' => 'thumbnail');
    $thumbnail = extrp_thumbnail($args);
    $extrp_noimage = $thumbnail->attachment_external();
    $output['noimage'] = array('attachment_id' => absint($extrp_noimage['attachment_id']), 'default' => esc_url_raw($extrp_noimage['default']), 'full_src' => esc_url_raw($extrp_noimage['default']), 'size' => $extrp_sanitize->size($extrp_noimage['size']), 'src' => esc_url_raw($extrp_noimage['src']), 'width' => intval($extrp_noimage['width']), 'height' => intval($extrp_noimage['height']), 'crop' => wp_validate_boolean($extrp_noimage['crop']));
    $args = wp_parse_args($output, $extrp_settings);
    return $args;
}
开发者ID:Jevuska,项目名称:extended-related-posts,代码行数:11,代码来源:functions.php

示例5: video

 /**
  * Builds the Video shortcode output.
  *
  * This implements the functionality of the Video Shortcode for displaying
  * WordPress mp4s in a post.
  *
  *
  * @param array  $attr {
  *     Attributes of the shortcode.
  *
  *     @type string $src      URL to the source of the video file. Default empty.
  *     @type int    $height   Height of the video embed in pixels. Default 360.
  *     @type int    $width    Width of the video embed in pixels. Default $content_width or 640.
  *     @type string $poster   The 'poster' attribute for the `<video>` element. Default empty.
  *     @type string $loop     The 'loop' attribute for the `<video>` element. Default empty.
  *     @type string $autoplay The 'autoplay' attribute for the `<video>` element. Default empty.
  *     @type string $preload  The 'preload' attribute for the `<video>` element.
  *                            Default 'metadata'.
  *     @type string $class    The 'class' attribute for the `<video>` element.
  *                            Default 'simple-fb-video-shortcode'.
  * }
  * @param string $content Shortcode content.
  * @return string|void HTML content to display video.
  */
 function video($attr, $content = '')
 {
     /**
      * Filter the default video shortcode output.
      *
      * If the filtered output isn't empty, it will be used instead of generating
      * the default video template.
      *
      * @since 3.6.0
      *
      * @see wp_video_shortcode()
      *
      * @param string $html     Empty variable to be replaced with shortcode markup.
      * @param array  $attr     Attributes of the video shortcode.
      * @param string $content  Video shortcode content.
      */
     $override = apply_filters('simple_fb_video_shortcode_override', '', $attr, $content);
     if ('' !== $override) {
         return $override;
     }
     $video = null;
     $default_types = wp_get_video_extensions();
     $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'width' => 640, 'height' => 360);
     foreach ($default_types as $type) {
         $defaults_atts[$type] = '';
     }
     // Boom, atts.
     $atts = shortcode_atts($defaults_atts, $attr, 'video');
     $primary = false;
     foreach ($default_types as $ext) {
         if (!empty($atts[$ext])) {
             $type = wp_check_filetype($atts[$ext], wp_get_mime_types());
             if (strtolower($type['ext']) === $ext) {
                 $primary = true;
             }
         }
     }
     if (!$primary) {
         $videos = get_attached_media('video', $post_id);
         if (empty($videos)) {
             return;
         }
         $video = reset($videos);
         $atts['src'] = wp_get_attachment_url($video->ID);
         if (empty($atts['src'])) {
             return;
         }
         array_unshift($default_types, 'src');
     }
     $html_atts = array('class' => apply_filters('wp_video_shortcode_class', 'simple-fb-video-shortcode'), 'id' => sprintf('video-%d', $post_id), 'width' => absint($atts['width']), 'height' => absint($atts['height']), 'poster' => esc_url($atts['poster']), 'loop' => wp_validate_boolean($atts['loop']), 'autoplay' => wp_validate_boolean($atts['autoplay']), 'preload' => $atts['preload']);
     // These ones should just be omitted altogether if they are blank
     foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) {
         if (empty($html_atts[$a])) {
             unset($html_atts[$a]);
         }
     }
     $attr_strings = array();
     foreach ($html_atts as $k => $v) {
         $attr_strings[] = $k . '="' . esc_attr($v) . '"';
     }
     $html = '';
     $html .= sprintf('<video %s controls="controls">', join(' ', $attr_strings));
     $fileurl = '';
     $source = '<source type="%s" src="%s" />';
     foreach ($default_types as $fallback) {
         if (!empty($atts[$fallback])) {
             if (empty($fileurl)) {
                 $fileurl = $atts[$fallback];
             }
             if ('src' === $fallback && $is_youtube) {
                 $type = array('type' => 'video/youtube');
             } elseif ('src' === $fallback && $is_vimeo) {
                 $type = array('type' => 'video/vimeo');
             } else {
                 $type = wp_check_filetype($atts[$fallback], wp_get_mime_types());
             }
//.........这里部分代码省略.........
开发者ID:Punkx001,项目名称:Simple-Instant-Articles-for-Facebook,代码行数:101,代码来源:shortcodes.php

示例6: test_string_false_mixedcase

 /**
  * @ticket 30238
  */
 public function test_string_false_mixedcase()
 {
     // Differs from (bool) conversion.
     $this->assertFalse(wp_validate_boolean('FaLsE'));
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:8,代码来源:WpValidateBoolean.php

示例7: get_item_stocks

 /**
  * Retrieve authenticated item stocks
  *
  * @since 1.0.0
  *
  * @param string $item_id [required]
  * @param int $post_id [optional] This processing performance is improved when specified the synchronizing post ID.
  * @return int $stocks
  */
 public function get_item_stocks($item_id = null, $post_id = null)
 {
     $_message_type = $this->message_type['err'];
     $_message = null;
     $stocks = 0;
     if (empty($item_id)) {
         return $stocks;
     }
     if (empty($post_id) || $post_id < 1) {
         $_posts = get_posts(array('numberposts' => -1, 'post_type' => $this->domain_name, 'author' => $this->current_user, 'meta_key' => 'wpqt_item_id', 'meta_value' => $item_id));
         if (!empty($_posts)) {
             $post_id = $_posts[0]->ID;
         }
     }
     if (empty($post_id) || $post_id < 1) {
         return $stocks;
     }
     if ($item_id === get_post_meta($post_id, 'wpqt_item_id', true)) {
         $reference_item_stocks = get_post_meta($post_id, 'wpqt_stocks', true);
     }
     $reference_item_stocks = isset($reference_item_stocks) && wp_validate_boolean($reference_item_stocks) ? intval($reference_item_stocks) : $stocks;
     //$this->token = empty( $this->token ) ? $current_user_meta['access_token'] : $this->token;
     $this->token = empty($this->token) ? $this->user_options['access_token'] : $this->token;
     $start_page = floor($reference_item_stocks / 100);
     $start_page = $start_page > 1 ? $start_page - 1 : 1;
     $stocks = ($start_page - 1) * 100;
     for ($i = $start_page; $i <= 100; $i++) {
         $url = $this->get_api_url(array('items', $item_id, 'stockers'), array('page' => $i, 'per_page' => 100));
         if (method_exists($this, 'request_api')) {
             $request_args = array('method' => 'GET', 'headers' => array('Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . $this->token));
             $response = wp_remote_request($url, $request_args);
             if ($this->validate_response_code($response)) {
                 // Success
                 $_parse_response = json_decode(wp_remote_retrieve_body($response));
                 if (count($_parse_response) > 0) {
                     $stocks += count($_parse_response);
                 } else {
                     break;
                 }
             } else {
                 // Fails
                 break;
             }
         }
     }
     update_post_meta($post_id, 'wpqt_stocks', $stocks);
     return $stocks;
 }
开发者ID:ka215,项目名称:wp-qiita,代码行数:57,代码来源:main.php

示例8: wa_render_shortcode

    /**
     * Renders a shortcode from either AJAX or paramenter and returns rendered html
     * @param string $shortcode shortcode to render
     * @param string $comments
     * @return string html content
     */
    public function wa_render_shortcode($shortcode = false, $comments = false)
    {
        $is_ajax = false;
        if (!$shortcode) {
            $shortcode = stripslashes($_POST['shortcode']);
            $comments = wp_validate_boolean($_POST['comments']);
            $is_ajax = true;
        }
        preg_match('/(?>\\[)([^\\s|^\\]]+)/s', $shortcode, $sub_matches);
        if (!empty($sub_matches) && $sub_matches[1] !== '') {
            $html = ($comments ? '<!-- shortcode -->' : '') . '
					<div
						class="wa-shortcode-wrap"
						data-shortcode-base="' . $sub_matches[1] . '"
						data-shortcode="' . rawurlencode($shortcode) . '">
						' . do_shortcode($shortcode) . '
					</div>
				' . ($comments ? '<!-- /shortcode -->' : '');
        } else {
            $html = '';
        }
        if ($is_ajax) {
            echo $html;
            die;
        } else {
            return $html;
        }
    }
开发者ID:r-a-y,项目名称:wa-fronted,代码行数:34,代码来源:wa-fronted.php

示例9: extract

                  </div>
                </div>
              </div><!-- /.form-horizontal -->

                  </div>
                </div>
              </div>
              
            </div><!-- /.panel-body -->
          </div><!-- /.panel-collapse -->
        </div><!-- /.panel -->
      </div><!-- /#accordion-->
<?php 
    } else {
        // Set defaults
        extract(array('_load_jquery' => isset($_qiita_user_meta['load_jquery']) ? wp_validate_boolean($_qiita_user_meta['load_jquery']) : true, '_show_posttype' => isset($_qiita_user_meta['show_posttype']) ? wp_validate_boolean($_qiita_user_meta['show_posttype']) : false, '_autosync' => isset($_qiita_user_meta['autosync']) ? wp_validate_boolean($_qiita_user_meta['autosync']) : false, '_autosync_interval' => isset($_qiita_user_meta['autosync_interval']) && intval($_qiita_user_meta['autosync_interval']) > 0 ? intval($_qiita_user_meta['autosync_interval']) : '', '_autosync_status' => __('Undefined', $this->domain_name), '_autopost' => isset($_qiita_user_meta['autopost']) ? wp_validate_boolean($_qiita_user_meta['autopost']) : false, '_remove_post' => isset($_qiita_user_meta['remove_post']) ? wp_validate_boolean($_qiita_user_meta['remove_post']) : false, '_deactivate_qiita' => isset($_qiita_user_meta['deactivate_qiita']) ? wp_validate_boolean($_qiita_user_meta['deactivate_qiita']) : false));
        foreach ($this->options as $_key => $_val) {
            $_[$_key] = $_val;
        }
        if (isset($this->options['autosync_datetime']) && !empty($this->options['autosync_datetime'])) {
            $_timezone = get_option('timezone_string');
            date_default_timezone_set($_timezone);
            $_next_autosync = date_i18n('Y-m-d H:i', $this->options['autosync_datetime'], false);
            $_autosync_status = sprintf(__('Next autosync will be executed at %s.', $this->domain_name), '<time>' . $_next_autosync . '</time>');
        }
        ?>
      <h3 class="text-success"><?php 
        _e('Currently, already Activated.', $this->domain_name);
        ?>
</h3>
      
开发者ID:ka215,项目名称:wp-qiita,代码行数:30,代码来源:wp-qiita-options.php

示例10: create_page

 /**
  * create admin plugin page
  *
  * @since 1.1
  *
  */
 public function create_page()
 {
     global $stt2extat_screen_id, $current_screen;
     if ($current_screen->id != $stt2extat_screen_id) {
         return;
     }
     add_filter('admin_footer_text', array($this, 'admin_footer_text'));
     add_filter('update_footer', array($this, 'update_footer'), 20);
     $error = false;
     if (isset($_REQUEST['message']) && ($code = (int) $_REQUEST['message'])) {
         $error = isset($_GET['error']) ? wp_validate_boolean($_GET['error']) : $error;
         do_action('stt2extat_notice', $code, $error, $add_setting_error = false);
     }
     $_SERVER['REQUEST_URI'] = remove_query_arg(array('message', 'error'), $_SERVER['REQUEST_URI']);
     $this->create_mb();
 }
开发者ID:Jevuska,项目名称:stt2-extension-add-terms,代码行数:22,代码来源:class-stt2extat-admin.php

示例11: ajx_noimg_view_cb

 public function ajx_noimg_view_cb()
 {
     global $extrp_sanitize, $extrp_screen_id;
     if (!wp_verify_nonce($_REQUEST['nonce'], 'heartbeat-nonce') || !check_ajax_referer('heartbeat-nonce', 'nonce', false)) {
         $noperm = array('result' => array('msg' => __('You do not have permission to do that.', 'extrp'), 'tokenid' => (int) 3));
         $msg = wp_json_encode($noperm);
         wp_die($msg);
     }
     if (isset($_POST['chk']) && 'settings_page_extrp' == sanitize_key($_POST['chk'])) {
         $thumb = $extrp_sanitize->data_thumb(array('size' => $extrp_sanitize->size($_POST['size']), 'src' => esc_url($_POST['src']), 'crop' => wp_validate_boolean($_POST['crop'])));
         if (!$thumb) {
             $fail = array('result' => array('msg' => __('Fail to generate image. Refresh your page and try again.', 'extrp'), 'tokenid' => (int) 2));
             $msg = wp_json_encode($fail);
             wp_die($msg);
         }
         if (!$thumb['src']) {
             $noperm = array('result' => array('msg' => __('Image not exists. Please check your image from media library. You can add new one or push &#39;Save Changes&#39; button to get default image directly.', 'extrp'), 'tokenid' => (int) 4));
             $msg = wp_json_encode($noperm);
             wp_die($msg);
         }
         $success = array('result' => array('title' => get_the_title(intval($_POST['attach_id'])), 'src' => esc_url($_POST['src']), 'thumbnail' => esc_url($thumb['src']), 'size' => sanitize_key($thumb['size']), 'width' => intval($thumb['width']), 'height' => intval($thumb['height']), 'crop' => wp_validate_boolean($thumb['crop']), 'shape' => $extrp_sanitize->shape($_POST['shape']), 'msg' => __('Success', 'extrp'), 'tokenid' => (int) 1));
         $result = wp_json_encode($success);
         wp_die($result);
     } else {
         $noperm = array('result' => array('msg' => __('You do not have permission to do that.', 'extrp'), 'tokenid' => (int) 3));
         $msg = wp_json_encode($noperm);
         wp_die($msg);
     }
 }
开发者ID:Jevuska,项目名称:extended-related-posts,代码行数:29,代码来源:class-extrp-admin.php

示例12: wp_playlist_shortcode

 /**
  * Builds the Playlist shortcode output.
  *
  * This implements the functionality of the playlist shortcode for
  * displaying a collection of WordPress audio or video files in a
  * post.
  *
  * This method is based on the WordPress core function
  * `wp_playlist_shortcode` but has been modified to add VTT data.
  *
  * @param array $attr {
  *     Array of default playlist attributes.
  *
  *     @type string  $type         Type of playlist to display. Accepts 'audio' or 'video'. Default 'audio'.
  *     @type string  $order        Designates ascending or descending order of items in the playlist.
  *                                 Accepts 'ASC', 'DESC'. Default 'ASC'.
  *     @type string  $orderby      Any column, or columns, to sort the playlist. If $ids are
  *                                 passed, this defaults to the order of the $ids array ('post__in').
  *                                 Otherwise default is 'menu_order ID'.
  *     @type int     $id           If an explicit $ids array is not present, this parameter
  *                                 will determine which attachments are used for the playlist.
  *                                 Default is the current post ID.
  *     @type array   $ids          Create a playlist out of these explicit attachment IDs. If empty,
  *                                 a playlist will be created from all $type attachments of $id.
  *                                 Default empty.
  *     @type array   $exclude      List of specific attachment IDs to exclude from the playlist. Default empty.
  *     @type string  $style        Playlist style to use. Accepts 'light' or 'dark'. Default 'light'.
  *     @type bool    $tracklist    Whether to show or hide the playlist. Default true.
  *     @type bool    $tracknumbers Whether to show or hide the numbers next to entries in the playlist. Default true.
  *     @type bool    $images       Show or hide the video or audio thumbnail (Featured Image/post
  *                                 thumbnail). Default true.
  *     @type bool    $artists      Whether to show or hide artist name in the playlist. Default true.
  * }
  * @return string Playlist output. Empty string if the passed type is unsupported.
  * @since 1.3.0
  * @global int $content_width
  * @staticvar int $instance
  * @see wp_playlist_shortcode
  */
 function wp_playlist_shortcode($attr)
 {
     static $instance = 0;
     $instance++;
     if (!empty($attr['ids'])) {
         $attr['include'] = $attr['ids'];
         // 'ids' is explicitly ordered, unless you specify otherwise.
         if (empty($attr['orderby'])) {
             $attr['orderby'] = 'post__in';
         }
     }
     $output = apply_filters('post_playlist', '', $attr, $instance);
     if ('' !== $output) {
         return $output;
     }
     unset($output);
     $atts = shortcode_atts(array('type' => 'audio', 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => get_the_ID() ?: 0, 'include' => '', 'exclude' => '', 'style' => 'light', 'tracklist' => true, 'tracknumbers' => true, 'images' => true, 'artists' => true), $attr, 'playlist');
     if ('audio' !== $atts['type']) {
         $atts['type'] = 'video';
     }
     $args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => $atts['type'], 'order' => $atts['order'], 'orderby' => $atts['orderby']);
     if ('' !== $atts['include']) {
         $args['include'] = $atts['include'];
     } else {
         $args['post_parent'] = intval($atts['id']);
         if ('' !== $atts['exclude']) {
             $args['exclude'] = $atts['exclude'];
         }
     }
     if (!($attachments = get_posts($args))) {
         return '';
     }
     if (is_feed()) {
         ob_start();
         echo "\n";
         foreach ($attachments as $a) {
             echo wp_get_attachment_link($a->ID), "\n";
         }
         return ob_get_clean();
     }
     $outer = 22;
     // default padding and border of wrapper
     global $content_width;
     $default_width = 640;
     $default_height = 360;
     $theme_width = empty($content_width) ? $default_width : $content_width - $outer;
     $theme_height = empty($content_width) ? $default_height : round($default_height * $theme_width / $default_width);
     ob_start();
     if (1 === $instance) {
         do_action('wp_playlist_scripts', $atts['type'], $atts['style']);
     }
     echo '<div class="wp-playlist wp-', $atts['type'], '-playlist wp-playlist-', esc_attr($atts['style']), '">';
     if ('audio' === $atts['type']) {
         echo '<div class="wp-playlist-current-item"></div><audio';
     } else {
         echo '<video height="', $theme_height, '"';
     }
     echo ' controls="controls" preload="none" width="', $theme_width, '">', '</', $atts['type'], '>';
     echo '<div class="wp-playlist-next"></div>', '<div class="wp-playlist-prev"></div>', '<noscript>', '<ol>';
     $atts['images'] = wp_validate_boolean($atts['images']);
     $tracks = array();
//.........这里部分代码省略.........
开发者ID:bobbywalters,项目名称:webvtt,代码行数:101,代码来源:class-webvtt.php

示例13: wp_bc_bool

/**
 * Convert string to boolean
 *
 * @since   0.2.1
 * @param   string  $value  Value to validate. Default: false.
 * @return  bool            True or false.
 */
function wp_bc_bool($value = false)
{
    if (function_exists('wp_validate_boolean')) {
        return wp_validate_boolean($value);
    }
    return filter_var($value, FILTER_VALIDATE_BOOLEAN);
}
开发者ID:dimiske,项目名称:gaastra,代码行数:14,代码来源:wp-bootstrap-carousel.php

示例14: sanitize

 public function sanitize($input)
 {
     $new_input = array();
     $keys = array_keys($this->default_setting);
     if (isset($input['activate']) && wp_validate_boolean($input['activate'])) {
         if ('' == sanitize_user($input['aff'])) {
             $msg = __('Your affiliate ID still empty. Try to add yours.', 'klikbayi');
             $flag = 'error';
             $new_input = false;
         } else {
             if ('' !== sanitize_user($this->options['aff'])) {
                 $text = __('Your Affiliate ID was added.', 'klikbayi');
                 $msg = $text . $this->options['aff'];
                 $flag = 'notice-warning';
                 $new_input = false;
             } else {
                 $text = __('Success to add your affiliate ID.', 'klikbayi');
                 $msg = $text . '<kbd>' . sanitize_user($input['aff']) . '</kbd>';
                 $flag = 'updated';
                 $input['active'] = (bool) 1;
                 $new_input = wp_parse_args($input, $this->default_setting);
             }
         }
         add_settings_error('klikbayi-notices', 'active-notice', $msg, esc_attr($flag));
         return $this->validate->sanitize($new_input);
     }
     if (isset($input['reset']) && 'Reset' == sanitize_text_field($input['reset'])) {
         $new_input = wp_parse_args(array('active' => (bool) 1, 'aff' => sanitize_user($this->options['aff'])), $this->default_setting);
         $msg = __('Success to reset your data.', 'klikbayi');
         add_settings_error('klikbayi-notices', 'reset-notice', $msg, 'updated');
         return $new_input;
     }
     if (isset($input['size_1']) || isset($input['size_2'])) {
         $input['size'] = array(absint($input['size_1']), absint($input['size_2']), 'px' == sanitize_text_field($input['size_3']) ? 'px' : '%%');
     }
     foreach ($keys as $k) {
         $new_input[$k] = $input[$k];
     }
     return $this->validate->sanitize($new_input);
 }
开发者ID:Jevuska,项目名称:marketing-tool-for-klikbayi-affiliate,代码行数:40,代码来源:class-klikbayi-admin.php

示例15: get_current_url

 /**
  * Get the URL of the current page with the full path
  *
  * @since 1.0.0
  *
  * @param boolean $absolute [required] Default is TRUE
  * @return string $url
  */
 public function get_current_url($absolute = true)
 {
     if ($_SERVER['SERVER_PROTOCOL']) {
         list($scheme, ) = explode('/', $_SERVER['SERVER_PROTOCOL']);
     }
     if ($_SERVER['HTTP_HOST']) {
         $hostname = $_SERVER['HTTP_HOST'];
     }
     if ($_SERVER['REQUEST_URI']) {
         $request_uri = $_SERVER['REQUEST_URI'];
     } else {
         if ($_SERVER['PHP_SELF'] && $_SERVER['QUERY_STRING']) {
             $request_uri = $_SERVER['PHP_SELF'] . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
         }
     }
     if (wp_validate_boolean($absolute)) {
         $_host = isset($scheme) && !empty($scheme) && isset($hostname) && !empty($hostname) ? strtolower($scheme) . '://' . $hostname : site_url();
         $url = rtrim($_host, '/') . $request_uri;
     } else {
         $url = $request_uri;
     }
     return $url;
 }
开发者ID:ka215,项目名称:wp-qiita,代码行数:31,代码来源:utils.php


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