Plugin Directory

Changeset 2745813


Ignore:
Timestamp:
06/21/2022 11:27:32 AM (4 years ago)
Author:
woeler
Message:

Update to version 2.0.0 from GitHub

Location:
publisher-collective-ads-txt
Files:
38 added
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • publisher-collective-ads-txt/tags/2.0.0/README.md

    r2616954 r2745813  
    33This 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.
    44
    5 This plugin will fetch content from the Publisher Collective ads.txt file here: https://kumo.network-n.com/adstxt/partner.txt
     5This 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  
    11<?php
     2
     3declare(strict_types=1);
    24
    35/*
     
    57Plugin URI: https://github.com/PathfinderMediaGroup/publisher-collective-ads-txt-wordpress
    68Description: Installs and frequently updates the ads.txt file for Publisher Collective websites
    7 Version: 1.1.0
     9Version: 2.0.0
     10Requires PHP: 8.0
    811Author: Woeler
    912Author URI: https://www.pathfindermediagroup.com
     
    1114*/
    1215
     16define('PUB_COL_PLUGIN_DIR', plugin_dir_path(__FILE__));
    1317defined('ABSPATH') || exit;
     18
     19require_once PUB_COL_PLUGIN_DIR.'assets/php/settings/PublisherCollectiveSettings.php';
     20
    1421add_action('plugins_loaded', 'PublisherCollective::setup');
    1522
    1623final class PublisherCollective
    1724{
    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
    1928    {
    20     }
    21 
    22     public static function setup()
    23     {
    24         $self = new PublisherCollective();
     29        $self = new self();
     30        (new PublisherCollectiveSettings())->init();
    2531        add_action('wp', [$self, 'pc_cronstarter_activation']);
    2632        add_action('fetch-publisher-collective-ads-txt', [$self, 'fetch_ads_txt']);
     
    2834    }
    2935
    30     public static function pc_cronstarter_activation()
     36    public static function pc_cronstarter_activation(): void
    3137    {
    32         if (!wp_next_scheduled('fetch-publisher-collective-ads-txt')) {
     38        if (! wp_next_scheduled('fetch-publisher-collective-ads-txt')) {
    3339            wp_schedule_event(time(), 'daily', 'fetch-publisher-collective-ads-txt');
    3440        }
    3541    }
    3642
    37     public static function fetch_ads_txt()
     43    public static function fetch_ads_txt(): void
    3844    {
    3945        self::get_ads_txt_content_or_cache(true);
    4046    }
    4147
    42     public static function pc_cronstarter_deactivate()
     48    public static function pc_cronstarter_deactivate(): void
    4349    {
    4450        $timestamp = wp_next_scheduled('fetch-publisher-collective-ads-txt');
     
    4652    }
    4753
    48     public static function pc_cronstarter_activate()
     54    public static function pc_cronstarter_activate(): void
    4955    {
    5056        self::get_ads_txt_content_or_cache(true);
    5157    }
    5258
    53 
    54     public static function display_pc_ads_txt($query_vars)
     59    public static function display_pc_ads_txt(array $query_vars): array
    5560    {
    5661        $request = isset($_SERVER['REQUEST_URI']) ? esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])) : false;
     
    6469    }
    6570
    66     public static function getServerName()
     71    private static function getServerName(): ?string
    6772    {
    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())) {
    6982            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'];
    7683        }
    7784
     
    7986    }
    8087
    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
    8289    {
    8390        $data = get_transient('publisher_collective_ads_txt');
    8491        if (empty($data) || $renew) {
    8592            $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            ));
    8796            if ($data !== false) {
    8897                set_transient('publisher_collective_ads_txt', $data, 86400);
    8998            }
    9099        }
     100        if (! empty($data)) {
     101            $adsTxtExtraParams = get_option('pc-ads-txt-extra-params', null);
     102            $data .= PHP_EOL.$adsTxtExtraParams;
     103        } else {
     104            return '';
     105        }
    91106
    92         return $data;
     107        return trim($data);
    93108    }
    94109}
  • publisher-collective-ads-txt/tags/2.0.0/readme.txt

    r2683705 r2745813  
    33Donate link: https://patreon.com/esohub
    44Tags: Publisher Collective Ads Txt
    5 Requires at least: 4.9
    6 Tested up to: 5.9
    7 Requires PHP: 5.6
     5Requires at least: 5.7
     6Tested up to: 6.0
     7Requires PHP: 8.0
    88Stable tag: trunk
    99License: GPLv3 or later
  • publisher-collective-ads-txt/trunk/README.md

    r2616954 r2745813  
    33This 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.
    44
    5 This plugin will fetch content from the Publisher Collective ads.txt file here: https://kumo.network-n.com/adstxt/partner.txt
     5This 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  
    11<?php
     2
     3declare(strict_types=1);
    24
    35/*
     
    57Plugin URI: https://github.com/PathfinderMediaGroup/publisher-collective-ads-txt-wordpress
    68Description: Installs and frequently updates the ads.txt file for Publisher Collective websites
    7 Version: 1.1.0
     9Version: 2.0.0
     10Requires PHP: 8.0
    811Author: Woeler
    912Author URI: https://www.pathfindermediagroup.com
     
    1114*/
    1215
     16define('PUB_COL_PLUGIN_DIR', plugin_dir_path(__FILE__));
    1317defined('ABSPATH') || exit;
     18
     19require_once PUB_COL_PLUGIN_DIR.'assets/php/settings/PublisherCollectiveSettings.php';
     20
    1421add_action('plugins_loaded', 'PublisherCollective::setup');
    1522
    1623final class PublisherCollective
    1724{
    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
    1928    {
    20     }
    21 
    22     public static function setup()
    23     {
    24         $self = new PublisherCollective();
     29        $self = new self();
     30        (new PublisherCollectiveSettings())->init();
    2531        add_action('wp', [$self, 'pc_cronstarter_activation']);
    2632        add_action('fetch-publisher-collective-ads-txt', [$self, 'fetch_ads_txt']);
     
    2834    }
    2935
    30     public static function pc_cronstarter_activation()
     36    public static function pc_cronstarter_activation(): void
    3137    {
    32         if (!wp_next_scheduled('fetch-publisher-collective-ads-txt')) {
     38        if (! wp_next_scheduled('fetch-publisher-collective-ads-txt')) {
    3339            wp_schedule_event(time(), 'daily', 'fetch-publisher-collective-ads-txt');
    3440        }
    3541    }
    3642
    37     public static function fetch_ads_txt()
     43    public static function fetch_ads_txt(): void
    3844    {
    3945        self::get_ads_txt_content_or_cache(true);
    4046    }
    4147
    42     public static function pc_cronstarter_deactivate()
     48    public static function pc_cronstarter_deactivate(): void
    4349    {
    4450        $timestamp = wp_next_scheduled('fetch-publisher-collective-ads-txt');
     
    4652    }
    4753
    48     public static function pc_cronstarter_activate()
     54    public static function pc_cronstarter_activate(): void
    4955    {
    5056        self::get_ads_txt_content_or_cache(true);
    5157    }
    5258
    53 
    54     public static function display_pc_ads_txt($query_vars)
     59    public static function display_pc_ads_txt(array $query_vars): array
    5560    {
    5661        $request = isset($_SERVER['REQUEST_URI']) ? esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])) : false;
     
    6469    }
    6570
    66     public static function getServerName()
     71    private static function getServerName(): ?string
    6772    {
    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())) {
    6982            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'];
    7683        }
    7784
     
    7986    }
    8087
    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
    8289    {
    8390        $data = get_transient('publisher_collective_ads_txt');
    8491        if (empty($data) || $renew) {
    8592            $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            ));
    8796            if ($data !== false) {
    8897                set_transient('publisher_collective_ads_txt', $data, 86400);
    8998            }
    9099        }
     100        if (! empty($data)) {
     101            $adsTxtExtraParams = get_option('pc-ads-txt-extra-params', null);
     102            $data .= PHP_EOL.$adsTxtExtraParams;
     103        } else {
     104            return '';
     105        }
    91106
    92         return $data;
     107        return trim($data);
    93108    }
    94109}
  • publisher-collective-ads-txt/trunk/readme.txt

    r2683705 r2745813  
    33Donate link: https://patreon.com/esohub
    44Tags: Publisher Collective Ads Txt
    5 Requires at least: 4.9
    6 Tested up to: 5.9
    7 Requires PHP: 5.6
     5Requires at least: 5.7
     6Tested up to: 6.0
     7Requires PHP: 8.0
    88Stable tag: trunk
    99License: GPLv3 or later
Note: See TracChangeset for help on using the changeset viewer.