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


PHP status_header函数代码示例

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


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

示例1: ajax_local_tags

 /**
  * Display a javascript collection for autocompletion script !
  *
  * @return void
  * @author Amaury Balmer
  */
 public static function ajax_local_tags()
 {
     status_header(200);
     // Send good header HTTP
     header("Content-Type: application/json; charset=" . get_bloginfo('charset'));
     $taxonomy = 'post_tag';
     if (isset($_REQUEST['taxonomy']) && taxonomy_exists($_REQUEST['taxonomy'])) {
         $taxonomy = $_REQUEST['taxonomy'];
     }
     if ((int) wp_count_terms($taxonomy, 'ignore_empty=false') == 0) {
         // No tags to suggest
         json_encode(array());
         exit;
     }
     // Prepare search
     $search = isset($_GET['term']) ? trim(stripslashes($_GET['term'])) : '';
     // Get all terms, or filter with search
     $terms = SimpleTags_Admin::getTermsForAjax($taxonomy, $search);
     if (empty($terms) || $terms == false) {
         json_encode(array());
         exit;
     }
     // Format terms
     $results = array();
     foreach ((array) $terms as $term) {
         $term->name = stripslashes($term->name);
         $term->name = str_replace(array("\r\n", "\r", "\n"), '', $term->name);
         $results[] = array('id' => $term->term_id, 'label' => $term->name, 'value' => $term->name);
     }
     echo json_encode($results);
     exit;
 }
开发者ID:rongandat,项目名称:best-picture,代码行数:38,代码来源:class.admin.autocomplete.php

示例2: block_direct_cron

 /**
  * Block direct cron execution as early as possible
  */
 public function block_direct_cron()
 {
     if (false !== stripos($_SERVER['REQUEST_URI'], '/wp-cron.php') || false !== stripos($_SERVER['SCRIPT_NAME'], '/wp-cron.php')) {
         status_header(403);
         wp_send_json_error(new \WP_Error('forbidden', sprintf(__('Normal cron execution is blocked when the %s plugin is active.', 'automattic-cron-control'), 'Cron Control')), array('status' => 400));
     }
 }
开发者ID:Automattic,项目名称:vip-mu-plugins-public,代码行数:10,代码来源:class-main.php

示例3: etivite_bp_activity_hashtags_screen_router

/**
 * Screen router for activity hashtags.
 *
 * Determines if we're on a hashtag page. If so, sends things along their
 * merry way!
 */
function etivite_bp_activity_hashtags_screen_router()
{
    if (!bp_is_activity_component() || !bp_is_current_action(BP_ACTIVITY_HASHTAGS_SLUG)) {
        return false;
    }
    if (!bp_action_variables()) {
        return false;
    }
    // RSS feed support
    if (bp_is_action_variable('feed', 1)) {
        // the cool way (BP 1.8+)
        if (class_exists('BP_Activity_Feed')) {
            global $bp;
            // setup the feed
            $bp->activity->feed = new BP_Activity_Feed(array('id' => 'sitewide-hashtag', 'title' => sprintf(__('%1$s | #%2$s | Hashtag', 'bp-follow'), bp_get_site_name(), urldecode(esc_attr(bp_action_variable(0)))), 'link' => bp_get_activity_hashtags_permalink(esc_attr(bp_action_variable(0))), 'description' => sprintf(__("Activity feed for the hashtag, #%s.", 'buddypress'), urldecode(esc_attr(bp_action_variable(0)))), 'activity_args' => array('search_terms' => '#' . bp_action_variable(0) . '<', 'display_comments' => 'stream')));
            // the ugly way
        } else {
            global $wp_query;
            $wp_query->is_404 = false;
            status_header(200);
            include_once dirname(__FILE__) . '/feeds/bp-activity-hashtags-feed.php';
            die;
        }
    } else {
        // BP 1.7 - add theme compat
        if (class_exists('BP_Theme_Compat')) {
            new BP_Activity_Hashtags_Theme_Compat();
        }
        bp_core_load_template('activity/index');
    }
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:37,代码来源:bp-activity-hashtags.php

示例4: run_preflight

/**
 * Perform preflight checks for Mercator
 *
 * Checks that we can actually run Mercator, then attaches the relevant actions
 * and filters to make it useful.
 */
function run_preflight()
{
    // Are we installing? Bail if so.
    if (defined('WP_INSTALLING')) {
        return;
    }
    // Are we still in sunrise stage?
    if (did_action('muplugins_loaded')) {
        warn_with_message('Mercator must be loaded in your <code>sunrise.php</code>. Check out the <a href="https://github.com/humanmade/Mercator/wiki/Installation">installation instructions</a>.');
        return;
    }
    // Are we actually on multisite?
    if (!is_multisite()) {
        warn_with_message('Mercator requires WordPress to be in <a href="http://codex.wordpress.org/Create_A_Network">multisite mode</a>.');
        return;
    }
    // Are we running a good version of WP?
    if (!function_exists('get_site_by_path')) {
        warn_with_message('Mercator requires <a href="https://wordpress.org/download/">WordPress 3.9</a> or newer. Update now.');
        return;
    }
    // Check for COOKIE_DOMAIN definition
    //
    // Note that this can't be an admin notice, as you'd never be able to log in
    // to see it.
    if (defined('COOKIE_DOMAIN')) {
        status_header(500);
        header('X-Mercator: COOKIE_DOMAIN');
        wp_die('The constant <code>COOKIE_DOMAIN</code> is defined (probably in <code>wp-config.php</code>). Please remove or comment out that <code>define()</code> line.');
    }
    // M: We have clearance, Clarence.
    // O: Roger, Roger. What's our Vector Victor?
    startup();
}
开发者ID:Tarendai,项目名称:Mercator,代码行数:40,代码来源:mercator.php

示例5: handle_papi_ajax

 /**
  * Handle Papi ajax.
  */
 public function handle_papi_ajax()
 {
     global $wp_query;
     if (!is_object($wp_query)) {
         return;
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!papi_is_empty(papi_get_qs('action'))) {
         $wp_query->set('papi_ajax_action', papi_get_qs('action'));
     }
     $ajax_action = $wp_query->get('papi_ajax_action');
     if (is_user_logged_in() && has_action($this->action_prefix . $ajax_action) !== false) {
         if (!defined('DOING_AJAX')) {
             define('DOING_AJAX', true);
         }
         if (!defined('DOING_PAPI_AJAX')) {
             define('DOING_PAPI_AJAX', true);
         }
         status_header(200);
         do_action($this->action_prefix . $ajax_action);
         wp_die();
     }
 }
开发者ID:ekandreas,项目名称:papi,代码行数:28,代码来源:class-papi-admin-ajax.php

示例6: menu_pages_js

 public static function menu_pages_js()
 {
     do_action("ws_plugin__qcache_before_menu_pages_js", get_defined_vars());
     /**/
     if ($_GET["ws_plugin__qcache_menu_pages_js"] && is_user_logged_in() && current_user_can("edit_plugins")) {
         status_header(200);
         /* 200 OK status header. */
         /**/
         header("Content-Type: text/javascript; charset=utf-8");
         header("Expires: " . gmdate("D, d M Y H:i:s", strtotime("-1 week")) . " GMT");
         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         header("Cache-Control: no-cache, must-revalidate, max-age=0");
         header("Pragma: no-cache");
         /**/
         eval('while (@ob_end_clean ());');
         /* Clean buffers. */
         /**/
         $u = $GLOBALS["WS_PLUGIN__"]["qcache"]["c"]["dir_url"];
         $i = $GLOBALS["WS_PLUGIN__"]["qcache"]["c"]["dir_url"] . "/images";
         /**/
         include_once dirname(dirname(__FILE__)) . "/menu-pages/menu-pages-min.js";
         /**/
         echo "\n";
         /* Add a line break before inclusion of this file. */
         /**/
         @(include_once dirname(dirname(__FILE__)) . "/menu-pages/menu-pages-s-min.js");
         /**/
         do_action("ws_plugin__qcache_during_menu_pages_js", get_defined_vars());
         /**/
         exit;
         /* Clean exit. */
     }
     /**/
     do_action("ws_plugin__qcache_after_menu_pages_js", get_defined_vars());
 }
开发者ID:arturo-mayorga,项目名称:am_com,代码行数:35,代码来源:admin-css-js-in.inc.php

示例7: sb_check_url

 function sb_check_url()
 {
     switch (basename($_SERVER['PHP_SELF'])) {
         case 'wp-rss.php':
         case 'wp-rss2.php':
         case 'wp-atom.php':
         case 'wp-rdf.php':
             if (trim(sb_get_option('feedburner_feed_url')) != '') {
                 if (function_exists('status_header')) {
                     status_header(302);
                 }
                 header("Location:" . trim(sb_get_option('feedburner_feed_url')));
                 header("HTTP/1.1 302 Temporary Redirect");
                 exit;
             }
             break;
         case 'wp-commentsrss2.php':
             if (trim(sb_get_option('feedburner_comments_url')) != '') {
                 if (function_exists('status_header')) {
                     status_header(302);
                 }
                 header("Location:" . trim(sb_get_option('feedburner_comments_url')));
                 header("HTTP/1.1 302 Temporary Redirect");
                 exit;
             }
             break;
     }
 }
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:28,代码来源:feedburner.php

示例8: listen

 private static function listen()
 {
     if ($key = filter_input(INPUT_GET, self::PURGE_QUERY_VAR)) {
         $response = new stdClass();
         if ($key === self::get_purge_key()) {
             delete_transient(EXTEND_UPDATE);
             delete_transient('pagelines_extend_themes');
             delete_transient('pagelines_extend_sections');
             delete_transient('pagelines_extend_plugins');
             delete_transient('pagelines_extend_integrations');
             delete_transient('pagelines_sections_cache');
             remove_theme_mod('available_updates');
             remove_theme_mod('pending_updates');
             do_action('extend_flush');
             $response->status = 'success';
             $response->message = 'Cache purged.';
             $status_code = 200;
         } else {
             $response->status = 'fail';
             $response->message = 'Invalid key.';
             $status_code = 422;
         }
         if (!headers_sent()) {
             nocache_headers();
             @header("Content-type: application/json");
             status_header($status_code);
             echo json_encode($response);
             exit;
         } else {
             wp_die($response->message, $response->status, array('response' => $status_code));
         }
         // silence
     }
 }
开发者ID:aaemnnosttv,项目名称:pl2x-remote-purge,代码行数:34,代码来源:pl2x-remote-purge.php

示例9: ajax_template

/**
 * Let's echo out the content we are looking to dynamically grab before we load any template files
 */
function ajax_template()
{
    global $wp, $wpdb, $current_user;
    //var_dump($wp->query_vars);
    if (isset($wp->query_vars['inc_ajax']) && !empty($wp->query_vars['inc_ajax'])) {
        $request_action = basename(trim(str_replace('-', '_', esc_attr($wp->query_vars['inc_ajax'])) . '_ajax'));
        $request_params = $_REQUEST;
        $comment_id = $request_params['comment_id'];
        $status = null;
        $message = null;
        status_header(200);
        header('Cache-Control: no-cache, must-revalidate');
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
        header('Content-type: application/json');
        if (function_exists($request_action)) {
            if (has_action('public_ajax_function', $request_action)) {
                if (has_action('public_ajax_function', $request_action)) {
                    call_user_func($request_action, $request_params);
                }
            }
            if (is_user_logged_in()) {
                if (has_action('authenticated_ajax_function', $request_action)) {
                    call_user_func($request_action, $request_params);
                }
            } else {
                //user is not logged in
                if (has_action('unauthenticated_ajax_function', $request_action)) {
                    call_user_func($request_action, $request_params);
                }
            }
            die;
        }
    }
}
开发者ID:angelmoratilla,项目名称:digressit,代码行数:37,代码来源:ajax-functions.php

示例10: stop_infinite_404_loops

 /**
  * Some plugins / themes fetch local resources over http.  When the resources aren't there,
  * WordPress returns a 404 page, which causes the theme / plugin to fire again and try to
  * fetch the same missing resource and creates an infinite 404 loop.  This intercedes and
  * stops that behavior.  Pages that end with .htm and .html will still render correctly.
  * @return void
  */
 public function stop_infinite_404_loops()
 {
     global $wp_query;
     if (is_404() && preg_match('/^[^?&=]+\\.(css|gif|jpeg|jpg|js|png)(\\?|&)?(.*)?$/i', $wp_query->query['pagename'])) {
         status_header(404);
         switch (strtolower(pathinfo($wp_query->query['pagename'], PATHINFO_EXTENSION))) {
             case 'gif':
                 gd_system_header('Content-type: image/gif');
                 include GD_SYSTEM_PLUGIN_DIR . '/images/404.gif';
                 break;
             case 'jpg':
             case 'jpeg':
                 gd_system_header('Content-type: image/jpeg');
                 include GD_SYSTEM_PLUGIN_DIR . '/images/404.jpg';
                 break;
             case 'png':
                 gd_system_header('Content-type: image/png');
                 include GD_SYSTEM_PLUGIN_DIR . '/images/404.png';
                 break;
             case 'css':
                 gd_system_header('Content-type: text/css');
                 echo "\n";
                 break;
             case 'js':
                 gd_system_header('Content-type: application/javascript');
                 echo "\n";
                 break;
         }
         add_filter('wp_die_handler', 'gd_system_die_handler', 10, 1);
         wp_die();
     }
 }
开发者ID:fernflores0463,项目名称:RandolphTimesWeb,代码行数:39,代码来源:class-gd-system-plugin-404.php

示例11: anywhere_login_init

 function anywhere_login_init()
 {
     if (!defined('ANYWHERE_LOGIN') || sha1('kfmadminlogin') != ANYWHERE_LOGIN) {
         status_header(403);
         exit;
     }
 }
开发者ID:hcone5006,项目名称:kfm,代码行数:7,代码来源:functions.php

示例12: bebop_feeds

function bebop_feeds()
{
    global $bp, $wp_query, $this_bp_feed;
    if (bp_is_activity_component()) {
        $active_extensions = bebop_extensions::bebop_get_active_extension_names();
        $active_extensions[] = 'all_oers';
        foreach ($active_extensions as $extension) {
            if (bp_current_action() == $extension) {
                if ($extension == 'all_oers') {
                    $this_bp_feed = $extension;
                } else {
                    if (bebop_tables::check_option_exists('bebop_' . $extension . '_rss_feed')) {
                        if (bebop_tables::get_option_value('bebop_' . $extension . '_rss_feed') == 'on') {
                            $this_bp_feed = $extension;
                        }
                    }
                }
            }
        }
    }
    if (empty($this_bp_feed)) {
        return false;
    }
    $wp_query->is_404 = false;
    status_header(200);
    include_once 'templates/user/bebop-feed-template.php';
    die;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:28,代码来源:bebop-feeds.php

示例13: throw404

 /**
  * Launch and display the 404 page depending upon the template
  *
  * @param   void
  * @return  void
  **/
 public function throw404()
 {
     // Change WP Query
     global $wp_query;
     $wp_query->set_404();
     status_header(404);
     // Disable that pesky Admin Bar
     add_filter('show_admin_bar', '__return_false', 900);
     remove_action('admin_footer', 'wp_admin_bar_render', 10);
     remove_action('wp_head', 'wp_admin_bar_header', 10);
     remove_action('wp_head', '_admin_bar_bump_cb', 10);
     wp_dequeue_script('admin-bar');
     wp_dequeue_style('admin-bar');
     // Template
     $four_tpl = apply_filters('LD_404', get_404_template());
     // Handle the admin bar
     @define('APP_REQUEST', TRUE);
     @define('DOING_AJAX', TRUE);
     if (empty($four_tpl) or !file_exists($four_tpl)) {
         // We're gonna try and get TwentyTen's one
         $twenty_ten_tpl = apply_filters('LD_404_FALLBACK', WP_CONTENT_DIR . '/themes/twentyfourteen/404.php');
         if (file_exists($twenty_ten_tpl)) {
             require $twenty_ten_tpl;
         } else {
             wp_die('404 - File not found!', '', array('response' => 404));
         }
     } else {
         // Their theme has a template!
         require $four_tpl;
     }
     // Either way, it's gonna stop right here.
     exit;
 }
开发者ID:estrategasdigitales,项目名称:glummer,代码行数:39,代码来源:Application.php

示例14: render_css

 /**
  * Renders the css for our frontend.
  *
  * Sets etags to avoid sending not needed data
  */
 public function render_css()
 {
     header('HTTP/1.1 200 OK');
     header('Content-Type: text/css', true, 200);
     // Aggressive caching to save future requests from the same client.
     $etag = '"' . md5(__FILE__ . $_GET[self::QUERY_STRING_PARAM]) . '"';
     header('ETag: ' . $etag);
     $max_age = 31536000;
     $time_sys = $this->_registry->get('date.system');
     header('Expires: ' . gmdate('D, d M Y H:i:s', $time_sys->current_time() + $max_age) . ' GMT');
     header('Cache-Control: public, max-age=' . $max_age);
     if (empty($_SERVER['HTTP_IF_NONE_MATCH']) || $etag !== stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) {
         // compress data if possible
         $compatibility_ob = $this->_registry->get('compatibility.ob');
         if ($this->_registry->get('http.request')->client_use_gzip()) {
             $compatibility_ob->start('ob_gzhandler');
             header('Content-Encoding: gzip');
         } else {
             $compatibility_ob->start();
         }
         $content = $this->get_compiled_css();
         echo $content;
         $compatibility_ob->end_flush();
     } else {
         // Not modified!
         status_header(304);
     }
     // We're done!
     Ai1ec_Http_Response_Helper::stop(0);
 }
开发者ID:newmight2015,项目名称:psmpsm,代码行数:35,代码来源:frontend.php

示例15: try_download

 /**
  * Try downloading and saving the image locally and then redirect to it.
  * @param string $img_path Path of the image inside uploads folder
  */
 public function try_download($img_path)
 {
     if (!function_exists('WP_Filesystem')) {
         require ABSPATH . 'wp-admin/includes/file.php';
     }
     global $wp_filesystem;
     WP_Filesystem();
     $mirror_url = $this->get_mirror_url($img_path);
     if ($mirror_url === false) {
         status_header(404);
         exit;
     }
     // Download
     $response = wp_remote_get($mirror_url);
     // Die if not successful.
     if (is_wp_error($response) || 200 !== $response['response']['code']) {
         wp_die(__('Unable to download the file.', 'h1aid'));
     }
     $body = wp_remote_retrieve_body($response);
     $abspath = $this->content_base_dir;
     $destination = trailingslashit($abspath) . $img_path;
     // Save to file system.
     $result = $wp_filesystem->put_contents($destination, $response['body'], FS_CHMOD_FILE);
     // predefined mode settings for WP files
     // Redirect if successful.
     if (true === $result) {
         wp_redirect(trailingslashit($this->content_base_url) . $img_path, 301);
         exit;
     } else {
         wp_die(__('Unable to save file to filesystem.', 'h1aid'));
     }
 }
开发者ID:h1fi,项目名称:h1-auto-image-download,代码行数:36,代码来源:class-h1-auto-image-download.php


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