summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2018-06-08 10:09:24 -0400
committerAnthony G. Basile <blueness@gentoo.org>2018-06-08 10:09:24 -0400
commita6b006c0f1ef757f23375f7906193370337d8bd7 (patch)
tree4467c6423b2c54e6ef8c3e79241a833fb17833a5 /plugins/jetpack/modules/wordads/php/api.php
parentUpdate akismet 4.0.7 (diff)
downloadblogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.gz
blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.tar.bz2
blogs-gentoo-a6b006c0f1ef757f23375f7906193370337d8bd7.zip
Update jetpack 6.2
Diffstat (limited to 'plugins/jetpack/modules/wordads/php/api.php')
-rw-r--r--plugins/jetpack/modules/wordads/php/api.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/wordads/php/api.php b/plugins/jetpack/modules/wordads/php/api.php
index f8203aa8..704193ed 100644
--- a/plugins/jetpack/modules/wordads/php/api.php
+++ b/plugins/jetpack/modules/wordads/php/api.php
@@ -44,6 +44,24 @@ class WordAds_API {
}
/**
+ * 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
*