php WordPress更新观看
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WordPress更新观看相关的知识,希望对你有一定的参考价值。
<?php
if( !empty($_GET['request']) ) {
$current_version = "";
$url = "https://api.wordpress.org/core/version-check/1.7/";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url
));
$result = curl_exec($curl);
if( $result ) {
$array = json_decode($result, true);
if( isset( $array['offers']) && is_array( $array['offers'] ) ) {
foreach( $array['offers'] as $offer ) {
if( isset($offer['response']) && $offer['response'] == 'upgrade' ) {
if( isset( $offer['current'] ) ) {
$current_version = $offer['current'];
}
}
}
}
}
echo $current_version;
die();
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<title>WordPress release Monitor</title>
</head>
<body>
<h1>The Current WordPress version is <span class="current-wp-ver">loading</span></h1>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<style>
body {
background-color: #080;
}
body.it-happened {
background-color: #800;
}
h1 {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
color: #fff;
text-align: center;
}
h1 .current-wp-ver {
display: block;
font-size: 6em;
}
</style>
<script>
jQuery(function($) {
var known_version = false;
function check_version() {
jQuery.get( location.href, { 'request': 1 }, function(response) {
if( response ) {
if(!known_version) {
known_version = response;
} else {
if( response != known_version ) {
$(body).addClass('it-happened');
}
}
$('.current-wp-ver').text(response);
}
setTimeout(function() {
check_version();
}, 5000);
} );
}
check_version();
});
</script>
</body>
</html>
以上是关于php WordPress更新观看的主要内容,如果未能解决你的问题,请参考以下文章