diff --git a/.gitattributes b/.gitattributes index a2fa8a4..9c1ef84 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,13 +4,7 @@ /tests export-ignore /vendor export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.phpcs.xml.dist export-ignore -/.phpcompat.xml.dist export-ignore -/.phpunit.result.cache export-ignore -/.wp-env.json export-ignore -/.wp-env.override.json export-ignore +/.* export-ignore /CHANGELOG.md export-ignore /CODE_OF_CONDUCT.md export-ignore /composer.json export-ignore diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e8228cc..4781eb3 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,5 +1,5 @@ -# These owners will be the default owners for everything in the repo. Unless a later match takes precedence, @peterwilsoncc, as primary maintainer will be requested for review when someone opens a Pull Request. -* @peterwilsoncc +# These owners will be the default owners for everything in the repo. Unless a later match takes precedence, @jeffpaul and @dkotter, as primary maintainers will be requested for review when someone opens a Pull Request. +* @jeffpaul @dkotter # GitHub and WordPress.org specifics /.github/ @jeffpaul diff --git a/.github/workflows/no-response.yml b/.github/workflows/close-stale-issues.yml similarity index 55% rename from .github/workflows/no-response.yml rename to .github/workflows/close-stale-issues.yml index ce0c42f..4ffcfbc 100644 --- a/.github/workflows/no-response.yml +++ b/.github/workflows/close-stale-issues.yml @@ -1,26 +1,27 @@ -name: No Response +name: 'Close stale issues' # **What it does**: Closes issues where the original author doesn't respond to a request for information. # **Why we have it**: To remove the need for maintainers to remember to check back on issues periodically to see if contributors have responded. -# **Who does it impact**: Everyone that works on docs or docs-internal. on: - issue_comment: - types: [created] schedule: - # Schedule for five minutes after the hour, every hour - - cron: '5 * * * *' + # Schedule for every day at 1:30am UTC + - cron: '30 1 * * *' + +permissions: + issues: write jobs: - noResponse: + stale: runs-on: ubuntu-latest steps: - - uses: lee-dohm/no-response@v0.5.0 + - uses: actions/stale@v9 with: - token: ${{ github.token }} - daysUntilClose: 14 # Number of days of inactivity before an Issue is closed for lack of response - responseRequiredLabel: "needs:feedback" # Label indicating that a response from the original author is required - closeComment: > + days-before-stale: 7 + days-before-close: 7 + stale-issue-message: > + It has been 7 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 7 days, but if you have more information to add then please comment and the issue will stay open. + close-issue-message: > This issue has been automatically closed because there has been no response to our request for more information. With only the information that is currently in the issue, we don't have enough information @@ -28,3 +29,8 @@ jobs: that we can investigate further. See [this blog post on bug reports and the importance of repro steps](https://www.lee-dohm.com/2015/01/04/writing-good-bug-reports/) for more information about the kind of information that may be helpful. + stale-issue-label: 'stale' + close-issue-reason: 'not_planned' + any-of-labels: 'needs:feedback' + remove-stale-when-updated: true + diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 4ca5066..e70ad88 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -19,13 +19,13 @@ jobs: matrix: core: - {name: 'WP latest', version: 'latest'} - - {name: 'WP minimum', version: 'WordPress/WordPress#5.7'} + - {name: 'WP minimum', version: 'WordPress/WordPress#6.3'} - {name: 'WP trunk', version: 'WordPress/WordPress#master'} steps: - name: Checkout uses: actions/checkout@v3 - name: Download build zip - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ github.event.repository.name }} path: ${{ github.event.repository.name }} @@ -62,7 +62,7 @@ jobs: npx mochawesome-report-generator tests/cypress/reports/mochawesome.json -o tests/cypress/reports/ cat ./tests/cypress/reports/mochawesome.md >> $GITHUB_STEP_SUMMARY - name: Make artifacts available - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() with: name: cypress-artifact diff --git a/.github/workflows/repo-automator.yml b/.github/workflows/repo-automator.yml new file mode 100644 index 0000000..66d037e --- /dev/null +++ b/.github/workflows/repo-automator.yml @@ -0,0 +1,32 @@ +name: 'Repo Automator' +on: + issues: + types: + - opened + push: + branches: + - develop + pull_request: + types: + - opened + - edited + - synchronize + - converted_to_draft + - ready_for_review + branches: + - develop + +jobs: + Validate: + runs-on: ubuntu-latest + steps: + - uses: 10up/action-repo-automator@trunk + with: + fail-label: needs:feedback + pass-label: needs:code-review + conflict-label: needs:refresh + reviewers: | + peterwilsoncc + team:open-source-practice + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/wordpress-latest.yml b/.github/workflows/wordpress-version-checker.yml similarity index 80% rename from .github/workflows/wordpress-latest.yml rename to .github/workflows/wordpress-version-checker.yml index b134ea5..34e4410 100644 --- a/.github/workflows/wordpress-latest.yml +++ b/.github/workflows/wordpress-version-checker.yml @@ -10,11 +10,14 @@ on: schedule: - cron: '0 0 * * 1' +permissions: + issues: write + jobs: wordpress-version-checker: runs-on: ubuntu-latest steps: - name: WordPress version checker - uses: skaut/wordpress-version-checker@v1.2.0 + uses: skaut/wordpress-version-checker@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 5bff5d0..5daec00 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ tests/cypress/reports .wp-env.override.json .phpunit.result.cache +.github/.DS_Store diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..df93858 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v20.11.0 \ No newline at end of file diff --git a/.wordpress-version-checker.json b/.wordpress-version-checker.json new file mode 100644 index 0000000..84aa873 --- /dev/null +++ b/.wordpress-version-checker.json @@ -0,0 +1,3 @@ +{ + "channel": "rc" +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2464056..1f50291 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,30 @@ All notable changes to this project will be documented in this file, per [the Ke ## [Unreleased] - TBD +## [1.4.4] - 2024-06-26 +### Added +- Placeholder record can be added with no authorized sellers or buyers (props [@ankitrox](https://github.com/ankitrox), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#129](https://github.com/10up/ads-txt/pull/129)). + +### Changed +- Bump WordPress "tested up to" version 6.5 (props [@zamanq](https://github.com/zamanq), [@QAharshalkadu](https://github.com/QAharshalkadu), [@jeffpaul](https://github.com/jeffpaul), [@qasumitbagthariya](https://github.com/qasumitbagthariya), [@sudip-md](https://github.com/sudip-md) via [#152](https://github.com/10up/ads-txt/pull/152), [#156](https://github.com/10up/ads-txt/pull/156), [#162](https://github.com/10up/ads-txt/issues/162)). + +### Fixed +- Better error handling for environments that don't match our minimum PHP version (props [@dkotter](https://github.com/dkotter), [@rahulsprajapati](https://github.com/rahulsprajapati), [@peterwilsoncc](https://github.com/peterwilsoncc), [@frankiebordone](https://github.com/frankiebordone), [@vikrampm1](https://github.com/vikrampm1) via [#149](https://github.com/10up/ads-txt/pull/149)). + +### Security +- Bump `semver` from 7.3.5 to 7.5.3 (props [@dependabot](https://github.com/apps/dependabot), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#147](https://github.com/10up/ads-txt/pull/147)). + +### Developer +- Added Repo Automator GitHub Action (props [@iamdharmesh](https://github.com/iamdharmesh) via [#167](https://github.com/10up/ads-txt/pull/167)). +- Added a "Testing" section in the `CONTRIBUTING.md` file (props [@kmgalanakis](https://github.com/kmgalanakis), [@jeffpaul](https://github.com/jeffpaul) via [#166](https://github.com/10up/ads-txt/pull/166)). +- Cleaned up NPM dependencies and update node to v20 (props [@Sidsector9](https://github.com/Sidsector9), [@dkotter](https://github.com/dkotter) via [#161](https://github.com/10up/ads-txt/pull/161)). +- Updated the `skaut/wordpress-version-checker` to check WordPress "tested up to" during the Release Candidate phase (props [@jeffpaul](https://github.com/jeffpaul), [@iamdharmesh](https://github.com/iamdharmesh) via [#145](https://github.com/10up/ads-txt/pull/145)). +- Upgraded the `download-artifact` from v3 to v4 (props [@iamdharmesh](https://github.com/iamdharmesh) via [#163](https://github.com/10up/ads-txt/pull/163)). +- Replaced `lee-dohm/no-response` with `actions/stale` to help with closing no-response/stale issues (props [@jeffpaul](https://github.com/jeffpaul) via [#164](https://github.com/10up/ads-txt/pull/164)). +- Bumped `Cypress` version from 11.2.0 to 13.2.0 (props [@iamdharmesh](https://github.com/iamdharmesh), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#154](https://github.com/10up/ads-txt/pull/154)). +- Bumped `@wordpress/env` version from 5.7.0 to 8.7.0 (props [@iamdharmesh](https://github.com/iamdharmesh), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#154](https://github.com/10up/ads-txt/pull/154)). +- Bumped `cypress-mochawesome-reporter` version 3.4.0 to 3.6.0 (props [@iamdharmesh](https://github.com/iamdharmesh), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#154](https://github.com/10up/ads-txt/pull/154)). + ## [1.4.3] - 2023-06-21 ### Added - `ads.txt` file exists check from the backend (props [@sksaju](https://github.com/sksaju), [@peterwilsoncc](https://github.com/peterwilsoncc), [@mmcachran](https://github.com/mmcachran), [@dinhtungdu](https://github.com/dinhtungdu), [@helen](https://github.com/helen), [@jeffpaul](https://github.com/jeffpaul) via [#131](https://github.com/10up/ads-txt/pull/131)). @@ -102,6 +126,7 @@ All notable changes to this project will be documented in this file, per [the Ke - Initial plugin release [Unreleased]: https://github.com/10up/ads-txt/compare/trunk...develop +[1.4.4]: https://github.com/10up/ads-txt/compare/1.4.3...1.4.4 [1.4.3]: https://github.com/10up/ads-txt/compare/1.4.2...1.4.3 [1.4.2]: https://github.com/10up/ads-txt/compare/1.4.1...1.4.2 [1.4.1]: https://github.com/10up/ads-txt/compare/1.4.0...1.4.1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1649d69..af363b9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,6 +22,10 @@ Pull requests represent a proposed solution to a specified problem. They should For more on how 10up writes and manages code, check out our [10up Engineering Best Practices](https://10up.github.io/Engineering-Best-Practices/). +### Testing + +Helping to test an open source project and provide feedback on success or failure of those tests is also a helpful contribution. You can find details on the Critical Flows and Test Cases in [this project's GitHub Wiki](https://github.com/10up/ads-txt/wiki) as well as details on our overall approach to [Critical Flows and Test Cases in our Open Source Best Practices](https://10up.github.io/Open-Source-Best-Practices/testing/#critial-flows). Submitting the results of testing via our Critical Flows as a comment on a Pull Request of a specific feature or as an Issue when testing the entire project is the best approach for providing testing results. + ## Maintenance process ### Triage @@ -90,8 +94,9 @@ Line 10: f08c47fec0942 does not appear to be a valid TAG-ID 8. Push: Push your `trunk` branch to GitHub (e.g. `git push origin trunk`). 9. [Compare](https://github.com/10up/ads-txt/compare/trunk...develop) trunk to develop to ensure no additional changes were missed. 10. Test the pre-release ZIP locally by [downloading](https://github.com/10up/ads-txt/actions/workflows/build-release-zip.yml) it from the Build release zip action artifact and installing it locally. Ensure this zip has all the files we expect, that it installs and activates correctly and that all basic functionality is working. -11. Release: Create a [new release](https://github.com/10up/ads-txt/releases/new), naming the tag and the release with the new version number, and targeting the `trunk` branch. Paste the changelog from `CHANGELOG.md` into the body of the release and include a link to the closed issues on the `X.Y.Z` milestone (e.g. ). -12. SVN: Wait for the [GitHub Action](https://github.com/10up/ads-txt/actions) to finish deploying to the WordPress.org repository. If all goes well, users with SVN commit access for that plugin will receive an emailed diff of changes. -13. Check WordPress.org: Ensure that the changes are live on [WordPress.org](https://wordpress.org/plugins/ads-txt/). This may take a few minutes. -14. Close milestone: Edit the [X.Y.Z milestone](https://github.com/10up/ads-txt/milestone/#) with release date (in the `Due date (optional)` field) and link to GitHub release (in the `Description` field), then close the milestone. -15. Punt incomplete items: If any open issues or PRs which were milestoned for `X.Y.Z` do not make it into the release, update their milestone to `X.Y.Z+1`, `X.Y+1.0`, `X+1.0.0` or `Future Release`. +11. Either perform a regression testing utilizing the available [Critical Flows](https://10up.github.io/Open-Source-Best-Practices/testing/#critical-flows) and Test Cases or if [end-to-end tests](https://10up.github.io/Open-Source-Best-Practices/testing/#e2e-testing) cover a significant portion of those Critical Flows then run e2e tests. Only proceed if everything tests successfully. +12. Release: Create a [new release](https://github.com/10up/ads-txt/releases/new), naming the tag and the release with the new version number, and targeting the `trunk` branch. Paste the changelog from `CHANGELOG.md` into the body of the release and include a link to the closed issues on the `X.Y.Z` milestone (e.g. ). +13. SVN: Wait for the [GitHub Action](https://github.com/10up/ads-txt/actions) to finish deploying to the WordPress.org repository. If all goes well, users with SVN commit access for that plugin will receive an emailed diff of changes. +14. Check WordPress.org: Ensure that the changes are live on [WordPress.org](https://wordpress.org/plugins/ads-txt/). This may take a few minutes. +15. Close milestone: Edit the [X.Y.Z milestone](https://github.com/10up/ads-txt/milestone/#) with release date (in the `Due date (optional)` field) and link to GitHub release (in the `Description` field), then close the milestone. +16. Punt incomplete items: If any open issues or PRs which were milestoned for `X.Y.Z` do not make it into the release, update their milestone to `X.Y.Z+1`, `X.Y+1.0`, `X+1.0.0` or `Future Release`. diff --git a/CREDITS.md b/CREDITS.md index 25fcb29..95cf973 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -10,7 +10,7 @@ The following individuals are responsible for curating the list of issues, respo Thank you to all the people who have already contributed to this repository via bug reports, code, design, ideas, project management, translation, testing, etc. -[10up (@10up)](https://github.com/10up), [Helen Hou-Sandi (@helen)](https://github.com/helen), [Adam Silverstein (@adamsilverstein)](https://github.com/adamsilverstein), [Scott Buscemi (@scottbuscemi)](https://github.com/scottbuscemi), [John Eckman (@jeckman)](https://github.com/jeckman), [philipjohn (@philipjohn)](https://github.com/philipjohn), [Keanan Koppenhaver (@kkoppenhaver)](https://github.com/kkoppenhaver), [vtellapmc (@vtellapmc)](https://github.com/vtellapmc), [Tom J. Nowell (@tomjn)](https://github.com/tomjn), [Ryan Welcher (@ryanwelcher)](https://github.com/ryanwelcher), [Ethan Clevenger (@ethanclevenger91)](https://github.com/ethanclevenger91), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Peter Westwood (@westi)](https://github.com/westi), [Matthew McAchran (@mmcachran)](https://github.com/mmcachran), [Stephanie Walters (@PypWalters)](https://github.com/PypWalters), [Barney Jeffries (@barneyjeffries)](https://github.com/barneyjeffries), [Darin Kotter (@dkotter)](https://github.com/dkotter), [Ramon Ahnert (@Rahmon)](https://github.com/Rahmon), [EVOKE (@evokelektrique)](https://github.com/evokelektrique), [Peter Wilson (@peterwilsoncc)](https://github.com/peterwilsoncc), [Max Lyuchin (@cadic)](https://github.com/cadic), [Vikram Moparthy (@vikrampm1)](https://github.com/vikrampm1), [Jayedul Kabir (@jayedul)](https://github.com/jayedul), [Thorsten Ott (@tott)](https://github.com/tott), [Sascha Greuel (@SoftCreatR)](https://github.com/SoftCreatR), [Tung Du (@dinhtungdu)](https://github.com/dinhtungdu), [Faisal Alvi (@faisal-alvi)](https://github.com/faisal-alvi), [Siddharth Thevaril (@Sidsector9)](https://github.com/Sidsector9), [Jake Goldman (@jakemgold)](https://github.com/jakemgold), [cp101 (@p0mmy)](https://github.com/p0mmy), [Ivan Kruchkoff (@ivankruchkoff)](https://github.com/ivankruchkoff), [Ankit K. Gupta (@ankitguptaindia)](https://github.com/ankitguptaindia), [Tim Moore (@tmoorewp)](https://github.com/tmoorewp), [Per Søderlind (@soderlind)](https://github.com/soderlind), [Daryll Doyle (@darylldoyle)](https://github.com/darylldoyle), [Mohit Dadhich (@mohitwp)](https://github.com/mohitwp), [RoeyHarari44 (@RoeyHarari44)](https://github.com/RoeyHarari44), [Dhanendran Rajagopal (@dhanendran)](https://github.com/dhanendran), [Shazahan Kabir Saju (@sksaju)](https://github.com/sksaju) +[10up (@10up)](https://github.com/10up), [Helen Hou-Sandi (@helen)](https://github.com/helen), [Adam Silverstein (@adamsilverstein)](https://github.com/adamsilverstein), [Scott Buscemi (@scottbuscemi)](https://github.com/scottbuscemi), [John Eckman (@jeckman)](https://github.com/jeckman), [philipjohn (@philipjohn)](https://github.com/philipjohn), [Keanan Koppenhaver (@kkoppenhaver)](https://github.com/kkoppenhaver), [vtellapmc (@vtellapmc)](https://github.com/vtellapmc), [Tom J. Nowell (@tomjn)](https://github.com/tomjn), [Ryan Welcher (@ryanwelcher)](https://github.com/ryanwelcher), [Ethan Clevenger (@ethanclevenger91)](https://github.com/ethanclevenger91), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Peter Westwood (@westi)](https://github.com/westi), [Matthew McAchran (@mmcachran)](https://github.com/mmcachran), [Stephanie Walters (@PypWalters)](https://github.com/PypWalters), [Barney Jeffries (@barneyjeffries)](https://github.com/barneyjeffries), [Darin Kotter (@dkotter)](https://github.com/dkotter), [Ramon Ahnert (@Rahmon)](https://github.com/Rahmon), [EVOKE (@evokelektrique)](https://github.com/evokelektrique), [Peter Wilson (@peterwilsoncc)](https://github.com/peterwilsoncc), [Max Lyuchin (@cadic)](https://github.com/cadic), [Vikram Moparthy (@vikrampm1)](https://github.com/vikrampm1), [Jayedul Kabir (@jayedul)](https://github.com/jayedul), [Thorsten Ott (@tott)](https://github.com/tott), [Sascha Greuel (@SoftCreatR)](https://github.com/SoftCreatR), [Tung Du (@dinhtungdu)](https://github.com/dinhtungdu), [Faisal Alvi (@faisal-alvi)](https://github.com/faisal-alvi), [Siddharth Thevaril (@Sidsector9)](https://github.com/Sidsector9), [Jake Goldman (@jakemgold)](https://github.com/jakemgold), [cp101 (@p0mmy)](https://github.com/p0mmy), [Ivan Kruchkoff (@ivankruchkoff)](https://github.com/ivankruchkoff), [Ankit K. Gupta (@ankitguptaindia)](https://github.com/ankitguptaindia), [Tim Moore (@tmoorewp)](https://github.com/tmoorewp), [Per Søderlind (@soderlind)](https://github.com/soderlind), [Daryll Doyle (@darylldoyle)](https://github.com/darylldoyle), [Mohit Dadhich (@mohitwp)](https://github.com/mohitwp), [RoeyHarari44 (@RoeyHarari44)](https://github.com/RoeyHarari44), [Dhanendran Rajagopal (@dhanendran)](https://github.com/dhanendran), [Shazahan Kabir Saju (@sksaju)](https://github.com/sksaju), [Ankit Gade (@ankitrox)](https://github.com/ankitrox), [Quamruz Zaman (@zamanq)](https://github.com/zamanq), [Harshal Kadu (@QAharshalkadu)](https://github.com/QAharshalkadu), [Sumit Bagthariya (@qasumitbagthariya)](https://github.com/qasumitbagthariya), [Sudip Dadhaniya (@sudip-md)](https://github.com/sudip-md), [Rahul Prajapati (@rahulsprajapati)](https://github.com/rahulsprajapati), [Frankie Bordone (@frankiebordone)](https://github.com/frankiebordone), [Dharmesh Patel (@iamdharmesh)](https://github.com/iamdharmesh), [Konstantinos Galanakis (@kmgalanakis)](https://github.com/kmgalanakis). ## Libraries diff --git a/README.md b/README.md index 9a5c40b..29bfdfb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ads.txt Manager for WordPress -> Create, manage, and validate your ads.txt and app-ads.txt from within WordPress, just like any other content asset. +> Create, manage, and validate your ads.txt and app-ads.txt from within WordPress, like any other content asset. [![Support Level](https://img.shields.io/badge/support-stable-blue.svg)](#support-level) [![Automated Tests](https://github.com/10up/ads-txt/workflows/Automated%20Tests/badge.svg)](https://github.com/10up/ads-txt/actions?query=workflow%3A%22Automated+Tests%22) [![Release Version](https://img.shields.io/github/tag/10up/ads-txt.svg?label=release)](https://github.com/10up/ads-txt/releases/latest) ![WordPress tested up to version](https://img.shields.io/wordpress/plugin/tested/ads-txt?label=WordPress) [![GPLv2 License](https://img.shields.io/github/license/10up/ads-txt.svg)](https://github.com/10up/ads-txt/blob/develop/LICENSE.md) @@ -21,7 +21,7 @@ Yes! However, if you are using a subfolder installation it will only work for th ## Requirements * Requires PHP 7.4+. -* Requires WordPress 5.7+. +* Requires WordPress 6.3+. * Ad blockers may break syntax highlighting and pre-save error checking on the edit screen. See [#20](https://github.com/10up/ads-txt/issues/20). * Rewrites need to be enabled. Without rewrites, WordPress cannot know to supply `/ads.txt` when requested. * 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. diff --git a/ads-txt.php b/ads-txt.php index 0d7b0a1..08c0451 100644 --- a/ads-txt.php +++ b/ads-txt.php @@ -1,13 +1,15 @@ post_content; - - /** - * Filter the ads.txt content. - * - * @since 1.2.0 - * - * @param type $adstxt The existing ads.txt content. - */ - echo esc_html( apply_filters( 'ads_txt_content', $adstxt ) ); - die(); - } - } elseif ( '/app-ads.txt' === $request || '/app-ads.txt?' === substr( $request, 0, 13 ) ) { - $post_id = get_option( APP_ADS_TXT_MANAGER_POST_OPTION ); - - // Set custom header for ads-txt - header( 'X-Ads-Txt-Generator: https://wordpress.org/plugins/ads-txt/' ); - - // Will fall through if no option found, likely to a 404. - if ( ! empty( $post_id ) ) { - $post = get_post( $post_id ); - - if ( ! $post instanceof WP_Post ) { - return; - } - - header( 'Content-Type: text/plain' ); - $adstxt = $post->post_content; - - /** - * Filter the app-ads.txt content. - * - * @since 1.3.0 - * - * @param type $app_adstxt The existing ads.txt content. - */ - echo esc_html( apply_filters( 'app_ads_txt_content', $adstxt ) ); - die(); - } - } +function adstxt_minimum_php_requirement() { + return '7.4'; } -add_action( 'init', 'tenup_display_ads_txt' ); /** - * Add custom capabilities. + * Whether PHP installation meets the minimum requirements * - * @return void + * @return bool True if meets minimum requirements, false otherwise. */ -function add_adstxt_capabilities() { - $role = get_role( 'administrator' ); - - // Bail early if the administrator role doesn't exist. - if ( null === $role ) { - return; - } - - if ( ! $role->has_cap( ADS_TXT_MANAGE_CAPABILITY ) ) { - $role->add_cap( ADS_TXT_MANAGE_CAPABILITY ); - } +function adstxt_site_meets_php_requirements() { + return version_compare( phpversion(), adstxt_minimum_php_requirement(), '>=' ); } -add_action( 'admin_init', 'add_adstxt_capabilities' ); -register_activation_hook( __FILE__, 'add_adstxt_capabilities' ); -/** - * Remove custom capabilities when deactivating the plugin. - * - * @return void - */ -function remove_adstxt_capabilities() { - $role = get_role( 'administrator' ); - - // Bail early if the administrator role doesn't exist. - if ( null === $role ) { - return; - } - - $role->remove_cap( ADS_TXT_MANAGE_CAPABILITY ); +// Ensuring our PHP version requirement is met first before loading plugin. +if ( ! adstxt_site_meets_php_requirements() ) { + add_action( + 'admin_notices', + function() { + ?> +
+

+ +

+
+ ID : false; $errors = get_post_meta( $post->ID, 'adstxt_errors', true ); + $warnings = get_post_meta( $post->ID, 'adstxt_warnings', true ); $revisions_link = $last_revision_id ? admin_url( 'revision.php?adstxt=1&revision=' . $last_revision_id ) : false; } else { @@ -272,6 +273,33 @@ function settings_screen( $post_id, $strings, $args ) { clean_orphaned_posts( $post_id, $args['post_type'] ); ?>
+ +
+
    + '; + + // Errors were originally stored as an array. + // This old style only needs to be accounted for here at runtime display. + if ( isset( $warning['message'] ) ) { + /* translators: Error message output. 1: Error message */ + $message = sprintf( + '%1$s', + $warning['message'] + ); + + echo esc_html( $message ); + } else { + display_formatted_error( $warning ); + } + + echo ''; + } + ?> +
+
+