Ads.txt Manager - Version 1.0

Version Description

  • Initial plugin release
Download this release

Release Info

Developer helen
Plugin Icon 128x128 Ads.txt Manager
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (6) hide show
  1. ads-txt.php +39 -0
  2. inc/admin.php +168 -0
  3. inc/post-type.php +45 -0
  4. inc/save.php +200 -0
  5. js/admin.js +76 -0
  6. readme.txt +48 -0
ads-txt.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Ads.txt Manager
4
+ * Description: Create, manage, and validate your Ads.txt from within WordPress, just like any other content asset. Requires PHP 5.3+ and WordPress 4.9+.
5
+ * Version: 1.0
6
+ * Author: 10up
7
+ * Author URI: http://10up.com
8
+ * License: GPLv2 or later
9
+ * Text Domain: ads-txt
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit; // Exit if accessed directly.
14
+ }
15
+
16
+ require_once __DIR__ . '/inc/post-type.php';
17
+ require_once __DIR__ . '/inc/admin.php';
18
+ require_once __DIR__ . '/inc/save.php';
19
+
20
+ /**
21
+ * Display the contents of /ads.txt when requested.
22
+ *
23
+ * @return void
24
+ */
25
+ function tenup_display_ads_txt() {
26
+ $request = esc_url_raw( $_SERVER['REQUEST_URI'] );
27
+ if ( '/ads.txt' === $request ) {
28
+ $post_id = get_option( 'adstxt_post' );
29
+
30
+ // Will fall through if no option found, likely to a 404.
31
+ if ( ! empty( $post_id ) ) {
32
+ $post = get_post( $post_id );
33
+ header( 'Content-Type: text/plain' );
34
+ echo esc_html( $post->post_content );
35
+ die();
36
+ }
37
+ }
38
+ }
39
+ add_action( 'init', 'tenup_display_ads_txt' );
inc/admin.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace AdsTxt;
4
+
5
+ /**
6
+ * Enqueue any necessary scripts.
7
+ *
8
+ * @param string $hook Hook name for the current screen.
9
+ *
10
+ * @return void
11
+ */
12
+ function admin_enqueue_scripts( $hook ) {
13
+ if ( 'settings_page_adstxt-settings' !== $hook ) {
14
+ return;
15
+ }
16
+
17
+ wp_enqueue_script( 'adstxt', plugins_url( '/js/admin.js', dirname( __FILE__ ) ), array( 'jquery', 'wp-backbone', 'wp-codemirror' ), false, true );
18
+ wp_enqueue_style( 'code-editor' );
19
+
20
+ $strings = array(
21
+ 'saved_message' => __( 'Ads.txt saved', 'ads-txt' ),
22
+ 'error_message' => __( 'Your Ads.txt contains the following issues:', 'ads-txt' ),
23
+ 'unknown_error' => __( 'An unknown error occurred.', 'ads-txt' ),
24
+ );
25
+
26
+ wp_localize_script( 'adstxt', 'adstxt', $strings );
27
+ }
28
+ add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\admin_enqueue_scripts' );
29
+
30
+ /**
31
+ * Output some CSS directly in the head of the document.
32
+ *
33
+ * Should there ever be more than ~25 lines of CSS, this should become a separate file.
34
+ *
35
+ * @return void
36
+ */
37
+ function admin_head_css() {
38
+ ?>
39
+ <style>
40
+ .CodeMirror {
41
+ width: 100%;
42
+ min-height: 60vh;
43
+ height: calc( 100vh - 295px );
44
+ border: 1px solid #ddd;
45
+ box-sizing: border-box;
46
+ }
47
+ </style>
48
+ <?php
49
+ }
50
+ add_action( 'admin_head-settings_page_adstxt-settings', __NAMESPACE__ . '\admin_head_css' );
51
+
52
+ /**
53
+ * Add admin menu page.
54
+ *
55
+ * @return void
56
+ */
57
+ function admin_menu() {
58
+ add_options_page( __( 'Ads.txt', 'ads-txt' ), __( 'Ads.txt', 'ads-txt' ), 'manage_options', 'adstxt-settings', __NAMESPACE__ . '\settings_screen' );
59
+ }
60
+ add_action( 'admin_menu', __NAMESPACE__ . '\admin_menu' );
61
+
62
+ /**
63
+ * Output the settings screen.
64
+ *
65
+ * @return void
66
+ */
67
+ function settings_screen() {
68
+ $post_id = get_option( 'adstxt_post' );
69
+ $post = false;
70
+ $content = false;
71
+
72
+ if ( $post_id ) {
73
+ $post = get_post( $post_id );
74
+ $content = isset( $post->post_content ) ? $post->post_content : '';
75
+ $errors = get_post_meta( $post->ID, 'adstxt_errors', true );
76
+ }
77
+ ?>
78
+ <div class="wrap">
79
+ <?php if ( ! empty( $errors ) ) : ?>
80
+ <div class="notice notice-error adstxt-notice">
81
+ <p><strong><?php echo esc_html( __( 'Your Ads.txt contains the following issues:', 'ads-txt' ) ); ?></strong></p>
82
+ <ul>
83
+ <?php
84
+ foreach ( $errors as $error ) {
85
+ echo '<li class="' . esc_attr( $error['type'] ) . '">' . esc_html( format_error( $error ) ) . '</li>';
86
+ }
87
+ ?>
88
+ </ul>
89
+ </div>
90
+ <?php endif; ?>
91
+
92
+ <h2><?php echo esc_html( __( 'Manage Ads.txt', 'ads-txt' ) ); ?></h2>
93
+
94
+ <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="adstxt-settings-form">
95
+ <input type="hidden" name="post_id" value="<?php echo ( $post ? esc_attr( $post->ID ) : '' ); ?>" />
96
+ <input type="hidden" name="action" value="adstxt-save" />
97
+ <?php wp_nonce_field( 'adstxt_save' ); ?>
98
+
99
+ <label class="screen-reader-text" for="adstxt_content"><?php echo esc_html( __( 'Ads.txt content', 'ads-txt' ) ); ?></label>
100
+ <textarea class="widefat code" rows="25" name="adstxt" id="adstxt_content"><?php echo esc_textarea( $content ); ?></textarea>
101
+
102
+ <div id="adstxt-notification-area"></div>
103
+
104
+ <p class="submit">
105
+ <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_attr( 'Save Changes' ); ?>">
106
+ <span class="spinner" style="float:none;vertical-align:top"></span>
107
+ </p>
108
+
109
+ </form>
110
+
111
+ <script type="text/template" id="tmpl-adstext-notice">
112
+ <# if ( ! _.isUndefined( data.saved ) ) { #>
113
+ <div class="notice notice-success adstxt-notice adstxt-saved">
114
+ <p>{{ data.saved.saved_message }}</p>
115
+ </div>
116
+ <# } #>
117
+
118
+ <# if ( ! _.isUndefined( data.errors ) ) { #>
119
+ <div class="notice notice-error adstxt-notice adstxt-errors">
120
+ <p><strong>{{ data.errors.error_message }}</strong></p>
121
+ <# if ( ! _.isUndefined( data.errors.errors ) ) { #>
122
+ <ul class="adstxt-errors-items">
123
+ <# _.each( data.errors.errors, function( error ) { #>
124
+ <li>{{ error }}.</li>
125
+ <# } ); #>
126
+ </ul>
127
+ <# } #>
128
+ </div>
129
+
130
+ <# if ( _.isUndefined( data.saved ) && ! _.isUndefined( data.errors.errors ) ) { #>
131
+ <p class="adstxt-ays">
132
+ <input id="adstxt-ays-checkbox" name="adstxt_ays" type="checkbox" value="y" />
133
+ <label for="adstxt-ays-checkbox">
134
+ <?php _e( 'Update anyway, even though it may adversely affect your ads?', 'ads-txt' ); ?>
135
+ </label>
136
+ </p>
137
+ <# } #>
138
+
139
+ <# } #>
140
+ </script>
141
+ </div>
142
+
143
+ <?php
144
+ }
145
+
146
+ /**
147
+ * Take an error array and turn it into a message.
148
+ *
149
+ * @param array $error {
150
+ * Array of error message components.
151
+ *
152
+ * @type string $type Type of error. Typically 'warning' or 'error'.
153
+ * @type int $line Line number of the error.
154
+ * @type string $message Error message.
155
+ * }
156
+ *
157
+ * @return string Formatted error message.
158
+ */
159
+ function format_error( $error ) {
160
+ /* translators: Error message output. 1: Line number, 2: Error message */
161
+ $message = sprintf(
162
+ __( 'Line %1$s: %2$s', 'ads-txt' ),
163
+ $error['line'],
164
+ $error['message']
165
+ );
166
+
167
+ return $message;
168
+ }
inc/post-type.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Adstxt;
4
+
5
+ /**
6
+ * Register the `adstxt` custom post type.
7
+ *
8
+ * @return void
9
+ */
10
+ function register() {
11
+ register_post_type(
12
+ 'adstxt', array(
13
+ 'labels' => array(
14
+ 'name' => _x( 'Ads.txt', 'post type general name', 'ads-txt' ),
15
+ 'singular_name' => _x( 'Ads.txt', 'post type singular name', 'ads-txt' ),
16
+ ),
17
+ 'public' => false,
18
+ 'hierarchical' => false,
19
+ 'rewrite' => false,
20
+ 'query_var' => false,
21
+ 'delete_with_user' => false,
22
+ 'supports' => array( 'revisions' ),
23
+ 'map_meta_cap' => true,
24
+ 'capabilities' => array(
25
+ 'create_posts' => 'customize',
26
+ 'delete_others_posts' => 'customize',
27
+ 'delete_post' => 'customize',
28
+ 'delete_posts' => 'customize',
29
+ 'delete_private_posts' => 'customize',
30
+ 'delete_published_posts' => 'customize',
31
+ 'edit_others_posts' => 'customize',
32
+ 'edit_post' => 'customize',
33
+ 'edit_posts' => 'customize',
34
+ 'edit_private_posts' => 'customize',
35
+ 'edit_published_posts' => 'customize',
36
+ 'publish_posts' => 'customize',
37
+ 'read' => 'read',
38
+ 'read_post' => 'customize',
39
+ 'read_private_posts' => 'customize',
40
+ ),
41
+ )
42
+ );
43
+ }
44
+
45
+ add_action( 'init', __NAMESPACE__ . '\register' );
inc/save.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Adstxt;
4
+
5
+ /**
6
+ * Process and save the ads.txt data.
7
+ *
8
+ * Handles both AJAX and POST saves via `admin-ajax.php` and `admin-post.php` respectively.
9
+ * AJAX calls output JSON; POST calls redirect back to the Ads.txt edit screen.
10
+ *
11
+ * @return void
12
+ */
13
+ function save() {
14
+ current_user_can( 'customize' ) || die;
15
+ check_admin_referer( 'adstxt_save' );
16
+ $_post = stripslashes_deep( $_POST );
17
+ $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
18
+
19
+ $post_id = $_post['post_id'];
20
+ $ays = isset( $_post['adstxt_ays'] ) ? $_post['adstxt_ays'] : null;
21
+
22
+ // Different browsers use different line endings.
23
+ $lines = preg_split( '/\r\n|\r|\n/', $_post['adstxt'] );
24
+ $sanitized = $errors = $response = array();
25
+
26
+ foreach ( $lines as $i => $line ) {
27
+ $line_number = $i + 1;
28
+ $result = validate_line( $line, $line_number );
29
+
30
+ $sanitized[] = $result['sanitized'];
31
+ if ( ! empty( $result['errors'] ) ) {
32
+ $errors = array_merge( $errors, $result['errors'] );
33
+ }
34
+ }
35
+
36
+ $sanitized = implode( PHP_EOL, $sanitized );
37
+
38
+ $postarr = array(
39
+ 'ID' => $post_id,
40
+ 'post_title' => 'Ads.txt',
41
+ 'post_content' => $sanitized,
42
+ 'post_type' => 'adstxt',
43
+ 'post_status' => 'publish',
44
+ 'meta_input' => array(
45
+ 'adstxt_errors' => $errors,
46
+ ),
47
+ );
48
+
49
+ if ( ! $doing_ajax || empty( $errors ) || 'y' === $ays ) {
50
+ $post_id = wp_insert_post( $postarr );
51
+
52
+ if ( $post_id ) {
53
+ update_option( 'adstxt_post', $post_id );
54
+ $response['saved'] = true;
55
+ }
56
+ }
57
+
58
+ if ( $doing_ajax ) {
59
+ $response['sanitized'] = $sanitized;
60
+
61
+ if ( ! empty( $errors ) ) {
62
+ // Transform errors into strings for easier i18n.
63
+ $response['errors'] = array_map( __NAMESPACE__ . '\format_error', $errors );
64
+ }
65
+
66
+ echo wp_json_encode( $response );
67
+ die();
68
+ }
69
+
70
+ wp_redirect( esc_url_raw( $_POST['_wp_http_referer'] ) . '&updated=true' );
71
+ exit;
72
+ }
73
+ add_action( 'admin_post_adstxt-save', __NAMESPACE__ . '\save' );
74
+ add_action( 'wp_ajax_adstxt-save', __NAMESPACE__ . '\save' );
75
+
76
+ /**
77
+ * Validate a single line.
78
+ *
79
+ * @param string $line The line to validate.
80
+ * @param string $line_number The line number being evaluated.
81
+ *
82
+ * @return array {
83
+ * @type string $sanitized Sanitized version of the original line.
84
+ * @type array $errors Array of errors associated with the line.
85
+ * }
86
+ */
87
+ function validate_line( $line, $line_number ) {
88
+ $domain_regex = '/^((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}$/i';
89
+ $errors = array();
90
+
91
+ if ( empty( $line ) ) {
92
+ $sanitized = '';
93
+ } elseif ( 0 === strpos( $line, '#' ) ) { // This is a full-line comment.
94
+ $sanitized = wp_strip_all_tags( $line );
95
+ } elseif ( 1 < strpos( $line, '=' ) ) { // This is a variable declaration.
96
+ // The spec currently supports CONTACT and SUBDOMAIN.
97
+ if ( ! preg_match( '/^(CONTACT|SUBDOMAIN)=/i', $line ) ) {
98
+ $errors[] = array(
99
+ 'line' => $line_number,
100
+ 'type' => 'warning',
101
+ 'message' => __( 'Unrecognized variable', 'ads-txt' ),
102
+ );
103
+ } elseif ( 0 === stripos( $line, 'subdomain=' ) ) { // Subdomains should be, well, subdomains.
104
+ // Disregard any comments.
105
+ $subdomain = explode( '#', $line );
106
+ $subdomain = $subdomain[0];
107
+
108
+ $subdomain = explode( '=', $subdomain );
109
+ array_shift( $subdomain );
110
+
111
+ // If there's anything other than one piece left something's not right.
112
+ if ( 1 !== count( $subdomain ) || ! preg_match( $domain_regex, $subdomain[0] ) ) {
113
+ $subdomain = implode( '', $subdomain );
114
+ $errors[] = array(
115
+ 'line' => $line_number,
116
+ 'type' => 'warning',
117
+ 'message' => sprintf(
118
+ /* translators: %s: Subdomain */
119
+ __( '"%s" does not appear to be a valid subdomain', 'ads-txt' ),
120
+ esc_html( $subdomain )
121
+ ),
122
+ );
123
+ }
124
+ }
125
+
126
+ $sanitized = wp_strip_all_tags( $line );
127
+
128
+ unset( $subdomain );
129
+ } else { // Data records: the most common.
130
+ // Disregard any comments.
131
+ $record = explode( '#', $line );
132
+ $record = $record[0];
133
+
134
+ // Record format: example.exchange.com,pub-id123456789,RESELLER|DIRECT,tagidhash123(optional).
135
+ $fields = explode( ',', $record );
136
+
137
+ if ( 3 <= count( $fields ) ) {
138
+ $exchange = trim( $fields[0] );
139
+ $pub_id = trim( $fields[1] );
140
+ $account_type = trim( $fields[2] );
141
+
142
+ if ( ! preg_match( $domain_regex, $exchange ) ) {
143
+ $errors[] = array(
144
+ 'line' => $line_number,
145
+ 'type' => 'warning',
146
+ 'message' => sprintf(
147
+ /* translators: %s: Exchange domain */
148
+ __( '"%s" does not appear to be a valid exchange domain', 'ads-txt' ),
149
+ esc_html( $exchange )
150
+ ),
151
+ );
152
+ }
153
+
154
+ if ( ! preg_match( '/^(RESELLER|DIRECT)$/i', $account_type ) ) {
155
+ $errors[] = array(
156
+ 'line' => $line_number,
157
+ 'type' => 'error',
158
+ 'message' => __( 'Third field should be RESELLER or DIRECT', 'ads-txt' ),
159
+ );
160
+ }
161
+
162
+ if ( isset( $fields[3] ) ) {
163
+ $tag_id = trim( $fields[3] );
164
+
165
+ // TAG-IDs appear to be 16 character hashes.
166
+ // TAG-IDs are meant to be checked against their DB - perhaps good for a service or the future.
167
+ if ( ! empty( $tag_id ) && ! preg_match( '/^[a-f0-9]{16}$/', $tag_id ) ) {
168
+ $errors[] = array(
169
+ 'line' => $line_number,
170
+ 'type' => 'warning',
171
+ 'message' => sprintf(
172
+ /* translators: %s: TAG-ID */
173
+ __( '"%s" does not appear to be a valid TAG-ID', 'ads-txt' ),
174
+ esc_html( $fields[3] )
175
+ ),
176
+ );
177
+ }
178
+ }
179
+
180
+ $sanitized = wp_strip_all_tags( $line );
181
+ } else {
182
+ // Not a comment, variable declaration, or data record; therefore, invalid.
183
+ // Early on we commented the line out for safety but it's kind of a weird thing to do with a JS AYS.
184
+ $sanitized = wp_strip_all_tags( $line );
185
+
186
+ $errors[] = array(
187
+ 'line' => $line_number,
188
+ 'type' => 'error',
189
+ 'message' => __( 'Invalid record', 'ads-txt' ),
190
+ );
191
+ }
192
+
193
+ unset( $record, $fields );
194
+ }
195
+
196
+ return array(
197
+ 'sanitized' => $sanitized,
198
+ 'errors' => $errors,
199
+ );
200
+ }
js/admin.js ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function( $, _ ) {
2
+ var submit = $( document.getElementById( 'submit' ) ),
3
+ notificationArea = $( document.getElementById( 'adstxt-notification-area' ) ),
4
+ notificationTemplate = wp.template( 'adstext-notice' ),
5
+ editor = wp.CodeMirror.fromTextArea( document.getElementById( 'adstxt_content' ), {
6
+ lineNumbers: true,
7
+ mode: 'shell'
8
+ } );
9
+
10
+ submit.on( 'click', function( e ){
11
+ e.preventDefault();
12
+
13
+ var textarea = $( document.getElementById( 'adstxt_content' ) ),
14
+ notices = $( '.adstxt-notice' ),
15
+ submit_wrap = $( 'p.submit' ),
16
+ spinner = submit_wrap.find( '.spinner' );
17
+
18
+ submit.attr( 'disabled', 'disabled' );
19
+ spinner.addClass( 'is-active' );
20
+
21
+ // clear any existing messages
22
+ notificationArea.hide();
23
+ notices.remove();
24
+
25
+ // Copy the code mirror contents into form for submission.
26
+ textarea.val( editor.getValue() );
27
+
28
+ $.ajax({
29
+ type: 'POST',
30
+ dataType: 'json',
31
+ url: ajaxurl,
32
+ data: $( '.adstxt-settings-form' ).serialize(),
33
+ success: function( r ) {
34
+ var templateData = {};
35
+
36
+ spinner.removeClass( 'is-active' );
37
+
38
+ if ( 'undefined' !== typeof r.sanitized ) {
39
+ textarea.val( r.sanitized );
40
+ }
41
+
42
+ if ( 'undefined' !== typeof r.saved && r.saved ) {
43
+ templateData.saved = {
44
+ 'saved_message': adstxt.saved_message
45
+ };
46
+ } else {
47
+ templateData.errors = {
48
+ 'error_message': adstxt.unknown_error
49
+ }
50
+ }
51
+
52
+ if ( 'undefined' !== typeof r.errors && r.errors.length > 0 ) {
53
+ templateData.errors = {
54
+ 'error_message': adstxt.error_message,
55
+ 'errors': r.errors
56
+ }
57
+ }
58
+ notificationArea.html( notificationTemplate( templateData ) ).show();
59
+ }
60
+ })
61
+ });
62
+
63
+ $( '.wrap' ).on( 'click', '#adstxt-ays-checkbox', function( e ) {
64
+ if ( true === $( this ).prop('checked') ) {
65
+ submit.removeAttr( 'disabled' );
66
+ } else {
67
+ submit.attr( 'disabled', 'disabled' );
68
+ }
69
+ } );
70
+
71
+ editor.on( 'change', function() {
72
+ $( '.adstxt-ays' ).remove();
73
+ submit.removeAttr( 'disabled' );
74
+ } );
75
+
76
+ } )( jQuery, _ );
readme.txt ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Ads.txt Manager ===
2
+ Contributors: 10up, helen, adamsilverstein, jakemgold
3
+ Author URI: http://10up.com
4
+ Plugin URI: https://github.com/10up/ads-txt
5
+ Tags: ads.txt, ads, ad manager, advertising, publishing, publishers
6
+ Requires at least: 4.9
7
+ Tested up to: 4.9.1
8
+ Requires PHP: 5.3
9
+ Stable tag: trunk
10
+ License: GPLv2 or later
11
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
+ Text Domain: ads-txt
13
+
14
+ Create, manage, and validate your ads.txt from within WordPress, just like any other content asset. Requires PHP 5.3+ and WordPress 4.9+.
15
+
16
+ == Description ==
17
+
18
+ Create, manage, and validate your ads.txt from within WordPress, just like any other content asset. Requires PHP 5.3+ and WordPress 4.9+.
19
+
20
+ === What is ads.txt? ===
21
+
22
+ Ads.txt is an initiative by the Interactive Advertising Bureau to enable publishers to take control over who can sell their ad inventory. Through our work at 10up with various publishers, we've created a way to manage and validate your ads.txt file from within WordPress, eliminating the need to upload a file. The validation baked into the plugin helps avoid malformed records, which can cause issues that end up cached for up to 24 hours and can lead to a drop in ad revenue.
23
+
24
+ === Technical Notes ===
25
+
26
+ * Requires PHP 5.3+.
27
+ * Requires WordPress 4.9+. Older versions of WordPress will not display any syntax highlighting and may break JavaScript and/or be unable to localize the plugin.
28
+ * Rewrites need to be enabled. Without rewrites, WordPress cannot know to supply `/ads.txt` when requested.
29
+ * Your site URL must not contain a path (e.g. `https://example.com/site/` or path-based multisite installs). While the plugin will appear to function in the admin, it will not display the contents at `https://example.com/site/ads.txt`. This is because the plugin follows the IAB spec, which requires that the ads.txt file be located at the root of a domain or subdomain.
30
+
31
+ === What about ads.cert? ===
32
+
33
+ We're closely monitoring continued developments in the ad fraud space, and see this plugin as not only a way to create and manage your ads.txt file but also be prepared for future changes and upgrades to specifications. Ads.cert is still in the extremely early stages so we don't see any immediate concerns with implementing ads.txt.
34
+
35
+ == Screenshots ==
36
+
37
+ 1. Example of editing an ads.txt file with errors
38
+
39
+ == Installation ==
40
+ 1. Install the plugin via the plugin installer, either by searching for it or uploading a .zip file.
41
+ 2. Activate the plugin.
42
+ 3. Head to Settings → Ads.txt and add the records you need.
43
+ 4. Check it out at yoursite.com/ads.txt!
44
+
45
+ == Changelog ==
46
+
47
+ = 1.0 =
48
+ * Initial plugin release