home
This commit is contained in:
@@ -0,0 +1,319 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license
|
||||
document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share
|
||||
and change it. By contrast, the GNU General Public License is intended to
|
||||
guarantee your freedom to share and change free software--to make sure the
|
||||
software is free for all its users. This General Public License applies to
|
||||
most of the Free Software Foundation's software and to any other program whose
|
||||
authors commit to using it. (Some other Free Software Foundation software
|
||||
is covered by the GNU Lesser General Public License instead.) You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our
|
||||
General Public Licenses are designed to make sure that you have the freedom
|
||||
to distribute copies of free software (and charge for this service if you
|
||||
wish), that you receive source code or can get it if you want it, that you
|
||||
can change the software or use pieces of it in new free programs; and that
|
||||
you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to
|
||||
deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of
|
||||
the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or
|
||||
for a fee, you must give the recipients all the rights that you have. You
|
||||
must make sure that they, too, receive or can get the source code. And you
|
||||
must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and (2)
|
||||
offer you this license which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain that
|
||||
everyone understands that there is no warranty for this free software. If
|
||||
the software is modified by someone else and passed on, we want its recipients
|
||||
to know that what they have is not the original, so that any problems introduced
|
||||
by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We
|
||||
wish to avoid the danger that redistributors of a free program will individually
|
||||
obtain patent licenses, in effect making the program proprietary. To prevent
|
||||
this, we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow.
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains a notice
|
||||
placed by the copyright holder saying it may be distributed under the terms
|
||||
of this General Public License. The "Program", below, refers to any such program
|
||||
or work, and a "work based on the Program" means either the Program or any
|
||||
derivative work under copyright law: that is to say, a work containing the
|
||||
Program or a portion of it, either verbatim or with modifications and/or translated
|
||||
into another language. (Hereinafter, translation is included without limitation
|
||||
in the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running the Program
|
||||
is not restricted, and the output from the Program is covered only if its
|
||||
contents constitute a work based on the Program (independent of having been
|
||||
made by running the Program). Whether that is true depends on what the Program
|
||||
does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's source code
|
||||
as you receive it, in any medium, provided that you conspicuously and appropriately
|
||||
publish on each copy an appropriate copyright notice and disclaimer of warranty;
|
||||
keep intact all the notices that refer to this License and to the absence
|
||||
of any warranty; and give any other recipients of the Program a copy of this
|
||||
License along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of it,
|
||||
thus forming a work based on the Program, and copy and distribute such modifications
|
||||
or work under the terms of Section 1 above, provided that you also meet all
|
||||
of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in whole or
|
||||
in part contains or is derived from the Program or any part thereof, to be
|
||||
licensed as a whole at no charge to all third parties under the terms of this
|
||||
License.
|
||||
|
||||
c) If the modified program normally reads commands interactively when run,
|
||||
you must cause it, when started running for such interactive use in the most
|
||||
ordinary way, to print or display an announcement including an appropriate
|
||||
copyright notice and a notice that there is no warranty (or else, saying that
|
||||
you provide a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this License.
|
||||
(Exception: if the Program itself is interactive but does not normally print
|
||||
such an announcement, your work based on the Program is not required to print
|
||||
an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Program, and can be reasonably
|
||||
considered independent and separate works in themselves, then this License,
|
||||
and its terms, do not apply to those sections when you distribute them as
|
||||
separate works. But when you distribute the same sections as part of a whole
|
||||
which is a work based on the Program, the distribution of the whole must be
|
||||
on the terms of this License, whose permissions for other licensees extend
|
||||
to the entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your
|
||||
rights to work written entirely by you; rather, the intent is to exercise
|
||||
the right to control the distribution of derivative or collective works based
|
||||
on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program with
|
||||
the Program (or with a work based on the Program) on a volume of a storage
|
||||
or distribution medium does not bring the other work under the scope of this
|
||||
License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it, under Section
|
||||
2) in object code or executable form under the terms of Sections 1 and 2 above
|
||||
provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable source code,
|
||||
which must be distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three years, to give
|
||||
any third party, for a charge no more than your cost of physically performing
|
||||
source distribution, a complete machine-readable copy of the corresponding
|
||||
source code, to be distributed under the terms of Sections 1 and 2 above on
|
||||
a medium customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer to distribute
|
||||
corresponding source code. (This alternative is allowed only for noncommercial
|
||||
distribution and only if you received the program in object code or executable
|
||||
form with such an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for making
|
||||
modifications to it. For an executable work, complete source code means all
|
||||
the source code for all modules it contains, plus any associated interface
|
||||
definition files, plus the scripts used to control compilation and installation
|
||||
of the executable. However, as a special exception, the source code distributed
|
||||
need not include anything that is normally distributed (in either source or
|
||||
binary form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component itself
|
||||
accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering access to
|
||||
copy from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place counts as distribution of the source code,
|
||||
even though third parties are not compelled to copy the source along with
|
||||
the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program except
|
||||
as expressly provided under this License. Any attempt otherwise to copy, modify,
|
||||
sublicense or distribute the Program is void, and will automatically terminate
|
||||
your rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses terminated
|
||||
so long as such parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not signed
|
||||
it. However, nothing else grants you permission to modify or distribute the
|
||||
Program or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the Program
|
||||
(or any work based on the Program), you indicate your acceptance of this License
|
||||
to do so, and all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the Program),
|
||||
the recipient automatically receives a license from the original licensor
|
||||
to copy, distribute or modify the Program subject to these terms and conditions.
|
||||
You may not impose any further restrictions on the recipients' exercise of
|
||||
the rights granted herein. You are not responsible for enforcing compliance
|
||||
by third parties to this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent infringement
|
||||
or for any other reason (not limited to patent issues), conditions are imposed
|
||||
on you (whether by court order, agreement or otherwise) that contradict the
|
||||
conditions of this License, they do not excuse you from the conditions of
|
||||
this License. If you cannot distribute so as to satisfy simultaneously your
|
||||
obligations under this License and any other pertinent obligations, then as
|
||||
a consequence you may not distribute the Program at all. For example, if a
|
||||
patent license would not permit royalty-free redistribution of the Program
|
||||
by all those who receive copies directly or indirectly through you, then the
|
||||
only way you could satisfy both it and this License would be to refrain entirely
|
||||
from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply and
|
||||
the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents
|
||||
or other property right claims or to contest validity of any such claims;
|
||||
this section has the sole purpose of protecting the integrity of the free
|
||||
software distribution system, which is implemented by public license practices.
|
||||
Many people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Program under this License may add an explicit geographical
|
||||
distribution limitation excluding those countries, so that distribution is
|
||||
permitted only in or among countries not thus excluded. In such case, this
|
||||
License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions of
|
||||
the General Public License from time to time. Such new versions will be similar
|
||||
in spirit to the present version, but may differ in detail to address new
|
||||
problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that version
|
||||
or of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of this License, you may choose
|
||||
any version ever published by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free programs
|
||||
whose distribution conditions are different, write to the author to ask for
|
||||
permission. For software which is copyrighted by the Free Software Foundation,
|
||||
write to the Free Software Foundation; we sometimes make exceptions for this.
|
||||
Our decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing and reuse
|
||||
of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
|
||||
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
|
||||
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
|
||||
OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
|
||||
OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
|
||||
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
|
||||
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible
|
||||
use to the public, the best way to achieve this is to make it free software
|
||||
which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach
|
||||
them to the start of each source file to most effectively convey the exclusion
|
||||
of warranty; and each file should have at least the "copyright" line and a
|
||||
pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and an idea of what it does.>
|
||||
|
||||
Copyright (C) <yyyy> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
|
||||
Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this when
|
||||
it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
|
||||
with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software,
|
||||
and you are welcome to redistribute it under certain conditions; type `show
|
||||
c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may be
|
||||
called something other than `show w' and `show c'; they could even be mouse-clicks
|
||||
or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
|
||||
is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision'
|
||||
(which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General
|
||||
Public License does not permit incorporating your program into proprietary
|
||||
programs. If your program is a subroutine library, you may consider it more
|
||||
useful to permit linking proprietary applications with the library. If this
|
||||
is what you want to do, use the GNU Lesser General Public License instead
|
||||
of this License.
|
||||
@@ -0,0 +1,102 @@
|
||||
# Disable Media Pages
|
||||
|
||||
[](https://github.com/joppuyo/disable-media-pages/actions?query=workflow%3ABuild)
|
||||
[](https://github.com/joppuyo/disable-media-pages/actions?query=workflow%3ATest)
|
||||
[](https://wordpress.org/plugins/disable-media-pages/)
|
||||
[](https://wordpress.org/plugins/disable-media-pages/)
|
||||
[](https://wordpress.org/plugins/disable-media-pages/)
|
||||
[](https://wordpress.org/plugins/disable-media-pages/)
|
||||
[](https://wordpress.org/plugins/disable-media-pages/)
|
||||
[](https://wordpress.org/plugins/disable-media-pages/)
|
||||
[](https://codecov.io/gh/joppuyo/disable-media-pages)
|
||||
[](https://gist.github.com/cheerfulstoic/d107229326a01ff0f333a1d3476e068d)
|
||||
|
||||
Completely disable "attachment" pages created by WordPress.
|
||||
|
||||
By default, WordPress creates a page for each of your attachments. This is can be undesirable because of two reasons:
|
||||
|
||||
### Search engine optimization
|
||||
|
||||
Attachment pages don't have any content, except an image, so they provide little value and can negatively affect your SEO because they are so-called [thin content](https://developers.google.com/search/docs/advanced/guidelines/thin-content). Even worse, attachment pages may in some cases rank higher than your actual content pages which leads to a poor user experience.
|
||||
|
||||
### Reserved slugs
|
||||
|
||||
Attachment pages can accidentally reserve slugs on your site. Let's say you upload an image named **contact.jpeg**, an attachment page `https://example.com/contact` is automatically created. If you then try to create a page named **Contact**, the URL for that page will be `https://example.com/contact-2` which isn't that great.
|
||||
|
||||
## How it works
|
||||
|
||||
This plugin works by automatically setting all attachment slugs to an unique id, so they won't conflict with your pages. If an attachment page is accessed, the plugin will return a 404 status code and display the "page not found" template.
|
||||
|
||||
You can also mangle any existing attachment slugs so they won't cause any issues in the future.
|
||||
|
||||
## WP CLI support
|
||||
|
||||
The plugin supports WP CLI.
|
||||
|
||||
### Mangle existing attachment slugs
|
||||
|
||||
```
|
||||
wp disable-media-pages mangle
|
||||
```
|
||||
|
||||
### Restore attachment slugs
|
||||
|
||||
```
|
||||
wp disable-media-pages restore
|
||||
```
|
||||
|
||||
|
||||
## Note for WordPress 6.4
|
||||
|
||||
WordPress 6.4 includes [a new feature](https://make.wordpress.org/core/2023/10/16/changes-to-attachment-pages/) that allows you to disable attachment pages. However, this feature redirects attachment pages to the file URL instead of returning a 404 error. To completely disable attachment pages, you should use this plugin instead. The WP 6.4 feature also does not fix the issue where attachment pages reserve slugs for pages.
|
||||
|
||||
Also, there is no user interface to enable or disable media pages, they are automatically disabled for new sites but remain enabled for existing sites.
|
||||
|
||||
Because of these issues, I recommend you to use this plugin instead of the built-in feature. The plugin will be updated in the foreseeable future, at least until attachment pages are completely removed from WordPress core and older WordPress versions are no longer in use.
|
||||
|
||||
## Requirements
|
||||
|
||||
* WordPress 6.0 or later
|
||||
* PHP 8.0 or later
|
||||
|
||||
## Installation
|
||||
|
||||
* Download latest version on [wordpress.org](https://wordpress.org/plugins/disable-media-pages/)
|
||||
* Upload the zip through the WordPress admin panel or unzip it and copy it into your wp-content/plugins directory
|
||||
* Activate the plugin on your plugins page in the WordPress admin panel
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
### How to mangle existing attachment slugs?
|
||||
|
||||
Go to the **Settings** ▸ **Disable Media Pages** ▸ **Mangle existing slugs**. This will show you a wizard to mangle existing attachment slugs.
|
||||
|
||||
### Why not just use Yoast SEO? It has a feature to redirect attachment pages to parent
|
||||
|
||||
First of all, not everyone uses Yoast SEO. More importantly, while Yoast SEO can fix the duplicate content issue, it does not help with issue of media files reserving slugs for pages.
|
||||
|
||||
### What if I want to redirect attachment pages to parent page instead?
|
||||
|
||||
Instead of displaying a 404 HTTP error, some people recommend you to redirect attachment pages to the parent page instead. I think this can be a good short-term solution if the attachment pages have been indexed by Google and you want to preserve SEO ranking for these URLs. There's a plenty of plugins on the plugin directory that let you to do that. In my opinion returning the 404 error is the correct long-term solution and if you are launching a new site, it's best to simply disable these pages so they won't ever end up in Google index.
|
||||
|
||||
### What kind of unique id is used?
|
||||
|
||||
The unique id is an UUIDv4, without dashes.
|
||||
|
||||
### Can I restore the attachment page slugs after mangling?
|
||||
|
||||
Yes, this functionality is available in version 1.1.0. The attachment slug restoration tool allows you to restore the attachment slugs back to ones based on the attachment title.
|
||||
|
||||
## Thanks
|
||||
|
||||
Special thanks to Greg Schoppe for [his research](https://gschoppe.com/wordpress/disable-attachment-pages/) and inspiration that helped a lot with developing this plugin.
|
||||
|
||||
## Support the plugin
|
||||
|
||||
Maintaining a WordPress plugin is a lot of work. If you like the plugin, please consider rating it on [WordPress.org](https://wordpress.org/support/plugin/disable-media-pages/reviews/#new-post). You can also support me on [GitHub sponsors](https://github.com/sponsors/joppuyo). Thank you!
|
||||
|
||||
If you are interested, you can also check out my other WordPress plugins:
|
||||
|
||||
* [Disable Customizer](https://wordpress.org/plugins/customizer-disabler/)
|
||||
* [Disable Drop Cap](https://wordpress.org/plugins/disable-drop-cap/)
|
||||
* [ACF Image Aspect Ratio Crop](https://wordpress.org/plugins/acf-image-aspect-ratio-crop/)
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "joppuyo/disable-media-pages",
|
||||
"description": "WordPress plugin to disable \"attachment\" pages for WordPress media.",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Johannes Siipola",
|
||||
"email": "johannes@siipo.la"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {"NPX\\DisableMediaPages\\": "lib/"}
|
||||
},
|
||||
"require-dev": {
|
||||
"lucatume/wp-browser": "^4.0",
|
||||
"codeception/c3": "^2.6"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"codeception/c3": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Plugin name: Disable Media Pages
|
||||
* Description: Plugin to disable "attachment" pages for WordPress media.
|
||||
* Author: Johannes Siipola
|
||||
* Author URI: https://siipo.la
|
||||
* Version: 4.0.3
|
||||
* License: GPL v2 or later
|
||||
* Text Domain: disable-media-pages
|
||||
*/
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// Load c3 in CI environment for code coverage. Codeception requests this file directly to collect the coverage
|
||||
// report, so this has to run before the ABSPATH check below.
|
||||
if (file_exists(__DIR__ . '/c3.php')) {
|
||||
require_once __DIR__ . '/c3.php';
|
||||
}
|
||||
|
||||
// Prevent direct access to this file outside of WordPress.
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
\NPX\DisableMediaPages\Plugin::get_instance();
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
||||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/wp-content/plugins/disable-media-pages/dist/",n(n.s=15)}({15:function(e,t,n){}});
|
||||
//# sourceMappingURL=style.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["webpack:///webpack/bootstrap"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,EAAmB,IAAI,IAAIM,KAAON,EAAOrB,EAAoBU,EAAEe,EAAIE,EAAK,SAASA,GAAO,OAAON,EAAMM,IAAQC,KAAK,KAAMD,IAC9I,OAAOF,GAIRzB,EAAoB6B,EAAI,SAAS1B,GAChC,IAAIS,EAAST,GAAUA,EAAOqB,WAC7B,WAAwB,OAAOrB,EAAgB,SAC/C,WAA8B,OAAOA,GAEtC,OADAH,EAAoBU,EAAEE,EAAQ,IAAKA,GAC5BA,GAIRZ,EAAoBa,EAAI,SAASiB,EAAQC,GAAY,OAAOjB,OAAOkB,UAAUC,eAAe1B,KAAKuB,EAAQC,IAGzG/B,EAAoBkC,EAAI,gDAIjBlC,EAAoBA,EAAoBmC,EAAI,I","file":"style.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/wp-content/plugins/disable-media-pages/dist/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 15);\n"],"sourceRoot":""}
|
||||
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace NPX\DisableMediaPages\Modules;
|
||||
|
||||
class Admin
|
||||
{
|
||||
private static $instance = null;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $plugin_file;
|
||||
|
||||
public static function get_instance(): Admin
|
||||
{
|
||||
if (static::$instance === null) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
$this->plugin_file = realpath(__DIR__ . '/../../disable-media-pages.php');
|
||||
add_filter('init', [$this, 'init']);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
add_filter('admin_enqueue_scripts', [$this, 'admin_enqueue_scripts']);
|
||||
add_filter(
|
||||
'plugin_action_links_' . plugin_basename($this->plugin_file),
|
||||
[$this, 'plugin_action_links']
|
||||
);
|
||||
add_filter('plugin_row_meta', [$this, 'donate_link'], 10, 2);
|
||||
add_action('admin_menu', [$this, 'admin_menu']);
|
||||
}
|
||||
|
||||
public function admin_menu()
|
||||
{
|
||||
add_submenu_page(
|
||||
'options-general.php',
|
||||
__(
|
||||
'Disable Media Pages',
|
||||
'disable-media-pages'
|
||||
),
|
||||
__(
|
||||
'Disable Media Pages',
|
||||
'disable-media-pages'
|
||||
),
|
||||
'manage_options',
|
||||
'disable-media-pages',
|
||||
[$this, 'settings_page']
|
||||
);
|
||||
}
|
||||
|
||||
public function settings_page()
|
||||
{
|
||||
echo '<div id="disable-media-pages"><disable-media-pages></disable-media-pages></div>';
|
||||
}
|
||||
|
||||
function admin_enqueue_scripts()
|
||||
{
|
||||
$plugin_data = get_plugin_data($this->plugin_file);
|
||||
$version = $plugin_data['Version'];
|
||||
$url = plugin_dir_url($this->plugin_file);
|
||||
$path = plugin_dir_path($this->plugin_file);
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if (empty($current_screen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($current_screen->id !== 'settings_page_disable-media-pages') {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_script(
|
||||
'dmp-script',
|
||||
"{$url}dist/script.js",
|
||||
[],
|
||||
WP_DEBUG ? md5_file($path . 'dist/script.js') : $version
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
'dmp-script',
|
||||
'disable_media_pages',
|
||||
[
|
||||
'root' => rest_url(),
|
||||
'token' => wp_create_nonce('wp_rest'),
|
||||
'i18n' => [
|
||||
'plugin_title' => __('Disable Media Pages', 'disable-media-pages'),
|
||||
'tab_status' => __('Plugin status', 'disable-media-pages'),
|
||||
'tab_mangle' => __('Mangle existing slugs', 'disable-media-pages'),
|
||||
'tab_restore' => __('Restore media slugs', 'disable-media-pages'),
|
||||
'mangle_title' => __('Mangle existing slugs', 'disable-media-pages'),
|
||||
'mangle_subtitle' => __(
|
||||
'Existing media slug mangling tool',
|
||||
'disable-media-pages'
|
||||
),
|
||||
'mangle_description' => __(
|
||||
"This tool will let you change all existing post slugs to unique ids so they won't conflict with your page titles",
|
||||
'disable-media-pages'
|
||||
),
|
||||
'mangle_button' => __('Start mangling process', 'disable-media-pages'),
|
||||
'mangle_progress_title' => __(
|
||||
'Mangling existing media slugs...',
|
||||
'disable-media-pages'
|
||||
),
|
||||
'mangle_progress_description' => __('Progress %d%%', 'disable-media-pages'),
|
||||
'mangle_success_title' => __('All media slugs mangled', 'disable-media-pages'),
|
||||
'mangle_success_button' => __('Start over', 'disable-media-pages'),
|
||||
'restore_title' => __('Restore media slugs', 'disable-media-pages'),
|
||||
'restore_subtitle' => __('Media slug restoration tool', 'disable-media-pages'),
|
||||
'restore_description' => __(
|
||||
"This tool allows you to restore media slugs from UUID4 format to a slug based on the post title.",
|
||||
'disable-media-pages'
|
||||
),
|
||||
'restore_button' => __('Start restoring process', 'disable-media-pages'),
|
||||
'restore_progress_title' => __(
|
||||
'Restoring media slugs...',
|
||||
'disable-media-pages'
|
||||
),
|
||||
'restore_progress_description' => __('Progress %d%%', 'disable-media-pages'),
|
||||
'restore_success_title' => __(
|
||||
'All media slugs restored',
|
||||
'disable-media-pages'
|
||||
),
|
||||
'restore_success_button' => __('Start over', 'disable-media-pages'),
|
||||
'tool_progress_subtitle' => __(
|
||||
'Processed %s out of %s attachments',
|
||||
'disable-media-pages'
|
||||
),
|
||||
'status_title' => __('Plugin status', 'disable-media-pages'),
|
||||
'status_loading_title' => __('Loading status', 'disable-media-pages'),
|
||||
'status_loading_description' => __(
|
||||
'Please wait while we fetch the plugin status…',
|
||||
'disable-media-pages'
|
||||
),
|
||||
'status_some_issues_title' => __("Some issues found", 'disable-media-pages'),
|
||||
'status_non_unique_count_singular' => __(
|
||||
'There is %d attachment with a non-unique slug.',
|
||||
'disable-media-pages'
|
||||
),
|
||||
'status_non_unique_count_plural' => __(
|
||||
'There are %d attachments with non-unique slugs.',
|
||||
'disable-media-pages'
|
||||
),
|
||||
'status_non_unique_description' => __(
|
||||
"With the plugin active, users can't access these pages. However, these attachments may accidentally reserve slugs from your pages. It's recommended to run the mangle attachments tool to prevent any potential issues in the future.",
|
||||
'disable-media-pages'
|
||||
),
|
||||
'status_no_issues_title' => __("No issues found", 'disable-media-pages'),
|
||||
'status_no_issues_description' => __(
|
||||
"All attachments have unique slugs. There's not risk of attachments accidentally reserving slugs from your pages.",
|
||||
'disable-media-pages'
|
||||
),
|
||||
'status_open_tool_button' => __("Open Tool", 'disable-media-pages'),
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'dmp-style',
|
||||
"{$url}dist/style.css",
|
||||
[],
|
||||
WP_DEBUG ? md5_file($path . 'dist/style.css') : $version
|
||||
);
|
||||
}
|
||||
|
||||
public function plugin_action_links($links)
|
||||
{
|
||||
$settings_link =
|
||||
'<a href="options-general.php?page=disable-media-pages">' .
|
||||
__('Settings', 'disable-media-pages') .
|
||||
'</a>';
|
||||
array_unshift($links, $settings_link);
|
||||
return $links;
|
||||
}
|
||||
|
||||
public function donate_link($links, $file) {
|
||||
if ($file === plugin_basename($this->plugin_file)) {
|
||||
array_push(
|
||||
$links,
|
||||
'<a href="https://github.com/sponsors/joppuyo">' .
|
||||
esc_html__(
|
||||
'Support development on GitHub Sponsors',
|
||||
'disable-media-pages'
|
||||
) .
|
||||
'</a>'
|
||||
);
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace NPX\DisableMediaPages\Modules;
|
||||
|
||||
class CLI
|
||||
{
|
||||
private static $instance = null;
|
||||
|
||||
public static function get_instance(): CLI
|
||||
{
|
||||
if (static::$instance === null) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
add_filter('cli_init', [$this, 'cli_init']);
|
||||
}
|
||||
|
||||
public function cli_init()
|
||||
{
|
||||
\WP_CLI::add_command('disable-media-pages mangle', [$this, 'mangle']);
|
||||
\WP_CLI::add_command('disable-media-pages restore', [$this, 'restore']);
|
||||
}
|
||||
|
||||
public function mangle()
|
||||
{
|
||||
$mangle = Mangle::get_instance();
|
||||
\WP_CLI::line('Mangling media slugs...');
|
||||
$attachment_ids = $mangle->get_attachments_to_mangle();
|
||||
foreach ($attachment_ids as $attachment_id) {
|
||||
\WP_CLI::line('Mangling attachment with ID ' . $attachment_id . ' and title ' . get_the_title($attachment_id));
|
||||
$mangle->mangle_attachment($attachment_id);
|
||||
}
|
||||
\WP_CLI::success('Successfully mangled ' . count($attachment_ids) . ' media slugs!');
|
||||
}
|
||||
|
||||
public function restore()
|
||||
{
|
||||
\WP_CLI::line('Restoring media slugs...');
|
||||
$restore = Restore::get_instance();
|
||||
$attachment_ids = $restore->get_attachments_to_restore();
|
||||
foreach ($attachment_ids as $attachment_id) {
|
||||
\WP_CLI::line('Restoring attachment with ID ' . $attachment_id . ' and title ' . get_the_title($attachment_id));
|
||||
$restore->restore_attachment($attachment_id);
|
||||
}
|
||||
\WP_CLI::success('Successfully restored ' . count($attachment_ids) . ' media slugs!');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace NPX\DisableMediaPages\Modules;
|
||||
|
||||
use NPX\DisableMediaPages\Plugin;
|
||||
|
||||
class Mangle
|
||||
{
|
||||
private static $instance = null;
|
||||
|
||||
public static function get_instance(): Mangle
|
||||
{
|
||||
if (static::$instance === null) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
public function get_attachments_to_mangle()
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$result = $wpdb->get_col(
|
||||
"SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_name NOT RLIKE '^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}$'"
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function mangle_attachment($attachment_id)
|
||||
{
|
||||
$plugin = Plugin::get_instance();
|
||||
$attachment = get_post($attachment_id);
|
||||
$slug = $attachment->post_name;
|
||||
|
||||
$is_uuid = Plugin::is_uuid($slug);
|
||||
|
||||
if (!$is_uuid) {
|
||||
$new_attachment = [
|
||||
'ID' => $attachment->ID,
|
||||
'post_name' => $plugin->generate_uuid_v4(),
|
||||
];
|
||||
|
||||
wp_update_post($new_attachment);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace NPX\DisableMediaPages\Modules;
|
||||
|
||||
use NPX\DisableMediaPages\Plugin;
|
||||
use WP_Query;
|
||||
use WP_REST_Request;
|
||||
use WP_REST_Response;
|
||||
|
||||
class REST
|
||||
{
|
||||
private static $instance = null;
|
||||
public $plugin_file = null;
|
||||
|
||||
public static function get_instance(): REST
|
||||
{
|
||||
if (static::$instance === null) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('init', [$this, 'init']);
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
add_action('rest_api_init', [$this, 'rest_api_init']);
|
||||
}
|
||||
|
||||
public function rest_api_init()
|
||||
{
|
||||
// Status
|
||||
register_rest_route(
|
||||
'disable-media-pages/v1',
|
||||
'/get_status',
|
||||
[
|
||||
'methods' => 'GET',
|
||||
'callback' => [$this, 'rest_api_get_status'],
|
||||
'permission_callback' => function () {
|
||||
return current_user_can('manage_options');
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
// Mangle
|
||||
register_rest_route(
|
||||
'disable-media-pages/v1',
|
||||
'/get_all_attachments',
|
||||
[
|
||||
'methods' => 'GET',
|
||||
'callback' => [$this, 'rest_api_get_all_attachments'],
|
||||
'permission_callback' => function () {
|
||||
return current_user_can('manage_options');
|
||||
},
|
||||
]
|
||||
);
|
||||
register_rest_route(
|
||||
'disable-media-pages/v1',
|
||||
'/process/(?P<id>\d+)',
|
||||
[
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'rest_api_process_attachment'],
|
||||
'args' => [
|
||||
'id' => [
|
||||
'validate_callback' => function ($param) {
|
||||
return is_numeric($param);
|
||||
},
|
||||
],
|
||||
],
|
||||
'permission_callback' => function () {
|
||||
return current_user_can('manage_options');
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
// Restore
|
||||
register_rest_route(
|
||||
'disable-media-pages/v1',
|
||||
'/get-attachments-to-restore',
|
||||
[
|
||||
'methods' => 'GET',
|
||||
'callback' => [$this, 'rest_api_get_attachments_to_restore'],
|
||||
'permission_callback' => function () {
|
||||
return current_user_can('manage_options');
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
'disable-media-pages/v1',
|
||||
'/restore/(?P<id>\d+)',
|
||||
[
|
||||
'methods' => 'POST',
|
||||
'callback' => [$this, 'rest_api_restore_attachment'],
|
||||
'args' => [
|
||||
'id' => [
|
||||
'validate_callback' => function ($param) {
|
||||
return is_numeric($param);
|
||||
},
|
||||
],
|
||||
],
|
||||
'permission_callback' => function () {
|
||||
return current_user_can('manage_options');
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function rest_api_get_status(WP_REST_Request $data)
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$result = $wpdb->get_var(
|
||||
"SELECT COUNT(ID) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_name NOT RLIKE '^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}$'"
|
||||
);
|
||||
|
||||
$json = [
|
||||
'non_unique_count' => (int)$result,
|
||||
];
|
||||
|
||||
return new WP_REST_Response($json);
|
||||
}
|
||||
|
||||
public function rest_api_get_all_attachments(WP_REST_Request $data)
|
||||
{
|
||||
|
||||
$mangle = Mangle::get_instance();
|
||||
|
||||
$result = $mangle->get_attachments_to_mangle();
|
||||
|
||||
$json = [
|
||||
'posts' => $result,
|
||||
'total' => count($result),
|
||||
'result' => $result,
|
||||
];
|
||||
|
||||
return new WP_REST_Response($json);
|
||||
}
|
||||
|
||||
public function rest_api_process_attachment(WP_REST_Request $data)
|
||||
{
|
||||
$mangle = Mangle::get_instance();
|
||||
|
||||
$post_id = $data->get_param('id');
|
||||
|
||||
$mangle->mangle_attachment($post_id);
|
||||
|
||||
return new WP_REST_Response([]);
|
||||
}
|
||||
|
||||
public function rest_api_get_attachments_to_restore(WP_REST_Request $data)
|
||||
{
|
||||
$restore = Restore::get_instance();
|
||||
|
||||
$result = $restore->get_attachments_to_restore();
|
||||
|
||||
$json = [
|
||||
'posts' => $result,
|
||||
'total' => count($result),
|
||||
'result' => $result,
|
||||
];
|
||||
|
||||
return new WP_REST_Response($json);
|
||||
}
|
||||
|
||||
public function rest_api_restore_attachment(WP_REST_Request $data)
|
||||
{
|
||||
$post_id = $data->get_param('id');
|
||||
|
||||
$restore = Restore::get_instance();
|
||||
|
||||
$restore->restore_attachment($post_id);
|
||||
|
||||
return new WP_REST_Response([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace NPX\DisableMediaPages\Modules;
|
||||
|
||||
use NPX\DisableMediaPages\Plugin;
|
||||
|
||||
class Restore
|
||||
{
|
||||
private static $instance = null;
|
||||
|
||||
public static function get_instance(): Restore
|
||||
{
|
||||
if (static::$instance === null) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
public function get_attachments_to_restore()
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$result = $wpdb->get_col(
|
||||
"SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_name RLIKE '^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}$' ORDER BY post_date ASC;"
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function restore_attachment($attachment_id)
|
||||
{
|
||||
|
||||
$plugin = Plugin::get_instance();
|
||||
|
||||
$attachment = get_post($attachment_id);
|
||||
$slug = $attachment->post_name;
|
||||
|
||||
$is_uuid = Plugin::is_uuid($slug);
|
||||
|
||||
if ($is_uuid) {
|
||||
$new_slug = sanitize_title($attachment->post_title);
|
||||
|
||||
// Remove our filter so we get a real slug instead of UUID
|
||||
remove_filter('wp_unique_post_slug', [$plugin, 'unique_slug'], 10);
|
||||
|
||||
$new_attachment = [
|
||||
'ID' => $attachment->ID,
|
||||
'post_name' => $new_slug,
|
||||
];
|
||||
wp_update_post($new_attachment);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace NPX\DisableMediaPages;
|
||||
|
||||
use NPX\DisableMediaPages\Modules\Admin;
|
||||
use NPX\DisableMediaPages\Modules\CLI;
|
||||
use NPX\DisableMediaPages\Modules\REST;
|
||||
use WP_Query;
|
||||
use WP_REST_Request;
|
||||
use WP_REST_Response;
|
||||
|
||||
class Plugin
|
||||
{
|
||||
private static $instance = null;
|
||||
public $plugin_file = null;
|
||||
|
||||
public static function get_instance(): Plugin
|
||||
{
|
||||
if (static::$instance === null) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
add_filter('wp_unique_post_slug', [$this, 'unique_slug'], 10, 6);
|
||||
add_filter('template_redirect', [$this, 'set_404']);
|
||||
add_filter('redirect_canonical', [$this, 'redirect_canonical'], 0, 2);
|
||||
add_filter('attachment_link', [$this, 'change_attachment_link'], 10, 2);
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('init', [$this, 'init']);
|
||||
REST::get_instance();
|
||||
Admin::get_instance();
|
||||
CLI::get_instance();
|
||||
}
|
||||
|
||||
public static function debug(...$messages)
|
||||
{
|
||||
if (defined('WP_DEBUG') && WP_DEBUG === true) {
|
||||
error_log(print_r($messages, true));
|
||||
}
|
||||
}
|
||||
|
||||
function set_404()
|
||||
{
|
||||
if (is_attachment()) {
|
||||
global $wp_query;
|
||||
$wp_query->set_404();
|
||||
status_header(404);
|
||||
}
|
||||
}
|
||||
|
||||
function redirect_canonical($redirect_url, $requested_url)
|
||||
{
|
||||
if (is_attachment()) {
|
||||
global $wp_query;
|
||||
$wp_query->set_404();
|
||||
status_header(404);
|
||||
|
||||
// Handle WordPress 6.4's attachment page redirection by cancelling the redirection.
|
||||
// https://make.wordpress.org/core/2023/10/16/changes-to-attachment-pages/
|
||||
global $wp_version;
|
||||
if (version_compare($wp_version, '6.4', '>=')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return $redirect_url;
|
||||
}
|
||||
|
||||
function change_attachment_link($url, $id)
|
||||
{
|
||||
$attachment_url = wp_get_attachment_url($id);
|
||||
if ($attachment_url) {
|
||||
return $attachment_url;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
function unique_slug($slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug)
|
||||
{
|
||||
if ($post_type === 'attachment' && !self::is_uuid($slug)) {
|
||||
return $this->generate_uuid_v4();
|
||||
}
|
||||
return $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|string[]
|
||||
*/
|
||||
public function generate_uuid_v4()
|
||||
{
|
||||
return str_replace('-', '', $this->wp_generate_uuid4_improved());
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate UUIDv4 with improved randomness. The built-in WordPress function starts to generate duplicate UUIDs
|
||||
* After 80 000 iterations. This function uses random_int() instead of mt_rand() to generate the UUID.
|
||||
* @see https://core.trac.wordpress.org/ticket/59239
|
||||
* @return string
|
||||
*/
|
||||
public function wp_generate_uuid4_improved()
|
||||
{
|
||||
try {
|
||||
return sprintf(
|
||||
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||
random_int(0, 0xffff),
|
||||
random_int(0, 0xffff),
|
||||
random_int(0, 0xffff),
|
||||
random_int(0, 0x0fff) | 0x4000,
|
||||
random_int(0, 0x3fff) | 0x8000,
|
||||
random_int(0, 0xffff),
|
||||
random_int(0, 0xffff),
|
||||
random_int(0, 0xffff)
|
||||
);
|
||||
} catch (\Exception $exception) {
|
||||
// If for some reason random_int() fails (eg. a source of randomness is not available), fall back to the
|
||||
// built-in WordPress function.
|
||||
return wp_generate_uuid4();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $slug
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_uuid(string $slug): bool
|
||||
{
|
||||
$is_uuid = (bool)preg_match(
|
||||
'/^[0-9a-f]{8}[0-9a-f]{4}4[0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/',
|
||||
$slug
|
||||
);
|
||||
return $is_uuid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "disable-media-pages",
|
||||
"author": "Johannes Siipola",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.8.3",
|
||||
"@babel/preset-env": "^7.8.3",
|
||||
"autoprefixer": "^9.7.4",
|
||||
"axios": "^0.21.2",
|
||||
"babel-loader": "^8.0.6",
|
||||
"core-js": "^3.6.4",
|
||||
"css-loader": "^1.0.1",
|
||||
"cssnano": "^4.1.11",
|
||||
"extract-loader": "^2.0.1",
|
||||
"file-loader": "^1.1.11",
|
||||
"mini-css-extract-plugin": "^0.4.5",
|
||||
"minireset.css": "0.0.7",
|
||||
"node-sass": "^4.13.1",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"qs": "^6.9.4",
|
||||
"raw-loader": "^1.0.0",
|
||||
"regenerator-runtime": "^0.13.3",
|
||||
"sass-loader": "^7.3.1",
|
||||
"sprintf-js": "^1.1.2",
|
||||
"svgo-loader": "^2.2.1",
|
||||
"vue": "^2.6.11",
|
||||
"vue-loader": "^15.9.2",
|
||||
"vue-template-compiler": "^2.6.11",
|
||||
"webpack": "^4.46.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"webpack-cli": "^3.3.10",
|
||||
"webpack-watch-time-plugin": "^0.3.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
# Disable Media Pages
|
||||
|
||||
Tags: remove, hide, attachment, image, permalink
|
||||
Contributors: joppuyo
|
||||
Requires at least: 6.0
|
||||
Tested up to: 7.1
|
||||
Requires PHP: 8.0
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
Donate link: https://github.com/sponsors/joppuyo
|
||||
Stable tag: 4.0.3
|
||||
|
||||
Completely remove "attachment" pages for WordPress media. Improve SEO and prevent conflicts between page and image permalinks.
|
||||
|
||||
## Description
|
||||
|
||||
Completely disable "attachment" pages created by WordPress.
|
||||
|
||||
By default, WordPress creates a page for each of your attachments. This is can be undesirable because of two reasons:
|
||||
|
||||
### Search engine optimization
|
||||
|
||||
Attachment pages don't have any content, except an image, so they provide little value and can negatively affect your SEO because they are so-called [thin content](https://developers.google.com/search/docs/advanced/guidelines/thin-content). Even worse, attachment pages may in some cases rank higher than your actual content pages which leads to a poor user experience.
|
||||
|
||||
### Reserved slugs
|
||||
|
||||
Attachment pages can accidentally reserve slugs on your site. Let's say you upload an image named **contact.jpeg**, an attachment page `https://example.com/contact` is automatically created. If you then try to create a page named **Contact**, the URL for that page will be `https://example.com/contact-2` which isn't that great.
|
||||
|
||||
### How it works
|
||||
|
||||
This plugin works by automatically setting all attachment slugs to an unique id, so they won't conflict with your pages. If an attachment page is accessed, the plugin will set a 404 status code and display the "page not found" template.
|
||||
|
||||
You can also mangle any existing attachment slugs so they won't cause any issues in the future.
|
||||
|
||||
### WP CLI support
|
||||
|
||||
The plugin supports WP CLI.
|
||||
|
||||
#### Mangle existing attachment slugs
|
||||
|
||||
`
|
||||
wp disable-media-pages mangle
|
||||
`
|
||||
|
||||
#### Restore attachment slugs
|
||||
|
||||
`
|
||||
wp disable-media-pages restore
|
||||
`
|
||||
|
||||
### Note for WordPress 6.4
|
||||
|
||||
WordPress 6.4 includes [a new feature](https://make.wordpress.org/core/2023/10/16/changes-to-attachment-pages/) that allows you to disable attachment pages. However, this feature redirects attachment pages to the file URL instead of returning a 404 error. To completely disable attachment pages, you should use this plugin instead. The WP 6.4 feature also does not fix the issue where attachment pages reserve slugs for pages.
|
||||
|
||||
Also, there is not user interface to enable or disable media pages, they are automatically disabled for new sites but remain enabled for existing sites.
|
||||
|
||||
Because of these issues, I recommend you to use this plugin instead of the built-in feature. The plugin will be updated in the foreseeable future, at least until attachment pages are completely removed from WordPress core and older WordPress versions are no longer in use.
|
||||
|
||||
### Thanks
|
||||
|
||||
Special thanks to Greg Schoppe for [his research](https://gschoppe.com/wordpress/disable-attachment-pages/) and inspiration that helped a lot with developing this plugin.
|
||||
|
||||
## Support the plugin
|
||||
|
||||
Maintaining a WordPress plugin is a lot of work. If you like the plugin, please consider rating it on [WordPress.org](https://wordpress.org/support/plugin/disable-media-pages/reviews/#new-post). You can also support me on [GitHub sponsors](https://github.com/sponsors/joppuyo). Thank you!
|
||||
|
||||
If you are interested, you can also check out my other WordPress plugins:
|
||||
|
||||
* [Disable Customizer](https://wordpress.org/plugins/customizer-disabler/)
|
||||
* [Disable Drop Cap](https://wordpress.org/plugins/disable-drop-cap/)
|
||||
* [ACF Image Aspect Ratio Crop](https://wordpress.org/plugins/acf-image-aspect-ratio-crop/)
|
||||
|
||||
## Installation
|
||||
|
||||
1. Install the plugin from your WordPress dashboard
|
||||
2. Activate the Disable Media Pages plugin via the plugins admin page
|
||||
3. From now on, media pages will be disabled and new media items uploaded in the library will get unique id slugs
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
### How to mangle existing attachment slugs?
|
||||
|
||||
Go to the **Settings** ▸ **Disable Media Pages** ▸ **Mangle existing slugs**. This will show you a wizard to mangle existing attachment slugs.
|
||||
|
||||
### Why not just use Yoast SEO? It has a feature to redirect attachment pages to parent
|
||||
|
||||
First of all, not everyone uses Yoast SEO. More importantly, while Yoast SEO can fix the duplicate content issue, it does not help with issue of media files reserving slugs for pages.
|
||||
|
||||
### What if I want to redirect attachment pages to parent page instead?
|
||||
|
||||
Instead of displaying a 404 HTTP error, some people recommend you to redirect attachment pages to the parent page instead. I think this can be a good short-term solution if the attachment pages have been indexed by Google and you want to preserve SEO ranking for these URLs. There's a plenty of plugins on the plugin directory that let you to do that. In my opinion returning the 404 error is the correct long-term solution and if you are launching a new site, it's best to simply disable these pages so they won't ever end up in Google index.
|
||||
|
||||
### What kind of unique id is used?
|
||||
|
||||
The unique id is an UUIDv4, without dashes.
|
||||
|
||||
### Can I restore the attachment page slugs after mangling?
|
||||
|
||||
Yes, this functionality is available in version 1.1.0. The attachment slug restoration tool allows you to restore the attachment slugs back to ones based on the attachment title.
|
||||
|
||||
### Can I find this plugin on GitHub?
|
||||
|
||||
Yes, check out the [GitHub repository.](https://github.com/joppuyo/disable-media-pages)
|
||||
|
||||
## Changelog
|
||||
|
||||
### 4.0.3 (2025‐09‐19)
|
||||
* Fix: Deployment fix
|
||||
|
||||
### 4.0.2 (2025‐09‐19)
|
||||
* Fix: Deployment fix
|
||||
|
||||
### 4.0.1 (2025‐09‐19)
|
||||
* Fix: Tested in WP 7.1
|
||||
|
||||
### 4.0.0 (2025‐08‐04)
|
||||
* Breaking change: Minimum supported WordPress version is now 6.0 and the minimum PHP version is now 8.0. This is because wp-browser, which is used for testing no longer supports PHP 7. If you are using an older version of WordPress or PHP, please use the last 3.x version of this plugin.
|
||||
* Fix: Tested in WP 6.8
|
||||
|
||||
### 3.1.3 (2024‐07‐25)
|
||||
* Fix: Tested in WP 6.6
|
||||
|
||||
### 3.1.2 (2024‐04‐04)
|
||||
* Fix: Tested in WP 6.5
|
||||
|
||||
### 3.1.1 (2024‐03‐26)
|
||||
* Fix: Removed unnecessary debugging statements
|
||||
* Fix: improve readme formatting
|
||||
|
||||
### 3.1.0 (2024‐03‐24)
|
||||
* Feature: Add WP CLI support
|
||||
|
||||
### 3.0.5 (2023‐11‐09)
|
||||
* Update readme
|
||||
|
||||
### 3.0.4 (2023‐11‐09)
|
||||
* Fix: WordPress 6.4 compatibility.
|
||||
* **Note for WordPress 6.4**
|
||||
|
||||
WordPress 6.4 includes [a new feature](https://make.wordpress.org/core/2023/10/16/changes-to-attachment-pages/) that allows you to disable attachment pages. However, this feature redirects attachment pages to the file URL instead of returning a 404 error. To completely disable attachment pages, you should use this plugin instead. The WP 6.4 feature also does not fix the issue where attachment pages reserve slugs for pages.
|
||||
|
||||
Also, it seems like this feature does not work as intended, because it will disable attachment pages only for users who are logged in. Anonymous users will still be able to access attachment pages. You can follow the progress of this issue on [WordPress Trac](https://core.trac.wordpress.org/ticket/59866).
|
||||
|
||||
Also, there is no user interface to enable or disable media pages, they are automatically disabled for new sites but remain enabled for existing sites.
|
||||
|
||||
Because of these issues, I recommend you to use this plugin instead of the built-in feature. The plugin will be updated in the foreseeable future, at least until attachment pages are completely removed from WordPress core and older WordPress versions are no longer in use.
|
||||
|
||||
### 3.0.3 (2023‐09‐26)
|
||||
* Fix: Improved randomness in UUIDv4 generation
|
||||
|
||||
### 3.0.2 (2023‐08‐10)
|
||||
* Fix: Tested in WP 6.3
|
||||
|
||||
### 3.0.1 (2023-06-15)
|
||||
* Fix: Fix typo
|
||||
|
||||
### 3.0.0 (2023-06-15)
|
||||
* Fix: Tested in WordPress 6.2
|
||||
* Breaking change: Dropped support for WordPress 5.0, WordPress 5.1, and PHP 7.0. The Debian version in the Docker images is so old it no longer works properly and crashes the build. This makes it very difficult to run tests. New minimum PHP version is 7.1 and minimum WordPress version is 5.2.
|
||||
|
||||
### 2.0.3 (2022-12-11)
|
||||
* Fix: Fix typo. Thanks to [porg](https://github.com/joppuyo/disable-media-pages/issues/34) for noticing this!
|
||||
|
||||
### 2.0.2 (2022-10-31)
|
||||
* Fix: Test in WP 6.1
|
||||
|
||||
### 2.0.1 (2022-07-26)
|
||||
* Fix: small update to readme
|
||||
|
||||
### 2.0.0 (2022-07-25)
|
||||
* Breaking change: fixed how the plugin hooks into the `redirect_canonical` action. Because the plugin didn't return a value from this filter, this caused the plugin to change default WordPress behaviour (eg. https://example.com/index.php did not redirect to https://example.com/ like with a normal WordPress installation). In this version the filter returns the value which restores this WordPress default functionality. I'm making this a major release because it changes the plugin behaviour, so I recommend testing your site in a development or staging environment before updating your production site. For more information, see [this support thread](https://wordpress.org/support/topic/index-php-bug-breaks-wp-rocket/).
|
||||
|
||||
### 1.3.0 (2022-06-03)
|
||||
* Feature: Improved slug generation logic. Now the plugin checks the slug is in UUIDv4 format before generating a new slug. This prevents slugs from changing when saving a post.
|
||||
|
||||
### 1.2.3 (2022-05-25)
|
||||
* Fix: Test in WP 6.0
|
||||
|
||||
### 1.2.2 (2022-02-05)
|
||||
* Fix: Add missing localization string
|
||||
* Fix: Minor readme updates
|
||||
* Fix: Optimize acceptance test database size
|
||||
|
||||
### 1.2.1 (2022-01-28)
|
||||
* Fix: Fix typo
|
||||
|
||||
### 1.2.0 (2022-01-28)
|
||||
* Feature: Improved plugin code structure
|
||||
* Feature: Add donate link
|
||||
* Fix: Readme update
|
||||
* Fix: Fix issue where the plugin was unable to mangle slugs that contained UUID along with some other text
|
||||
|
||||
### 1.1.3 (2022-01-28)
|
||||
* Fix: Bump supported WordPress version to 5.9
|
||||
* Fix: Readme updates
|
||||
* Fix: Add automated test for slug restore functionality
|
||||
|
||||
### 1.1.2 (2022-01-19)
|
||||
* Fix: Remove debugging statements
|
||||
* Fix: Fix typo in readme
|
||||
|
||||
### 1.1.1 (2022-01-06)
|
||||
* Fix: Minor fix to the icon
|
||||
|
||||
### 1.1.0 (2022-01-06)
|
||||
* Feature: Add a tool for restoring media slugs back to the original ones
|
||||
* Feature: Add status page for the plugin which tells you if you have attachments without unique ids
|
||||
* Fix: Add menu for the plugin under Settings on the WordPress dashboard
|
||||
* Fix: Update plugin icon
|
||||
|
||||
### 1.0.8 (2021-07-24)
|
||||
* Fix: Bump supported WordPress version to 5.8
|
||||
* Fix: Update dependencies
|
||||
|
||||
### 1.0.7 (2021-06-14)
|
||||
* Fix: Update dependencies
|
||||
* Fix: Update FAQ
|
||||
* Fix: Tweak icon
|
||||
|
||||
### 1.0.6 (2021-06-09)
|
||||
* Fix: Fix issue with deployment
|
||||
|
||||
### 1.0.5 (2021-06-09)
|
||||
* Fix: Bump tested up to @ 5.7
|
||||
* Fix: Add acceptance tests
|
||||
|
||||
### 1.0.4 (2021-01-02)
|
||||
* Change: Add icon
|
||||
|
||||
### 1.0.3 (2020-12-31)
|
||||
* Fix: Change required WordPress version correctly to 5.0
|
||||
* Fix: Optimize autoloader
|
||||
|
||||
### 1.0.2 (2020-12-31)
|
||||
* Change: Release on WordPress plugin directory
|
||||
* Change: Changes to internal plugin structure
|
||||
* Fix: Make plugin translatable
|
||||
* Fix: Load JavaScript and CSS only on plugin page
|
||||
|
||||
### 1.0.1 (2020-12-19)
|
||||
* Fix: WordPress 5.6 compatibility, thanks [@tnottu](https://github.com/tnottu)
|
||||
|
||||
### 1.0.0 (2020-09-26)
|
||||
* Initial release
|
||||
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<div class="disable-media-pages">
|
||||
<div class="disable-media-pages-toolbar">
|
||||
<div class="disable-media-pages-toolbar__plugin-title">
|
||||
<h1>{{ i18n.plugin_title }}</h1>
|
||||
</div>
|
||||
<div class="disable-media-pages-toolbar__tabs">
|
||||
<button class="disable-media-pages-toolbar__tabs-tab"
|
||||
v-on:click="currentTab = 'status'"
|
||||
v-bind:class="{'disable-media-pages-toolbar__tabs-tab--active': currentTab === 'status'}"
|
||||
>
|
||||
{{ i18n.tab_status }}
|
||||
</button>
|
||||
<button class="disable-media-pages-toolbar__tabs-tab"
|
||||
v-on:click="currentTab = 'mangle'"
|
||||
v-bind:class="{'disable-media-pages-toolbar__tabs-tab--active': currentTab === 'mangle'}"
|
||||
>
|
||||
{{ i18n.tab_mangle }}
|
||||
</button>
|
||||
<button class="disable-media-pages-toolbar__tabs-tab"
|
||||
v-on:click="currentTab = 'restore'"
|
||||
v-bind:class="{'disable-media-pages-toolbar__tabs-tab--active': currentTab === 'restore'}"
|
||||
>
|
||||
{{ i18n.tab_restore }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="disable-media-pages-content">
|
||||
<Status v-if="currentTab === 'status'" />
|
||||
<Mangle v-if="currentTab === 'mangle'" />
|
||||
<Restore v-if="currentTab === 'restore'" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { sprintf } from 'sprintf-js';
|
||||
import Mangle from "./Mangle";
|
||||
import Restore from "./Restore";
|
||||
import Status from "./Status";
|
||||
export default {
|
||||
components: {Restore, Mangle, Status},
|
||||
data: function () {
|
||||
return {
|
||||
i18n: window.disable_media_pages.i18n,
|
||||
currentTab: 'status',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
methods: {
|
||||
sprintf(...args) {
|
||||
return sprintf(...args)
|
||||
},
|
||||
goToMangle() {
|
||||
this.currentTab = 'mangle';
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$root.$on('go-to-mangle', this.goToMangle);
|
||||
},
|
||||
beforeDestroy() {
|
||||
// https://readybytes.in/blog/how-to-fix-duplicate-event-listeners-in-vuejs
|
||||
this.$root.$off('go-to-mangle', this.goToMangle);
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,130 @@
|
||||
<template>
|
||||
<div>
|
||||
<ToolStart v-if="!fetchingAllPosts && !manglingPosts && !complete"
|
||||
v-bind:title="i18n.mangle_title"
|
||||
v-bind:subtitle="i18n.mangle_subtitle"
|
||||
v-bind:description="i18n.mangle_description"
|
||||
v-bind:button-text="i18n.mangle_button"
|
||||
v-bind:event-name="'fetch-all-posts'"
|
||||
/>
|
||||
<ToolFetch v-if="fetchingAllPosts"
|
||||
v-bind:title="i18n.mangle_title"
|
||||
v-bind:subtitle="i18n.mangle_progress_title"
|
||||
v-bind:description="i18n.mangle_progress_description"
|
||||
/>
|
||||
<ToolProcess v-if="manglingPosts"
|
||||
v-bind:title="i18n.mangle_title"
|
||||
v-bind:subtitle="i18n.mangle_progress_title"
|
||||
v-bind:description="i18n.mangle_progress_description"
|
||||
v-bind:progress="progress"
|
||||
v-bind:total="total"
|
||||
v-bind:processed="processed"
|
||||
/>
|
||||
<ToolResult
|
||||
v-if="complete"
|
||||
v-bind:title="i18n.mangle_title"
|
||||
v-bind:subtitle="i18n.mangle_success_title"
|
||||
v-bind:description="i18n.mangle_progress_description"
|
||||
v-bind:button-text="i18n.mangle_success_button"
|
||||
v-bind:total="total"
|
||||
v-bind:processed="processed"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
import {sprintf} from 'sprintf-js';
|
||||
import ToolStart from "./ToolStart";
|
||||
import ToolFetch from "./ToolFetch";
|
||||
import ToolProcess from "./ToolProcess";
|
||||
import ToolResult from "./ToolResult";
|
||||
|
||||
export default {
|
||||
components: {ToolResult, ToolProcess, ToolFetch, ToolStart},
|
||||
data: function () {
|
||||
return {
|
||||
fetchingAllPosts: false,
|
||||
manglingPosts: false,
|
||||
posts: [],
|
||||
total: 0,
|
||||
processed: 0,
|
||||
currentIndex: 0,
|
||||
complete: false,
|
||||
i18n: window.disable_media_pages.i18n,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
progress: function () {
|
||||
return Math.round(this.processed / this.total * 100)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$root.$on('fetch-all-posts', this.fetchAllPosts);
|
||||
this.$root.$on('start-over', this.startOver);
|
||||
},
|
||||
beforeDestroy() {
|
||||
// https://readybytes.in/blog/how-to-fix-duplicate-event-listeners-in-vuejs
|
||||
this.$root.$off('fetch-all-posts', this.fetchAllPosts);
|
||||
this.$root.$off('start-over', this.startOver);
|
||||
},
|
||||
methods: {
|
||||
sprintf(...args) {
|
||||
return sprintf(...args)
|
||||
},
|
||||
fetchAllPosts() {
|
||||
this.fetchingAllPosts = true;
|
||||
const options = {
|
||||
headers: {
|
||||
'X-WP-Nonce': window.disable_media_pages.token,
|
||||
}
|
||||
}
|
||||
axios.get(`${window.disable_media_pages.root}disable-media-pages/v1/get_all_attachments`, options).then(response => {
|
||||
console.log(response)
|
||||
this.posts = response.data.posts;
|
||||
this.total = response.data.total;
|
||||
|
||||
this.fetchingAllPosts = false;
|
||||
this.manglingPosts = true;
|
||||
if (this.total > 0) {
|
||||
this.processImage(this.posts[0])
|
||||
} else {
|
||||
// Nothing to process
|
||||
this.manglingPosts = false;
|
||||
this.complete = true;
|
||||
}
|
||||
})
|
||||
},
|
||||
processImage(id) {
|
||||
const options = {
|
||||
headers: {
|
||||
'X-WP-Nonce': window.disable_media_pages.token,
|
||||
}
|
||||
}
|
||||
axios.post(`${window.disable_media_pages.root}disable-media-pages/v1/process/${id}`, null, options).then(response => {
|
||||
|
||||
}).catch(response => {
|
||||
// TODO: handle error?
|
||||
}).finally(() => {
|
||||
this.processed = this.processed + 1;
|
||||
let newIndex = this.currentIndex + 1;
|
||||
if (this.posts[newIndex]) {
|
||||
this.currentIndex = newIndex;
|
||||
this.processImage(this.posts[newIndex]);
|
||||
} else {
|
||||
this.manglingPosts = false;
|
||||
this.complete = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
startOver() {
|
||||
this.complete = false;
|
||||
this.posts = [];
|
||||
this.currentIndex = 0;
|
||||
this.total = 0;
|
||||
this.processed = 0;
|
||||
this.currentIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<div>
|
||||
<ToolStart v-if="!fetchingAllPosts && !manglingPosts && !complete"
|
||||
v-bind:title="i18n.restore_title"
|
||||
v-bind:subtitle="i18n.restore_subtitle"
|
||||
v-bind:description="i18n.restore_description"
|
||||
v-bind:button-text="i18n.restore_button"
|
||||
v-bind:event-name="'fetch-all-posts-to-restore'"
|
||||
/>
|
||||
<ToolFetch v-if="fetchingAllPosts"
|
||||
v-bind:description="i18n.restore_progress_description"
|
||||
v-bind:title="i18n.restore_title"
|
||||
v-bind:subtitle="i18n.restore_progress_title"
|
||||
/>
|
||||
<ToolProcess
|
||||
v-if="manglingPosts"
|
||||
v-bind:progress="progress"
|
||||
v-bind:description="i18n.restore_progress_description"
|
||||
v-bind:title="i18n.restore_title"
|
||||
v-bind:subtitle="i18n.restore_progress_title"
|
||||
v-bind:total="total"
|
||||
v-bind:processed="processed"
|
||||
/>
|
||||
<ToolResult
|
||||
v-if="complete"
|
||||
v-bind:title="i18n.restore_title"
|
||||
v-bind:subtitle="i18n.restore_success_title"
|
||||
v-bind:description="i18n.restore_progress_description"
|
||||
v-bind:button-text="i18n.restore_success_button"
|
||||
v-bind:total="total"
|
||||
v-bind:processed="processed"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
import {sprintf} from 'sprintf-js';
|
||||
import ToolStart from "./ToolStart";
|
||||
import ToolProcess from "./ToolProcess";
|
||||
import ToolResult from "./ToolResult";
|
||||
import ToolFetch from "./ToolFetch";
|
||||
|
||||
export default {
|
||||
components: {ToolFetch, ToolResult, ToolProcess, ToolStart},
|
||||
data: function () {
|
||||
return {
|
||||
fetchingAllPosts: false,
|
||||
manglingPosts: false,
|
||||
posts: [],
|
||||
total: 0,
|
||||
processed: 0,
|
||||
currentIndex: 0,
|
||||
complete: false,
|
||||
i18n: window.disable_media_pages.i18n,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
progress: function () {
|
||||
return Math.round(this.processed / this.total * 100)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$root.$on('fetch-all-posts-to-restore', this.fetchAllPosts);
|
||||
this.$root.$on('start-over', this.startOver);
|
||||
},
|
||||
beforeDestroy() {
|
||||
// https://readybytes.in/blog/how-to-fix-duplicate-event-listeners-in-vuejs
|
||||
this.$root.$off('fetch-all-posts-to-restore', this.fetchAllPosts);
|
||||
this.$root.$off('start-over', this.startOver);
|
||||
},
|
||||
methods: {
|
||||
sprintf(...args) {
|
||||
return sprintf(...args)
|
||||
},
|
||||
fetchAllPosts() {
|
||||
this.fetchingAllPosts = true;
|
||||
const options = {
|
||||
headers: {
|
||||
'X-WP-Nonce': window.disable_media_pages.token,
|
||||
}
|
||||
}
|
||||
axios.get(`${window.disable_media_pages.root}disable-media-pages/v1/get-attachments-to-restore`, options).then(response => {
|
||||
console.log(response)
|
||||
this.posts = response.data.posts;
|
||||
this.total = response.data.total;
|
||||
|
||||
this.fetchingAllPosts = false;
|
||||
this.manglingPosts = true;
|
||||
if (this.total > 0) {
|
||||
this.processImage(this.posts[0])
|
||||
} else {
|
||||
// Nothing to process
|
||||
this.manglingPosts = false;
|
||||
this.complete = true;
|
||||
}
|
||||
})
|
||||
},
|
||||
processImage(id) {
|
||||
const options = {
|
||||
headers: {
|
||||
'X-WP-Nonce': window.disable_media_pages.token,
|
||||
}
|
||||
}
|
||||
axios.post(`${window.disable_media_pages.root}disable-media-pages/v1/restore/${id}`, null, options).then(response => {
|
||||
|
||||
}).catch(response => {
|
||||
// TODO: handle error?
|
||||
}).finally(() => {
|
||||
this.processed = this.processed + 1;
|
||||
let newIndex = this.currentIndex + 1;
|
||||
if (this.posts[newIndex]) {
|
||||
this.currentIndex = newIndex;
|
||||
this.processImage(this.posts[newIndex]);
|
||||
} else {
|
||||
this.manglingPosts = false;
|
||||
this.complete = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
startOver() {
|
||||
this.complete = false;
|
||||
this.posts = [];
|
||||
this.currentIndex = 0;
|
||||
this.total = 0;
|
||||
this.processed = 0;
|
||||
this.currentIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="disable-media-pages-tool__title-container">
|
||||
<h2 class="disable-media-pages-tool__title">{{ i18n.status_title }}</h2>
|
||||
</div>
|
||||
<div class="disable-media-pages-tool__card">
|
||||
<div class="disable-media-pages-health" v-if="loading">
|
||||
<div class="disable-media-pages-health__icon"
|
||||
v-html="require('!raw-loader!./icons/icon-loading.svg')"
|
||||
>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<div class="disable-media-pages-health__title">
|
||||
{{ i18n.status_loading_title }}
|
||||
</div>
|
||||
<div class="disable-media-pages-health__description">
|
||||
{{ i18n.status_loading_description }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="disable-media-pages-health" v-if="!loading && this.nonUniqueCount === 0">
|
||||
<div class="disable-media-pages-health__icon" v-html="require('!raw-loader!./icons/icon-ok.svg')"></div>
|
||||
<div>
|
||||
<div class="disable-media-pages-health__title">
|
||||
{{ i18n.status_no_issues_title }}
|
||||
</div>
|
||||
<div class="disable-media-pages-health__description">
|
||||
{{ i18n.status_no_issues_description }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="disable-media-pages-health" v-if="!loading && this.nonUniqueCount > 0">
|
||||
<div class="disable-media-pages-health__icon" v-html="require('!raw-loader!./icons/icon-warning.svg')"></div>
|
||||
<div>
|
||||
<div class="disable-media-pages-health__title">
|
||||
<div>{{ i18n.status_some_issues_title }}</div>
|
||||
</div>
|
||||
<div class="disable-media-pages-health__description disable-media-pages-health__description--has-button">
|
||||
<p><span v-if="nonUniqueCount === 1">{{sprintf(i18n.status_non_unique_count_singular, nonUniqueCount)}}</span>
|
||||
<span v-else>{{sprintf(i18n.status_non_unique_count_plural, nonUniqueCount)}}</span>
|
||||
<span>{{i18n.status_non_unique_description}}</span></p>
|
||||
</div>
|
||||
<div class="disable-media-pages-health__button">
|
||||
<button class="button button-primary" v-on:click="goToMangle">{{i18n.status_open_tool_button}}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
import {sprintf} from 'sprintf-js';
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
data: function () {
|
||||
return {
|
||||
nonUniqueCount: null,
|
||||
loading: false,
|
||||
error: false,
|
||||
i18n: window.disable_media_pages.i18n,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
},
|
||||
mounted() {
|
||||
this.fetchStatus();
|
||||
},
|
||||
beforeDestroy() {
|
||||
},
|
||||
methods: {
|
||||
sprintf(...args) {
|
||||
return sprintf(...args)
|
||||
},
|
||||
fetchStatus() {
|
||||
const options = {
|
||||
headers: {
|
||||
'X-WP-Nonce': window.disable_media_pages.token,
|
||||
}
|
||||
}
|
||||
this.loading = true;
|
||||
axios.get(`${window.disable_media_pages.root}disable-media-pages/v1/get_status`, options).then(response => {
|
||||
console.log(response)
|
||||
this.loading = false;
|
||||
this.nonUniqueCount = response.data.non_unique_count;
|
||||
})
|
||||
},
|
||||
goToMangle() {
|
||||
this.$root.$emit('go-to-mangle');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,44 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="disable-media-pages-tool__title-container">
|
||||
<h2 class="disable-media-pages-tool__title">{{ title }}</h2>
|
||||
</div>
|
||||
<div class="disable-media-pages-tool__card">
|
||||
<div class="disable-media-pages-tool__subtitle">
|
||||
{{ subtitle }}
|
||||
</div>
|
||||
<div class="disable-media-pages-tool">
|
||||
|
||||
<div class="disable-media-pages-tool__progress-title">
|
||||
{{ sprintf(description, 0) }}
|
||||
</div>
|
||||
|
||||
<div class="disable-media-pages__progress-bar disable-media-pages__progress-bar--indeterminate"></div>
|
||||
|
||||
<div class="disable-media-pages-tool__progress-subtitle">
|
||||
{{ sprintf(i18n.tool_progress_subtitle, 0, '-') }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {sprintf} from 'sprintf-js';
|
||||
|
||||
export default {
|
||||
props: ['title', 'description', 'subtitle'],
|
||||
data: function () {
|
||||
return {
|
||||
i18n: window.disable_media_pages.i18n,
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
sprintf(...args) {
|
||||
return sprintf(...args)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="disable-media-pages-tool__title-container">
|
||||
<h2 class="disable-media-pages-tool__title">{{ title }}</h2>
|
||||
</div>
|
||||
<div class="disable-media-pages-tool__card">
|
||||
<div class="disable-media-pages-tool__subtitle">
|
||||
{{ subtitle }}
|
||||
</div>
|
||||
|
||||
<div class="disable-media-pages-tool__progress-title">
|
||||
{{ sprintf(i18n.mangle_progress_description, progress) }}
|
||||
</div>
|
||||
|
||||
<div class="disable-media-pages__progress-bar">
|
||||
<div class="disable-media-pages__progress-bar-inner" v-bind:style="{
|
||||
width: `${progress}%`
|
||||
}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="disable-media-pages-tool__progress-subtitle">
|
||||
{{ sprintf(i18n.tool_progress_subtitle, processed, total) }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {sprintf} from 'sprintf-js';
|
||||
|
||||
export default {
|
||||
props: ['title', 'description', 'progress', 'subtitle', 'processed', 'total'],
|
||||
data: function () {
|
||||
return {
|
||||
i18n: window.disable_media_pages.i18n,
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
sprintf(...args) {
|
||||
return sprintf(...args)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="disable-media-pages-tool__title-container">
|
||||
<h2 class="disable-media-pages-tool__title">{{ title }}</h2>
|
||||
</div>
|
||||
<div class="disable-media-pages-tool__card">
|
||||
|
||||
<div class="disable-media-pages-tool__subtitle">{{ subtitle }}</div>
|
||||
|
||||
<div class="disable-media-pages-tool__progress-title">
|
||||
{{ sprintf(description, 100) }}
|
||||
</div>
|
||||
|
||||
<div class="disable-media-pages__progress-bar">
|
||||
<div class="disable-media-pages__progress-bar-inner" v-bind:style="{
|
||||
width: '100%'
|
||||
}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="disable-media-pages-tool__progress-subtitle disable-media-pages-tool__progress-subtitle--has-button">
|
||||
{{ sprintf(i18n.tool_progress_subtitle, processed, total) }}
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<button class="button button-primary" v-on:click="startOver">{{ buttonText }}</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {sprintf} from 'sprintf-js';
|
||||
import Mangle from "./Mangle";
|
||||
|
||||
export default {
|
||||
props: ['title', 'description', 'buttonText', 'subtitle', 'total', 'processed'],
|
||||
components: {Mangle},
|
||||
data: function () {
|
||||
return {
|
||||
i18n: window.disable_media_pages.i18n,
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
sprintf(...args) {
|
||||
return sprintf(...args)
|
||||
},
|
||||
startOver() {
|
||||
this.$root.$emit('start-over');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="disable-media-pages-tool__title-container">
|
||||
<h2 class="disable-media-pages-tool__title">{{ title }}</h2>
|
||||
</div>
|
||||
<div class="disable-media-pages-tool__card">
|
||||
<div class="disable-media-pages-tool__subtitle">
|
||||
{{subtitle}}
|
||||
</div>
|
||||
<div class="disable-media-pages-tool__description">
|
||||
<p>
|
||||
{{ description }}
|
||||
</p>
|
||||
</div>
|
||||
<p>
|
||||
<button class="button button-primary" v-on:click="sendEvent">{{ buttonText }}</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {sprintf} from 'sprintf-js';
|
||||
|
||||
export default {
|
||||
props: ['title', 'description', 'button-text', 'event-name', 'subtitle'],
|
||||
data: function () {
|
||||
return {
|
||||
i18n: window.disable_media_pages.i18n,
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
sprintf(...args) {
|
||||
return sprintf(...args)
|
||||
},
|
||||
sendEvent() {
|
||||
this.$root.$emit(this.eventName);
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1 @@
|
||||
<svg width="42" height="42" viewBox="0 0 42 42" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M42 21a21 21 0 1 1-42 0 21 21 0 0 1 42 0Z" fill-opacity=".33" fill="#8D8D8D" fill-rule="nonzero"/><path d="M5 5h32v32H5z"/><path d="M21.5 12.6v3.95l5.25-5.28L21.5 6v3.95a10.52 10.52 0 0 0-8.87 16.17l1.91-1.93a7.9 7.9 0 0 1 6.96-11.6Zm8.87 2.28-1.91 1.93a7.9 7.9 0 0 1-6.96 11.6v-3.96l-5.25 5.28L21.5 35v-3.95a10.52 10.52 0 0 0 8.87-16.17Z" fill="#8D8D8D" fill-rule="nonzero"/></g></svg>
|
||||
|
After Width: | Height: | Size: 513 B |
@@ -0,0 +1 @@
|
||||
<svg width="42" height="42" viewBox="0 0 42 42" xmlns="http://www.w3.org/2000/svg"><g fill="#4CAF50" fill-rule="evenodd"><path d="M42 21a21 21 0 1 1-42 0 21 21 0 0 1 42 0Z" opacity=".33" fill-rule="nonzero"/><path d="m19.23 29.74 13.06-13.07a1 1 0 0 0 0-1.41l-1.99-2a1 1 0 0 0-1.41 0l-9.66 9.66a1 1 0 0 1-1.42 0l-3.7-3.7a1 1 0 0 0-1.41 0l-2 2a1 1 0 0 0 0 1.41l7.11 7.1a1 1 0 0 0 1.42 0Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 399 B |
@@ -0,0 +1 @@
|
||||
<svg width="42" height="42" viewBox="0 0 42 42" xmlns="http://www.w3.org/2000/svg"><g fill="#F44336" fill-rule="evenodd"><path d="M21 0a21 21 0 1 0 0 42 21 21 0 0 0 0-42Z" opacity=".33" fill-rule="nonzero"/><circle cx="21" cy="30" r="3"/><path d="M22.07 24h-2.14a1 1 0 0 1-1-.93l-.85-12a1 1 0 0 1 1-1.07h3.85a1 1 0 0 1 1 1.07l-.86 12a1 1 0 0 1-1 .93Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 363 B |
@@ -0,0 +1,14 @@
|
||||
import Vue from 'vue';
|
||||
import App from "./App";
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
let element = document.getElementById('disable-media-pages');
|
||||
if (element) {
|
||||
new Vue({
|
||||
el: element,
|
||||
components: {
|
||||
'disable-media-pages': App,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,253 @@
|
||||
.settings_page_disable-media-pages #wpbody #wpbody-content .notice {
|
||||
margin: 0;
|
||||
margin-top: 20px;
|
||||
margin-right: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.disable-media-pages {
|
||||
|
||||
all: initial;
|
||||
|
||||
@import '~minireset.css/minireset.sass';
|
||||
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
|
||||
font-size: 14px;
|
||||
|
||||
.disable-media-pages-toolbar {
|
||||
margin-left: -20px;
|
||||
padding-left: 20px;
|
||||
background: #fff;
|
||||
border-bottom: 1px solid #ccd0d4;
|
||||
height: 42px;
|
||||
display: flex;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.disable-media-pages-toolbar__plugin-title {
|
||||
height: 42px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 20px;
|
||||
font-size: 14px;
|
||||
white-space: nowrap;
|
||||
h1 {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.disable-media-pages-toolbar__tabs {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.disable-media-pages-toolbar__tabs-tab {
|
||||
all: inherit;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
border-bottom: 3px solid transparent;
|
||||
border-top: 2px solid transparent;
|
||||
font-size: 14px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.disable-media-pages-toolbar__tabs-tab--active {
|
||||
border-bottom: 3px solid #007CBA;
|
||||
}
|
||||
|
||||
.disable-media-pages-content {
|
||||
margin-left: -20px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.disable-media-pages-tool__title-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.disable-media-pages-tool__title {
|
||||
font-size: 24px;
|
||||
line-height: 1.5;
|
||||
&::before {
|
||||
content: "";
|
||||
margin-bottom: -0.4055em;
|
||||
display: table;
|
||||
}
|
||||
&::after {
|
||||
content: "";
|
||||
margin-top: -0.3805em;
|
||||
display: table;
|
||||
}
|
||||
}
|
||||
|
||||
.disable-media-pages-tool__subtitle {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20px;
|
||||
line-height: 1.5;
|
||||
&::before {
|
||||
content: "";
|
||||
margin-bottom: -0.4055em;
|
||||
display: table;
|
||||
}
|
||||
&::after {
|
||||
content: "";
|
||||
margin-top: -0.3805em;
|
||||
display: table;
|
||||
}
|
||||
}
|
||||
|
||||
.disable-media-pages-tool__description {
|
||||
max-width: 800px;
|
||||
p {
|
||||
line-height: 1.5;
|
||||
&::before {
|
||||
content: "";
|
||||
margin-bottom: -0.4055em;
|
||||
display: table;
|
||||
}
|
||||
&::after {
|
||||
content: "";
|
||||
margin-top: -0.3805em;
|
||||
display: table;
|
||||
}
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.disable-media-pages-health {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.disable-media-pages-health__icon {
|
||||
height: 42px;
|
||||
width: 42px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.disable-media-pages-health__title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20px;
|
||||
line-height: 1.5;
|
||||
&::before {
|
||||
content: "";
|
||||
margin-bottom: -0.4055em;
|
||||
display: table;
|
||||
}
|
||||
&::after {
|
||||
content: "";
|
||||
margin-top: -0.3805em;
|
||||
display: table;
|
||||
}
|
||||
}
|
||||
|
||||
.disable-media-pages-health__description {
|
||||
max-width: 800px;
|
||||
p {
|
||||
line-height: 1.5;
|
||||
&::before {
|
||||
content: "";
|
||||
margin-bottom: -0.4055em;
|
||||
display: table;
|
||||
}
|
||||
&::after {
|
||||
content: "";
|
||||
margin-top: -0.3805em;
|
||||
display: table;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.disable-media-pages-health__description--has-button {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.disable-media-pages-tool__progress-title {
|
||||
margin-bottom: 20px;
|
||||
line-height: 1.5;
|
||||
&::before {
|
||||
content: "";
|
||||
margin-bottom: -0.4055em;
|
||||
display: table;
|
||||
}
|
||||
&::after {
|
||||
content: "";
|
||||
margin-top: -0.3805em;
|
||||
display: table;
|
||||
}
|
||||
}
|
||||
|
||||
.disable-media-pages-tool__progress-subtitle {
|
||||
font-size: 13px;
|
||||
|
||||
line-height: 1.5;
|
||||
opacity: 0.5;
|
||||
&::before {
|
||||
content: "";
|
||||
margin-bottom: -0.4055em;
|
||||
display: table;
|
||||
}
|
||||
&::after {
|
||||
content: "";
|
||||
margin-top: -0.3805em;
|
||||
display: table;
|
||||
}
|
||||
}
|
||||
|
||||
.disable-media-pages-tool__progress-subtitle--has-button {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.disable-media-pages-tool__card {
|
||||
background-color: white;
|
||||
border-radius: 3px;
|
||||
border: 1px solid #D9D9D9;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.disable-media-pages__progress-bar {
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
background-color: #e9ecef;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.disable-media-pages__progress-bar-inner {
|
||||
height: 6px;
|
||||
background-color: #007cba;
|
||||
}
|
||||
.disable-media-pages__progress-bar--indeterminate {
|
||||
background-color: #007cba;
|
||||
background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%,
|
||||
transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%,
|
||||
rgba(255, 255, 255, 0.15) 75%,
|
||||
transparent 75%,
|
||||
transparent);
|
||||
-webkit-animation: disable-media-pages-progress-bar-stripes 1s linear infinite;
|
||||
animation: disable-media-pages-progress-bar-stripes 1s linear infinite;
|
||||
background-size: 1rem 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes disable-media-pages-progress-bar-stripes {
|
||||
from {
|
||||
background-position: 20px 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes disable-media-pages-progress-bar-stripes {
|
||||
from {
|
||||
background-position: 16px 0;
|
||||
}
|
||||
to {
|
||||
background-position: 0 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, $err);
|
||||
} elseif (!headers_sent()) {
|
||||
echo $err;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException($err);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit5300e49fe86bd50f95b88ce4db036dcb::getLoader();
|
||||
@@ -0,0 +1,579 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/** @var \Closure(string):void */
|
||||
private static $includeFile;
|
||||
|
||||
/** @var string|null */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* List of PSR-0 prefixes
|
||||
*
|
||||
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
||||
*
|
||||
* @var array<string, array<string, list<string>>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
/** @var bool */
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
/** @var bool */
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var string|null */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var array<string, self>
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param string|null $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
self::initializeIncludeClosure();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> Array of classname => path
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $classMap Class to filename map
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param list<string>|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
$paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
$paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
$paths = (array) $paths;
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
$paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
$paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param list<string>|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param list<string>|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
|
||||
if (null === $this->vendorDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($prepend) {
|
||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||
} else {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
|
||||
if (null !== $this->vendorDir) {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return true|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
$includeFile = self::$includeFile;
|
||||
$includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
||||
*
|
||||
* @return array<string, self>
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
return self::$registeredLoaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $ext
|
||||
* @return string|false
|
||||
*/
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private static function initializeIncludeClosure()
|
||||
{
|
||||
if (self::$includeFile !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
self::$includeFile = \Closure::bind(static function($file) {
|
||||
include $file;
|
||||
}, null, null);
|
||||
}
|
||||
}
|
||||
+396
@@ -0,0 +1,396 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Composer\Semver\VersionParser;
|
||||
|
||||
/**
|
||||
* This class is copied in every Composer installed project and available to all
|
||||
*
|
||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||
*
|
||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class InstalledVersions
|
||||
{
|
||||
/**
|
||||
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
|
||||
* @internal
|
||||
*/
|
||||
private static $selfDir = null;
|
||||
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private static $installedIsLocalDir;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
private static $canGetVendors;
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
private static $installedByVendor = array();
|
||||
|
||||
/**
|
||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
$packages = array();
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
$packages[] = array_keys($installed['versions']);
|
||||
}
|
||||
|
||||
if (1 === \count($packages)) {
|
||||
return $packages[0];
|
||||
}
|
||||
|
||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all package names with a specific type e.g. 'library'
|
||||
*
|
||||
* @param string $type
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackagesByType($type)
|
||||
{
|
||||
$packagesByType = array();
|
||||
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
foreach ($installed['versions'] as $name => $package) {
|
||||
if (isset($package['type']) && $package['type'] === $type) {
|
||||
$packagesByType[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $packagesByType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package is installed
|
||||
*
|
||||
* This also returns true if the package name is provided or replaced by another package
|
||||
*
|
||||
* @param string $packageName
|
||||
* @param bool $includeDevRequirements
|
||||
* @return bool
|
||||
*/
|
||||
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package satisfies a version constraint
|
||||
*
|
||||
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||
*
|
||||
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||
*
|
||||
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||
* @param string $packageName
|
||||
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||
* @return bool
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints((string) $constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||
*
|
||||
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||
* whether a given version of a package is installed, and not just whether it exists
|
||||
*
|
||||
* @param string $packageName
|
||||
* @return string Version constraint usable with composer/semver
|
||||
*/
|
||||
public static function getVersionRanges($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ranges = array();
|
||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||
}
|
||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||
}
|
||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||
}
|
||||
|
||||
return implode(' || ', $ranges);
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getPrettyVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||
*/
|
||||
public static function getReference($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['reference'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||
*/
|
||||
public static function getInstallPath($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
||||
*/
|
||||
public static function getRootPackage()
|
||||
{
|
||||
$installed = self::getInstalled();
|
||||
|
||||
return $installed[0]['root'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw installed.php data for custom implementations
|
||||
*
|
||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||
* @return array[]
|
||||
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
||||
*/
|
||||
public static function getRawData()
|
||||
{
|
||||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = include __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
return self::$installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||
*
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
public static function getAllRawData()
|
||||
{
|
||||
return self::getInstalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets you reload the static array from another file
|
||||
*
|
||||
* This is only useful for complex integrations in which a project needs to use
|
||||
* this class but then also needs to execute another project's autoloader in process,
|
||||
* and wants to ensure both projects have access to their version of installed.php.
|
||||
*
|
||||
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||
* the data it needs from this class, then call reload() with
|
||||
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||
* the project in which it runs can then also use this class safely, without
|
||||
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||
*
|
||||
* @param array[] $data A vendor/composer/installed.php data set
|
||||
* @return void
|
||||
*
|
||||
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
||||
*/
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
|
||||
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
|
||||
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
|
||||
// so we have to assume it does not, and that may result in duplicate data being returned when listing
|
||||
// all installed packages for example
|
||||
self::$installedIsLocalDir = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private static function getSelfDir()
|
||||
{
|
||||
if (self::$selfDir === null) {
|
||||
self::$selfDir = strtr(__DIR__, '\\', '/');
|
||||
}
|
||||
|
||||
return self::$selfDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
||||
*/
|
||||
private static function getInstalled()
|
||||
{
|
||||
if (null === self::$canGetVendors) {
|
||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||
}
|
||||
|
||||
$installed = array();
|
||||
$copiedLocalDir = false;
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
$selfDir = self::getSelfDir();
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
$vendorDir = strtr($vendorDir, '\\', '/');
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require $vendorDir.'/composer/installed.php';
|
||||
self::$installedByVendor[$vendorDir] = $required;
|
||||
$installed[] = $required;
|
||||
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
|
||||
self::$installed = $required;
|
||||
self::$installedIsLocalDir = true;
|
||||
}
|
||||
}
|
||||
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
|
||||
$copiedLocalDir = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
||||
$required = require __DIR__ . '/installed.php';
|
||||
self::$installed = $required;
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$installed !== array() && !$copiedLocalDir) {
|
||||
$installed[] = self::$installed;
|
||||
}
|
||||
|
||||
return $installed;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\Admin' => $baseDir . '/lib/Modules/Admin.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\CLI' => $baseDir . '/lib/Modules/CLI.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\Mangle' => $baseDir . '/lib/Modules/Mangle.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\REST' => $baseDir . '/lib/Modules/REST.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\Restore' => $baseDir . '/lib/Modules/Restore.php',
|
||||
'NPX\\DisableMediaPages\\Plugin' => $baseDir . '/lib/Plugin.php',
|
||||
);
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'NPX\\DisableMediaPages\\' => array($baseDir . '/lib'),
|
||||
);
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit5300e49fe86bd50f95b88ce4db036dcb
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5300e49fe86bd50f95b88ce4db036dcb', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5300e49fe86bd50f95b88ce4db036dcb', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit5300e49fe86bd50f95b88ce4db036dcb::getInitializer($loader));
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit5300e49fe86bd50f95b88ce4db036dcb
|
||||
{
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'N' =>
|
||||
array (
|
||||
'NPX\\DisableMediaPages\\' => 22,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'NPX\\DisableMediaPages\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/../..' . '/lib',
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\Admin' => __DIR__ . '/../..' . '/lib/Modules/Admin.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\CLI' => __DIR__ . '/../..' . '/lib/Modules/CLI.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\Mangle' => __DIR__ . '/../..' . '/lib/Modules/Mangle.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\REST' => __DIR__ . '/../..' . '/lib/Modules/REST.php',
|
||||
'NPX\\DisableMediaPages\\Modules\\Restore' => __DIR__ . '/../..' . '/lib/Modules/Restore.php',
|
||||
'NPX\\DisableMediaPages\\Plugin' => __DIR__ . '/../..' . '/lib/Plugin.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit5300e49fe86bd50f95b88ce4db036dcb::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit5300e49fe86bd50f95b88ce4db036dcb::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit5300e49fe86bd50f95b88ce4db036dcb::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"packages": [],
|
||||
"dev": false,
|
||||
"dev-package-names": []
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => 'joppuyo/disable-media-pages',
|
||||
'pretty_version' => 'v4.0.3',
|
||||
'version' => '4.0.3.0',
|
||||
'reference' => '768596db58770f729cc4bf07b55374200a0ec270',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev' => false,
|
||||
),
|
||||
'versions' => array(
|
||||
'joppuyo/disable-media-pages' => array(
|
||||
'pretty_version' => 'v4.0.3',
|
||||
'version' => '4.0.3.0',
|
||||
'reference' => '768596db58770f729cc4bf07b55374200a0ec270',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user