| Server IP : 27.254.66.5 / Your IP : 216.73.217.39 Web Server : Apache/2 System : Linux cs82.hostneverdie.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : technic2 ( 1951) PHP Version : 7.4.30 Disable Function : apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd,exec, fp, fput, highlight_file, ini_alter, ini_restore, inject_code, passthru,phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid,posix_setuid, posix_setuid, posix_uname,proc_open,proc_close, proc_get_status, proc_nice, proc_terminate, shell_exec, syslog, system, xmlrpc_entity_decode, show_source,sleep,pcntl_exec,virtual,suexec,dbmopen,dl,symlink,disk_free_space,diskfreespace,leak MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/technic2/public_html/old-website/wp-content/plugins/jetpack/modules/wordads/php/ |
Upload File : |
<?php
/**
* Methods for accessing data through the WPCOM REST API
*
* @since 4.5.0
*/
class WordAds_API {
private static $wordads_status = null;
/**
* Returns site's WordAds status
* @return array boolean values for 'approved' and 'active'
*
* @since 4.5.0
*/
public static function get_wordads_status() {
global $wordads_status_response;
if ( Jetpack::is_development_mode() ) {
self::$wordads_status = array(
'approved' => true,
'active' => true,
'house' => true,
);
return self::$wordads_status;
}
$endpoint = sprintf( '/sites/%d/wordads/status', Jetpack::get_option( 'id' ) );
$wordads_status_response = $response = Jetpack_Client::wpcom_json_api_request_as_blog( $endpoint );
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
return new WP_Error( 'api_error', __( 'Error connecting to API.', 'jetpack' ), $response );
}
$body = json_decode( wp_remote_retrieve_body( $response ) );
self::$wordads_status = array(
'approved' => $body->approved,
'active' => $body->active,
'house' => $body->house,
);
return self::$wordads_status;
}
/**
* Returns the ads.txt content needed to run WordAds.
* @return array string contents of the ads.txt file.
*
* @since 6.1.0
*/
public static function get_wordads_ads_txt() {
$endpoint = sprintf( '/sites/%d/wordads/ads-txt', Jetpack::get_option( 'id' ) );
$wordads_status_response = $response = Jetpack_Client::wpcom_json_api_request_as_blog( $endpoint );
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
return new WP_Error( 'api_error', __( 'Error connecting to API.', 'jetpack' ), $response );
}
$body = json_decode( wp_remote_retrieve_body( $response ) );
$ads_txt = str_replace( '\\n', PHP_EOL, $body->adstxt );
return $ads_txt;
}
/**
* Returns status of WordAds approval.
* @return boolean true if site is WordAds approved
*
* @since 4.5.0
*/
public static function is_wordads_approved() {
if ( is_null( self::$wordads_status ) ) {
self::get_wordads_status();
}
return self::$wordads_status['approved'] ? '1' : '0';
}
/**
* Returns status of WordAds active.
* @return boolean true if ads are active on site
*
* @since 4.5.0
*/
public static function is_wordads_active() {
if ( is_null( self::$wordads_status ) ) {
self::get_wordads_status();
}
return self::$wordads_status['active'] ? '1' : '0';
}
/**
* Returns status of WordAds house ads.
* @return boolean true if WP.com house ads should be shown
*
* @since 4.5.0
*/
public static function is_wordads_house() {
if ( is_null( self::$wordads_status ) ) {
self::get_wordads_status();
}
return self::$wordads_status['house'] ? '1' : '0';
}
/**
* Grab WordAds status from WP.com API and store as option
*
* @since 4.5.0
*/
static function update_wordads_status_from_api() {
$status = self::get_wordads_status();
if ( ! is_wp_error( $status ) ) {
update_option( 'wordads_approved', self::is_wordads_approved(), true );
update_option( 'wordads_active', self::is_wordads_active(), true );
update_option( 'wordads_house', self::is_wordads_house(), true );
}
}
}