├── .deployignore ├── .gitattributes ├── .gitignore ├── .scaffolder └── feature │ ├── config.yml │ ├── feature.php.hbs │ └── test.php.hbs ├── CHANGELOG.md ├── LICENSE ├── README.md ├── composer.json ├── package-lock.json ├── package.json ├── phpstan.neon ├── src └── alley │ └── wp │ └── alleyvate │ ├── class-feature.php │ ├── class-site-health-panel.php │ ├── features │ ├── class-cache-slow-queries.php │ ├── class-clean-admin-bar.php │ ├── class-disable-apple-news-non-prod-push.php │ ├── class-disable-attachment-routing.php │ ├── class-disable-block-editor-rest-api-preload-paths.php │ ├── class-disable-comments.php │ ├── class-disable-custom-fields-meta-box.php │ ├── class-disable-dashboard-widgets.php │ ├── class-disable-deep-pagination.php │ ├── class-disable-pantheon-constant-overrides.php │ ├── class-disable-password-change-notification.php │ ├── class-disable-site-health-directories.php │ ├── class-disable-sticky-posts.php │ ├── class-disable-trackbacks.php │ ├── class-disable-xmlrpc.php │ ├── class-disallow-file-edit.php │ ├── class-force-two-factor-authentication.php │ ├── class-login-nonce.php │ ├── class-noindex-password-protected-posts.php │ ├── class-prevent-framing.php │ ├── class-redirect-guess-shortcircuit.php │ ├── class-remove-shortlink.php │ ├── class-twitter-embeds.php │ └── class-user-enumeration-restrictions.php │ └── load.php └── wp-alleyvate.php /.deployignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .github 3 | .phpcs 4 | .phpcs.xml 5 | .phpunit.result.cache 6 | .scaffolder 7 | .scoper 8 | *.sql 9 | *.tar.gz 10 | *.zip 11 | bin 12 | composer.lock 13 | configure.php 14 | DOCKER_ENV 15 | Dockerfile 16 | Makefile 17 | node_modules/ 18 | output.log 19 | phpunit.xml 20 | phpunit.xml 21 | tests 22 | tests 23 | Thumbs.db 24 | wp-cli.local.yml 25 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # Exclude these files from release archives. 3 | # 4 | # This will also make the files unavailable when using Composer with `--prefer-dist`. 5 | # If you develop using Composer, use `--prefer-source`. 6 | # 7 | # Via WPCS. 8 | # 9 | /.editorconfig export-ignore 10 | /phpcs.xml export-ignore 11 | /phpunit.xml export-ignore 12 | /.github export-ignore 13 | /tests export-ignore 14 | 15 | # 16 | # Auto detect text files and perform LF normalization. 17 | # 18 | # http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/ 19 | # 20 | * text=auto 21 | 22 | # 23 | # The above will handle all files not found below. 24 | # 25 | *.md text 26 | *.php text 27 | *.inc text 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build files 2 | build 3 | vendor 4 | composer.lock 5 | node_modules 6 | 7 | # Log files 8 | *.log 9 | 10 | # Cache files 11 | .phpcs/*.json 12 | .phpunit.result.cache 13 | .php-cs-fixer.cache 14 | .php_cs.cache 15 | 16 | # Ignore temporary OS files 17 | .DS_Store 18 | .DS_Store? 19 | .Spotlight-V100 20 | .Trashes 21 | ehthumbs.db 22 | Thumbs.db 23 | .thumbsdb 24 | 25 | # IDE files 26 | *.code-workspace 27 | .idea 28 | .vscode 29 | -------------------------------------------------------------------------------- /.scaffolder/feature/config.yml: -------------------------------------------------------------------------------- 1 | name: wp-alleyvate@feature 2 | 3 | inputs: 4 | - name: featureName 5 | description: "Feature Name" 6 | type: string 7 | - name: tests 8 | description: "Include Tests?" 9 | type: boolean 10 | default: true 11 | 12 | files: 13 | - source: feature.php.hbs 14 | destination: src/alley/wp/alleyvate/features/{{ wpClassFilename inputs.featureName }} 15 | - source: test.php.hbs 16 | if: "{{ inputs.tests }}" 17 | destination: tests/alley/wp/alleyvate/features/{{ wpClassFilename inputs.featureName prefix="test-" }} 18 | -------------------------------------------------------------------------------- /.scaffolder/feature/feature.php.hbs: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * {{ wpClassName inputs.featureName }} feature. 19 | */ 20 | final class {{ wpClassName inputs.featureName }} implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | // ... 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.scaffolder/feature/test.php.hbs: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | declare( strict_types=1 ); 14 | 15 | namespace Alley\WP\Alleyvate\Features; 16 | 17 | use Mantle\Testing\Concerns\Refresh_Database; 18 | use Mantle\Testkit\Test_Case; 19 | 20 | /** 21 | * Tests for {{ wpClassName inputs.featureName }} feature. 22 | */ 23 | final class {{ wpClassName inputs.featureName prefix="Test_" }} extends Test_Case { 24 | use Refresh_Database; 25 | 26 | /** 27 | * Feature instance. 28 | * 29 | * @var {{ wpClassName inputs.featureName }} 30 | */ 31 | private {{ wpClassName inputs.featureName }} $feature; 32 | 33 | /** 34 | * Set up. 35 | */ 36 | protected function setUp(): void { 37 | parent::setUp(); 38 | 39 | $this->feature = new {{ wpClassName inputs.featureName }}(); 40 | } 41 | 42 | /** 43 | * Example Test. 44 | */ 45 | public function test_example(): void { 46 | // Activate the feature. 47 | $this->feature->boot(); 48 | 49 | $this->assertTrue( true ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | This library adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/en/1.0.0/). 4 | 5 | ## Unreleased 6 | 7 | Nothing yet. 8 | 9 | ## 3.4.0 10 | 11 | ### Changed 12 | 13 | * Minimum PHP version is now 8.2. 14 | * Upgraded to `symfony/http-foundation` v7. 15 | 16 | ## 3.7.2 17 | 18 | ### Added 19 | 20 | ### Changed 21 | 22 | * `disable_deep_pagination`: For urls over max pages display 404 template and set header stauts to 410. 23 | * `disable_deep_pagination`: Pagination display accordingly to max pages. 24 | 25 | ## 3.7.1 26 | 27 | ### Fixed 28 | 29 | * `twitter_embeds`: Fixed an issue where support for x.com embeds would load too late in some cases. 30 | 31 | ## 3.7.0 32 | 33 | ### Added 34 | 35 | * `noindex_password_protected_posts`: Added a feature to add noindex to the robots meta tag content for password-protected posts. 36 | 37 | ### Changed 38 | 39 | * Removed fsockopen backstop option for Twitter/X oEmbeds. 40 | * On login nonce failure, redirect back to the login page with an error message. 41 | 42 | ## 3.6.0 43 | 44 | ### Added 45 | 46 | * Added a feature to improve Twitter/X oEmbed handling. 47 | 48 | ## 3.5.2 49 | 50 | * Optimize some unit tests that created a lot of posts. 51 | 52 | ## 3.5.1 53 | 54 | * Added support for `alleyinteractive/wp-type-extensions` v3. 55 | 56 | ## 3.5.0 57 | 58 | ### Added 59 | 60 | * Added build release scripts and GitHub Actions for automated releases (used for this release). 61 | * Added a feature to disable XML-RPC (and removes all methods) for all requests that come from IPs that are not known Jetpack IPs. 62 | 63 | ### Fixed 64 | 65 | * `login_nonce`: Fixed issue where loading cached version of login page would store invalid nonce. 66 | 67 | ## 3.4.0 68 | 69 | ### Changed 70 | 71 | * The `disable_attachment_routing` feature now also disables the automatic redirect from an attachment to its corresponding file URL. 72 | 73 | ## 3.3.0 74 | 75 | ### Added 76 | 77 | * `disable_site_health_directories`: Added a feature to disable the site health check for information about the WordPress directories and their sizes. 78 | 79 | ## 3.2.0 80 | 81 | ### Added 82 | 83 | * `disable_apple_news_non_prod_push`: Added a feature to disable pushing to Apple News when not on a production environment. 84 | 85 | ### Fixed 86 | 87 | * `force_two_factor_authentication`: Fixed an infinite loop issue on VIP sites. 88 | 89 | ## 3.1.0 90 | 91 | ### Added 92 | 93 | * `disable_pantheon_constant_overrides`: Added a feature to disable forcing use of `WP_SITEURL` and `WP_HOME` on Pantheon environments. 94 | * `force_two_factor_authentication`: Added a feature to force Two Factor Authentication for users with `edit_posts` permissions. 95 | * `disable_deep_pagination`: Added a feature to restrict pagination to at most 100 pages, by default. This includes a filter `alleyvate_deep_pagination_max_pages` to override this limit, as well as a new `WP_Query` argument to override the limit: `__dangerously_set_max_pages`. 96 | * `disable_block_editor_rest_api_preload_paths` Added a feature to disable preloading Synced Patterns (Reusable 97 | Blocks) on the block edit screen to improve performance on sites with many patterns. 98 | 99 | ## 3.0.1 100 | 101 | ### Changed 102 | 103 | * Removed `composer/installers` from Composer dependencies. 104 | 105 | ## 3.0.0 106 | 107 | ### Added 108 | 109 | * Added PHPStan to the development dependencies. 110 | * `Alley\WP\Alleyvate\Feature` class implementing the `Alley\WP\Types\Feature` interface. 111 | * `remove_shortlink`: Added a feature to remove the shortlink from the head of the site. 112 | * `cache_slow_queries`: Added a feature to cache slow queries for performance. 113 | 114 | ### Changed 115 | 116 | * The minimum PHP version is now 8.1. 117 | * Feature classes now implement the `Alley\WP\Types\Feature` interface instead of `Alley\WP\Alleyvate\Feature`. 118 | * Unit tests: misc changes and fixes. 119 | * Unit tests: the `$feature` property uses the main feature class for better IDE intelephense support. 120 | * Unit tests: all test cases use `declare( strict_types=1 );`. 121 | * Unit tests: added test to confirm the attachment rewrite rules are removed 122 | * Unit tests: support for `convertDeprecationsToExceptions="true"` added. Tests 123 | will fail if there are PHP deprecation warnings. 124 | 125 | ### Removed 126 | 127 | * `site_health`: Removed as a dedicated feature and now implemented directly in the plugin. 128 | * `Alley\WP\Alleyvate\Feature` interface. 129 | 130 | ## 2.4.0 131 | 132 | ### Added 133 | 134 | * `login_nonce`: Added a `no-store` header to the wp-login.php page. 135 | * `prevent_framing`: Added a feature to prevent framing of the site via the 136 | `X-Frame-Options` header. 137 | 138 | ## 2.3.1 139 | 140 | ### Changed 141 | 142 | * `login_nonce`: make sure the nonce lifetime is run only for the login action 143 | as to not affect the other `wp-login.php` actions, e.g: logout. 144 | 145 | ## 2.3.0 146 | 147 | ### Added 148 | 149 | * `disable_attachment_routing`: Added a feature to disable attachment routing. 150 | * `disable_custom_fields_meta_box`: Added a feature to disable the custom fields meta box. 151 | * `disable_password_change_notification`: Added a feature that disables sending password change notification emails to site admins. 152 | 153 | ### Changed 154 | 155 | * `disable_comments`: Removes the `commentstatusdiv` meta box when comments are 156 | disabled. Previously, only `commentsdiv` was removed. 157 | 158 | ## 2.2.1 159 | 160 | ### Added 161 | 162 | * `login_nonce`: Added a feature to add a nonce to wp-login 163 | 164 | ### Changed 165 | 166 | * `disable_comments`: Akismet: Removed the comment spam queue section from the WP dashboard 167 | 168 | ## 2.2.0 169 | 170 | ### Added 171 | 172 | * Added a feature to remove commonly unused dashboard widgets. 173 | * Added a feature to remove specific admin bar links (comments and themes). 174 | * Added a Site Health screen panel with information about the enabled/disabled features of the plugin. 175 | 176 | ### Changed 177 | 178 | * Upgraded to Alley Coding Standards 2.0. 179 | * Upgraded to Mantle TestKit 0.12. 180 | 181 | ## 2.1.0 182 | 183 | ### Added 184 | 185 | * Added a feature to disable comments. 186 | * Added a feature to disable sticky posts. 187 | * Added a feature to disable trackbacks. 188 | * Added a feature to disallow file editing. 189 | 190 | ### Fixed 191 | 192 | * Fixed a bug with the autoloader where the plugin would fatal if the autoloader didn't exist (if `composer install` was not run). 193 | 194 | ### Upgrade Notes 195 | 196 | Please ensure that if your site is using comments that you turn off the `disable_comments` feature before applying the plugin update to your production site, otherwise comments will break. This version disables comments, but doesn't have a utility for removing them from the database, but that is planned for a future version. Likewise, if your site uses sticky posts for controlling curation, make sure to turn off `disable_sticky_posts` before deploying. 197 | 198 | To disable one or more of these features: 199 | * `add_filter( 'alleyvate_load_disable_comments', '__return_false' );` 200 | * `add_filter( 'alleyvate_load_disable_trackbacks', '__return_false' );` 201 | * `add_filter( 'alleyvate_load_disable_sticky_posts', '__return_false' );` 202 | 203 | ## 2.0.0 204 | 205 | ### Added 206 | 207 | * Added a feature to disable `redirect_guess_404_permalink()`. 208 | 209 | ### Changed 210 | 211 | * Alleyvate is now installed by Composer as a WordPress plugin, not autoloaded. 212 | 213 | ### Upgrade Notes 214 | 215 | * When applying this version, inexact URLs will result in 404s. This may lead to a spike in 404s on the site, which developers should pay attention to after deploying this update. It could be that there are links on the site, or externally, that were just a little bit wrong and were relying on this behavior to get to the right place. If discovered, proper 301 redirects should be put in place for those URLs. 216 | 217 | To disable this feature: 218 | * `add_filter( 'alleyvate_load_redirect_guess_shortcircuit', '__return_false' );` 219 | 220 | ## 1.0.0 221 | 222 | Initial release. 223 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Alleyvate 2 | 3 | Alleyvate contains baseline customizations and functionality for WordPress sites that are essential to delivering a project meeting Alley's standard of quality. 4 | 5 | ## Installation 6 | 7 | Install the latest version with: 8 | 9 | ```bash 10 | composer require alleyinteractive/wp-alleyvate 11 | ``` 12 | 13 | ## Basic usage 14 | 15 | Alleyvate is a collection of distinct features, each of which is enabled by default. Each feature has a handle, and sites can opt out of individual features with the `alleyvate_load_feature` or `alleyvate_load_{$handle}` filters. Features load on the `after_setup_theme` hook, so your filters must be in place before then. 16 | 17 | ### Disabling Features 18 | 19 | The intention of this plugin is that all features should be on by default, unless there is a good reason to turn them off. For example most sites will want to have the `disable_comments` feature turned on, unless a site is actually using WordPress comments, in which case it should be turned off. 20 | 21 | To disable a feature, use the `alleyvate_load_{$feature_name}` filter and return `false`. For example, to tell Alleyvate to _not_ disable comments: 22 | 23 | ```php 24 | add_filter( 'alleyvate_load_disable_comments', '__return_false' ); 25 | ``` 26 | 27 | ## Features 28 | 29 | Each feature's handle is listed below, along with a description of what it does. 30 | 31 | ### `cache_slow_queries` 32 | 33 | This feature caches/optimizes slow queries to the database to improve 34 | performance. It is enabled by default and currently includes the following slow 35 | queries with the relevant filters to disable them: 36 | 37 | - `alleyvate_cache_months_dropdown`: The dropdown for selecting a month in the post list table. 38 | 39 | ### `clean_admin_bar` 40 | 41 | This feature removes selected nodes from the admin bar. 42 | 43 | ### `disable_apple_news_non_prod_push` 44 | 45 | This feature disables pushing to Apple News when not on a production environment. This is determined by setting the `WP_ENVIRONMENT_TYPE` environment variable, or the `WP_ENVIRONMENT_TYPE` constant. 46 | 47 | ### `disable_attachment_routing` 48 | 49 | This feature disables WordPress attachment pages entirely from the front end of the site. 50 | 51 | ### `disable_block_editor_rest_api_preload_paths` 52 | 53 | This feature enhances the stability and performance of the block edit screen by disabling the preloading of Synced 54 | Patterns (Reusable Blocks). Typically, preloading triggers `the_content` filter for each block, along with 55 | additional processing. This can lead to unexpected behavior and performance degradation, especially on sites with 56 | hundreds of synced patterns. Notably, an error in a single block can propagate issues across all block edit screens. 57 | Disabling preloading makes the system more resilient—less susceptible to cascading failures—thus improving overall 58 | admin stability. For technical details on how WP core implements preloading, refer to 59 | `wp-admin/edit-form-blocks.php.` 60 | 61 | ### `disable_comments` 62 | 63 | This feature disables WordPress comments entirely, including the ability to post, view, edit, list, count, modify settings for, or access URLs that are related to comments completely. The blocks are also removed from the Gutenberg block editor. 64 | 65 | ### `disable_custom_fields_meta_box` 66 | 67 | This feature removes the custom fields meta box from the post editor. 68 | 69 | ### `disable_dashboard_widgets` 70 | 71 | This feature removes clutter from the dashboard. 72 | 73 | ### `disable_deep_pagination` 74 | 75 | This feature restricts pagination queries to, at most, 100 pages by default. This value is filterable using the `alleyvate_deep_pagination_max_pages` filter, or by passing the `__dangerously_set_max_pages` argument to `WP_Query`. 76 | 77 | ```php 78 | // An example. 79 | $query = new WP_Query( 80 | [ 81 | 'paged' => 102, 82 | '__dangerously_set_max_pages' => 150, 83 | ] 84 | ); 85 | ``` 86 | 87 | ### `disable_file_edit` 88 | 89 | This feature prevents the editing of themes and plugins directly from the admin. 90 | 91 | Such editing can introduce unexpected and undocumented code changes. 92 | 93 | ### `disable_pantheon_constant_overrides` 94 | 95 | This feature prevents Pantheon environments from forcing CLI and Cron runs to use the `WP_HOME` or `WP_SITEURL` constants, 96 | which have been shown to force those environments to use an insecure protocol at times. 97 | 98 | ### `disable_password_change_notification` 99 | 100 | This feature disables sending password change notification emails to site admins. 101 | 102 | ### `disable_site_health_directories` 103 | 104 | This feature disables the site health check for information about the WordPress directories and their sizes. 105 | 106 | ### `disable_sticky_posts` 107 | 108 | This feature disables WordPress sticky posts entirely, including the ability to set and query sticky posts. 109 | 110 | 111 | ### `disable_trackbacks` 112 | 113 | This feature disables WordPress from sending or receiving trackbacks or pingbacks. 114 | 115 | ### `disable_xmlrpc` 116 | 117 | This feature disables XML-RPC (and removes all methods) for all requests made to XML-RPC that come from IPs that are not known Jetpack IPs. 118 | 119 | ### `force_two_factor_authentication` 120 | 121 | This feature forces users with `edit_posts` permissions to use two factor authentication (2fa) for their accounts. 122 | 123 | ### `login_nonce` 124 | 125 | This feature adds a nonce to the login form to prevent CSRF attacks. 126 | 127 | ### `noindex_password_protected_posts` 128 | 129 | This feature adds noindex to the robots meta tag content for password-protected posts. 130 | 131 | ### `prevent_framing` 132 | 133 | This feature prevents the site from being framed by other sites by outputting a 134 | `X-Frame-Options: SAMEORIGIN` header. The header can be disabled by filtering 135 | `alleyvate_prevent_framing_disable` to return true. The value of the header can 136 | be filtered using the `alleyvate_prevent_framing_x_frame_options` filter. 137 | 138 | The feature can also output a `Content-Security-Policy` header instead of 139 | `X-Frame-Options` by filtering `alleyvate_prevent_framing_csp` to return true. 140 | By default, it will output `Content-Security-Policy: frame-ancestors 'self'`. 141 | The value of the header can be filtered using 142 | `alleyvate_prevent_framing_csp_frame_ancestors` to filter the allowed 143 | frame-ancestors. The entire header can be filtered using 144 | `alleyvate_prevent_framing_csp_header`. 145 | 146 | ### `redirect_guess_shortcircuit` 147 | 148 | This feature stops WordPress from attempting to guess a redirect URL for a 404 request. 149 | 150 | The underlying behavior of `redirect_guess_404_permalink()` often confuses clients, and its database queries are non-performant on larger sites. 151 | 152 | ### `remove_shortlink` 153 | 154 | This feature removes the shortlink from the head of the site. By default, 155 | WordPress adds a shortlink to the head of the site, which is not used by most 156 | sites. 157 | 158 | ### `user_enumeration_restrictions` 159 | 160 | This feature requires users to be logged in before accessing data about registered users that would otherwise be publicly accessible. Its handle is `user_enumeration_restrictions`. 161 | 162 | WordPress core ["doesn't consider usernames or user IDs to be private or secure information"][1] and therefore allows users to be listed through some of its APIs. 163 | 164 | Our clients tend to not want information about the registered users on their sites to be discoverable; such lists can even disclose Alley's relationship with a client. 165 | 166 | ### `twitter_embeds` 167 | 168 | This feature adds full support for `x.com` URLs for oEmbeds. Out of the box, only `twitter.com` URLs are fully supported in WordPress (the block editor, it should be noted, [replaces x.com with twitter.com](https://github.com/WordPress/gutenberg/blob/a2b6d39d01d023b6c7c48ad6df5002b78a06794d/packages/block-library/src/embed/edit.js#L161-L166)). 169 | 170 | This feature also adds fallback handling for Twitter's oEmbed API endpoint, which can unpredictably and inexplicably return 404 responses (see [the X Developers Forum for numerous threads on the topic](https://devcommunity.x.com/tag/oembed)). If a 404 is encountered, the response is passed through the `alleyvate_twitter_embeds_404_backstop` filter, along with data about the request and the number of attempts to that endpoint during this pageload. 171 | 172 | By default, Alleyvate hooks into this filter to provide one additional attempt at getting a successful response from a proxy server, if the ENV variable `TWITTER_OEMBED_BACKSTOP_ENDPOINT` is set. WPVIP offers a fallback proxy server which seems to reliably return a valid response. 173 | 174 | If one doesn't have a proxy service, one suggestion would be to hook into this filter to enqueue a cron task that makes many (e.g. up to 100) rapid-fire requests to twitter until a successful response comes back. In experimenting with the Twitter oEmbed endpoint, we've found that it both works and fails in spurts, and if we make 100 requests in a loop, we eventually get a 200 response. 175 | 176 | ## About 177 | 178 | ### License 179 | 180 | [GPL-2.0-or-later](https://github.com/alleyinteractive/wp-alleyvate/blob/main/LICENSE) 181 | 182 | ### Maintainers 183 | 184 | [Alley Interactive](https://github.com/alleyinteractive) 185 | 186 | [1]: https://make.wordpress.org/core/handbook/testing/reporting-security-vulnerabilities/#why-are-disclosures-of-usernames-or-user-ids-not-a-security-issue 187 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "alleyinteractive/wp-alleyvate", 3 | "description": "Defaults for WordPress sites by Alley.", 4 | "type": "wordpress-plugin", 5 | "license": "GPL-2.0-or-later", 6 | "authors": [ 7 | { 8 | "name": "Alley", 9 | "email": "info@alley.com" 10 | } 11 | ], 12 | "config": { 13 | "allow-plugins": { 14 | "alleyinteractive/composer-wordpress-autoloader": true, 15 | "composer/installers": true, 16 | "dealerdirect/phpcodesniffer-composer-installer": true 17 | }, 18 | "lock": false, 19 | "sort-packages": true 20 | }, 21 | "require": { 22 | "php": "^8.2", 23 | "alleyinteractive/composer-wordpress-autoloader": "^1.0", 24 | "alleyinteractive/wp-type-extensions": "^2.0|^3.0", 25 | "symfony/http-foundation": "^v7.2" 26 | }, 27 | "require-dev": { 28 | "alleyinteractive/alley-coding-standards": "^2.0", 29 | "mantle-framework/testkit": "^1.6", 30 | "szepeviktor/phpstan-wordpress": "^1.3.5" 31 | }, 32 | "scripts": { 33 | "lint": [ 34 | "@phpcs", 35 | "@phpstan" 36 | ], 37 | "phpcbf": "phpcbf", 38 | "phpcs": "phpcs", 39 | "phpstan": "phpstan --memory-limit=768M", 40 | "phpunit": "phpunit", 41 | "scaffold": "npx @alleyinteractive/scaffolder@latest wp-alleyvate@feature", 42 | "test": [ 43 | "@lint", 44 | "@phpunit" 45 | ] 46 | }, 47 | "autoload-dev": { 48 | "psr-4": { 49 | "Alley\\WP\\Alleyvate\\": "tests/Alley/WP/Alleyvate" 50 | } 51 | }, 52 | "extra": { 53 | "wordpress-autoloader": { 54 | "autoload": { 55 | "Alley\\": "src/alley/" 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wp-alleyvate", 3 | "lockfileVersion": 3, 4 | "requires": true, 5 | "packages": { 6 | "": { 7 | "name": "wp-alleyvate", 8 | "hasInstallScript": true, 9 | "license": "GPL-2.0-or-later", 10 | "devDependencies": { 11 | "check-node-version": "^4.2.1" 12 | }, 13 | "engines": { 14 | "node": "22", 15 | "npm": "10" 16 | } 17 | }, 18 | "node_modules/ansi-styles": { 19 | "version": "4.3.0", 20 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", 21 | "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", 22 | "dev": true, 23 | "license": "MIT", 24 | "dependencies": { 25 | "color-convert": "^2.0.1" 26 | }, 27 | "engines": { 28 | "node": ">=8" 29 | }, 30 | "funding": { 31 | "url": "https://github.com/chalk/ansi-styles?sponsor=1" 32 | } 33 | }, 34 | "node_modules/chalk": { 35 | "version": "3.0.0", 36 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", 37 | "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", 38 | "dev": true, 39 | "license": "MIT", 40 | "dependencies": { 41 | "ansi-styles": "^4.1.0", 42 | "supports-color": "^7.1.0" 43 | }, 44 | "engines": { 45 | "node": ">=8" 46 | } 47 | }, 48 | "node_modules/check-node-version": { 49 | "version": "4.2.1", 50 | "resolved": "https://registry.npmjs.org/check-node-version/-/check-node-version-4.2.1.tgz", 51 | "integrity": "sha512-YYmFYHV/X7kSJhuN/QYHUu998n/TRuDe8UenM3+m5NrkiH670lb9ILqHIvBencvJc4SDh+XcbXMR4b+TtubJiw==", 52 | "dev": true, 53 | "license": "Unlicense", 54 | "dependencies": { 55 | "chalk": "^3.0.0", 56 | "map-values": "^1.0.1", 57 | "minimist": "^1.2.0", 58 | "object-filter": "^1.0.2", 59 | "run-parallel": "^1.1.4", 60 | "semver": "^6.3.0" 61 | }, 62 | "bin": { 63 | "check-node-version": "bin.js" 64 | }, 65 | "engines": { 66 | "node": ">=8.3.0" 67 | } 68 | }, 69 | "node_modules/color-convert": { 70 | "version": "2.0.1", 71 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", 72 | "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", 73 | "dev": true, 74 | "license": "MIT", 75 | "dependencies": { 76 | "color-name": "~1.1.4" 77 | }, 78 | "engines": { 79 | "node": ">=7.0.0" 80 | } 81 | }, 82 | "node_modules/color-name": { 83 | "version": "1.1.4", 84 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", 85 | "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", 86 | "dev": true, 87 | "license": "MIT" 88 | }, 89 | "node_modules/has-flag": { 90 | "version": "4.0.0", 91 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", 92 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", 93 | "dev": true, 94 | "license": "MIT", 95 | "engines": { 96 | "node": ">=8" 97 | } 98 | }, 99 | "node_modules/map-values": { 100 | "version": "1.0.1", 101 | "resolved": "https://registry.npmjs.org/map-values/-/map-values-1.0.1.tgz", 102 | "integrity": "sha512-BbShUnr5OartXJe1GeccAWtfro11hhgNJg6G9/UtWKjVGvV5U4C09cg5nk8JUevhXODaXY+hQ3xxMUKSs62ONQ==", 103 | "dev": true, 104 | "license": "Public Domain" 105 | }, 106 | "node_modules/minimist": { 107 | "version": "1.2.8", 108 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", 109 | "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", 110 | "dev": true, 111 | "license": "MIT", 112 | "funding": { 113 | "url": "https://github.com/sponsors/ljharb" 114 | } 115 | }, 116 | "node_modules/object-filter": { 117 | "version": "1.0.2", 118 | "resolved": "https://registry.npmjs.org/object-filter/-/object-filter-1.0.2.tgz", 119 | "integrity": "sha512-NahvP2vZcy1ZiiYah30CEPw0FpDcSkSePJBMpzl5EQgCmISijiGuJm3SPYp7U+Lf2TljyaIw3E5EgkEx/TNEVA==", 120 | "dev": true, 121 | "license": "MIT" 122 | }, 123 | "node_modules/queue-microtask": { 124 | "version": "1.2.3", 125 | "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", 126 | "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", 127 | "dev": true, 128 | "funding": [ 129 | { 130 | "type": "github", 131 | "url": "https://github.com/sponsors/feross" 132 | }, 133 | { 134 | "type": "patreon", 135 | "url": "https://www.patreon.com/feross" 136 | }, 137 | { 138 | "type": "consulting", 139 | "url": "https://feross.org/support" 140 | } 141 | ], 142 | "license": "MIT" 143 | }, 144 | "node_modules/run-parallel": { 145 | "version": "1.2.0", 146 | "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", 147 | "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", 148 | "dev": true, 149 | "funding": [ 150 | { 151 | "type": "github", 152 | "url": "https://github.com/sponsors/feross" 153 | }, 154 | { 155 | "type": "patreon", 156 | "url": "https://www.patreon.com/feross" 157 | }, 158 | { 159 | "type": "consulting", 160 | "url": "https://feross.org/support" 161 | } 162 | ], 163 | "license": "MIT", 164 | "dependencies": { 165 | "queue-microtask": "^1.2.2" 166 | } 167 | }, 168 | "node_modules/semver": { 169 | "version": "6.3.1", 170 | "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", 171 | "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", 172 | "dev": true, 173 | "license": "ISC", 174 | "bin": { 175 | "semver": "bin/semver.js" 176 | } 177 | }, 178 | "node_modules/supports-color": { 179 | "version": "7.2.0", 180 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", 181 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", 182 | "dev": true, 183 | "license": "MIT", 184 | "dependencies": { 185 | "has-flag": "^4.0.0" 186 | }, 187 | "engines": { 188 | "node": ">=8" 189 | } 190 | } 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wp-alleyvate", 3 | "license": "GPL-2.0-or-later", 4 | "main": "wp-alleyvate.php", 5 | "engines": { 6 | "node": "22", 7 | "npm": "10" 8 | }, 9 | "scripts": { 10 | "release": "npx @alleyinteractive/create-release@latest" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | includes: 2 | - vendor/szepeviktor/phpstan-wordpress/extension.neon 3 | 4 | parameters: 5 | # Level 9 is the highest level 6 | level: max 7 | 8 | paths: 9 | - src/ 10 | - wp-alleyvate.php 11 | 12 | ignoreErrors: 13 | - '#WP_REST_Request but does not specify its#' 14 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/class-feature.php: -------------------------------------------------------------------------------- 1 | handle ); 54 | 55 | /** 56 | * Filters whether to load the given Alleyvate feature. 57 | * 58 | * The dynamic portion of the hook name, `$this->$this->handle`, refers to the 59 | * machine name for the feature. 60 | * 61 | * @param bool $load Whether to load the feature. Default true. 62 | */ 63 | $load = apply_filters( "alleyvate_load_{$this->handle}", $load ); 64 | 65 | if ( $load ) { 66 | $this->booted = true; 67 | $this->origin->boot(); 68 | } 69 | } 70 | 71 | /** 72 | * Add debug information to the Site Health screen. 73 | * 74 | * @param array}> $info Debug information. 75 | * @return array}> $info Debug information. Debug information. 76 | */ 77 | public function add_debug_information( $info ): array { 78 | if ( ! \is_array( $info ) ) { 79 | $info = []; 80 | } 81 | 82 | $info['wp-alleyvate']['fields'] ??= []; 83 | $info['wp-alleyvate']['fields'][] = [ 84 | 'label' => \sprintf( 85 | /* translators: %s: Feature name. */ 86 | __( 'Feature: %s', 'alley' ), 87 | $this->handle, 88 | ), 89 | 'value' => $this->booted ? __( 'Enabled', 'alley' ) : __( 'Disabled', 'alley' ), 90 | ]; 91 | 92 | return $info; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/class-site-health-panel.php: -------------------------------------------------------------------------------- 1 | }> $info Debug information. 27 | * @return array}> Debug information. 28 | */ 29 | public function add_debug_panel( $info ): array { 30 | if ( ! \is_array( $info ) ) { 31 | $info = []; 32 | } 33 | 34 | $info['wp-alleyvate'] = [ 35 | 'label' => __( 'Alleyvate', 'alley' ), 36 | 'description' => __( 'Diagnostic information about the Alleyvate plugin and which features are enabled.', 'alley' ), 37 | 'fields' => [], 38 | ]; 39 | 40 | return $info; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-cache-slow-queries.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | declare( strict_types=1 ); 14 | 15 | namespace Alley\WP\Alleyvate\Features; 16 | 17 | use Alley\WP\Types\Feature; 18 | 19 | /** 20 | * Cache slow queries that do not perform well for large sites. 21 | */ 22 | final class Cache_Slow_Queries implements Feature { 23 | /** 24 | * Whether to cache the months dropdown. 25 | * 26 | * @var bool 27 | */ 28 | public bool $cache_months_dropdown = false; 29 | 30 | /** 31 | * Boot the feature. 32 | */ 33 | public function boot(): void { 34 | /** 35 | * Filter if the months dropdown query should be cached. 36 | * 37 | * @param bool $cache_months_dropdown Whether to cache the months dropdown. Default true. 38 | */ 39 | if ( apply_filters( 'alleyvate_cache_months_dropdown', true ) ) { 40 | add_filter( 'pre_months_dropdown_query', [ $this, 'filter__pre_months_dropdown_query' ], 10, 2 ); 41 | add_filter( 'months_dropdown_results', [ $this, 'filter__months_dropdown_results' ], 10, 2 ); 42 | add_action( 'save_post', [ $this, 'action__save_post' ], 10, 2 ); 43 | add_action( 'delete_post', [ $this, 'action__delete_post' ], 10, 2 ); 44 | } 45 | } 46 | 47 | /** 48 | * Filter the pre months dropdown query to return the cached result. 49 | * 50 | * @param object[]|false $months 'Months' drop-down results. Default false. 51 | * @param string $post_type The post type. 52 | * @return object[]|false 53 | */ 54 | public function filter__pre_months_dropdown_query( $months, $post_type ) { 55 | $cache = wp_cache_get( $post_type, 'alleyvate_months_dropdown' ); 56 | 57 | if ( \is_array( $cache ) ) { 58 | return $cache; 59 | } 60 | 61 | // Set the flag to cache the months dropdown. 62 | $this->cache_months_dropdown = true; 63 | 64 | return $months; 65 | } 66 | 67 | /** 68 | * Filter the months dropdown results. 69 | * 70 | * @param object[] $months Array of the months drop-down query results. 71 | * @param string $post_type The post type. 72 | * @return object[]|false 73 | */ 74 | public function filter__months_dropdown_results( $months, $post_type ) { 75 | if ( $this->cache_months_dropdown && \is_array( $months ) ) { 76 | wp_cache_set( $post_type, $months, 'alleyvate_months_dropdown', DAY_IN_SECONDS ); 77 | 78 | $this->cache_months_dropdown = false; 79 | } 80 | 81 | return $months; 82 | } 83 | 84 | /** 85 | * Action to delete the cache when a post is published. 86 | * 87 | * @param int $post_id The post ID. 88 | * @param \WP_Post $post The post object. 89 | */ 90 | public function action__save_post( $post_id, $post ): void { 91 | if ( 'publish' !== $post->post_status ) { 92 | return; 93 | } 94 | 95 | $cache = wp_cache_get( $post->post_type, 'alleyvate_months_dropdown' ); 96 | 97 | if ( ! \is_array( $cache ) ) { 98 | return; 99 | } 100 | 101 | // Check if the post's month is in the cache. 102 | $cache = array_map( 103 | fn ( $month ) => "{$month->year}-{$month->month}", 104 | $cache, 105 | ); 106 | 107 | // Clear the month dropdown cache if the post's month is not in the cache. 108 | if ( ! \in_array( get_the_date( 'Y-n', $post ), $cache, true ) ) { 109 | wp_cache_delete( $post->post_type, 'alleyvate_months_dropdown' ); 110 | } 111 | } 112 | 113 | /** 114 | * Handle a post being deleted. 115 | * 116 | * @param int $post_id The post ID. 117 | * @param \WP_Post $post The post object. 118 | */ 119 | public function action__delete_post( $post_id, $post ): void { 120 | wp_cache_delete( $post->post_type, 'alleyvate_months_dropdown' ); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-clean-admin-bar.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Cleans admin bar. 19 | */ 20 | final class Clean_Admin_Bar implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | add_action( 'wp_before_admin_bar_render', [ $this, 'before_admin_bar_render' ], 9999 ); 26 | } 27 | 28 | /** 29 | * Disables specified menus in admin bar. 30 | */ 31 | public function before_admin_bar_render(): void { 32 | global $wp_admin_bar; 33 | 34 | foreach ( $this->get_disposable_nodes() as $node ) { 35 | $wp_admin_bar->remove_menu( $node ); 36 | } 37 | } 38 | 39 | /** 40 | * Set menus to be disabled. 41 | * 42 | * @return array 43 | */ 44 | public function get_disposable_nodes(): array { 45 | $disposable_nodes = [ 46 | 'comments', 47 | 'themes', 48 | 'updates', 49 | 'wp-logo', 50 | ]; 51 | 52 | /** 53 | * Filters the admin bar menus to be removed. 54 | * 55 | * @param array $disposable_nodes Admin bar menus to be removed. 56 | */ 57 | return (array) apply_filters( 'alleyvate_clean_admin_bar_menus', $disposable_nodes ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-apple-news-non-prod-push.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Disables Apple News Push on Non Production Environments. 19 | */ 20 | final class Disable_Apple_News_Non_Prod_Push implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | add_filter( 'apple_news_skip_push', [ $this, 'filter_apple_news_skip_push' ], 9999 ); 26 | } 27 | 28 | /** 29 | * Filter the Apple News push skip flag. If we are not on a production environment, skip the push. 30 | * 31 | * @param bool $skip Should we skip the Apple News push. 32 | */ 33 | public function filter_apple_news_skip_push( bool $skip ): bool { 34 | // If we are on a production environment, don't modify the value. 35 | if ( 'production' === wp_get_environment_type() ) { 36 | return $skip; 37 | } 38 | 39 | // All other cases, return true. 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-attachment-routing.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use WP_Admin_Bar; 16 | use WP_Query; 17 | use Alley\WP\Types\Feature; 18 | 19 | /** 20 | * Disable attachment routing. 21 | */ 22 | final class Disable_Attachment_Routing implements Feature { 23 | /** 24 | * Boot the feature. 25 | */ 26 | public function boot(): void { 27 | add_filter( 'pre_option_wp_attachment_pages_enabled', '__return_zero', 100 ); 28 | add_filter( 'rewrite_rules_array', [ self::class, 'filter__rewrite_rules_array' ] ); 29 | add_filter( 'attachment_link', [ self::class, 'filter__attachment_link' ] ); 30 | add_filter( 'pre_handle_404', [ self::class, 'filter__pre_handle_404' ], 10, 2 ); 31 | add_action( 'admin_bar_menu', [ self::class, 'action__admin_bar_menu' ], 100 ); 32 | } 33 | 34 | /** 35 | * Remove support for the attachment rewrite rule. 36 | * 37 | * @param array $rules Rewrite rules. 38 | * @return array 39 | */ 40 | public static function filter__rewrite_rules_array( $rules ): array { 41 | foreach ( $rules as $regex => $query ) { 42 | if ( strpos( $regex, 'attachment' ) || strpos( $query, 'attachment' ) ) { 43 | unset( $rules[ $regex ] ); 44 | } 45 | } 46 | 47 | return $rules; 48 | } 49 | 50 | /** 51 | * Remove the attachment link. 52 | * 53 | * @return string 54 | */ 55 | public static function filter__attachment_link(): string { 56 | return ''; 57 | } 58 | 59 | /** 60 | * Filters whether to short-circuit default header status handling. 61 | * 62 | * @param bool $preempt Whether to short-circuit default header status handling. 63 | * @param WP_Query $wp_query Query object. 64 | * @return bool 65 | */ 66 | public static function filter__pre_handle_404( $preempt, $wp_query ) { 67 | if ( $wp_query->is_attachment() ) { 68 | $preempt = true; 69 | 70 | // This wipes out `is_attachment`, so the redirect to the attachment file in `canonical_redirect()` is bypassed. 71 | $wp_query->set_404(); 72 | 73 | // `WP::handle_404()` normally calls these, but we're preempting that. 74 | status_header( 404 ); 75 | nocache_headers(); 76 | } 77 | 78 | return $preempt; 79 | } 80 | 81 | /** 82 | * Remove attachment link from admin bar. 83 | * 84 | * @param WP_Admin_Bar $wp_admin_bar Admin bar class. 85 | */ 86 | public static function action__admin_bar_menu( $wp_admin_bar ): void { 87 | if ( 'attachment' === get_post_type() ) { 88 | $wp_admin_bar->remove_node( 'view' ); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-block-editor-rest-api-preload-paths.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | declare( strict_types=1 ); 14 | 15 | namespace Alley\WP\Alleyvate\Features; 16 | 17 | use Alley\WP\Types\Feature; 18 | 19 | /** 20 | * Disables the preloading of the blocks which happens on all edit post pages. 21 | */ 22 | final class Disable_Block_Editor_Rest_Api_Preload_Paths implements Feature { 23 | /** 24 | * Boot the feature. 25 | */ 26 | public function boot(): void { 27 | add_filter( 28 | 'block_editor_rest_api_preload_paths', 29 | [ self::class, 'filter__block_editor_rest_api_preload_paths' ], 30 | 9999 31 | ); 32 | } 33 | 34 | /** 35 | * Filter the block editor REST API preload paths. 36 | * 37 | * @param mixed[] $paths The paths to preload. 38 | * 39 | * @return mixed[] The filtered paths. 40 | */ 41 | public static function filter__block_editor_rest_api_preload_paths( $paths ) { 42 | if ( ! \is_array( $paths ) ) { 43 | return $paths; 44 | } 45 | return array_values( 46 | array_filter( 47 | $paths, 48 | function ( $v ) { 49 | // Remove the blocks preload path for performance reasons. 50 | return ! \is_string( $v ) || ! str_starts_with( $v, '/wp/v2/blocks?context=edit' ); 51 | }, 52 | ) 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-comments.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Fully disables comments. 19 | */ 20 | final class Disable_Comments implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | add_action( 'add_meta_boxes', [ self::class, 'action__add_meta_boxes' ], 9999 ); 26 | add_action( 'admin_bar_menu', [ self::class, 'action__admin_bar_menu' ], 9999 ); 27 | add_action( 'admin_footer', [ self::class, 'action__admin_footer' ], 9999 ); 28 | add_action( 'admin_init', [ self::class, 'action__admin_init' ], 0 ); 29 | add_action( 'admin_menu', [ self::class, 'action__admin_menu' ], 9999 ); 30 | add_action( 'init', [ self::class, 'action__init' ], 9999 ); 31 | add_filter( 'comments_open', '__return_false', 9999 ); 32 | add_filter( 'comments_pre_query', [ self::class, 'filter__comments_pre_query' ], 9999, 2 ); 33 | add_filter( 'comments_rewrite_rules', '__return_empty_array', 9999 ); 34 | add_filter( 'get_comments_number', '__return_zero', 9999 ); 35 | add_filter( 'rest_endpoints', [ self::class, 'filter__rest_endpoints' ], 9999 ); 36 | add_filter( 'rewrite_rules_array', [ self::class, 'filter__rewrite_rules_array' ], 9999 ); 37 | } 38 | 39 | /** 40 | * Removes the comments metabox from the classic editor. 41 | * 42 | * @param string $post_type The post type that metaboxes are being registered for. 43 | */ 44 | public static function action__add_meta_boxes( string $post_type ): void { 45 | remove_meta_box( 'commentsdiv', $post_type, 'normal' ); 46 | remove_meta_box( 'commentstatusdiv', $post_type, 'normal' ); 47 | } 48 | 49 | /** 50 | * Removes the comments node from the admin bar menu. 51 | * 52 | * @param \WP_Admin_Bar $wp_admin_bar An instance of the WP_Admin_Bar class. 53 | */ 54 | public static function action__admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ): void { 55 | $wp_admin_bar->remove_node( 'comments' ); 56 | } 57 | 58 | /** 59 | * Removes blocks related to core/comments from the admin block selector. 60 | * 61 | * JavaScript is used to selectively remove blocks from the editor. 62 | * The PHP filter for allowed blocks passes ‘true’ to allow all blocks by default, 63 | * so you can’t get the full list of blocks and selectively remove them. 64 | * https://developer.wordpress.org/news/2024/01/how-to-disable-specific-blocks-in-wordpress/#disable-blocks-with-php 65 | */ 66 | public static function action__admin_footer(): void { 67 | echo " 68 | "; 81 | } 82 | 83 | /** 84 | * Redirects direct requests for the comments list and discussion settings page to the admin dashboard. 85 | */ 86 | public static function action__admin_init(): void { 87 | global $pagenow; 88 | 89 | if ( \in_array( $pagenow, [ 'edit-comments.php', 'options-discussion.php' ], true ) ) { 90 | wp_safe_redirect( admin_url() ); 91 | exit; 92 | } 93 | } 94 | 95 | /** 96 | * Removes the Comments primary menu item and the Discussion submenu item (under Settings) from admin menus. 97 | */ 98 | public static function action__admin_menu(): void { 99 | remove_menu_page( 'edit-comments.php' ); 100 | remove_submenu_page( 'options-general.php', 'options-discussion.php' ); 101 | } 102 | 103 | /** 104 | * Add actions and filters to run on the init hook. 105 | */ 106 | public static function action__init(): void { 107 | 108 | // Removes post type support for comments and filters REST responses for each post type to remove comment support. 109 | foreach ( get_post_types() as $post_type ) { 110 | if ( post_type_supports( $post_type, 'comments' ) ) { 111 | remove_post_type_support( $post_type, 'comments' ); 112 | } 113 | 114 | // The REST API filters don't have a generic form, so they need to be registered for each post type. 115 | add_filter( "rest_prepare_{$post_type}", [ self::class, 'filter__rest_prepare' ], 9999 ); 116 | } 117 | 118 | // Removes the Akismet comments section from the dashboard. 119 | remove_action( 'rightnow_end', [ 'Akismet_Admin', 'rightnow_stats' ] ); 120 | } 121 | 122 | /** 123 | * Short-circuits the comments query to return an empty array or 0 (if count was requested). 124 | * 125 | * @param array|int|null $comment_data Not used. 126 | * @param \WP_Comment_Query $comment_query The comment query object to filter results for. 127 | * @return int|array 128 | */ 129 | public static function filter__comments_pre_query( $comment_data, \WP_Comment_Query $comment_query ) { 130 | return $comment_query->query_vars['count'] ? 0 : []; 131 | } 132 | 133 | /** 134 | * Removes REST endpoints related to comments. 135 | * 136 | * @param array $endpoints REST endpoints to be filtered. 137 | * 138 | * @return array Filtered endpoints. 139 | */ 140 | public static function filter__rest_endpoints( array $endpoints ): array { 141 | unset( $endpoints['/wp/v2/comments'] ); 142 | unset( $endpoints['/wp/v2/comments/(?P[\d]+)'] ); 143 | 144 | return $endpoints; 145 | } 146 | 147 | /** 148 | * Filters REST responses for post endpoints to force comment_status to be closed. 149 | * 150 | * @param \WP_REST_Response $response Response to filter. 151 | * 152 | * @return \WP_REST_Response Filtered response. 153 | */ 154 | public static function filter__rest_prepare( \WP_REST_Response $response ): \WP_REST_Response { 155 | $response->remove_link( 'replies' ); 156 | 157 | if ( \is_array( $response->data ) && isset( $response->data['comment_status'] ) ) { 158 | $response->data['comment_status'] = 'closed'; 159 | } 160 | 161 | return $response; 162 | } 163 | 164 | /** 165 | * Removes rewrite rules related to comments. 166 | * 167 | * @param array $rules Rewrite rules to be filtered. 168 | * 169 | * @return array Filtered rewrite rules. 170 | */ 171 | public static function filter__rewrite_rules_array( array $rules ): array { 172 | foreach ( $rules as $regex => $rewrite ) { 173 | if ( str_contains( $rewrite, 'cpage=$' ) ) { 174 | unset( $rules[ $regex ] ); 175 | } 176 | } 177 | 178 | return $rules; 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-custom-fields-meta-box.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Disable the custom fields meta box. 19 | */ 20 | final class Disable_Custom_Fields_Meta_Box implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | add_action( 'add_meta_boxes', [ self::class, 'action__add_meta_boxes' ], 9999 ); 26 | } 27 | 28 | /** 29 | * Remove the "Custom Fields" meta box. 30 | * 31 | * It generates an expensive query and is almost never used in practice. 32 | */ 33 | public static function action__add_meta_boxes(): void { 34 | // @phpstan-ignore-next-line 35 | remove_meta_box( 'postcustom', null, 'normal' ); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-dashboard-widgets.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Disable selected unpopular dashboard widgets. 19 | */ 20 | final class Disable_Dashboard_Widgets implements Feature { 21 | 22 | /** 23 | * Array of widgets to be removed. 24 | * 25 | * @var array 26 | */ 27 | public array $widgets = [ 28 | [ 29 | 'context' => 'side', 30 | 'priority' => 'core', 31 | 'id' => 'dashboard_primary', 32 | ], 33 | [ 34 | 'context' => 'side', 35 | 'priority' => 'core', 36 | 'id' => 'dashboard_quick_press', 37 | ], 38 | [ 39 | 'context' => 'side', 40 | 'priority' => 'core', 41 | 'id' => 'jetpack_summary_widget', 42 | ], 43 | ]; 44 | 45 | /** 46 | * Boot the feature. 47 | */ 48 | public function boot(): void { 49 | add_action( 'wp_dashboard_setup', [ $this, 'action__disable_dashboard_widgets' ] ); 50 | } 51 | 52 | /** 53 | * Disable selected unpopular dashboard widgets. 54 | * 55 | * @return void 56 | */ 57 | public function action__disable_dashboard_widgets() { 58 | foreach ( $this->widgets as $widget ) { 59 | remove_meta_box( $widget['id'], 'dashboard', $widget['context'] ); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-deep-pagination.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | use WP_Query; 18 | 19 | /** 20 | * Disables Pagination beyond a filterable maximum. Beyond that return 21 | * a 400 error describing why the issue has arisen. 22 | */ 23 | final class Disable_Deep_Pagination implements Feature { 24 | 25 | /** 26 | * Boot the feature. 27 | */ 28 | public function boot(): void { 29 | add_filter( 'posts_where', [ self::class, 'filter__posts_where' ], 10, 2 ); 30 | add_filter( 'posts_results', [ self::class, 'filter__posts_results' ], 9999, 2 ); // High priority to ensure we can override the max_num_pages. 31 | } 32 | 33 | /** 34 | * Filter the query to force no results if beyond page maximum. 35 | * 36 | * @param string $where The WHERE clause. 37 | * @param WP_Query $wp_query The WP_Query object, passed by reference. 38 | * @return string 39 | */ 40 | public static function filter__posts_where( string $where, WP_Query $wp_query ): string { 41 | // If this is an admin request, or a JSON request with a logged in user, return the posts as normal. 42 | $max_pages = ! empty( $wp_query->query['__dangerously_set_max_pages'] ) ? $wp_query->query['__dangerously_set_max_pages'] : 100; 43 | if ( 44 | is_admin() || 45 | ( 46 | wp_is_json_request() && 47 | is_user_logged_in() 48 | ) || 49 | empty( $wp_query->query['paged'] ) || 50 | $wp_query->query['paged'] <= apply_filters( 'alleyvate_deep_pagination_max_pages', $max_pages ) 51 | ) { 52 | return $where; 53 | } 54 | 55 | // If this is a JSON request, and the user is not logged in, we need to return a 400 error. 56 | if ( wp_is_json_request() ) { 57 | wp_die( 58 | \sprintf( 59 | /* translators: The maximum number of pages. */ 60 | esc_html__( 'Invalid Request: Pagination beyond page %d has been disabled for performance reasons.', 'alley' ), 61 | esc_html( $max_pages ), 62 | ), 63 | esc_html__( 'Deep Pagination Disabled', 'alley' ), 64 | 400 65 | ); 66 | } 67 | 68 | // Set the HTTP response status code to 410. 69 | status_header( 410 ); 70 | // Load the 404 template. 71 | include get_404_template(); 72 | return $where . 'AND 1 = 0'; 73 | } 74 | 75 | /** 76 | * Filter post results to force max num of pages. 77 | * 78 | * @param array<\WP_Post> $posts The posts. 79 | * @param WP_Query $wp_query The WP_Query object, passed by reference. 80 | * @return array<\WP_Post> 81 | */ 82 | public static function filter__posts_results( array $posts, WP_Query $wp_query ): array { 83 | // If this is an admin request, or a JSON request with a logged in user, return the posts as normal. 84 | $max_pages = apply_filters( 'alleyvate_deep_pagination_max_pages', ! empty( $wp_query->query['__dangerously_set_max_pages'] ) ? $wp_query->query['__dangerously_set_max_pages'] : 100 ); 85 | if ( 86 | ! is_admin() && 87 | ( 88 | ! wp_is_json_request() || 89 | ! is_user_logged_in() 90 | ) && 91 | $wp_query->max_num_pages > $max_pages 92 | ) { 93 | $wp_query->max_num_pages = $max_pages; 94 | } 95 | 96 | return $posts; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-pantheon-constant-overrides.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Disallow the WP_SITEURL and WP_HOME constants from overriding the option 19 | * value on Cron or CLI runs. 20 | */ 21 | final class Disable_Pantheon_Constant_Overrides implements Feature { 22 | 23 | /** 24 | * Boot the feature. 25 | */ 26 | public function boot(): void { 27 | if ( 28 | isset( $_ENV['PANTHEON_ENVIRONMENT'] ) && 29 | ( 30 | ( \defined( 'WP_CLI' ) && WP_CLI ) || 31 | ( \defined( 'DOING_CRON' ) && DOING_CRON ) 32 | ) 33 | ) { 34 | remove_filter( 'option_siteurl', '_config_wp_siteurl' ); 35 | remove_filter( 'option_home', '_config_wp_home' ); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-password-change-notification.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Fully disables password change notifications. 19 | */ 20 | final class Disable_Password_Change_Notification implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | remove_action( 'after_password_reset', 'wp_password_change_notification' ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-site-health-directories.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Disable_Site_Health_Directories feature. 19 | */ 20 | final class Disable_Site_Health_Directories implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | add_filter( 'rest_pre_dispatch', [ $this, 'filter_rest_pre_dispatch' ], 10, 3 ); 26 | add_filter( 'debug_information', [ $this, 'filter_debug_information' ] ); 27 | } 28 | 29 | /** 30 | * Filter REST API requests to remove Site Health directories. 31 | * 32 | * @param mixed $result Response to replace the requested version with. Can be anything a normal endpoint can return, or null to not hijack the request. 33 | * @param \WP_REST_Server $server Server instance. 34 | * @param \WP_REST_Request $request Request used to generate the response. 35 | * @return mixed Response to replace the requested version with. 36 | */ 37 | public function filter_rest_pre_dispatch( $result, $server, $request ) { 38 | if ( $request->get_route() === '/wp-site-health/v1/directory-sizes' ) { 39 | return new \WP_Error( 'rest_disabled', 'REST API endpoint disabled.', [ 'status' => 403 ] ); 40 | } 41 | 42 | return $result; 43 | } 44 | 45 | /** 46 | * Filter debug information to remove Site Health directories. 47 | * 48 | * @param array}> $info Debug information. 49 | * @return array}> Debug information. 50 | */ 51 | public function filter_debug_information( $info ): array { 52 | if ( ! \is_array( $info ) ) { 53 | $info = []; 54 | } 55 | 56 | if ( isset( $info['wp-paths-sizes'] ) ) { 57 | unset( $info['wp-paths-sizes'] ); 58 | } 59 | 60 | return $info; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-sticky-posts.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Fully disables sticky posts. 19 | */ 20 | final class Disable_Sticky_Posts implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | add_filter( 'pre_option_sticky_posts', '__return_empty_array', 9999 ); 26 | add_filter( 'is_sticky', '__return_false', 9999 ); 27 | add_action( 'admin_head', [ $this, 'on_admin_head' ] ); 28 | add_filter( 'rest_prepare_post', [ $this, 'on_rest_prepare_post' ], 9999 ); 29 | } 30 | 31 | /** 32 | * Remove sticky posts from the admin edit screen. 33 | * 34 | * Includes a script to remove the checkbox from the quick edit screen that 35 | * will cover the browsers that :has is not supported in yet. 36 | */ 37 | public function on_admin_head(): void { 38 | ?> 39 | 45 | 46 | 55 | remove_link( 'https://api.w.org/action-sticky' ); 68 | 69 | return $response; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-trackbacks.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Fully disables pingbacks and trackbacks. 19 | */ 20 | final class Disable_Trackbacks implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | add_action( 'init', [ self::class, 'action__init' ], 9999 ); 26 | add_filter( 'pings_open', '__return_false', 9999 ); 27 | add_filter( 'rewrite_rules_array', [ self::class, 'filter__rewrite_rules_array' ], 9999 ); 28 | } 29 | 30 | /** 31 | * Removes post type support for trackbacks and filters REST responses for each post type to remove trackback support. 32 | */ 33 | public static function action__init(): void { 34 | foreach ( get_post_types() as $post_type ) { 35 | if ( post_type_supports( $post_type, 'trackbacks' ) ) { 36 | remove_post_type_support( $post_type, 'trackbacks' ); 37 | } 38 | 39 | // The REST API filters don't have a generic form, so they need to be registered for each post type. 40 | add_filter( "rest_prepare_{$post_type}", [ self::class, 'filter__rest_prepare' ], 9999 ); 41 | } 42 | } 43 | 44 | /** 45 | * Filters REST responses for post endpoints to force ping_status to be closed. 46 | * 47 | * @param \WP_REST_Response $response Response to filter. 48 | * 49 | * @return \WP_REST_Response Filtered response. 50 | */ 51 | public static function filter__rest_prepare( \WP_REST_Response $response ): \WP_REST_Response { 52 | if ( \is_array( $response->data ) && isset( $response->data['ping_status'] ) ) { 53 | $response->data['ping_status'] = 'closed'; 54 | } 55 | 56 | return $response; 57 | } 58 | 59 | /** 60 | * Removes rewrite rules related to trackbacks. 61 | * 62 | * @param array $rules Rewrite rules to be filtered. 63 | * 64 | * @return array Filtered rewrite rules. 65 | */ 66 | public static function filter__rewrite_rules_array( array $rules ): array { 67 | foreach ( $rules as $regex => $rewrite ) { 68 | if ( str_contains( $rewrite, 'tb=1' ) ) { 69 | unset( $rules[ $regex ] ); 70 | } 71 | } 72 | 73 | return $rules; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disable-xmlrpc.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | declare( strict_types=1 ); 14 | 15 | namespace Alley\WP\Alleyvate\Features; 16 | 17 | use Symfony\Component\HttpFoundation\IpUtils; 18 | use Alley\WP\Types\Feature; 19 | 20 | /** 21 | * Disables XMLRPC requests and methods for all requests except those coming from known Jetpack IPs. 22 | */ 23 | final class Disable_XMLRPC implements Feature { 24 | /** 25 | * Boot the feature. 26 | */ 27 | public function boot(): void { 28 | 29 | // Disable XML-RPC for non-Jetpack requests. 30 | add_filter( 31 | 'xmlrpc_enabled', 32 | fn( $enabled ) => self::is_jetpack_enabled() && self::is_jetpack_xmlrpc_request() ? $enabled : false, 33 | \PHP_INT_MAX, 34 | ); 35 | 36 | // Remove all XML-RPC methods for non-Jetpack requests. 37 | add_filter( 38 | 'xmlrpc_methods', 39 | fn( $methods ) => self::is_jetpack_enabled() && self::is_jetpack_xmlrpc_request() ? $methods : [], 40 | \PHP_INT_MAX, 41 | ); 42 | } 43 | 44 | /** 45 | * Determine if Jetpack is enabled. 46 | * 47 | * @return bool 48 | */ 49 | public static function is_jetpack_enabled(): bool { 50 | return \defined( 'JETPACK__VERSION' ); 51 | } 52 | 53 | /** 54 | * Determine if the current request is a Jetpack XML-RPC request. 55 | * 56 | * @return bool 57 | */ 58 | public static function is_jetpack_xmlrpc_request(): bool { 59 | // Bail if there's no remote address. 60 | if ( empty( $_SERVER['REMOTE_ADDR'] ) ) { // phpcs:ignore WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders 61 | return false; 62 | } 63 | 64 | // Get Jetpack IPs. 65 | $jetpack_ips = self::get_jetpack_ips(); 66 | 67 | // Bail if we don't have any Jetpack IPs. 68 | if ( empty( $jetpack_ips ) ) { 69 | return false; 70 | } 71 | 72 | // Check if the request is from a Jetpack IP. 73 | // phpcs:ignore WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__ 74 | if ( IpUtils::checkIp( $_SERVER['REMOTE_ADDR'], $jetpack_ips ) ) { 75 | return true; 76 | } 77 | 78 | // Check if the request is from a forwarded Jetpack IP. 79 | // phpcs:ignore WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__ 80 | return isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && IpUtils::checkIp( $_SERVER['HTTP_X_FORWARDED_FOR'], $jetpack_ips ); 81 | } 82 | 83 | /** 84 | * Get the Jetpack IPs. 85 | * 86 | * @return array List of IPs. Empty array if unable to retrieve. 87 | */ 88 | public static function get_jetpack_ips(): array { 89 | // Look for cache. 90 | $jetpack_ips = wp_cache_get( 'jetpack_ips', 'alleyvate_disable_xmlrpc' ); 91 | 92 | // If there's no cache, fetch the Jetpack IPs. 93 | if ( empty( $jetpack_ips ) ) { 94 | $response = wp_safe_remote_get( 'https://jetpack.com/ips-v4.json' ); 95 | if ( ! is_wp_error( $response ) ) { 96 | // Ensure good response. 97 | if ( 200 === (int) wp_remote_retrieve_response_code( $response ) ) { 98 | $body = wp_remote_retrieve_body( $response ); 99 | $jetpack_ips = json_decode( $body, true ); 100 | 101 | // Update cache. 102 | wp_cache_set( 103 | 'jetpack_ips', 104 | $jetpack_ips, 105 | 'alleyvate_disable_xmlrpc', 106 | \is_array( $jetpack_ips ) ? WEEK_IN_SECONDS : HOUR_IN_SECONDS // phpcs:ignore WordPressVIPMinimum.Performance.LowExpiryCacheTime.CacheTimeUndetermined 107 | ); 108 | } 109 | } else { 110 | // cache the "bad result" for a short time to avoid hammering the jetpack endpoint. 111 | wp_cache_set( 'jetpack_ips', [], 'alleyvate_disable_xmlrpc', HOUR_IN_SECONDS ); 112 | } 113 | } 114 | 115 | return \is_array( $jetpack_ips ) ? $jetpack_ips : []; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-disallow-file-edit.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Disallow theme/plugin editing in the filesystem to safeguard against unexpected code changes. 19 | */ 20 | final class Disallow_File_Edit implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | if ( ! \defined( 'DISALLOW_FILE_EDIT' ) ) { 26 | \define( 'DISALLOW_FILE_EDIT', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-force-two-factor-authentication.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Forces 2FA for users with Edit permissions or higher when 2FA is available. 19 | * 20 | * A lot of this is inspired by Automattic's checks for VIP Go. 21 | */ 22 | final class Force_Two_Factor_Authentication implements Feature { 23 | 24 | /** 25 | * Boot the feature. 26 | */ 27 | public function boot(): void { 28 | if ( self::is_vip_environment() ) { 29 | add_filter( 'wpcom_vip_two_factor_enforcement_cap', [ self::class, 'filter__wpcom_vip_two_factor_enforcement_cap' ], \PHP_INT_MAX ); 30 | return; 31 | } 32 | 33 | // For non-VIP environments, we do the forcing ourselves. 34 | add_filter( 'map_meta_cap', [ self::class, 'filter__map_meta_cap' ], 0, 4 ); 35 | 36 | add_action( 'admin_notices', [ self::class, 'action__admin_notices' ] ); 37 | } 38 | 39 | /** 40 | * Filter the user capabilities to restrict them to just those capabilities required to enabled two factor authentication. 41 | * 42 | * @param array $caps The user capabilities. 43 | * @param string $cap The currently active user capability. 44 | * @param int $user_id The user ID. 45 | * @param array $args Context to the capability check. 46 | * @return array 47 | */ 48 | public static function filter__map_meta_cap( $caps, $cap, $user_id, $args ): array { 49 | if ( ! self::should_use_two_factor_authentication() ) { 50 | return $caps; 51 | } 52 | 53 | $subscriber_caps = [ 54 | 'read', 55 | 'level_0', 56 | ]; 57 | 58 | if ( 59 | 'edit_user' === $cap && 60 | ! empty( $args ) && 61 | (int) $user_id === (int) $args[0] // @phpstan-ignore-line 62 | ) { 63 | $subscriber_caps[] = 'edit_user'; 64 | } 65 | 66 | return \in_array( $cap, $subscriber_caps, true ) ? $caps : [ 'do_not_allow' ]; 67 | } 68 | 69 | /** 70 | * Adds admin notices for the end user. 71 | */ 72 | public static function action__admin_notices(): void { 73 | if ( self::should_use_two_factor_authentication() ) { 74 | self::admin_notice__configure_two_factor(); 75 | } 76 | 77 | if ( ! self::two_factor_plugin_active() ) { 78 | self::admin_notice__plugin_dependency(); 79 | } 80 | } 81 | 82 | /** 83 | * Returns the capability level that accounts will be required to use 2fa. 84 | * 85 | * @return string 86 | */ 87 | public static function filter__wpcom_vip_two_factor_enforcement_cap(): string { 88 | return apply_filters( 'alleyvate_force_2fa_capability', 'edit_posts' ); 89 | } 90 | 91 | /** 92 | * Adds an Admin Notice notifying the end user that they need to enable Two Factor authentication. 93 | */ 94 | public static function admin_notice__configure_two_factor(): void { 95 | ?> 96 |
97 |

98 | 99 | set up two-factor authentication to continue.', 'alley' ) 104 | ), 105 | esc_url( admin_url( 'profile.php' ) ) 106 | ); 107 | ?> 108 |

109 |
110 | 122 |
123 |

124 | 125 | Two Factor plugin to enable this feature.', 'alley' ) 130 | ), 131 | esc_url( 'https://wordpress.org/plugins/two-factor/' ) 132 | ); 133 | ?> 134 |

135 |
136 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Adds a nonce field to the login form. 19 | * 20 | * Heavily inspired by `wp-login-nonce` by `elyobo` 21 | * 22 | * @link https://github.com/elyobo/wp-login-nonce 23 | */ 24 | final class Login_Nonce implements Feature { 25 | 26 | /** 27 | * The name to use for the nonce. 28 | * 29 | * @var string 30 | */ 31 | public const NONCE_NAME = 'wp_alleyvate_login_nonce'; 32 | 33 | /** 34 | * The action to use for the nonce. 35 | * 36 | * @var string 37 | */ 38 | public const NONCE_ACTION = 'alleyvate_login_action'; 39 | 40 | /** 41 | * The nonce lifetime. Stored in seconds. 42 | * 43 | * @var int 44 | */ 45 | public const NONCE_TIMEOUT = 1800; 46 | 47 | /** 48 | * Boot the feature. 49 | */ 50 | public function boot(): void { 51 | add_action( 'login_form_login', [ self::class, 'action__add_nonce_life_filter' ] ); 52 | add_action( 'login_form_expired', [ self::class, 'action__prep_expired_form' ] ); 53 | add_action( 'login_head', [ self::class, 'action__add_meta_refresh' ] ); 54 | add_action( 'after_setup_theme', [ self::class, 'action__pre_validate_login_nonce' ], 9999 ); 55 | add_filter( 'nocache_headers', [ self::class, 'add_no_store_to_login' ] ); 56 | } 57 | 58 | /** 59 | * Adds the `no-store` flag to the `Cache-Control` headers. 60 | * 61 | * @param array $headers The headers array. 62 | * @return array 63 | */ 64 | public static function add_no_store_to_login( $headers ): array { 65 | if ( ! \is_array( $headers ) ) { 66 | $headers = []; 67 | } 68 | 69 | if ( ! isset( $GLOBALS['pagenow'] ) || 'wp-login.php' !== $GLOBALS['pagenow'] ) { 70 | return $headers; 71 | } 72 | 73 | if ( ! isset( $headers['Cache-Control'] ) || ! str_contains( $headers['Cache-Control'], 'no-store' ) ) { 74 | $headers['Cache-Control'] = 'no-cache, must-revalidate, max-age=0, no-store'; 75 | } 76 | 77 | return $headers; 78 | } 79 | 80 | /** 81 | * Add a meta refresh to the login page, so it will refresh after the nonce timeout. 82 | */ 83 | public static function action__add_meta_refresh(): void { 84 | printf( '', esc_attr( (string) self::NONCE_TIMEOUT ) ); 85 | ?> 86 | 93 | 112 | */ 113 | public static function action__add_nonce_life_filter(): void { 114 | add_filter( 'nonce_life', [ __CLASS__, 'nonce_life_filter' ], 10, 2 ); 115 | add_action( 'login_form', [ __CLASS__, 'action__add_nonce_to_form' ] ); 116 | } 117 | 118 | /** 119 | * Filter the nonce timeout. 120 | * 121 | * @param int $nonce_lifetime The lifetime of the nonce in seconds. 122 | * @param string|int $action The nonce action, or -1 if none was provided. 123 | * @return int 124 | */ 125 | public static function nonce_life_filter( $nonce_lifetime, $action ): int { 126 | if ( self::NONCE_ACTION !== $action ) { 127 | return $nonce_lifetime; 128 | } 129 | 130 | return self::NONCE_TIMEOUT; 131 | } 132 | 133 | /** 134 | * Validates the login nonce as early as possible to avoid login attempts. 135 | */ 136 | public static function action__pre_validate_login_nonce(): void { 137 | /* 138 | * If this request is not specifically a login attempt on the wp-login.php page, 139 | * then skip it. 140 | */ 141 | if ( 142 | 'wp-login.php' !== ( $GLOBALS['pagenow'] ?? '' ) || 143 | empty( $_POST['pwd'] ) 144 | ) { 145 | return; 146 | } 147 | 148 | /* 149 | * Nonce life is used to generate the nonce value. If this differs from the form, 150 | * the nonce will not validate. 151 | */ 152 | add_filter( 'nonce_life', [ __CLASS__, 'nonce_life_filter' ], 10, 2 ); 153 | 154 | $nonce = sanitize_key( $_POST[ self::NONCE_NAME ] ?? '' ); 155 | 156 | if ( ! wp_verify_nonce( $nonce, self::NONCE_ACTION ) ) { 157 | // If the nonce is invalid, redirect to the login form with an error. 158 | // @phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized 159 | wp_safe_redirect( add_query_arg( 'action', 'expired', wp_login_url( $_REQUEST['redirect_to'] ?? '' ) ) ); 160 | exit; 161 | } 162 | 163 | /* 164 | * Clean up after ourselves. 165 | */ 166 | remove_filter( 'nonce_life', [ __CLASS__, 'nonce_life_filter' ] ); 167 | } 168 | 169 | /** 170 | * Prepare the login form following a failed nonce check. 171 | */ 172 | public static function action__prep_expired_form(): void { 173 | add_filter( 'wp_login_errors', [ __CLASS__, 'filter__expired_login_error' ] ); 174 | self::action__add_nonce_life_filter(); 175 | } 176 | 177 | /** 178 | * Add the expired message to the login screen. 179 | * 180 | * @return \WP_Error Error message for a bad nonce. 181 | */ 182 | public static function filter__expired_login_error(): \WP_Error { 183 | return new \WP_Error( 'nonce_error', __( 'The login form was expired, please try again.', 'alley' ) ); 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-noindex-password-protected-posts.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Adds noindex to the robots meta tag content for password-protected posts. 19 | */ 20 | final class Noindex_Password_Protected_Posts implements Feature { 21 | 22 | /** 23 | * Boot the feature. 24 | */ 25 | public function boot(): void { 26 | add_filter( 'wp_robots', [ $this, 'filter_robots_content' ] ); 27 | } 28 | 29 | /** 30 | * Filters the robots meta tag content to add a noindex directive. 31 | * 32 | * @param array $robots Associative array of directives. 33 | * 34 | * @return array 35 | */ 36 | public function filter_robots_content( array $robots ): array { 37 | if ( post_password_required() ) { 38 | $robots['noindex'] = true; 39 | } 40 | 41 | return $robots; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-prevent-framing.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Headers to prevent iframe-ing of the site. 19 | * 20 | * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options 21 | * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy 22 | */ 23 | final class Prevent_Framing implements Feature { 24 | /** 25 | * Boot the feature. 26 | */ 27 | public function boot(): void { 28 | add_filter( 'wp_headers', [ self::class, 'filter__wp_headers' ] ); 29 | } 30 | 31 | /** 32 | * Output the X-Frame-Options header to prevent sites from being able to be iframe'd. 33 | * 34 | * @param array $headers The headers to be sent. 35 | * @return array The headers to be sent. 36 | */ 37 | public static function filter__wp_headers( $headers ): array { 38 | if ( ! \is_array( $headers ) ) { 39 | $headers = []; 40 | } 41 | 42 | /** 43 | * Optionally allow the Content-Security-Policy header to be used 44 | * instead of X-Frame-Options. 45 | * 46 | * The Content-Security-Policy header obsoletes the X-Frame-Options 47 | * header when used. 48 | */ 49 | if ( apply_filters( 'alleyvate_prevent_framing_csp', false ) ) { 50 | if ( isset( $headers['Content-Security-Policy'] ) ) { 51 | return $headers; 52 | } 53 | 54 | $headers['Content-Security-Policy'] = self::get_content_security_policy_header(); 55 | 56 | return $headers; 57 | } 58 | 59 | if ( isset( $headers['X-Frame-Options'] ) ) { 60 | return $headers; 61 | } 62 | 63 | /** 64 | * Allow the X-Frame-Options header to be disabled. 65 | * 66 | * @param bool $prevent_framing Whether to prevent framing. Default false. 67 | */ 68 | if ( apply_filters( 'alleyvate_prevent_framing_disable', false ) ) { 69 | return $headers; 70 | } 71 | 72 | /** 73 | * Filter the X-Frame-Options header value. 74 | * 75 | * The header can return DENY, SAMEORIGIN, or ALLOW-FROM uri. 76 | * 77 | * @param string $value The value of the X-Frame-Options header. Default SAMEORIGIN. 78 | */ 79 | $headers['X-Frame-Options'] = apply_filters( 'alleyvate_prevent_framing_x_frame_options', 'SAMEORIGIN' ); 80 | 81 | if ( ! \in_array( $headers['X-Frame-Options'], [ 'DENY', 'SAMEORIGIN' ], true ) && 0 !== strpos( $headers['X-Frame-Options'], 'ALLOW-FROM' ) ) { 82 | _doing_it_wrong( 83 | __METHOD__, 84 | \sprintf( 85 | /* translators: %s: The value of the X-Frame-Options header. */ 86 | esc_html__( 'Invalid value for %s. Must be DENY, SAMEORIGIN, or ALLOW-FROM uri.', 'alley' ), 87 | 'X-Frame-Options' 88 | ), 89 | '2.4.0' 90 | ); 91 | } 92 | 93 | return $headers; 94 | } 95 | 96 | /** 97 | * Get the Content-Security-Policy header value. 98 | * 99 | * @return string 100 | */ 101 | protected static function get_content_security_policy_header(): string { 102 | /** 103 | * Filter the Content-Security-Policy header ancestors. 104 | * 105 | * @param array $frame_ancestors The frame ancestors. Default ['\'self\'']. 106 | */ 107 | $frame_ancestors = apply_filters( 108 | 'alleyvate_prevent_framing_csp_frame_ancestors', 109 | [ 110 | '\'self\'', 111 | ] 112 | ); 113 | 114 | /** 115 | * Filter the value of the Content-Security-Policy header. 116 | * 117 | * @param string $value The value of the Content-Security-Policy header. Defaults to 'frame-ancestors \'self\'' 118 | */ 119 | return apply_filters( 120 | 'alleyvate_prevent_framing_csp_header', 121 | 'frame-ancestors ' . implode( ' ', $frame_ancestors ) 122 | ); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-redirect-guess-shortcircuit.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Disable `redirect_guess_404_permalink()`, whose behavior often confuses clients 19 | * and is non-performant on larger sites. 20 | */ 21 | final class Redirect_Guess_Shortcircuit implements Feature { 22 | /** 23 | * Boot the feature. 24 | */ 25 | public function boot(): void { 26 | add_filter( 'do_redirect_guess_404_permalink', '__return_false' ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-remove-shortlink.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | 17 | /** 18 | * Remove the shortlink link tag from the head of pages. 19 | */ 20 | final class Remove_Shortlink implements Feature { 21 | /** 22 | * Boot the feature. 23 | */ 24 | public function boot(): void { 25 | remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-twitter-embeds.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | declare( strict_types=1 ); 14 | 15 | namespace Alley\WP\Alleyvate\Features; 16 | 17 | use Alley\WP\Types\Feature; 18 | use WP_Error; 19 | 20 | /** 21 | * Twitter_Embeds feature. 22 | */ 23 | final class Twitter_Embeds implements Feature { 24 | /** 25 | * Array of attempts to catch 404 responses from Twitter. 26 | * 27 | * @var int[] $attempts 28 | */ 29 | private array $attempts = []; 30 | 31 | /** 32 | * Boot the feature. 33 | */ 34 | public function boot(): void { 35 | /* 36 | * Use `wp_oembed_add_provider()` to avoid timing issues with the `oembed_providers` filter. 37 | * See https://github.com/alleyinteractive/wp-alleyvate/issues/133. 38 | */ 39 | wp_oembed_add_provider( '#https?://(www\.)?x\.com/\w{1,15}/status(es)?/.*#i', 'https://publish.twitter.com/oembed', true ); 40 | wp_oembed_add_provider( '#https?://(www\.)?x\.com/\w{1,15}$#i', 'https://publish.twitter.com/oembed', true ); 41 | wp_oembed_add_provider( '#https?://(www\.)?x\.com/\w{1,15}/likes$#i', 'https://publish.twitter.com/oembed', true ); 42 | wp_oembed_add_provider( '#https?://(www\.)?x\.com/\w{1,15}/lists/.*#i', 'https://publish.twitter.com/oembed', true ); 43 | wp_oembed_add_provider( '#https?://(www\.)?x\.com/\w{1,15}/timelines/.*#i', 'https://publish.twitter.com/oembed', true ); 44 | wp_oembed_add_provider( '#https?://(www\.)?x\.com/i/moments/.*#i', 'https://publish.twitter.com/oembed', true ); 45 | 46 | add_filter( 'http_response', [ $this, 'filter_twitter_oembed_404s' ], 10, 3 ); 47 | add_filter( 'alleyvate_twitter_embeds_404_backstop', [ $this, 'attempt_404_backstop' ], 10, 3 ); 48 | } 49 | 50 | /** 51 | * Attempt to catch 404 responses from Twitter. 52 | * 53 | * @param array|WP_Error $response HTTP response. 54 | * @param array $parsed_args HTTP request arguments. 55 | * @param string $url URL of the HTTP request. 56 | * @return array|WP_Error 57 | */ 58 | public function filter_twitter_oembed_404s( array|WP_Error $response, array $parsed_args, string $url ): array|WP_Error { 59 | if ( 60 | strpos( $url, 'publish.twitter.com' ) !== false 61 | && 404 === wp_remote_retrieve_response_code( $response ) 62 | ) { 63 | $this->attempts[ $url ] = ( $this->attempts[ $url ] ?? 0 ) + 1; 64 | 65 | /** 66 | * Filter the response for a 404 from Twitter. 67 | * 68 | * @param array $response HTTP response. 69 | * @param string $url URL of the HTTP request. 70 | * @param int $attempts Number of times this filter has fired for this URL during this request. 71 | * @param array $parsed_args HTTP request arguments. 72 | */ 73 | return apply_filters( /* @phpstan-ignore parameter.phpDocType */ 74 | 'alleyvate_twitter_embeds_404_backstop', 75 | $response, 76 | $url, 77 | $this->attempts[ $url ], 78 | $parsed_args 79 | ); 80 | } 81 | 82 | return $response; 83 | } 84 | 85 | /** 86 | * Attempt to catch 404 responses from Twitter. 87 | * 88 | * @param array $response HTTP response. 89 | * @param string $url URL of the HTTP request. 90 | * @param int $attempts Number of times this filter has fired for this URL during this request. 91 | * @return array 92 | */ 93 | public function attempt_404_backstop( array $response, string $url, int $attempts ): array|WP_Error { 94 | if ( 1 === $attempts ) { 95 | $env_endpoint = \function_exists( 'vip_get_env_var' ) 96 | ? vip_get_env_var( 'TWITTER_OEMBED_BACKSTOP_ENDPOINT' ) 97 | : getenv( 'TWITTER_OEMBED_BACKSTOP_ENDPOINT' ); 98 | if ( $env_endpoint ) { 99 | // If there's a backstop endpoint defined, attempt to get the oembed from there. 100 | $url = str_replace( 'https://publish.twitter.com/oembed', $env_endpoint, $url ); 101 | $backstop = wp_safe_remote_get( $url ); 102 | if ( 200 === wp_remote_retrieve_response_code( $backstop ) ) { 103 | return $backstop; 104 | } 105 | } 106 | } 107 | return $response; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/features/class-user-enumeration-restrictions.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate\Features; 14 | 15 | use Alley\WP\Types\Feature; 16 | use WP_Error; 17 | use WP_HTTP_Response; 18 | use WP_REST_Request; 19 | use WP_REST_Response; 20 | 21 | /** 22 | * Require that a user be logged in before enumerating WordPress users over the REST API. 23 | * WordPress core doesn't consider usernames or user IDs to be private, but our clients 24 | * tend to not want information about the registered users on their sites to be discoverable. 25 | */ 26 | final class User_Enumeration_Restrictions implements Feature { 27 | /** 28 | * Boot the feature. 29 | */ 30 | public function boot(): void { 31 | add_filter( 'rest_request_before_callbacks', [ $this, 'restrict_rest_user_enumeration' ], 10, 3 ); 32 | } 33 | 34 | /** 35 | * Require that a user be logged in before enumerating users over the REST API. 36 | * 37 | * This filter precedes and augments the 'permission_callback' for the route, 38 | * if any, since the result of a permission callback is not filterable. 39 | * 40 | * @param WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response Result to send to the client. 41 | * @param array $handler Route handler used for the request. 42 | * @param WP_REST_Request $request Request used to generate the response. 43 | * @return WP_REST_Response|WP_HTTP_Response|WP_Error|mixed The updated result. 44 | */ 45 | public function restrict_rest_user_enumeration( $response, $handler, $request ) { 46 | $route = $request->get_route(); 47 | 48 | if ( 49 | preg_match( '#^/wp/v\d+/users($|/)#', $route ) // This is a core users route. 50 | && $request->get_method() === 'GET' // This is an enumeration request. 51 | && ! is_user_logged_in() // Authorization check. 52 | ) { 53 | $response = new WP_Error( 54 | 'rest_forbidden', 55 | __( 'Sorry, you are not allowed to list users.', 'alley' ), 56 | [ 57 | 'status' => rest_authorization_required_code(), 58 | ], 59 | ); 60 | } 61 | 62 | return $response; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/alley/wp/alleyvate/load.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | namespace Alley\WP\Alleyvate; 14 | 15 | use Alley\WP\Features\Group; 16 | 17 | /** 18 | * Load plugin features. 19 | */ 20 | function load(): void { 21 | // Bail if the Alleyvate feature class isn't loaded to prevent a fatal error. 22 | if ( ! class_exists( Feature::class ) ) { 23 | return; 24 | } 25 | 26 | $plugin = new Group( 27 | new Site_Health_Panel(), 28 | new Feature( 29 | 'cache_slow_queries', 30 | new Features\Cache_Slow_Queries(), 31 | ), 32 | new Feature( 33 | 'clean_admin_bar', 34 | new Features\Clean_Admin_Bar(), 35 | ), 36 | new Feature( 37 | 'disable_apple_news_non_prod_push', 38 | new Features\Disable_Apple_News_Non_Prod_Push(), 39 | ), 40 | new Feature( 41 | 'disable_attachment_routing', 42 | new Features\Disable_Attachment_Routing(), 43 | ), 44 | new Feature( 45 | 'disable_comments', 46 | new Features\Disable_Comments(), 47 | ), 48 | new Feature( 49 | 'disable_custom_fields_meta_box', 50 | new Features\Disable_Custom_Fields_Meta_Box(), 51 | ), 52 | new Feature( 53 | 'disable_dashboard_widgets', 54 | new Features\Disable_Dashboard_Widgets(), 55 | ), 56 | new Feature( 57 | 'disable_password_change_notification', 58 | new Features\Disable_Password_Change_Notification(), 59 | ), 60 | new Feature( 61 | 'disable_site_health_directories', 62 | new Features\Disable_Site_Health_Directories(), 63 | ), 64 | new Feature( 65 | 'disable_sticky_posts', 66 | new Features\Disable_Sticky_Posts(), 67 | ), 68 | new Feature( 69 | 'disable_trackbacks', 70 | new Features\Disable_Trackbacks(), 71 | ), 72 | new Feature( 73 | 'disable_xmlrpc', 74 | new Features\Disable_XMLRPC(), 75 | ), 76 | new Feature( 77 | 'disallow_file_edit', 78 | new Features\Disallow_File_Edit(), 79 | ), 80 | new Feature( 81 | 'login_nonce', 82 | new Features\Login_Nonce(), 83 | ), 84 | new Feature( 85 | 'prevent_framing', 86 | new Features\Prevent_Framing(), 87 | ), 88 | new Feature( 89 | 'redirect_guess_shortcircuit', 90 | new Features\Redirect_Guess_Shortcircuit(), 91 | ), 92 | new Feature( 93 | 'user_enumeration_restrictions', 94 | new Features\User_Enumeration_Restrictions(), 95 | ), 96 | new Feature( 97 | 'remove_shortlink', 98 | new Features\Remove_Shortlink(), 99 | ), 100 | new Feature( 101 | 'disable_pantheon_constant_overrides', 102 | new Features\Disable_Pantheon_Constant_Overrides(), 103 | ), 104 | new Feature( 105 | 'force_two_factor_authentication', 106 | new Features\Force_Two_Factor_Authentication(), 107 | ), 108 | new Feature( 109 | 'disable_deep_pagination', 110 | new Features\Disable_Deep_Pagination(), 111 | ), 112 | new Feature( 113 | 'disable_block_editor_rest_api_preload_paths', 114 | new Features\Disable_Block_Editor_Rest_Api_Preload_Paths(), 115 | ), 116 | new Feature( 117 | 'noindex_password_protected_posts', 118 | new Features\Noindex_Password_Protected_Posts(), 119 | ), 120 | new Feature( 121 | 'twitter_embeds', 122 | new Features\Twitter_Embeds(), 123 | ), 124 | ); 125 | 126 | $plugin->boot(); 127 | } 128 | -------------------------------------------------------------------------------- /wp-alleyvate.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | * 10 | * @package wp-alleyvate 11 | */ 12 | 13 | /** 14 | * Plugin Name: Alleyvate 15 | * Plugin URI: https://github.com/alleyinteractive/wp-alleyvate 16 | * Description: Defaults for WordPress sites by Alley 17 | * Version: 3.8.0 18 | * Author: Alley 19 | * Author URI: https://www.alley.com 20 | * Requires at least: 6.2 21 | */ 22 | 23 | if ( ! defined( 'ABSPATH' ) ) { 24 | return; 25 | } 26 | 27 | // Load Composer dependencies. 28 | if ( file_exists( __DIR__ . '/vendor/wordpress-autoload.php' ) ) { 29 | require_once __DIR__ . '/vendor/wordpress-autoload.php'; 30 | } 31 | 32 | // Load the feature loader. 33 | require_once __DIR__ . '/src/alley/wp/alleyvate/load.php'; 34 | 35 | \Alley\WP\Alleyvate\load(); 36 | --------------------------------------------------------------------------------