Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created October 8, 2015 14:51
Show Gist options
  • Save mikejolley/80dafb61b74b5d3a0246 to your computer and use it in GitHub Desktop.
Save mikejolley/80dafb61b74b5d3a0246 to your computer and use it in GitHub Desktop.
Test server can access WPJobManager.com for updates
<?php
/**
* Plugin Name: WP Job Manager - Update access tester
* Description: Pings our site to see if your server can connect. Just head to <a href="/?wpjm-test=1">yoursite.com/?wpjm-test=1</a> whilst logged in as admin.
* Version: 1.0.0
* Author: Mike Jolley
* Requires at least: 4.1
* Tested up to: 4.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'wp_loaded', 'wpjm_update_access_tester' );
function wpjm_update_access_tester() {
if ( ! empty( $_GET['wpjm-test'] ) && current_user_can( 'manage_options' ) ) {
$response = wp_safe_remote_get( 'https://wpjobmanager.com' );
if ( ! is_wp_error( $response ) ) {
wp_die( 'SUCCESS' );
} else {
wp_die( 'FAIL - ' . $response->get_error_message() );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment