'; echo '
'; echo '

Authorized Digital Sellers / ads.txt

'; echo '

Authorized Digital Sellers, or ads.txt, is an IAB initiative to improve transparency in programmatic advertising.

'; echo '

You can easily manage your ads.txt from within Wp-Insert, providing confidence to brands they are buying authentic publisher inventory, protect you from counterfiet inventory and might even lead to higher monetization for your ad invertory.

'; echo '
'; echo '
'; if ( wp_insert_adstxt_file_exists() ) { echo 'Modify ads.txt'; } else { echo 'Generate ads.txt'; } echo '
'; echo ''; } /* End Add Card in Admin Panel */ /* Begin Create Ads.txt */ add_action( 'wp_ajax_wp_insert_adstxt_generate_form_get_content', 'wp_insert_adstxt_generate_form_get_content' ); function wp_insert_adstxt_generate_form_get_content() { check_ajax_referer( 'wp-insert', 'wp_insert_nonce' ); echo '
'; echo '
'; $control = new smartlogixControls(); echo '

ads.txt Content

'; echo '
'; $control->add_control( [ 'type' => 'textarea', 'id' => 'wp_insert_adstxt_content', 'name' => 'wp_insert_adstxt_content', 'style' => 'height: 220px;', 'value' => wp_insert_adstxt_get_content(), 'helpText' => 'You can directly edit the entries here or you can use the entry generator below to quickly create new entries', ] ); $control->create_section( 'ads.txt Content' ); wp_insert_echo_html( $control->HTML ); $control->clear_controls(); echo '
'; echo '

Entry Generator

'; echo '
'; $control->add_control( [ 'type' => 'text', 'id' => 'wp_insert_adstxt_new_entry_domain', 'name' => 'wp_insert_adstxt_new_entry_domain', 'label' => 'Domain name of the advertising system (Required)', 'value' => '', 'helpText' => 'For Google Adsense Use "google.com"; for other networks, contact your service provider for values.', ] ); $control->add_control( [ 'type' => 'text', 'id' => 'wp_insert_adstxt_new_entry_pid', 'name' => 'wp_insert_adstxt_new_entry_pid', 'label' => 'Publisher’s Account ID (Required)', 'value' => '', 'helpText' => 'For Google Adsense Use your Publisher ID "pub-xxxxxxxxxxxxxxxx"; for other networks, contact your service provider for values.', ] ); $control->add_control( [ 'type' => 'select', 'id' => 'wp_insert_adstxt_new_entry_type', 'name' => 'wp_insert_adstxt_new_entry_type', 'label' => 'Type of Account / Relationship (Required)', 'value' => '', 'options' => [ [ 'text' => 'Direct', 'value' => 'DIRECT', ], [ 'text' => 'Reseller', 'value' => 'RESELLER', ], ], 'helpText' => 'For Google Adsense select "Reseller"; for other networks, contact your service provider for values.', ] ); $control->add_control( [ 'type' => 'text', 'id' => 'wp_insert_adstxt_new_entry_certauthority', 'name' => 'wp_insert_adstxt_new_entry_certauthority', 'label' => 'Certification Authority ID', 'value' => '', 'helpText' => 'Contact your service provider for values.', ] ); $control->HTML .= '

'; $control->create_section( 'Entry Generator' ); wp_insert_echo_html( $control->HTML ); echo '
'; echo '
'; echo ''; echo '
'; wp_die(); } /* End Create Ads.txt */ /* Begin Update Ads.txt */ add_action( 'wp_ajax_wp_insert_adstxt_generate_form_save_action', 'wp_insert_adstxt_generate_form_save_action' ); function wp_insert_adstxt_generate_form_save_action() { check_ajax_referer( 'wp-insert', 'wp_insert_nonce' ); $content = ( ( isset( $_POST['wp_insert_adstxt_content'] ) ) ? sanitize_textarea_field( wp_unslash( $_POST['wp_insert_adstxt_content'] ) ) : '' ); $output = wp_insert_adstxt_updation_failed_message( $content ); $output .= ''; if ( wp_insert_adstxt_update_content( $content ) ) { echo '###SUCCESS###'; } else { wp_insert_echo_html( $output ); } wp_die(); } /* End Update Ads.txt */ /* Begin Common Functions */ function wp_insert_adstxt_file_exists() { if ( file_exists( trailingslashit( get_home_path() ) . 'ads.txt' ) ) { return true; } return false; } function wp_insert_adstxt_get_content() { if ( wp_insert_adstxt_file_exists() ) { global $wp_filesystem; if ( ! $wp_filesystem ) { require_once ABSPATH . 'wp-admin/includes/file.php'; WP_Filesystem(); } $contents = $wp_filesystem->get_contents( trailingslashit( get_home_path() ) . 'ads.txt' ); return ( false === $contents ) ? '' : $contents; } return ''; } function wp_insert_adstxt_update_content( $content ) { wp_insert_adstxt_adsense_admin_notice_reset(); if ( get_filesystem_method() === 'direct' ) { $creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, [] ); if ( ! WP_Filesystem( $creds ) ) { return false; } global $wp_filesystem; if ( ! $wp_filesystem->put_contents( trailingslashit( get_home_path() ) . 'ads.txt', $content, FS_CHMOD_FILE ) ) { return false; } } else { return false; } return true; } function wp_insert_adstxt_updation_failed_message( $content ) { $output = '
'; $output .= '

Auto Creation / Updation of ads.txt failed due to access permission restrictions on the server.

'; $output .= '

You have to manually upload the file using your Host\'s File manager or your favourite FTP program

'; $output .= '

ads.txt should be located in the root of your server. After manually uploading the file click here to check if its accessible from the correct location

'; $output .= ''; $output .= '

Download ads.txt

'; $output .= '
'; return $output; } /* End Common Functions */