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


PHP get_status_header_desc函数代码示例

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


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


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