/** * 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; }
/** * 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)); } }
/** * 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'); } }
/** * 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(); }
/** * 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(); } }
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()); }
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; } }
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 } }
/** * 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; } } }
/** * 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(); } }
function anywhere_login_init() { if (!defined('ANYWHERE_LOGIN') || sha1('kfmadminlogin') != ANYWHERE_LOGIN) { status_header(403); exit; } }
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; }
/** * 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; }
/** * 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); }
/** * 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')); } }
function nebula_http_status($status = 200, $redirect = 0) { if (isset($_GET['http'])) { $status = $_GET['http']; } $GLOBALS['http'] = intval($status); if (is_int($GLOBALS['http']) && $GLOBALS['http'] != 0 && $GLOBALS['http'] != 200) { if ($GLOBALS['http'] == '404') { global $wp_query; $wp_query->set_404(); status_header(404); if ($redirect == 1 || 1 == 2) { header('Location: '); //@TODO "Nebula" 0: Redirect to a generic error page w/ the error query. } else { get_template_part('404'); } } else { status_header(403); if ($redirect == 1 || 1 == 2) { header('Location: '); //@TODO "Nebula" 0: Redirect to a generic error page w/ the error query. } else { get_template_part('http_status'); } } die; } }
/** * This will kill the request if the current request doesn't pass authorization checks. */ function authorize_request() { if (!verify_request_signature() || !verify_referer()) { status_header(401); exit; } }
/** * Redirects to another page, with a workaround for the IIS Set-Cookie bug. * * @link http://support.microsoft.com/kb/q176113/ * @since 1.5.1 * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status. * * @param string $location The path to redirect to * @param int $status Status code to use * * @return bool False if $location is not set */ function fs_redirect($location, $status = 302) { global $is_IIS; if (headers_sent()) { return false; } if (defined('DOING_AJAX')) { // Don't redirect on AJAX calls. return false; } if (!$location) { return false; } $location = fs_sanitize_redirect($location); if ($is_IIS) { header("Refresh: 0;url={$location}"); } else { if (php_sapi_name() != 'cgi-fcgi') { status_header($status); } // This causes problems on IIS and some FastCGI setups header("Location: {$location}"); } return true; }
function handle_direct_download() { if (!isset($_GET['download_media_file'])) { return; } $media_file_id = (int) $_GET['download_media_file']; $media_file = Model\MediaFile::find_by_id($media_file_id); if (!$media_file) { status_header(404); exit; } $episode_asset = $media_file->episode_asset(); if (!$episode_asset || !$episode_asset->downloadable) { status_header(404); exit; } // tell WP Super Cache to not cache download links if (!defined('DONOTCACHEPAGE')) { define('DONOTCACHEPAGE', true); } header("Expires: 0"); header('Cache-Control: must-revalidate'); header('Pragma: public'); header("Content-Type: application/force-download"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=" . $media_file->get_download_file_name()); header("Content-Transfer-Encoding: binary"); if ($media_file->size > 0) { header('Content-Length: ' . $media_file->size); } ob_clean(); flush(); readfile($media_file->get_file_url()); exit; }
/** * Handles Remote Operation communications. * * @package s2Member\API_Remote_Ops * @since 110713 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution with a serialized array on success, or a string beginning with `Error:` on failure. */ public static function remote_ops() { if (!empty($_GET["s2member_pro_remote_op"]) && !empty($_POST["s2member_pro_remote_op"])) { c_ws_plugin__s2member_no_cache::no_cache_constants(true); /**/ status_header(200); /* Send a 200 OK status header. */ header("Content-Type: text/plain; charset=utf-8"); /* Content-Type text/plain with UTF-8. */ eval('while (@ob_end_clean ());'); /* End/clean all output buffers that may or may not exist. */ /**/ if (is_array($op = maybe_unserialize(c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST["s2member_pro_remote_op"]))))) { if (is_array($op = c_ws_plugin__s2member_utils_strings::trim_deep($op))) { if (!empty($op["api_key"]) && $op["api_key"] === c_ws_plugin__s2member_pro_remote_ops::remote_ops_key_gen()) { if (!empty($op["op"]) && is_callable("c_ws_plugin__s2member_pro_remote_ops_in::" . $op["op"])) { exit(call_user_func("c_ws_plugin__s2member_pro_remote_ops_in::" . $op["op"], $op)); } else { exit('Error: $_POST["s2member_pro_remote_op"]["op"] is empty or invalid.'); } } else { exit('Error: $_POST["s2member_pro_remote_op"]["api_key"] is empty or invalid.'); } } else { exit('Error: $_POST["s2member_pro_remote_op"] is NOT a serialized array.'); } } else { exit('Error: $_POST["s2member_pro_remote_op"] is NOT a serialized array.'); } } }
/** * 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::GET_VARIBALE_NAME]) . '"'; header('ETag: ' . $etag); $max_age = 31536000; header('Expires: ' . gmdate('D, d M Y H:i:s', Ai1ec_Time_Utility::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 if (Ai1ec_Http_Utility::client_use_gzip()) { ob_start('ob_gzhandler'); header('Content-Encoding: gzip'); } else { ob_start(); } $content = $this->get_compiled_css(); echo $content; ob_end_flush(); } else { // Not modified! status_header(304); } // We're done! ai1ec_stop(0); }
/** * Copy and paste of WordPress original function where headers are but stored * before sending to avoid CLI limitations. * * @param $location * @param int $status * @return bool */ function wp_redirect($location, $status = 302) { global $is_IIS; /** * Filter the redirect location. * * @since 2.1.0 * * @param string $location The path to redirect to. * @param int $status Status code to use. */ $location = apply_filters('wp_redirect', $location, $status); /** * Filter the redirect status code. * * @since 2.3.0 * * @param int $status Status code to use. * @param string $location The path to redirect to. */ $status = apply_filters('wp_redirect_status', $status, $location); if (!$location) { return false; } $location = wp_sanitize_redirect($location); if (!$is_IIS && PHP_SAPI != 'cgi-fcgi') { status_header($status); } // This causes problems on IIS and some FastCGI setups header("Location: {$location}", true, $status); global $cli_headers; $cli_headers["Location: {$location}"] = $status; return true; }
/** * Display a javascript collection for autocompletion script ! * * @return void * @author Amaury Balmer */ function ajaxLocalTags() { status_header(200); // Send good header HTTP header("Content-Type: text/plain; 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 exit; } // Prepare search $search = isset($_GET['q']) ? trim(stripslashes($_GET['q'])) : ''; // Get all terms, or filter with search $terms = $this->getTermsForAjax($taxonomy, $search); if (empty($terms) || $terms == false) { exit; } // Format terms foreach ((array) $terms as $term) { $term->name = stripslashes($term->name); $term->name = str_replace(array("\r\n", "\r", "\n"), '', $term->name); echo "{$term->term_id}|{$term->name}\n"; } exit; }
function gp_tmpl_header($args = array()) { if (isset($args['http_status'])) { status_header($args['http_status']); } gp_tmpl_load('header', $args); }
/** * Outputs the JS for administrative menu pages. * * @package s2Member\Admin_CSS_JS * @since 3.5 * * @attaches-to ``add_action("init");`` * * @return null Or exits script execution after loading JS. */ public static function menu_pages_js() { do_action("ws_plugin__s2member_before_menu_pages_js", get_defined_vars()); if (!empty($_GET["ws_plugin__s2member_menu_pages_js"]) && is_user_logged_in() && current_user_can("create_users")) { status_header(200); // 200 OK status header. header("Content-Type: application/x-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"); while (@ob_end_clean()) { } // Clean any existing output buffers. $u = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]; $i = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . "/images"; for ($n = 0, $labels = ""; $n <= $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; $n++) { $labels .= "labels['level" . $n . "'] = '" . (!empty($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_label"]) ? str_replace('"', "", c_ws_plugin__s2member_utils_strings::esc_js_sq($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $n . "_label"], 3)) : "") . "';"; } unset($n); 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__s2member_during_menu_pages_js", get_defined_vars()); exit; // Clean exit. } do_action("ws_plugin__s2member_after_menu_pages_js", get_defined_vars()); }
protected function prepare() { include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; try { $this->api = $api = Sputnik::get_plugin($this->id); } catch (Exception $e) { status_header(500); $this->header(); echo '<p>' . $e->getMessage() . '</p>'; $this->footer(); return; } if (!Sputnik::is_purchased($this->api->slug)) { wp_redirect(Sputnik_Admin::build_url(array('buy' => $this->id))); die; } if (!current_user_can('install_plugins')) { wp_die(__('You do not have sufficient permissions to install plugins for this site.', 'sputnik')); } check_admin_referer($this->nonce_prefix . $this->api->slug); include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $title = sprintf($this->title_format, $this->api->name . ' ' . $this->api->version); $nonce = $this->nonce_prefix . $this->id; $url = 'update.php?action=install-plugin&plugin=' . $this->id; if (isset($_GET['from'])) { $url .= '&from=' . urlencode(stripslashes($_GET['from'])); } $type = 'web'; //Install plugin type, From Web or an Upload. if ($this->api->is_theme) { $this->upgrader = new Sputnik_ThemeUpgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api'))); } else { $this->upgrader = new Sputnik_Upgrader(new Sputnik_View_Install_Skin(compact('title', 'url', 'nonce', 'plugin', 'api'))); } }
/** * Returns a json response and dies. * @param $data */ function json_response($data) { status_header(200); header('Content-type: application/json; charset=UTF-8'); echo json_encode($data, JSON_PRETTY_PRINT); die; }
/** * API request - Trigger any API requests. * * @since 2.0 * @version 2.4 */ public function handle_api_requests() { global $wp; if (!empty($_GET['wc-api'])) { $wp->query_vars['wc-api'] = $_GET['wc-api']; } // wc-api endpoint requests. if (!empty($wp->query_vars['wc-api'])) { // Buffer, we won't want any output here. ob_start(); // No cache headers. nocache_headers(); // Clean the API request. $api_request = strtolower(wc_clean($wp->query_vars['wc-api'])); // Trigger generic action before request hook. do_action('woocommerce_api_request', $api_request); // Is there actually something hooked into this API request? If not trigger 400 - Bad request. status_header(has_action('woocommerce_api_' . $api_request) ? 200 : 400); // Trigger an action which plugins can hook into to fulfill the request. do_action('woocommerce_api_' . $api_request); // Done, clear buffer and exit. ob_end_clean(); die('-1'); } }
function remove_author_pages_page() { if (is_author()) { global $wp_query; $wp_query->set_404(); status_header(404); } }
public static function import($params = array()) { global $wp_filter; // Set error handler @set_error_handler('Ai1wm_Handler::error'); // Set params if (empty($params)) { $params = ai1wm_urldecode($_REQUEST); } // Set priority $priority = 10; if (isset($params['priority'])) { $priority = (int) $params['priority']; } // Set secret key $secret_key = null; if (isset($params['secret_key'])) { $secret_key = $params['secret_key']; } // Verify secret key by using the value in the database, not in cache if ($secret_key !== get_option(AI1WM_SECRET_KEY)) { Ai1wm_Status::error(sprintf(__('Unable to authenticate your request with secret_key = "%s"', AI1WM_PLUGIN_NAME), $secret_key), __('Unable to import', AI1WM_PLUGIN_NAME)); exit; } // Get hook if (isset($wp_filter['ai1wm_import']) && ($filters = $wp_filter['ai1wm_import']) && ksort($filters)) { while ($hooks = current($filters)) { if ($priority == key($filters)) { foreach ($hooks as $hook) { try { $params = call_user_func_array($hook['function'], array($params)); } catch (Ai1wm_Import_Retry_Exception $exception) { status_header($exception->getCode()); echo json_encode(array('message' => $exception->getMessage())); exit; } catch (Exception $e) { Ai1wm_Status::error($e->getMessage(), __('Unable to import', AI1WM_PLUGIN_NAME)); exit; } } // Set completed $completed = true; if (isset($params['completed'])) { $completed = (bool) $params['completed']; } // Log request if (empty($params['priority']) || is_file(ai1wm_import_path($params))) { Ai1wm_Log::import($params); } // Do request if ($completed === false || ($next = next($filters)) && ($params['priority'] = key($filters))) { return Ai1wm_Http::get(admin_url('admin-ajax.php?action=ai1wm_import'), $params); } } next($filters); } } }