• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_status_header_desc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: table_test

 /**
  * Check authentication and do update
  *
  */
 public function table_test()
 {
     if (!defined('DOING_AJAX') && $this->has_auth()) {
         // Grab all config file and test them.
         $config_files = glob($this->get_config_dir() . '/db/*.php');
         if (!empty($config_files)) {
             try {
                 $messages = [];
                 foreach ($config_files as $file) {
                     $message = $this->db_update($file);
                     if (!empty($message)) {
                         $messages[] = $message;
                     }
                 }
                 if (!empty($messages)) {
                     add_action('admin_notices', function () use($messages) {
                         printf('<div class="updated">%s</div>', implode('', array_map(function ($message) {
                             return sprintf('<p>%s</p>', $message);
                         }, $messages)));
                     });
                 }
             } catch (\Exception $e) {
                 wp_die(sprintf('[DB Error] Failed to parse DB configs: ' . $e->getMessage()), get_status_header_desc(500), ['response' => 500]);
             }
         }
     }
 }
开发者ID:hametuha,项目名称:wpametu,代码行数:31,代码来源:TableBuilder.php


示例2: fetch_remote_file

function fetch_remote_file($url, $post)
{
    global $url_remap;
    // extract the file name and extension from the url
    $file_name = basename($url);
    // get placeholder file in the upload dir with a unique, sanitized filename
    $upload = wp_upload_bits($file_name, 0, '', $post['upload_date']);
    if ($upload['error']) {
        return new WP_Error('upload_dir_error', $upload['error']);
    }
    // fetch the remote url and write it to the placeholder file
    $headers = wp_get_http($url, $upload['file']);
    // request failed
    if (!$headers) {
        @unlink($upload['file']);
        return new WP_Error('import_file_error', __('Remote server did not respond', 'wordpress-importer'));
    }
    // make sure the fetch was successful
    if ($headers['response'] != '200') {
        @unlink($upload['file']);
        return new WP_Error('import_file_error', sprintf(__('Remote server returned error response %1$d %2$s', 'wordpress-importer'), esc_html($headers['response']), get_status_header_desc($headers['response'])));
    }
    $filesize = filesize($upload['file']);
    if (isset($headers['content-length']) && $filesize != $headers['content-length']) {
        @unlink($upload['file']);
        return new WP_Error('import_file_error', __('Remote file is incorrect size', 'wordpress-importer'));
    }
    if (0 == $filesize) {
        @unlink($upload['file']);
        return new WP_Error('import_file_error', __('Zero size file downloaded', 'wordpress-importer'));
    }
    // keep track of the old and new urls so we can substitute them later
    $url_remap[$url] = $upload['url'];
    return $upload;
}
开发者ID:centroculturalsp,项目名称:cultural,代码行数:35,代码来源:importimages.php


示例3: test_http_response_code_constants

 /**
  * @ticket 35426
  */
 public function test_http_response_code_constants()
 {
     global $wp_header_to_desc;
     $ref = new ReflectionClass('WP_Http');
     $constants = $ref->getConstants();
     // This primes the `$wp_header_to_desc` global:
     get_status_header_desc(200);
     $this->assertEquals(array_keys($wp_header_to_desc), array_values($constants));
 }
开发者ID:pbearne,项目名称:contrib2core,代码行数:12,代码来源:http.php


示例4: load_view

 /**
  * @param array $template
  * @param mixed $query
  * @param int $status_code
  * @param bool $tparams
  * @return bool
  */
 public static function load_view($template, $query = false, $status_code = 200, $tparams = false)
 {
     $fullPath = is_readable($template);
     if (!$fullPath) {
         $template = locate_template($template);
     }
     if ($tparams) {
         global $params;
         $params = $tparams;
     }
     if ($status_code) {
         add_filter('status_header', function ($status_header, $header, $text, $protocol) use($status_code) {
             $text = get_status_header_desc($status_code);
             $header_string = "{$protocol} {$status_code} {$text}";
             return $header_string;
         }, 10, 4);
         if (404 != $status_code) {
             add_action('parse_query', function ($query) {
                 if ($query->is_main_query()) {
                     $query->is_404 = false;
                 }
             }, 1);
             add_action('template_redirect', function () {
                 global $wp_query;
                 $wp_query->is_404 = false;
             }, 1);
         }
     }
     if ($query) {
         add_action('do_parse_request', function () use($query) {
             global $wp;
             if (is_callable($query)) {
                 $query = call_user_func($query);
             }
             if (is_array($query)) {
                 $wp->query_vars = $query;
             } elseif (!empty($query)) {
                 parse_str($query, $wp->query_vars);
             } else {
                 return true;
             }
             // Could not interpret query. Let WP try.
             return false;
         });
     }
     if ($template) {
         add_filter('template_include', function ($t) use($template) {
             return $template;
         });
         return true;
     }
     return false;
 }
开发者ID:aauroux,项目名称:timber,代码行数:60,代码来源:timber-routes.php


示例5: addHeader

 public function addHeader($status_header)
 {
     global $clmvc_http_code;
     if ($clmvc_http_code) {
         header_remove('X-Powered-By');
         header_remove('X-Pingback');
         header_remove('Pragma');
         $description = get_status_header_desc($clmvc_http_code);
         $protocol = 'HTTP/1.0';
         $status_header = "{$protocol} {$clmvc_http_code} {$description}";
     }
     return $status_header;
 }
开发者ID:ArtOfWP,项目名称:CloudLess,代码行数:13,代码来源:WpEngine.php


示例6: findById

 public static function findById($app, $taxonomy_name, $id)
 {
     $taxonomy = Taxonomies::findById($app, $taxonomy_name);
     $term = self::model()->findById($taxonomy_name, $id);
     if (!$term) {
         $app->halt('404', get_status_header_desc('404'));
     }
     if ($lastModified = apply_filters('thermal_term_last_modified', false)) {
         $app->lastModified(strtotime($lastModified . ' GMT'));
     }
     self::format($term, 'read');
     return $term;
 }
开发者ID:katymdc,项目名称:thermal-api,代码行数:13,代码来源:Terms.php


示例7: wp_redirect_status

 /**
  * wp_redirect_status()
  *
  * @param int $status_code
  * @return int $status_code
  **/
 static function wp_redirect_status($status_code)
 {
     $text = get_status_header_desc($status_code);
     $protocol = $_SERVER["SERVER_PROTOCOL"];
     if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) {
         $protocol = 'HTTP/1.0';
     }
     $status_header = "{$protocol} {$status_code} {$text}";
     if (function_exists('apply_filters')) {
         $status_header = apply_filters('status_header', $status_header, $status_code, $text, $protocol);
     }
     return $status_code;
 }
开发者ID:semiologic,项目名称:sem-cache,代码行数:19,代码来源:static-cache.php


示例8: preprocess_comment_submit

 /**
  * Check comment stability
  *
  * @param int $comment_post_ID
  */
 public function preprocess_comment_submit($comment_post_ID)
 {
     if (!is_user_logged_in() && $this->is_thread(get_post_type($comment_post_ID)) && $this->input->verify_nonce('nichan_comment', '_nichancommentnonce')) {
         $recaptcha = $this->recaptcha->verify($this->option->recaptcha_priv_key, $this->input->post('g-recaptcha-response'), $this->input->remote_ip());
         if (!$recaptcha || is_wp_error($recaptcha)) {
             // This is anonymous comment.
             wp_die(__('Anonimous comment requires spam check of reCAPTCHA', '2ch'), get_status_header_desc(401) . ' | ' . get_bloginfo('name'), array('back_link' => true, 'response' => 401));
         } else {
             // Set current user as Anonymous user.
             wp_set_current_user($this->option->post_as);
         }
     }
 }
开发者ID:hametuha,项目名称:2ch,代码行数:18,代码来源:Comment.php


示例9: findById

 public static function findById($app, $id)
 {
     if (($list_users_cap = self::get_list_users_cap()) && !current_user_can($list_users_cap) && $id !== get_current_user_id()) {
         $app->halt('403', get_status_header_desc('403'));
     }
     $model = self::model();
     $user = $model->findById($id);
     if (!$user) {
         $user->halt('404', get_status_header_desc('404'));
     }
     self::format($user, 'read');
     return $user;
 }
开发者ID:katymdc,项目名称:thermal-api,代码行数:13,代码来源:Users.php


示例10: __construct

 /**
  * Constructor
  *
  * @param array $setting
  */
 public function __construct(array $setting = [])
 {
     try {
         $this->test_setting($setting);
         $setting = $this->parse_args($setting);
         $this->setting = $setting;
     } catch (\Exception $e) {
         if (headers_sent()) {
             // Header sent.
             printf('<div class="error"><p>%s</p></div>', $e->getMessage());
         } else {
             // Header didn't sent
             wp_die($e->getMessage(), get_status_header_desc($e->getCode()), ['response' => $e->getCode(), 'back_link' => true]);
         }
     }
 }
开发者ID:hametuha,项目名称:wpametu,代码行数:21,代码来源:Base.php


示例11: findById

 public static function findById($app, $id)
 {
     $taxonomy = self::model()->findById($id);
     if (!$taxonomy) {
         $app->halt('404', get_status_header_desc('404'));
     }
     if (!$taxonomy->public) {
         if (is_user_logged_in()) {
             if (!current_user_can($taxonomy->cap->manage_terms, $taxonomy->ID)) {
                 $app->halt('403', get_status_header_desc('403'));
             }
         } else {
             $app->halt('401', get_status_header_desc('401'));
         }
     }
     self::format($taxonomy, 'read');
     return $taxonomy;
 }
开发者ID:katymdc,项目名称:thermal-api,代码行数:18,代码来源:Taxonomies.php


示例12: get_item

 /**
  * Callback for the API endpoint.
  *
  * Returns the JSON object for the post.
  *
  * @since 4.4.0
  *
  * @param WP_REST_Request $request Full data about the request.
  * @return WP_Error|array oEmbed response data or WP_Error on failure.
  */
 public function get_item($request)
 {
     $post_id = url_to_postid($request['url']);
     /**
      * Filter the determined post ID.
      *
      * @since 4.4.0
      *
      * @param int    $post_id The post ID.
      * @param string $url     The requested URL.
      */
     $post_id = apply_filters('oembed_request_post_id', $post_id, $request['url']);
     $data = get_oembed_response_data($post_id, $request['maxwidth']);
     if (!$data) {
         return new WP_Error('oembed_invalid_url', get_status_header_desc(404), array('status' => 404));
     }
     return $data;
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:28,代码来源:class-wp-oembed-controller.php


示例13: setupStatusCode

 /**
  * @param int    $status   Http status code
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 private function setupStatusCode($status)
 {
     add_filter('status_header', function ($statusHeader, $header, $text, $protocol) use($status) {
         $text = get_status_header_desc($status);
         $header = "{$protocol} {$status} {$text}";
         return $header;
     }, 10, 4);
     if ($status == 404) {
         return;
     }
     add_action('parse_query', function ($query) {
         if ($query->is_main_query()) {
             $query->is_404 = false;
         }
     });
     add_action('template_redirect', function () {
         global $wp_query;
         $wp_query->is_404 = false;
     });
 }
开发者ID:carboncreative,项目名称:carbon-router-wordpress,代码行数:24,代码来源:Routing.php


示例14: findById

 public static function findById($app, $id)
 {
     $post = self::model()->findById($id);
     if (!$post) {
         $app->halt('404', get_status_header_desc('404'));
     }
     $post_type_obj = get_post_type_object(get_post_type($post));
     $post_status_obj = get_post_status_object(get_post_status($post));
     if (is_user_logged_in()) {
         if (!current_user_can($post_type_obj->cap->read, $post->ID)) {
             $app->halt('403', get_status_header_desc('403'));
         }
     } elseif (!($post_type_obj->public && $post_status_obj->public)) {
         $app->halt('401', get_status_header_desc('401'));
     }
     if ($lastModified = apply_filters('thermal_post_last_modified', $post->post_modified_gmt)) {
         $app->lastModified(strtotime($lastModified . ' GMT'));
     }
     self::format($post, 'read');
     return $post;
 }
开发者ID:katymdc,项目名称:thermal-api,代码行数:21,代码来源:Posts.php


示例15: convert_request

 /**
  * Filter and validate the parameters that will be passed to the model.
  * @param array $request_args
  * @return array
  */
 protected static function convert_request($request_args)
 {
     // Remove any args that are not allowed by the API
     $request_filters = array('before' => array(), 'after' => array(), 's' => array(), 'paged' => array(), 'per_page' => array('\\intval'), 'offset' => array('\\intval'), 'orderby' => array(), 'order' => array(), 'in' => array('\\Voce\\Thermal\\v1\\toArray', '\\Voce\\Thermal\\v1\\applyInt'), 'parent' => array('\\intval'), 'post_id' => array('\\intval'), 'post_name' => array(), 'type' => array(), 'status' => array(), 'user_id' => array('\\intval'), 'include_found' => array('\\Voce\\Thermal\\v1\\toBool'));
     //strip any nonsafe args
     $request_args = array_intersect_key($request_args, $request_filters);
     //run through basic sanitation
     foreach ($request_args as $key => $value) {
         foreach ($request_filters[$key] as $callback) {
             $value = call_user_func($callback, $value);
         }
         $request_args[$key] = $value;
     }
     //make sure per_page is below MAX
     if (!empty($request_args['per_page'])) {
         if (absint($request_args['per_page']) > \Voce\Thermal\v1\MAX_TERMS_PER_PAGE) {
             $request_args['per_page'] = \Voce\Thermal\v1\MAX_COMMENTS_PER_PAGE;
         } else {
             $request_args['per_page'] = absint($request_args['per_page']);
         }
     }
     //filter status by user privelages
     if (isset($request_args['status']) && $request_args['status'] !== 'approve') {
         if (is_user_logged_in()) {
             if (!current_user_can('moderate_comments')) {
                 $app->halt('403', get_status_header_desc('403'));
             }
         } else {
             $app->halt('401', get_status_header_desc('401'));
         }
     }
     if (!empty($request_args['per_page']) && $request_args['per_page'] > \Voce\Thermal\v1\MAX_POSTS_PER_PAGE) {
         $request_args['per_page'] = \Voce\Thermal\v1\MAX_POSTS_PER_PAGE;
     }
     if (!empty($request_args['paged']) && !isset($request_args['include_found'])) {
         $request_args['include_found'] = true;
     }
     return $request_args;
 }
开发者ID:katymdc,项目名称:thermal-api,代码行数:44,代码来源:Comments.php


示例16: status_header

/**
 * Set HTTP status header.
 *
 * @since 2.0.0
 *
 * @see get_status_header_desc()
 *
 * @param int $code HTTP status code.
 */
function status_header($code)
{
    $description = get_status_header_desc($code);
    if (empty($description)) {
        return;
    }
    $protocol = $_SERVER['SERVER_PROTOCOL'];
    if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) {
        $protocol = 'HTTP/1.0';
    }
    $status_header = "{$protocol} {$code} {$description}";
    if (function_exists('apply_filters')) {
        /**
         * Filter an HTTP status header.
         *
         * @since 2.2.0
         *
         * @param string $status_header HTTP status header.
         * @param int    $code          HTTP status code.
         * @param string $description   Description for the status code.
         * @param string $protocol      Server protocol.
         */
        $status_header = apply_filters('status_header', $status_header, $code, $description, $protocol);
    }
    @header($status_header, true, $code);
}
开发者ID:hpilevar,项目名称:WordPress,代码行数:35,代码来源:functions.php


示例17: status_header

/**
 * Set HTTP status header.
 *
 * @since 2.0.0
 * @since 4.4.0 Added the `$description` parameter.
 *
 * @see get_status_header_desc()
 *
 * @param int    $code        HTTP status code.
 * @param string $description Optional. A custom description for the HTTP status.
 */
function status_header($code, $description = '')
{
    if (!$description) {
        $description = get_status_header_desc($code);
    }
    if (empty($description)) {
        return;
    }
    $protocol = wp_get_server_protocol();
    $status_header = "{$protocol} {$code} {$description}";
    if (function_exists('apply_filters')) {
        /**
         * Filter an HTTP status header.
         *
         * @since 2.2.0
         *
         * @param string $status_header HTTP status header.
         * @param int    $code          HTTP status code.
         * @param string $description   Description for the status code.
         * @param string $protocol      Server protocol.
         */
        $status_header = apply_filters('status_header', $status_header, $code, $description, $protocol);
    }
    @header($status_header, true, $code);
}
开发者ID:nissuk,项目名称:WordPress,代码行数:36,代码来源:functions.php


示例18: status_header

/**
 * status_header
 * Set HTTP status header from status code
 * @Inspired from WordPress
 */
function status_header($code)
{
    $desc = get_status_header_desc($code);
    if (empty($desc)) {
        return false;
    }
    $protocol = $_SERVER['SERVER_PROTOCOL'];
    if ('HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol) {
        $protocol = 'HTTP/1.0';
    }
    $status_header = "{$protocol} {$code} {$desc}";
    return @header($status_header, true, $code);
}
开发者ID:JJaicmkmy,项目名称:Chevereto,代码行数:18,代码来源:functions.php


示例19: fetch_remote_file

 function fetch_remote_file($post, $url)
 {
     add_filter('http_request_timeout', array(&$this, 'bump_request_timeout'));
     $upload = wp_upload_dir($post['post_date']);
     // extract the file name and extension from the url
     $file_name = basename($url);
     // get placeholder file in the upload dir with a unique sanitized filename
     $upload = wp_upload_bits($file_name, 0, '', $post['post_date']);
     if ($upload['error']) {
         echo $upload['error'];
         return new WP_Error('upload_dir_error', $upload['error']);
     }
     // fetch the remote url and write it to the placeholder file
     $headers = wp_get_http($url, $upload['file']);
     //Request failed
     if (!$headers) {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', __('Remote server did not respond', 'wordpress-importer'));
     }
     // make sure the fetch was successful
     if ($headers['response'] != '200') {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', sprintf(__('Remote file returned error response %1$d %2$s', 'wordpress-importer'), $headers['response'], get_status_header_desc($headers['response'])));
     } elseif (isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length']) {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', __('Remote file is incorrect size', 'wordpress-importer'));
     }
     $max_size = $this->max_attachment_size();
     if (!empty($max_size) and filesize($upload['file']) > $max_size) {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', sprintf(__('Remote file is too large, limit is %s', size_format($max_size), 'wordpress-importer')));
     }
     // keep track of the old and new urls so we can substitute them later
     $this->url_remap[$url] = $upload['url'];
     $this->url_remap[$post['guid']] = $upload['url'];
     // if the remote url is redirected somewhere else, keep track of the destination too
     if ($headers['x-final-location'] != $url) {
         $this->url_remap[$headers['x-final-location']] = $upload['url'];
     }
     return $upload;
 }
开发者ID:nishant368,项目名称:newlifeoffice-new,代码行数:41,代码来源:class.wordpress_importer.php


示例20: wpcf_fields_image_get_remote

/**
 * Fetches remote images.
 *
 * @param type $url
 * @return \WP_Error
 */
function wpcf_fields_image_get_remote($url)
{
    global $wpcf;
    $refresh = false;
    // Set directory
    $cache_dir = wpcf_fields_image_get_cache_directory();
    if (is_wp_error($cache_dir)) {
        return $cache_dir;
    }
    // Validate image
    $extension = pathinfo($url, PATHINFO_EXTENSION);
    if (!in_array(strtolower($extension), wpcf_fields_image_valid_extension())) {
        return new WP_Error('wpcf_image_cache_not_valid', sprintf(__('Image %s not valid', 'wpcf'), $url));
    }
    $image = $cache_dir . md5($url) . '.' . $extension;
    // Refresh if necessary
    $refresh_time = intval(wpcf_get_settings('images_remote_cache_time'));
    if ($refresh_time != 0 && file_exists($image)) {
        $time_modified = filemtime($image);
        if (time() - $time_modified > $refresh_time * 60 * 60) {
            $refresh = true;
            $files = glob($cache_dir . DIRECTORY_SEPARATOR . md5($url) . "-*");
            if ($files) {
                foreach ($files as $filename) {
                    @unlink($filename);
                }
            }
        }
    }
    // Check if image is fetched
    if ($refresh || !file_exists($image)) {
        // fetch the remote url and write it to the placeholder file
        add_filter('http_request_timeout', 'wpcf_image_http_request_timeout', 10, 1);
        $resp = wp_safe_remote_get($url);
        // Check if response type is expected
        if (is_object($resp)) {
            return new WP_Error('wpcf_image_cache_file_error', sprintf(__('Remote server returned error response %1$d %2$s', 'wpcf'), esc_html($resp->errors["http_request_failed"][0]), get_status_header_desc($resp->errors["http_request_failed"][0])));
        }
        remove_filter('http_request_timeout', 'wpcf_image_http_request_timeout', 10, 1);
        // make sure the fetch was successful
        if ($resp['response']['code'] != '200') {
            return new WP_Error('wpcf_image_cache_file_error', sprintf(__('Remote server returned error response %1$d %2$s', 'wpcf'), esc_html($resp['response']), get_status_header_desc($resp['response'])));
        }
        if (!isset($resp['headers']['content-length']) || strlen($resp['body']) != $resp['headers']['content-length']) {
            return new WP_Error('wpcf_image_cache_file_error', __('Remote file is incorrect size', 'wpcf'));
        }
        $out_fp = fopen($image, 'w');
        if (!$out_fp) {
            return new WP_Error('wpcf_image_cache_file_error', __('Could not create cache file', 'wpcf'));
        }
        fwrite($out_fp, $resp['body']);
        fclose($out_fp);
        $max_size = (int) apply_filters('import_attachment_size_limit', 0);
        $filesize = filesize($image);
        if (!empty($max_size) && $filesize > $max_size) {
            @unlink($image);
            return new WP_Error('wpcf_image_cache_file_error', sprintf(__('Remote file is too large, limit is %s', 'wpcf'), size_format($max_size)));
        }
    }
    return array('abspath' => $image, 'relpath' => wpcf_image_attachment_url($image));
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:67,代码来源:image.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_status_list函数代码示例发布时间:2022-05-15
下一篇:
PHP get_status_color函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap