Changeset 2745813
- Timestamp:
- 06/21/2022 11:27:32 AM (4 years ago)
- Location:
- publisher-collective-ads-txt
- Files:
-
- 38 added
- 6 edited
- 1 copied
-
tags/2.0.0 (copied) (copied from publisher-collective-ads-txt/trunk)
-
tags/2.0.0/.disignore (added)
-
tags/2.0.0/.php-cs-fixer.php (added)
-
tags/2.0.0/README.md (modified) (1 diff)
-
tags/2.0.0/assets (added)
-
tags/2.0.0/assets/php (added)
-
tags/2.0.0/assets/php/settings (added)
-
tags/2.0.0/assets/php/settings/PublisherCollectiveSettings.php (added)
-
tags/2.0.0/assets/templates (added)
-
tags/2.0.0/assets/templates/additional-line-items-error-messages.php (added)
-
tags/2.0.0/assets/templates/additional-line-items-form.php (added)
-
tags/2.0.0/composer.json (added)
-
tags/2.0.0/composer.lock (added)
-
tags/2.0.0/phpunit.xml (added)
-
tags/2.0.0/publisher-collective.php (modified) (7 diffs)
-
tags/2.0.0/readme.txt (modified) (1 diff)
-
tags/2.0.0/tests (added)
-
tags/2.0.0/tests/PublisherCollectiveAdstxtPluginTest.php (added)
-
tags/2.0.0/tests/assets (added)
-
tags/2.0.0/tests/assets/php (added)
-
tags/2.0.0/tests/assets/php/settings (added)
-
tags/2.0.0/tests/assets/php/settings/PublisherCollectiveSettingsTest.php (added)
-
tags/2.0.0/tests/publisher-collective_mock_functions.php (added)
-
trunk/.disignore (added)
-
trunk/.php-cs-fixer.php (added)
-
trunk/README.md (modified) (1 diff)
-
trunk/assets (added)
-
trunk/assets/php (added)
-
trunk/assets/php/settings (added)
-
trunk/assets/php/settings/PublisherCollectiveSettings.php (added)
-
trunk/assets/templates (added)
-
trunk/assets/templates/additional-line-items-error-messages.php (added)
-
trunk/assets/templates/additional-line-items-form.php (added)
-
trunk/composer.json (added)
-
trunk/composer.lock (added)
-
trunk/phpunit.xml (added)
-
trunk/publisher-collective.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/tests (added)
-
trunk/tests/PublisherCollectiveAdstxtPluginTest.php (added)
-
trunk/tests/assets (added)
-
trunk/tests/assets/php (added)
-
trunk/tests/assets/php/settings (added)
-
trunk/tests/assets/php/settings/PublisherCollectiveSettingsTest.php (added)
-
trunk/tests/publisher-collective_mock_functions.php (added)
Legend:
- Unmodified
- Added
- Removed
-
publisher-collective-ads-txt/tags/2.0.0/README.md
r2616954 r2745813 3 3 This plugin will make sure the /ads.txt route of your website will be up to date with the latest ads.txt file from Publisher Collective. 4 4 5 This plugin will fetch content from the Publisher Collective ads.txt file here: https://kumo.network-n.com/adstxt/partner.txt 5 This plugin will fetch content from the Publisher Collective ads.txt file here: `https://kumo.network-n.com/adstxt/?domain={{your-domain-name}}` 6 7 <em>Please change {{your-domain-name}} to your domain URL.</em> -
publisher-collective-ads-txt/tags/2.0.0/publisher-collective.php
r2683705 r2745813 1 1 <?php 2 3 declare(strict_types=1); 2 4 3 5 /* … … 5 7 Plugin URI: https://github.com/PathfinderMediaGroup/publisher-collective-ads-txt-wordpress 6 8 Description: Installs and frequently updates the ads.txt file for Publisher Collective websites 7 Version: 1.1.0 9 Version: 2.0.0 10 Requires PHP: 8.0 8 11 Author: Woeler 9 12 Author URI: https://www.pathfindermediagroup.com … … 11 14 */ 12 15 16 define('PUB_COL_PLUGIN_DIR', plugin_dir_path(__FILE__)); 13 17 defined('ABSPATH') || exit; 18 19 require_once PUB_COL_PLUGIN_DIR.'assets/php/settings/PublisherCollectiveSettings.php'; 20 14 21 add_action('plugins_loaded', 'PublisherCollective::setup'); 15 22 16 23 final class PublisherCollective 17 24 { 18 public function __construct() 25 public const ADS_TXT_URL_PREFIX = 'https://kumo.network-n.com/adstxt/?domain='; 26 27 public static function setup(): void 19 28 { 20 } 21 22 public static function setup() 23 { 24 $self = new PublisherCollective(); 29 $self = new self(); 30 (new PublisherCollectiveSettings())->init(); 25 31 add_action('wp', [$self, 'pc_cronstarter_activation']); 26 32 add_action('fetch-publisher-collective-ads-txt', [$self, 'fetch_ads_txt']); … … 28 34 } 29 35 30 public static function pc_cronstarter_activation() 36 public static function pc_cronstarter_activation(): void 31 37 { 32 if (! wp_next_scheduled('fetch-publisher-collective-ads-txt')) {38 if (! wp_next_scheduled('fetch-publisher-collective-ads-txt')) { 33 39 wp_schedule_event(time(), 'daily', 'fetch-publisher-collective-ads-txt'); 34 40 } 35 41 } 36 42 37 public static function fetch_ads_txt() 43 public static function fetch_ads_txt(): void 38 44 { 39 45 self::get_ads_txt_content_or_cache(true); 40 46 } 41 47 42 public static function pc_cronstarter_deactivate() 48 public static function pc_cronstarter_deactivate(): void 43 49 { 44 50 $timestamp = wp_next_scheduled('fetch-publisher-collective-ads-txt'); … … 46 52 } 47 53 48 public static function pc_cronstarter_activate() 54 public static function pc_cronstarter_activate(): void 49 55 { 50 56 self::get_ads_txt_content_or_cache(true); 51 57 } 52 58 53 54 public static function display_pc_ads_txt($query_vars) 59 public static function display_pc_ads_txt(array $query_vars): array 55 60 { 56 61 $request = isset($_SERVER['REQUEST_URI']) ? esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])) : false; … … 64 69 } 65 70 66 p ublic static function getServerName()71 private static function getServerName(): ?string 67 72 { 68 if (!empty(get_home_url())) { 73 return self::getDomain() 74 ?? $_SERVER['SERVER_NAME'] 75 ?? $_SERVER['HTTP_HOST'] 76 ?? null; 77 } 78 79 private static function getDomain(): ?string 80 { 81 if (! empty(get_home_url())) { 69 82 return rtrim(str_replace(['https://', 'http://', 'www.'], '', get_home_url()), '/'); 70 }71 if (!empty($_SERVER['SERVER_NAME'])) {72 return $_SERVER['SERVER_NAME'];73 }74 if (!empty($_SERVER['HTTP_HOST'])) {75 return $_SERVER['HTTP_HOST'];76 83 } 77 84 … … 79 86 } 80 87 81 public static function get_ads_txt_content_or_cache( $renew = false)88 public static function get_ads_txt_content_or_cache(bool $renew = false): string 82 89 { 83 90 $data = get_transient('publisher_collective_ads_txt'); 84 91 if (empty($data) || $renew) { 85 92 $serverName = self::getServerName(); 86 $data = wp_remote_retrieve_body(wp_remote_get('https://kumo.network-n.com/adstxt/' . (empty($serverName) ? '' : ('?domain=' . $serverName)))); 93 $data = wp_remote_retrieve_body(wp_remote_get( 94 $serverName ? (self::ADS_TXT_URL_PREFIX.$serverName) : self::ADS_TXT_URL_PREFIX 95 )); 87 96 if ($data !== false) { 88 97 set_transient('publisher_collective_ads_txt', $data, 86400); 89 98 } 90 99 } 100 if (! empty($data)) { 101 $adsTxtExtraParams = get_option('pc-ads-txt-extra-params', null); 102 $data .= PHP_EOL.$adsTxtExtraParams; 103 } else { 104 return ''; 105 } 91 106 92 return $data;107 return trim($data); 93 108 } 94 109 } -
publisher-collective-ads-txt/tags/2.0.0/readme.txt
r2683705 r2745813 3 3 Donate link: https://patreon.com/esohub 4 4 Tags: Publisher Collective Ads Txt 5 Requires at least: 4.96 Tested up to: 5.97 Requires PHP: 5.65 Requires at least: 5.7 6 Tested up to: 6.0 7 Requires PHP: 8.0 8 8 Stable tag: trunk 9 9 License: GPLv3 or later -
publisher-collective-ads-txt/trunk/README.md
r2616954 r2745813 3 3 This plugin will make sure the /ads.txt route of your website will be up to date with the latest ads.txt file from Publisher Collective. 4 4 5 This plugin will fetch content from the Publisher Collective ads.txt file here: https://kumo.network-n.com/adstxt/partner.txt 5 This plugin will fetch content from the Publisher Collective ads.txt file here: `https://kumo.network-n.com/adstxt/?domain={{your-domain-name}}` 6 7 <em>Please change {{your-domain-name}} to your domain URL.</em> -
publisher-collective-ads-txt/trunk/publisher-collective.php
r2683705 r2745813 1 1 <?php 2 3 declare(strict_types=1); 2 4 3 5 /* … … 5 7 Plugin URI: https://github.com/PathfinderMediaGroup/publisher-collective-ads-txt-wordpress 6 8 Description: Installs and frequently updates the ads.txt file for Publisher Collective websites 7 Version: 1.1.0 9 Version: 2.0.0 10 Requires PHP: 8.0 8 11 Author: Woeler 9 12 Author URI: https://www.pathfindermediagroup.com … … 11 14 */ 12 15 16 define('PUB_COL_PLUGIN_DIR', plugin_dir_path(__FILE__)); 13 17 defined('ABSPATH') || exit; 18 19 require_once PUB_COL_PLUGIN_DIR.'assets/php/settings/PublisherCollectiveSettings.php'; 20 14 21 add_action('plugins_loaded', 'PublisherCollective::setup'); 15 22 16 23 final class PublisherCollective 17 24 { 18 public function __construct() 25 public const ADS_TXT_URL_PREFIX = 'https://kumo.network-n.com/adstxt/?domain='; 26 27 public static function setup(): void 19 28 { 20 } 21 22 public static function setup() 23 { 24 $self = new PublisherCollective(); 29 $self = new self(); 30 (new PublisherCollectiveSettings())->init(); 25 31 add_action('wp', [$self, 'pc_cronstarter_activation']); 26 32 add_action('fetch-publisher-collective-ads-txt', [$self, 'fetch_ads_txt']); … … 28 34 } 29 35 30 public static function pc_cronstarter_activation() 36 public static function pc_cronstarter_activation(): void 31 37 { 32 if (! wp_next_scheduled('fetch-publisher-collective-ads-txt')) {38 if (! wp_next_scheduled('fetch-publisher-collective-ads-txt')) { 33 39 wp_schedule_event(time(), 'daily', 'fetch-publisher-collective-ads-txt'); 34 40 } 35 41 } 36 42 37 public static function fetch_ads_txt() 43 public static function fetch_ads_txt(): void 38 44 { 39 45 self::get_ads_txt_content_or_cache(true); 40 46 } 41 47 42 public static function pc_cronstarter_deactivate() 48 public static function pc_cronstarter_deactivate(): void 43 49 { 44 50 $timestamp = wp_next_scheduled('fetch-publisher-collective-ads-txt'); … … 46 52 } 47 53 48 public static function pc_cronstarter_activate() 54 public static function pc_cronstarter_activate(): void 49 55 { 50 56 self::get_ads_txt_content_or_cache(true); 51 57 } 52 58 53 54 public static function display_pc_ads_txt($query_vars) 59 public static function display_pc_ads_txt(array $query_vars): array 55 60 { 56 61 $request = isset($_SERVER['REQUEST_URI']) ? esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])) : false; … … 64 69 } 65 70 66 p ublic static function getServerName()71 private static function getServerName(): ?string 67 72 { 68 if (!empty(get_home_url())) { 73 return self::getDomain() 74 ?? $_SERVER['SERVER_NAME'] 75 ?? $_SERVER['HTTP_HOST'] 76 ?? null; 77 } 78 79 private static function getDomain(): ?string 80 { 81 if (! empty(get_home_url())) { 69 82 return rtrim(str_replace(['https://', 'http://', 'www.'], '', get_home_url()), '/'); 70 }71 if (!empty($_SERVER['SERVER_NAME'])) {72 return $_SERVER['SERVER_NAME'];73 }74 if (!empty($_SERVER['HTTP_HOST'])) {75 return $_SERVER['HTTP_HOST'];76 83 } 77 84 … … 79 86 } 80 87 81 public static function get_ads_txt_content_or_cache( $renew = false)88 public static function get_ads_txt_content_or_cache(bool $renew = false): string 82 89 { 83 90 $data = get_transient('publisher_collective_ads_txt'); 84 91 if (empty($data) || $renew) { 85 92 $serverName = self::getServerName(); 86 $data = wp_remote_retrieve_body(wp_remote_get('https://kumo.network-n.com/adstxt/' . (empty($serverName) ? '' : ('?domain=' . $serverName)))); 93 $data = wp_remote_retrieve_body(wp_remote_get( 94 $serverName ? (self::ADS_TXT_URL_PREFIX.$serverName) : self::ADS_TXT_URL_PREFIX 95 )); 87 96 if ($data !== false) { 88 97 set_transient('publisher_collective_ads_txt', $data, 86400); 89 98 } 90 99 } 100 if (! empty($data)) { 101 $adsTxtExtraParams = get_option('pc-ads-txt-extra-params', null); 102 $data .= PHP_EOL.$adsTxtExtraParams; 103 } else { 104 return ''; 105 } 91 106 92 return $data;107 return trim($data); 93 108 } 94 109 } -
publisher-collective-ads-txt/trunk/readme.txt
r2683705 r2745813 3 3 Donate link: https://patreon.com/esohub 4 4 Tags: Publisher Collective Ads Txt 5 Requires at least: 4.96 Tested up to: 5.97 Requires PHP: 5.65 Requires at least: 5.7 6 Tested up to: 6.0 7 Requires PHP: 8.0 8 8 Stable tag: trunk 9 9 License: GPLv3 or later
Note: See TracChangeset
for help on using the changeset viewer.