PluginProbe
Ads.txt & App-ads.txt Manager for WordPress / trunk
Ads.txt & App-ads.txt Manager for WordPress vtrunk
1.1.12 1.1.11 1.1.10 trunk
app-ads-txt / app-ads-txt.php

app-ads-txt.php in Ads.txt & App-ads.txt Manager for WordPress trunk, at app-ads-txt.php

232 lines 10.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * Plugin Name: Ads.txt & App-ads.txt Manager
5 * Description: App-ads.txt & Ads.txt manager allows you to create, manage & publish your app-ads.txt & ads.txt files from your WordPress dashboard.
6 * Author: Pagup
7 * Version: 1.1.12
8 * Author URI: https://pagup.com/
9 * Text Domain: app-ads-txt
10 * Domain Path: /languages/
11 */
12 if ( !defined( 'ABSPATH' ) ) {
13 exit;
14 }
15 if ( function_exists( 'adtm__fs' ) ) {
16 adtm__fs()->set_basename( false, __FILE__ );
17 } else {
18 if ( !function_exists( 'adtm__fs' ) ) {
19 if ( !defined( 'ADTM_PLUGIN_BASE' ) ) {
20 define( 'ADTM_PLUGIN_BASE', plugin_basename( __DIR__ ) );
21 }
22 if ( !defined( 'ADTM_PLUGIN_URL' ) ) {
23 define( 'ADTM_PLUGIN_URL', plugins_url( '', __FILE__ ) );
24 }
25 // Create a helper function for easy SDK access.
26 function adtm__fs() {
27 global $adtm__fs;
28 if ( !isset( $adtm__fs ) ) {
29 // Include Freemius SDK.
30 require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
31 $adtm__fs = fs_dynamic_init( array(
32 'id' => '4445',
33 'slug' => 'app-ads-txt',
34 'type' => 'plugin',
35 'public_key' => 'pk_07707b3aad7d8a6ef5bfb48f29e57',
36 'is_premium' => false,
37 'premium_suffix' => 'App-ads & ads.txt Manager PRO',
38 'has_addons' => false,
39 'has_paid_plans' => true,
40 'has_affiliation' => 'selected',
41 'trial' => array(
42 'days' => 7,
43 'is_require_payment' => true,
44 ),
45 'has_affiliation' => 'all',
46 'menu' => array(
47 'slug' => 'adtm',
48 'override_exact' => true,
49 'first-path' => 'options-general.php?page=adtm',
50 'support' => false,
51 'parent' => array(
52 'slug' => 'options-general.php',
53 ),
54 ),
55 'is_live' => true,
56 ) );
57 }
58 return $adtm__fs;
59 }
60
61 // Init Freemius.
62 adtm__fs();
63 // Signal that SDK was initiated.
64 do_action( 'adtm__fs_loaded' );
65 function adtm__fs_settings_url() {
66 return admin_url( 'options-general.php?page=adtm&tab=adtm-settings' );
67 }
68
69 adtm__fs()->add_filter( 'connect_url', 'adtm__fs_settings_url' );
70 adtm__fs()->add_filter( 'after_skip_url', 'adtm__fs_settings_url' );
71 adtm__fs()->add_filter( 'after_connect_url', 'adtm__fs_settings_url' );
72 adtm__fs()->add_filter( 'after_pending_connect_url', 'adtm__fs_settings_url' );
73 }
74 // freemius opt-in
75 function adtm__fs_custom_connect_message(
76 $message,
77 $user_first_name,
78 $product_title,
79 $user_login,
80 $site_link,
81 $freemius_link
82 ) {
83 $break = "<br><br>";
84 $more_plugins = '<p><a target="_blank" href="https://wordpress.org/plugins/meta-tags-for-seo/">Meta Tags for SEO</a>, <a target="_blank" href="https://wordpress.org/plugins/automatic-internal-links-for-seo/">Auto internal links for SEO</a>, <a target="_blank" href="https://wordpress.org/plugins/bulk-image-alt-text-with-yoast/">Bulk auto image Alt Text</a>, <a target="_blank" href="https://wordpress.org/plugins/bulk-image-title-attribute/">Bulk auto image Title Tag</a>, <a target="_blank" href="https://wordpress.org/plugins/mobilook/">Mobile view</a>, <a target="_blank" href="https://wordpress.org/plugins/better-robots-txt/">Wordpress Better-Robots.txt</a>, <a target="_blank" href="https://wordpress.org/plugins/wp-google-street-view/">Wp Google Street View</a>, <a target="_blank" href="https://wordpress.org/plugins/vidseo/">VidSeo</a>, ...</p>';
85 return sprintf( esc_html__( 'Hey %1$s, %2$s Click on Allow & Continue to start optimizing your app-ads.txt and ads-txt files. %2$s Never miss an important update -- opt-in to our security and feature updates notifications. %2$s See you on the other side.', 'app-ads-txt' ), $user_first_name, $break ) . $more_plugins;
86 }
87
88 adtm__fs()->add_filter(
89 'connect_message',
90 'adtm__fs_custom_connect_message',
91 10,
92 6
93 );
94 class adtm {
95 function __construct() {
96 // stuff to do on plugin activation/deactivation
97 register_activation_hook( __FILE__, array(&$this, 'adtm__activate') );
98 register_deactivation_hook( __FILE__, array(&$this, 'adtm__deactivate') );
99 //add quick links to plugin settings
100 $plugin = plugin_basename( __FILE__ );
101 if ( is_admin() ) {
102 add_filter( "plugin_action_links_{$plugin}", array(&$this, 'adtm__setting_link') );
103 }
104 }
105
106 // end function __construct()
107 // quick setting link in plugin section
108 function adtm__setting_link( $links ) {
109 $settings_link = '<a href="options-general.php?page=adtm">' . esc_html__( 'Settings', 'app-ads-txt' ) . '</a>';
110 array_unshift( $links, $settings_link );
111 return $links;
112 }
113
114 // end function setting_link()
115 // register options
116 function adtm__options() {
117 $adtm__options = get_option( 'app-ads-txt' );
118 return $adtm__options;
119 }
120
121 // end function adtm__options()
122 // removed settings (if checked) on plugin deactivation
123 function adtm__deactivate() {
124 $adtm__options = $this->adtm__options();
125 if ( is_array( $adtm__options ) && ! empty( $adtm__options['remove_settings'] ) ) {
126 delete_option( 'app-ads-txt' );
127 delete_option( 'app_ads_txt_evidence_v01' );
128 }
129 }
130
131 function adtm__activate() {
132 flush_rewrite_rules();
133 }
134
135 }
136
137 // end class
138 $adtm = new adtm();
139 add_action( 'init', 'adtm__rewrite' );
140 function adtm__rewrite() {
141 add_rewrite_rule( 'ads.txt/?', 'index.php?ads=1', 'top' );
142 //if ( adtm__fs()->can_use_premium_code__premium_only() ) { // pro only
143 add_rewrite_rule( 'app-ads.txt/?', 'index.php?app-ads=1', 'top' );
144 //}
145 }
146
147 add_filter( 'query_vars', 'adtm__query_vars' );
148 function adtm__query_vars( $query_vars ) {
149 $query_vars[] = 'ads';
150 //if ( adtm__fs()->can_use_premium_code__premium_only() ) { // pro only
151 $query_vars[] = 'app-ads';
152 //}
153 return $query_vars;
154 }
155
156 //if ( adtm__fs()->can_use_premium_code__premium_only() ) { // pro only
157 add_action( 'parse_request', 'adtm__main' );
158 function adtm__main( &$wp ) {
159 if ( array_key_exists( 'app-ads', $wp->query_vars ) ) {
160 header( 'Content-Type:text/plain' );
161 global $adtm;
162 $adtm__options = $adtm->adtm__options();
163 $output = "";
164 if ( empty( $adtm__options['app-ads'][1]['domain'] ) && empty( $adtm__options['app-ads-custom'] ) ) {
165 $output .= "# Records - App-ads.txt";
166 }
167 if ( isset( $adtm__options['app-ads'] ) && !empty( $adtm__options['app-ads'] ) ) {
168 foreach ( $adtm__options['app-ads'] as $key => $value ) {
169 $domain = ( isset( $value['domain'] ) && !empty( $value['domain'] ) ? $value['domain'] : "" );
170 $publisher = ( isset( $value['pub'] ) && !empty( $value['pub'] ) ? ", " . $value['pub'] : "" );
171 $relation = ( isset( $value['relation'] ) && !empty( $value['relation'] ) ? ", " . $value['relation'] : "" );
172 $cert = ( isset( $value['cert'] ) && !empty( $value['cert'] ) ? ", " . $value['cert'] : "" );
173 $output .= $domain . $publisher . $relation . $cert . "\n";
174 }
175 }
176 if ( isset( $adtm__options['app-ads-custom'] ) && !empty( $adtm__options['app-ads-custom'] ) ) {
177 $output .= "\n";
178 $output .= $adtm__options['app-ads-custom'];
179 }
180 $output .= "\n";
181 $output .= "# This app-ads.txt file was created by App-ads.txt & Ads.txt Manager Plugin. https://www.better-robots.com/";
182 echo $output;
183 exit;
184 }
185 }
186
187 //}
188 add_action( 'parse_request', 'adtm__ads_main' );
189 function adtm__ads_main( &$wp ) {
190 if ( array_key_exists( 'ads', $wp->query_vars ) ) {
191 header( 'Content-Type:text/plain' );
192 global $adtm;
193 $adtm__options = $adtm->adtm__options();
194 $output = "";
195 if ( empty( $adtm__options['ads-txt'][1]['domain'] ) && empty( $adtm__options['ads-txt-custom'] ) ) {
196 $output .= "# Records - Ads.txt";
197 }
198 if ( isset( $adtm__options['ads-txt'] ) && !empty( $adtm__options['ads-txt'] ) ) {
199 foreach ( $adtm__options['ads-txt'] as $key => $value ) {
200 $domain = ( isset( $value['domain'] ) && !empty( $value['domain'] ) ? $value['domain'] : "" );
201 $publisher = ( isset( $value['pub'] ) && !empty( $value['pub'] ) ? ", " . $value['pub'] : "" );
202 $relation = ( isset( $value['relation'] ) && !empty( $value['relation'] ) ? ", " . $value['relation'] : "" );
203 $cert = ( isset( $value['cert'] ) && !empty( $value['cert'] ) ? ", " . $value['cert'] : "" );
204 $output .= $domain . $publisher . $relation . $cert . "\n";
205 }
206 }
207 if ( isset( $adtm__options['ads-txt-custom'] ) && !empty( $adtm__options['ads-txt-custom'] ) ) {
208 $output .= "\n";
209 $output .= $adtm__options['ads-txt-custom'];
210 }
211 $output .= "\n";
212 $output .= "# This ads.txt file was created by App-ads.txt & Ads.txt Manager Plugin. https://www.better-robots.com/";
213 echo $output;
214 exit;
215 }
216 }
217
218 // Evidence parser module (no runtime scan or UI side effects in v0.1).
219 include_once dirname( __FILE__ ) . '/inc/evidence/bootstrap.php';
220
221 // admin notifications
222 include_once dirname( __FILE__ ) . '/inc/notices.php';
223 add_action( 'init', 'adtm__textdomain' );
224 function adtm__textdomain() {
225 load_plugin_textdomain( 'app-ads-txt', false, basename( dirname( __FILE__ ) ) . '/languages' );
226 }
227
228 if ( is_admin() ) {
229 include_once dirname( __FILE__ ) . '/app-ads-txt-admin.php';
230 }
231 }
232