v1.0.0
This commit is contained in:
parent
8caa140991
commit
5cdf7f48e5
29 changed files with 6526 additions and 0 deletions
674
LICENSE
Normal file
674
LICENSE
Normal file
|
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. 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
|
||||||
|
them 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 prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. 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.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey 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;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If 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 convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU 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 that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
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.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
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
|
||||||
|
state 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 a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <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 3 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, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program 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, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU 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. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
51
changelog.txt
Normal file
51
changelog.txt
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.0.0 =
|
||||||
|
|
||||||
|
_Release date: 2026-02-27_
|
||||||
|
|
||||||
|
**Highlights**
|
||||||
|
|
||||||
|
* First production release. Complete six-step migration wizard from MultilingualPress 2 to MultilingualPress 5.
|
||||||
|
|
||||||
|
**Added**
|
||||||
|
|
||||||
|
* Table preparation step: renames MLP2 tables (`{prefix}mlp_*` → `{prefix}mlp2bak_*`) so MLP5 can activate cleanly. Fully reversible.
|
||||||
|
* Wizard Step 1 — Preflight Checks: verifies backup tables exist and MLP5 is network-active before allowing migration to proceed.
|
||||||
|
* Wizard Step 2 — Analysis: scans MLP2 backup tables, counts records, detects orphaned sites/posts/terms and duplicate rows, validates MLP5 schema compatibility.
|
||||||
|
* Wizard Step 3 — Site Relations: migrates all site connections from MLP2 backup tables to MLP5. Idempotent (safe to re-run).
|
||||||
|
* Wizard Step 4 — Content Relations: migrates post and term relationships in AJAX batches with a real-time progress bar, pause/resume support, and orphan filtering.
|
||||||
|
* Wizard Step 5 — Verification: compares expected totals with log counts by category; offers full CSV export of the migration log.
|
||||||
|
* Wizard Step 6 — Cleanup (optional): network-deactivates MLP2, drops backup tables, and removes MLP2 sitemeta entries. Requires explicit `DELETE` confirmation.
|
||||||
|
* Migration log table (`{prefix}mlp_migrator_log`) with structured entries (type, context, source/target IDs, message).
|
||||||
|
* MLP5 schema detector: identifies `mlp_site_relations`, `mlp_content_relations`, and `mlp_relationships` tables and validates column presence.
|
||||||
|
* MLP2 detector: locates MLP2 plugin file, reads version, detects backup tables. Supports `mlp_relationships`, `mlp_content_relations`, and `multilingual_linked` as content relations table candidates.
|
||||||
|
* Auto-update integration via `Robotstxt_Updater` (Gitea-based update server).
|
||||||
|
* Spanish (es_ES) translation.
|
||||||
|
|
||||||
|
**Compatibility**
|
||||||
|
|
||||||
|
* WordPress: 6.7 – 6.9
|
||||||
|
* PHP: 8.2 – 8.5
|
||||||
|
|
||||||
|
= 0.1.0 =
|
||||||
|
|
||||||
|
_Release date: 2026-02-27_
|
||||||
|
|
||||||
|
**Highlights**
|
||||||
|
|
||||||
|
* Initial plugin scaffold.
|
||||||
|
|
||||||
|
**Added**
|
||||||
|
|
||||||
|
* Main plugin file with required WordPress headers and Multisite-only guard.
|
||||||
|
* Plugin bootstrap class with activation, deactivation, and i18n hooks.
|
||||||
|
* Uninstall handler stub.
|
||||||
|
* PHPCS configuration targeting WordPress Coding Standards and PHPCompatibilityWP for PHP 8.2–8.5.
|
||||||
|
* Deploy script to generate a distributable ZIP.
|
||||||
|
* Auto-update integration via Robotstxt_Updater.
|
||||||
|
|
||||||
|
**Compatibility**
|
||||||
|
|
||||||
|
* WordPress: 6.7 – 6.9
|
||||||
|
* PHP: 8.2 – 8.5
|
||||||
583
includes/class-robotstxt-mlp2-mlp5-admin-page.php
Normal file
583
includes/class-robotstxt-mlp2-mlp5-admin-page.php
Normal file
|
|
@ -0,0 +1,583 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Network Admin page.
|
||||||
|
*
|
||||||
|
* Registers the plugin settings page under Network Admin > Settings and
|
||||||
|
* orchestrates the full migration wizard. Handles all POST actions for:
|
||||||
|
* - Table rename / restore (preparation)
|
||||||
|
* - Wizard step navigation (steps 1–6)
|
||||||
|
* - Wizard reset
|
||||||
|
* - CSV log export
|
||||||
|
*
|
||||||
|
* Network Admin only. Uses exclusively:
|
||||||
|
* network_admin_menu, network_admin_init.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Admin_Page
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Admin_Page {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menu slug for the plugin settings page.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const MENU_SLUG = 'robotstxt-mlp2-mlp5';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required capability to access the plugin page.
|
||||||
|
*
|
||||||
|
* The manage_network capability is the standard for Network Admin settings.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const CAPABILITY = 'manage_network';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the Network Admin page and all POST/GET handlers.
|
||||||
|
*/
|
||||||
|
public static function init(): void {
|
||||||
|
add_action( 'network_admin_menu', array( static::class, 'register_menu' ) );
|
||||||
|
add_action( 'admin_post_mlp_migrator_rename_tables', array( static::class, 'handle_rename_action' ) );
|
||||||
|
add_action( 'admin_post_mlp_migrator_restore_tables', array( static::class, 'handle_restore_action' ) );
|
||||||
|
add_action( 'admin_post_mlp_migrator_step', array( static::class, 'handle_step_actions' ) );
|
||||||
|
add_action( 'admin_post_mlp_migrator_reset_wizard', array( static::class, 'handle_reset_action' ) );
|
||||||
|
add_action( 'admin_post_mlp_migrator_export_log', array( 'Robotstxt_Mlp2_Mlp5_Step_Verification', 'maybe_export_csv' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the settings page under Network Admin > Settings.
|
||||||
|
*/
|
||||||
|
public static function register_menu(): void {
|
||||||
|
add_submenu_page(
|
||||||
|
'settings.php',
|
||||||
|
__( 'MLP2 to MLP5 Migrator', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
__( 'MLP Migrator', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
self::CAPABILITY,
|
||||||
|
self::MENU_SLUG,
|
||||||
|
array( static::class, 'render' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the URL to this plugin's Network Admin page.
|
||||||
|
*
|
||||||
|
* @param array $extra Optional extra query args.
|
||||||
|
* @return string Absolute URL.
|
||||||
|
*/
|
||||||
|
public static function page_url( array $extra = array() ): string {
|
||||||
|
$args = array_merge( array( 'page' => self::MENU_SLUG ), $extra );
|
||||||
|
return network_admin_url( 'settings.php?' . http_build_query( $args ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// POST handlers (preparation)
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the "Rename MLP2 tables" POST action.
|
||||||
|
*/
|
||||||
|
public static function handle_rename_action(): void {
|
||||||
|
check_admin_referer( 'mlp_migrator_rename', 'mlp_migrator_nonce' );
|
||||||
|
if ( ! current_user_can( self::CAPABILITY ) ) {
|
||||||
|
wp_die( esc_html__( 'You do not have permission to perform this action.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
$result = Robotstxt_Mlp2_Mlp5_Table_Preparer::rename_to_backup();
|
||||||
|
$args = array( 'renamed' => count( $result['renamed'] ) );
|
||||||
|
if ( ! empty( $result['errors'] ) ) {
|
||||||
|
$args['rename_errors'] = count( $result['errors'] );
|
||||||
|
}
|
||||||
|
wp_safe_redirect( self::page_url( $args ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the "Restore original table names" POST action.
|
||||||
|
*/
|
||||||
|
public static function handle_restore_action(): void {
|
||||||
|
check_admin_referer( 'mlp_migrator_restore', 'mlp_migrator_nonce' );
|
||||||
|
if ( ! current_user_can( self::CAPABILITY ) ) {
|
||||||
|
wp_die( esc_html__( 'You do not have permission to perform this action.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
$result = Robotstxt_Mlp2_Mlp5_Table_Preparer::restore_from_backup();
|
||||||
|
$args = array( 'restored' => count( $result['restored'] ) );
|
||||||
|
if ( ! empty( $result['errors'] ) ) {
|
||||||
|
$args['restore_errors'] = count( $result['errors'] );
|
||||||
|
}
|
||||||
|
wp_safe_redirect( self::page_url( $args ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// POST handlers (wizard steps)
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Route all wizard step POST actions.
|
||||||
|
*/
|
||||||
|
public static function handle_step_actions(): void {
|
||||||
|
// phpcs:ignore WordPress.Security.NonceVerification.Missing
|
||||||
|
if ( ! isset( $_POST['mlp_migrator_step_action'] ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( ! current_user_can( self::CAPABILITY ) ) {
|
||||||
|
wp_die( esc_html__( 'You do not have permission to perform this action.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||||
|
$action = sanitize_key( wp_unslash( $_POST['mlp_migrator_step_action'] ) );
|
||||||
|
|
||||||
|
switch ( $action ) {
|
||||||
|
case '1':
|
||||||
|
self::handle_step_1_next();
|
||||||
|
break;
|
||||||
|
case '2_run':
|
||||||
|
self::handle_step_2_run();
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
self::handle_step_next( 2, 3, 'mlp_migrator_step_2' );
|
||||||
|
break;
|
||||||
|
case '3_run':
|
||||||
|
self::handle_step_3_run();
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
self::handle_step_next( 3, 4, 'mlp_migrator_step_3' );
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
self::handle_step_next( 4, 5, 'mlp_migrator_step_4' );
|
||||||
|
break;
|
||||||
|
case '5':
|
||||||
|
self::handle_step_next( 5, 6, 'mlp_migrator_step_5' );
|
||||||
|
break;
|
||||||
|
case '6_cleanup':
|
||||||
|
self::handle_step_6_cleanup();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle "Next" from Step 1 (Preflight).
|
||||||
|
*/
|
||||||
|
private static function handle_step_1_next(): void {
|
||||||
|
check_admin_referer( 'mlp_migrator_step_1', 'mlp_migrator_nonce' );
|
||||||
|
$checks = Robotstxt_Mlp2_Mlp5_Step_Preflight::run();
|
||||||
|
if ( $checks['can_proceed'] ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Wizard_State::mark_step_complete( 1 );
|
||||||
|
Robotstxt_Mlp2_Mlp5_Wizard_State::set_step( 2 );
|
||||||
|
}
|
||||||
|
wp_safe_redirect( self::page_url() );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle "Run Analysis" from Step 2.
|
||||||
|
*/
|
||||||
|
private static function handle_step_2_run(): void {
|
||||||
|
check_admin_referer( 'mlp_migrator_analysis', 'mlp_migrator_nonce' );
|
||||||
|
$result = Robotstxt_Mlp2_Mlp5_Step_Analysis::run();
|
||||||
|
Robotstxt_Mlp2_Mlp5_Wizard_State::set_step_data( 2, $result );
|
||||||
|
wp_safe_redirect( self::page_url() );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle "Start" from Step 3 (Site Relations).
|
||||||
|
*/
|
||||||
|
private static function handle_step_3_run(): void {
|
||||||
|
check_admin_referer( 'mlp_migrator_site_relations', 'mlp_migrator_nonce' );
|
||||||
|
$result = Robotstxt_Mlp2_Mlp5_Step_Site_Relations::run();
|
||||||
|
Robotstxt_Mlp2_Mlp5_Wizard_State::set_step_data( 3, $result );
|
||||||
|
wp_safe_redirect( self::page_url() );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle "Next" for a standard step (advance to next, mark complete).
|
||||||
|
*
|
||||||
|
* @param int $current_step Current step number.
|
||||||
|
* @param int $next_step Next step number.
|
||||||
|
* @param string $nonce_action Nonce action string.
|
||||||
|
*/
|
||||||
|
private static function handle_step_next( int $current_step, int $next_step, string $nonce_action ): void {
|
||||||
|
check_admin_referer( $nonce_action, 'mlp_migrator_nonce' );
|
||||||
|
Robotstxt_Mlp2_Mlp5_Wizard_State::mark_step_complete( $current_step );
|
||||||
|
Robotstxt_Mlp2_Mlp5_Wizard_State::set_step( $next_step );
|
||||||
|
wp_safe_redirect( self::page_url() );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the cleanup POST from Step 6.
|
||||||
|
*/
|
||||||
|
private static function handle_step_6_cleanup(): void {
|
||||||
|
check_admin_referer( 'mlp_migrator_cleanup', 'mlp_migrator_nonce' );
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||||
|
$confirm = isset( $_POST['cleanup_confirm'] ) ? wp_unslash( $_POST['cleanup_confirm'] ) : '';
|
||||||
|
if ( 'DELETE' !== $confirm ) {
|
||||||
|
wp_safe_redirect( self::page_url( array( 'cleanup_error' => '1' ) ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$deactivate = ! empty( $_POST['cleanup_deactivate'] );
|
||||||
|
$drop_tables = ! empty( $_POST['cleanup_drop_tables'] ) && $deactivate;
|
||||||
|
$sitemeta = ! empty( $_POST['cleanup_sitemeta'] );
|
||||||
|
|
||||||
|
if ( $deactivate ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Step_Cleanup::deactivate_mlp2();
|
||||||
|
}
|
||||||
|
if ( $drop_tables ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Step_Cleanup::drop_backup_tables();
|
||||||
|
}
|
||||||
|
if ( $sitemeta ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Step_Cleanup::remove_mlp2_sitemeta();
|
||||||
|
}
|
||||||
|
|
||||||
|
Robotstxt_Mlp2_Mlp5_Wizard_State::mark_step_complete( 6 );
|
||||||
|
wp_safe_redirect( self::page_url( array( 'cleanup_done' => '1' ) ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the wizard reset POST action.
|
||||||
|
*/
|
||||||
|
public static function handle_reset_action(): void {
|
||||||
|
check_admin_referer( 'mlp_migrator_reset', 'mlp_migrator_nonce' );
|
||||||
|
if ( ! current_user_can( self::CAPABILITY ) ) {
|
||||||
|
wp_die( esc_html__( 'You do not have permission to perform this action.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
Robotstxt_Mlp2_Mlp5_Wizard_State::reset();
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::clear();
|
||||||
|
wp_safe_redirect( self::page_url( array( 'reset' => '1' ) ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Rendering
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the full page.
|
||||||
|
*/
|
||||||
|
public static function render(): void {
|
||||||
|
if ( ! current_user_can( self::CAPABILITY ) ) {
|
||||||
|
wp_die( esc_html__( 'You do not have permission to access this page.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$has_original = Robotstxt_Mlp2_Mlp5_Table_Preparer::has_original_tables();
|
||||||
|
$has_backup = Robotstxt_Mlp2_Mlp5_Table_Preparer::has_backup_tables();
|
||||||
|
$mlp5 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp5();
|
||||||
|
$mlp5_active = $mlp5->is_active();
|
||||||
|
|
||||||
|
// Once MLP5 is active its own tables match the mlp_* pattern.
|
||||||
|
// They are not leftover MLP2 tables, so suppress the "must be renamed" signal.
|
||||||
|
if ( $mlp5_active ) {
|
||||||
|
$has_original = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Migration is complete when wizard step 6 is marked done.
|
||||||
|
$wizard_done = Robotstxt_Mlp2_Mlp5_Wizard_State::is_step_complete( Robotstxt_Mlp2_Mlp5_Wizard_State::TOTAL_STEPS );
|
||||||
|
$ready = ( $has_backup && $mlp5_active ) || ( $wizard_done && $mlp5_active );
|
||||||
|
?>
|
||||||
|
<div class="wrap">
|
||||||
|
<h1><?php esc_html_e( 'MLP2 to MLP5 Migrator', 'robotstxt-mlp2-mlp5' ); ?></h1>
|
||||||
|
|
||||||
|
<?php self::render_feedback_notices(); ?>
|
||||||
|
|
||||||
|
<?php if ( $ready ) : ?>
|
||||||
|
<?php self::render_wizard( $has_original, $has_backup, $mlp5_active, $mlp5 ); ?>
|
||||||
|
<?php else : ?>
|
||||||
|
<?php self::render_state_banner( $has_original, $has_backup, $mlp5_active ); ?>
|
||||||
|
<?php self::render_status_card( $has_original, $has_backup, $mlp5_active, $mlp5 ); ?>
|
||||||
|
<?php self::render_action_forms( $has_original, $has_backup, $mlp5_active ); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the full wizard when the system is ready (State C).
|
||||||
|
*
|
||||||
|
* @param bool $has_original Whether original MLP2 tables exist.
|
||||||
|
* @param bool $has_backup Whether backup MLP2 tables exist.
|
||||||
|
* @param bool $mlp5_active Whether MLP5 is network-active.
|
||||||
|
* @param Robotstxt_Mlp2_Mlp5_Detector_Mlp5 $mlp5 MLP5 detector instance.
|
||||||
|
*/
|
||||||
|
private static function render_wizard(
|
||||||
|
bool $has_original,
|
||||||
|
bool $has_backup,
|
||||||
|
bool $mlp5_active,
|
||||||
|
Robotstxt_Mlp2_Mlp5_Detector_Mlp5 $mlp5
|
||||||
|
): void {
|
||||||
|
$current_step = Robotstxt_Mlp2_Mlp5_Wizard_State::get_current_step();
|
||||||
|
$step_labels = array(
|
||||||
|
1 => __( 'Preflight', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
2 => __( 'Analysis', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
3 => __( 'Site Relations', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
4 => __( 'Content Relations', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
5 => __( 'Verification', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
6 => __( 'Cleanup', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
<div style="background:#fff;border:1px solid #c3c4c7;padding:1.5em;max-width:780px;">
|
||||||
|
|
||||||
|
<?php /* Step indicator */ ?>
|
||||||
|
<ol style="display:flex;list-style:none;margin:0 0 1.5em;padding:0;gap:0;">
|
||||||
|
<?php for ( $i = 1; $i <= Robotstxt_Mlp2_Mlp5_Wizard_State::TOTAL_STEPS; $i++ ) : ?>
|
||||||
|
<?php
|
||||||
|
$is_done = Robotstxt_Mlp2_Mlp5_Wizard_State::is_step_complete( $i );
|
||||||
|
$is_current = ( $i === $current_step );
|
||||||
|
if ( $is_current ) {
|
||||||
|
$bg = '#2271b1';
|
||||||
|
$color = '#fff';
|
||||||
|
} elseif ( $is_done ) {
|
||||||
|
$bg = '#00a32a';
|
||||||
|
$color = '#fff';
|
||||||
|
} else {
|
||||||
|
$bg = '#f0f0f1';
|
||||||
|
$color = '#50575e';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<li style="flex:1;text-align:center;padding:.5em .25em;background:<?php echo esc_attr( $bg ); ?>;color:<?php echo esc_attr( $color ); ?>;font-size:.85em;font-weight:<?php echo $is_current ? '700' : '400'; ?>;border-right:2px solid #fff;">
|
||||||
|
<?php echo esc_html( $i . '. ' . $step_labels[ $i ] ); ?>
|
||||||
|
<?php echo $is_done ? ' ✓' : ''; ?>
|
||||||
|
</li>
|
||||||
|
<?php endfor; ?>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<?php /* Step content */ ?>
|
||||||
|
<div style="min-height:200px;">
|
||||||
|
<?php
|
||||||
|
switch ( $current_step ) {
|
||||||
|
case 1:
|
||||||
|
Robotstxt_Mlp2_Mlp5_Step_Preflight::render();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Robotstxt_Mlp2_Mlp5_Step_Analysis::render();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Robotstxt_Mlp2_Mlp5_Step_Site_Relations::render();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
Robotstxt_Mlp2_Mlp5_Step_Content_Relations::render();
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
Robotstxt_Mlp2_Mlp5_Step_Verification::render();
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
Robotstxt_Mlp2_Mlp5_Step_Cleanup::render();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php /* Reset disclosure */ ?>
|
||||||
|
<details style="margin-top:2em;border-top:1px solid #e2e2e2;padding-top:1em;">
|
||||||
|
<summary style="cursor:pointer;color:#646970;"><?php esc_html_e( 'Reset migration (start over)', 'robotstxt-mlp2-mlp5' ); ?></summary>
|
||||||
|
<div style="margin-top:.75em;padding:.75em;border:1px solid #dcdcde;background:#fff8f8;">
|
||||||
|
<p><?php esc_html_e( 'This will reset the wizard to Step 1 and clear the migration log. It does not modify MLP5 data.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_reset', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_reset_wizard" />
|
||||||
|
<button type="submit" class="button button-secondary"><?php esc_html_e( 'Reset wizard', 'robotstxt-mlp2-mlp5' ); ?></button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php /* Status sidebar (compact, always visible) */ ?>
|
||||||
|
<div style="margin-top:1em;max-width:780px;">
|
||||||
|
<details>
|
||||||
|
<summary style="cursor:pointer;color:#646970;"><?php esc_html_e( 'System status', 'robotstxt-mlp2-mlp5' ); ?></summary>
|
||||||
|
<div style="margin-top:.5em;">
|
||||||
|
<?php self::render_status_card( $has_original, $has_backup, $mlp5_active, $mlp5 ); ?>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Shared UI helpers (used in both preparation and wizard views)
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show feedback notices after redirects.
|
||||||
|
*/
|
||||||
|
private static function render_feedback_notices(): void {
|
||||||
|
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||||
|
if ( isset( $_GET['renamed'] ) ) {
|
||||||
|
$count = (int) $_GET['renamed'];
|
||||||
|
/* translators: %d: number of renamed tables */
|
||||||
|
printf( '<div class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html( sprintf( _n( '%d table renamed successfully.', '%d tables renamed successfully.', $count, 'robotstxt-mlp2-mlp5' ), $count ) ) ); // phpcs:ignore WordPress.WP.I18n.MismatchedPlaceholders
|
||||||
|
}
|
||||||
|
if ( isset( $_GET['rename_errors'] ) ) {
|
||||||
|
$count = (int) $_GET['rename_errors'];
|
||||||
|
/* translators: %d: number of tables that could not be renamed */
|
||||||
|
printf( '<div class="notice notice-error"><p>%s</p></div>', esc_html( sprintf( _n( '%d table could not be renamed. Check database permissions.', '%d tables could not be renamed. Check database permissions.', $count, 'robotstxt-mlp2-mlp5' ), $count ) ) ); // phpcs:ignore WordPress.WP.I18n.MismatchedPlaceholders
|
||||||
|
}
|
||||||
|
if ( isset( $_GET['restored'] ) ) {
|
||||||
|
$count = (int) $_GET['restored'];
|
||||||
|
/* translators: %d: number of restored tables */
|
||||||
|
printf( '<div class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html( sprintf( _n( '%d table restored to original name.', '%d tables restored to original names.', $count, 'robotstxt-mlp2-mlp5' ), $count ) ) ); // phpcs:ignore WordPress.WP.I18n.MismatchedPlaceholders
|
||||||
|
}
|
||||||
|
if ( isset( $_GET['restore_errors'] ) ) {
|
||||||
|
$count = (int) $_GET['restore_errors'];
|
||||||
|
/* translators: %d: number of tables that could not be restored */
|
||||||
|
printf( '<div class="notice notice-error"><p>%s</p></div>', esc_html( sprintf( _n( '%d table could not be restored. Check database permissions.', '%d tables could not be restored. Check database permissions.', $count, 'robotstxt-mlp2-mlp5' ), $count ) ) ); // phpcs:ignore WordPress.WP.I18n.MismatchedPlaceholders
|
||||||
|
}
|
||||||
|
if ( isset( $_GET['reset'] ) ) {
|
||||||
|
printf( '<div class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html__( 'Wizard reset. You can start the migration from Step 1.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
if ( isset( $_GET['cleanup_done'] ) ) {
|
||||||
|
printf( '<div class="notice notice-success is-dismissible"><p>%s</p></div>', esc_html__( 'Cleanup completed.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
if ( isset( $_GET['cleanup_error'] ) ) {
|
||||||
|
printf( '<div class="notice notice-error"><p>%s</p></div>', esc_html__( 'Cleanup confirmation invalid. Type DELETE exactly.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a banner communicating the overall system state (preparation view only).
|
||||||
|
*
|
||||||
|
* @param bool $has_original Whether original MLP2 tables exist.
|
||||||
|
* @param bool $has_backup Whether backup MLP2 tables exist.
|
||||||
|
* @param bool $mlp5_active Whether MLP5 is network-active.
|
||||||
|
*/
|
||||||
|
private static function render_state_banner( bool $has_original, bool $has_backup, bool $mlp5_active ): void {
|
||||||
|
if ( $has_original && ! $has_backup ) {
|
||||||
|
$color = '#d63638';
|
||||||
|
$msg = __( 'Action required: MLP2 tables must be renamed before MultilingualPress 5 can be activated.', 'robotstxt-mlp2-mlp5' );
|
||||||
|
} elseif ( $has_backup && ! $mlp5_active ) {
|
||||||
|
$color = '#dba617';
|
||||||
|
$msg = __( 'MLP2 tables renamed. Now go to Network Admin > Plugins and activate MultilingualPress 5.', 'robotstxt-mlp2-mlp5' );
|
||||||
|
} elseif ( $has_original && $has_backup ) {
|
||||||
|
$color = '#dba617';
|
||||||
|
$msg = __( 'Warning: both original and backup MLP2 tables were found. Investigate before proceeding.', 'robotstxt-mlp2-mlp5' );
|
||||||
|
} else {
|
||||||
|
$color = '#d63638';
|
||||||
|
$msg = __( 'No MLP2 tables found. Migration cannot proceed. Restore your database from a backup.', 'robotstxt-mlp2-mlp5' );
|
||||||
|
}
|
||||||
|
printf(
|
||||||
|
'<div style="border-left:4px solid %s;padding:.75em 1em;margin:1em 0;background:#fff;max-width:640px;"><strong>%s</strong></div>',
|
||||||
|
esc_attr( $color ),
|
||||||
|
wp_kses_post( $msg )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the system status card.
|
||||||
|
*
|
||||||
|
* @param bool $has_original Whether original MLP2 tables exist.
|
||||||
|
* @param bool $has_backup Whether backup MLP2 tables exist.
|
||||||
|
* @param bool $mlp5_active Whether MLP5 is network-active.
|
||||||
|
* @param Robotstxt_Mlp2_Mlp5_Detector_Mlp5 $mlp5 MLP5 detector instance.
|
||||||
|
*/
|
||||||
|
private static function render_status_card(
|
||||||
|
bool $has_original,
|
||||||
|
bool $has_backup,
|
||||||
|
bool $mlp5_active,
|
||||||
|
Robotstxt_Mlp2_Mlp5_Detector_Mlp5 $mlp5
|
||||||
|
): void {
|
||||||
|
$orig_count = count( Robotstxt_Mlp2_Mlp5_Table_Preparer::get_original_tables() );
|
||||||
|
$backup_count = count( Robotstxt_Mlp2_Mlp5_Table_Preparer::get_backup_tables() );
|
||||||
|
?>
|
||||||
|
<div class="card" style="max-width:640px;margin-top:1em;">
|
||||||
|
<h2 style="margin-top:0;"><?php esc_html_e( 'System Status', 'robotstxt-mlp2-mlp5' ); ?></h2>
|
||||||
|
<table class="widefat striped" style="border:0;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><?php esc_html_e( 'MLP2 tables (original names)', 'robotstxt-mlp2-mlp5' ); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php if ( $has_original ) : ?>
|
||||||
|
<span style="color:#d63638;">● <?php echo esc_html( sprintf( /* translators: %d: number of tables */ _n( '%d table — must be renamed', '%d tables — must be renamed', $orig_count, 'robotstxt-mlp2-mlp5' ), $orig_count ) ); // phpcs:ignore WordPress.WP.I18n.MismatchedPlaceholders ?></span>
|
||||||
|
<?php else : ?>
|
||||||
|
<span style="color:#46b450;">✓ <?php esc_html_e( 'None', 'robotstxt-mlp2-mlp5' ); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php esc_html_e( 'MLP2 tables (backup copies)', 'robotstxt-mlp2-mlp5' ); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php if ( $has_backup ) : ?>
|
||||||
|
<span style="color:#46b450;">✓ <?php echo esc_html( sprintf( /* translators: %d: number of backup tables */ _n( '%d backup table ready', '%d backup tables ready', $backup_count, 'robotstxt-mlp2-mlp5' ), $backup_count ) ); // phpcs:ignore WordPress.WP.I18n.MismatchedPlaceholders ?></span>
|
||||||
|
<?php else : ?>
|
||||||
|
<span style="color:#888;">— <?php esc_html_e( 'Not yet renamed', 'robotstxt-mlp2-mlp5' ); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php esc_html_e( 'MultilingualPress 5 (network-active)', 'robotstxt-mlp2-mlp5' ); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php if ( $mlp5_active ) : ?>
|
||||||
|
<span style="color:#46b450;">✓ <?php echo esc_html( sprintf( /* translators: %s: version */ __( 'Active (v%s)', 'robotstxt-mlp2-mlp5' ), $mlp5->get_version() ) ); ?></span>
|
||||||
|
<?php else : ?>
|
||||||
|
<span style="color:#888;">— <?php esc_html_e( 'Not active', 'robotstxt-mlp2-mlp5' ); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render action forms for the preparation view.
|
||||||
|
*
|
||||||
|
* @param bool $has_original Whether original MLP2 tables exist.
|
||||||
|
* @param bool $has_backup Whether backup MLP2 tables exist.
|
||||||
|
* @param bool $mlp5_active Whether MLP5 is network-active.
|
||||||
|
*/
|
||||||
|
private static function render_action_forms( bool $has_original, bool $has_backup, bool $mlp5_active ): void {
|
||||||
|
if ( $has_original ) {
|
||||||
|
?>
|
||||||
|
<div style="max-width:640px;margin-top:1.5em;">
|
||||||
|
<h2><?php esc_html_e( 'Step 1 — Rename MLP2 Tables', 'robotstxt-mlp2-mlp5' ); ?></h2>
|
||||||
|
<p><?php esc_html_e( 'MultilingualPress 5 cannot activate while the original MLP2 table names are present. Click below to rename them to temporary backup copies ({prefix}mlp2bak_*). This is safe and fully reversible.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_rename', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_rename_tables" />
|
||||||
|
<p><button type="submit" class="button button-primary"><?php esc_html_e( 'Rename MLP2 tables (prepare for MLP5 activation)', 'robotstxt-mlp2-mlp5' ); ?></button></p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $has_backup && ! $mlp5_active ) {
|
||||||
|
?>
|
||||||
|
<div style="max-width:640px;margin-top:1.5em;">
|
||||||
|
<h2><?php esc_html_e( 'Step 2 — Activate MultilingualPress 5', 'robotstxt-mlp2-mlp5' ); ?></h2>
|
||||||
|
<p><?php esc_html_e( 'MLP2 tables have been renamed. MultilingualPress 5 can now be activated without the old-version compatibility error.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
<p><a href="<?php echo esc_url( network_admin_url( 'plugins.php' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Go to Network Admin › Plugins', 'robotstxt-mlp2-mlp5' ); ?></a></p>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $has_backup ) {
|
||||||
|
?>
|
||||||
|
<div style="max-width:640px;margin-top:2em;">
|
||||||
|
<details>
|
||||||
|
<summary style="cursor:pointer;color:#646970;"><?php esc_html_e( 'Emergency: restore original MLP2 table names', 'robotstxt-mlp2-mlp5' ); ?></summary>
|
||||||
|
<div style="margin-top:.75em;padding:.75em;border:1px solid #dcdcde;background:#fff8f8;">
|
||||||
|
<p><?php esc_html_e( 'This renames backup tables back to their original MLP2 names. Only use this before MLP5 has been activated.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_restore', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_restore_tables" />
|
||||||
|
<button type="submit" class="button button-secondary"><?php esc_html_e( 'Restore original table names', 'robotstxt-mlp2-mlp5' ); ?></button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
56
includes/class-robotstxt-mlp2-mlp5-ajax.php
Normal file
56
includes/class-robotstxt-mlp2-mlp5-ajax.php
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* AJAX handler registry.
|
||||||
|
*
|
||||||
|
* All AJAX actions for the migration wizard are registered here.
|
||||||
|
* Every handler verifies a nonce and the manage_network capability
|
||||||
|
* before performing any work.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Ajax
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Ajax {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nonce action used for all batch AJAX requests.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const NONCE_ACTION = 'mlp_migrator_batch';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register all AJAX hooks. Called once on plugins_loaded.
|
||||||
|
*/
|
||||||
|
public static function register(): void {
|
||||||
|
add_action( 'wp_ajax_mlp_migrator_run_batch', array( static::class, 'action_run_batch' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AJAX handler: run one content-relations migration batch.
|
||||||
|
*
|
||||||
|
* Verifies nonce and capability, delegates to Step_Content_Relations,
|
||||||
|
* and returns a JSON progress snapshot.
|
||||||
|
*/
|
||||||
|
public static function action_run_batch(): void {
|
||||||
|
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||||
|
$raw_nonce = isset( $_POST['nonce'] ) ? wp_unslash( $_POST['nonce'] ) : '';
|
||||||
|
if ( ! wp_verify_nonce( (string) $raw_nonce, self::NONCE_ACTION ) ) {
|
||||||
|
wp_send_json_error( array( 'message' => 'Invalid nonce.' ), 403 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! current_user_can( 'manage_network' ) ) {
|
||||||
|
wp_send_json_error( array( 'message' => 'Insufficient permissions.' ), 403 );
|
||||||
|
}
|
||||||
|
|
||||||
|
$progress = Robotstxt_Mlp2_Mlp5_Step_Content_Relations::run_batch();
|
||||||
|
|
||||||
|
wp_send_json_success( $progress );
|
||||||
|
}
|
||||||
|
}
|
||||||
64
includes/class-robotstxt-mlp2-mlp5-db-upgrader.php
Normal file
64
includes/class-robotstxt-mlp2-mlp5-db-upgrader.php
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Database schema upgrader.
|
||||||
|
*
|
||||||
|
* Compares the installed DB schema version with the current version constant
|
||||||
|
* and runs any pending upgrade routines in sequence.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Db_Upgrader
|
||||||
|
*
|
||||||
|
* How to add a new schema version:
|
||||||
|
* 1. Increment ROBOTSTXT_MLP2_MLP5_DB_VERSION in robotstxt-mlp2-mlp5.php (e.g. '1.1').
|
||||||
|
* 2. Add a private static method upgrade_to_1_1() with the schema changes.
|
||||||
|
* 3. Add a version_compare block for '1.1' inside maybe_upgrade().
|
||||||
|
* 4. Update changelog.txt and CHANGELOG.md.
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Db_Upgrader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run any pending DB upgrade routines.
|
||||||
|
*
|
||||||
|
* Reads the installed schema version from sitemeta and compares it with
|
||||||
|
* the ROBOTSTXT_MLP2_MLP5_DB_VERSION constant. If the installed version
|
||||||
|
* is lower, all intermediate upgrade methods are executed in order and
|
||||||
|
* the stored version is updated to the current value.
|
||||||
|
*
|
||||||
|
* Safe to call on every request — exits immediately when no upgrade is
|
||||||
|
* needed (one cached sitemeta read).
|
||||||
|
*/
|
||||||
|
public static function maybe_upgrade(): void {
|
||||||
|
$installed = (string) get_site_option( Robotstxt_Mlp2_Mlp5_Logger::DB_VERSION_KEY, '0' );
|
||||||
|
$current = ROBOTSTXT_MLP2_MLP5_DB_VERSION;
|
||||||
|
|
||||||
|
if ( version_compare( $installed, $current, '>=' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute upgrade routines in ascending version order.
|
||||||
|
if ( version_compare( $installed, '1.0', '<' ) ) {
|
||||||
|
self::upgrade_to_1_0();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Future version upgrade blocks go here, following the same pattern above.
|
||||||
|
|
||||||
|
update_site_option( Robotstxt_Mlp2_Mlp5_Logger::DB_VERSION_KEY, $current );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upgrade DB schema to version 1.0.
|
||||||
|
*
|
||||||
|
* Creates the migration log table for the first time. dbDelta() is
|
||||||
|
* idempotent and handles both initial creation and incremental ALTER safely.
|
||||||
|
*/
|
||||||
|
private static function upgrade_to_1_0(): void {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::create_table();
|
||||||
|
}
|
||||||
|
}
|
||||||
282
includes/class-robotstxt-mlp2-mlp5-detector-mlp2.php
Normal file
282
includes/class-robotstxt-mlp2-mlp5-detector-mlp2.php
Normal file
|
|
@ -0,0 +1,282 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MultilingualPress 2 detection service.
|
||||||
|
*
|
||||||
|
* Detects whether MultilingualPress 2 is installed (active or inactive),
|
||||||
|
* reads its plugin metadata, and identifies its database tables and schema.
|
||||||
|
*
|
||||||
|
* Note: MLP2 does not need to be active for migration. Only its database
|
||||||
|
* tables need to exist. See docs/ROADMAP.md — Background section.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Detector_Mlp2
|
||||||
|
*
|
||||||
|
* Instantiate once to detect MLP2; all detection results are cached in
|
||||||
|
* instance properties to avoid repeated file or database reads.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* $mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
||||||
|
* if ( $mlp2->get_site_relations_table() !== '' ) { ... }
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Detector_Mlp2 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Known plugin basename for MultilingualPress 2 (WordPress.org slug).
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const PLUGIN_BASENAME = 'multilingual-press/multilingual-press.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolved MLP2 plugin basename, or empty string if not found on disk.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $plugin_file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin header data from get_plugin_data(), or empty array if unavailable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private array $plugin_data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Locates the MLP2 plugin file and loads its header data.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
$this->plugin_file = $this->find_plugin_file();
|
||||||
|
$this->plugin_data = $this->plugin_file ? $this->load_plugin_data() : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether MultilingualPress 2 is currently network-active.
|
||||||
|
*
|
||||||
|
* Informational only. MLP2 may be deactivated or uninstalled while its
|
||||||
|
* database tables still exist. Table presence is the migration gate, not
|
||||||
|
* plugin activity.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function is_active(): bool {
|
||||||
|
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '' !== $this->plugin_file && is_plugin_active_for_network( $this->plugin_file );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the MLP2 version string, or empty string if unavailable.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_version(): string {
|
||||||
|
return isset( $this->plugin_data['Version'] ) ? (string) $this->plugin_data['Version'] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the resolved MLP2 plugin basename, or empty string if not on disk.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_plugin_file(): string {
|
||||||
|
return $this->plugin_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether a given table exists in the database.
|
||||||
|
*
|
||||||
|
* @param string $table Full table name (including prefix).
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function table_exists( string $table ): bool {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
return (string) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) ) === $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the full MLP2 site relations table name, or empty string if absent.
|
||||||
|
*
|
||||||
|
* Checks the original name first. If the original has been renamed by the
|
||||||
|
* Table_Preparer, returns the backup name instead so that later phases can
|
||||||
|
* read the data regardless of whether preparation has run.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_site_relations_table(): string {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$table = $wpdb->base_prefix . 'mlp_site_relations';
|
||||||
|
$backup = Robotstxt_Mlp2_Mlp5_Table_Preparer::backup_name( $table );
|
||||||
|
|
||||||
|
// Check backup first: after preparation the original name belongs to MLP5.
|
||||||
|
if ( '' !== $backup && $this->table_exists( $backup ) ) {
|
||||||
|
return $backup;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to original only when no backup tables exist (preparation not done yet).
|
||||||
|
if ( ! Robotstxt_Mlp2_Mlp5_Table_Preparer::has_backup_tables() && $this->table_exists( $table ) ) {
|
||||||
|
return $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the full MLP2 content relations table name, or empty string if absent.
|
||||||
|
*
|
||||||
|
* MLP2 uses `mlp_relationships` in older minor versions,
|
||||||
|
* `mlp_content_relations` in newer ones, and `multilingual_linked` in some
|
||||||
|
* installations (table name lacks the mlp_ prefix and is never renamed by
|
||||||
|
* the Table_Preparer). All three are checked. If the original table has been
|
||||||
|
* renamed by the Table_Preparer, its backup name is returned.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_content_relations_table(): string {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
// After preparation, original names belong to MLP5; only look at backups.
|
||||||
|
$preparation_done = Robotstxt_Mlp2_Mlp5_Table_Preparer::has_backup_tables();
|
||||||
|
|
||||||
|
foreach ( array( 'mlp_relationships', 'mlp_content_relations' ) as $candidate ) {
|
||||||
|
$table = $wpdb->base_prefix . $candidate;
|
||||||
|
$backup = Robotstxt_Mlp2_Mlp5_Table_Preparer::backup_name( $table );
|
||||||
|
|
||||||
|
if ( '' !== $backup && $this->table_exists( $backup ) ) {
|
||||||
|
return $backup;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to original only when preparation has not run yet.
|
||||||
|
if ( ! $preparation_done && $this->table_exists( $table ) ) {
|
||||||
|
return $table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some MLP2 installations store content relations in `multilingual_linked`
|
||||||
|
// (no mlp_ prefix). This table is never touched by Table_Preparer, so it
|
||||||
|
// remains accessible regardless of whether preparation has run.
|
||||||
|
$linked = $wpdb->base_prefix . 'multilingual_linked';
|
||||||
|
if ( $this->table_exists( $linked ) ) {
|
||||||
|
return $linked;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all tables in the database that match the MLP table prefix pattern.
|
||||||
|
*
|
||||||
|
* This may include tables belonging to MLP5 if it uses the same prefix.
|
||||||
|
* Use get_site_relations_table() and get_content_relations_table() for
|
||||||
|
* precise MLP2-specific detection.
|
||||||
|
*
|
||||||
|
* @return string[] Array of full table names.
|
||||||
|
*/
|
||||||
|
public function get_all_tables(): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$like = $wpdb->esc_like( $wpdb->base_prefix . 'mlp_' ) . '%';
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$tables = $wpdb->get_col( $wpdb->prepare( 'SHOW TABLES LIKE %s', $like ) );
|
||||||
|
|
||||||
|
return is_array( $tables ) ? $tables : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return column definitions for a table.
|
||||||
|
*
|
||||||
|
* @param string $table Full table name (must start with the DB base prefix).
|
||||||
|
* @return array Associative array keyed by column name (Field), or empty array
|
||||||
|
* if the table does not exist or the name fails validation.
|
||||||
|
*/
|
||||||
|
public function describe_table( string $table ): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
// Validate: table name must start with the base prefix.
|
||||||
|
if ( ! str_starts_with( $table, $wpdb->base_prefix ) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $this->table_exists( $table ) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$columns = $wpdb->get_results( "SHOW COLUMNS FROM {$table}", ARRAY_A );
|
||||||
|
|
||||||
|
if ( empty( $columns ) || ! is_array( $columns ) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
foreach ( $columns as $column ) {
|
||||||
|
if ( isset( $column['Field'] ) ) {
|
||||||
|
$result[ $column['Field'] ] = $column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locate the MLP2 plugin file on disk.
|
||||||
|
*
|
||||||
|
* Checks the known canonical basename first. If not found, scans all
|
||||||
|
* installed plugins for a plugin named "MultilingualPress" with a
|
||||||
|
* version below 3.0.0 (which marks the MLP3+ series).
|
||||||
|
*
|
||||||
|
* @return string Plugin basename, or empty string if not found.
|
||||||
|
*/
|
||||||
|
private function find_plugin_file(): string {
|
||||||
|
if ( file_exists( WP_PLUGIN_DIR . '/' . self::PLUGIN_BASENAME ) ) {
|
||||||
|
return self::PLUGIN_BASENAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'get_plugins' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( get_plugins() as $basename => $data ) {
|
||||||
|
if (
|
||||||
|
isset( $data['Name'], $data['Version'] ) &&
|
||||||
|
'MultilingualPress' === $data['Name'] &&
|
||||||
|
version_compare( (string) $data['Version'], '3.0.0', '<' )
|
||||||
|
) {
|
||||||
|
return $basename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load plugin header data from the MLP2 main file.
|
||||||
|
*
|
||||||
|
* @return array Plugin data from get_plugin_data(), or empty array on failure.
|
||||||
|
*/
|
||||||
|
private function load_plugin_data(): array {
|
||||||
|
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = WP_PLUGIN_DIR . '/' . $this->plugin_file;
|
||||||
|
|
||||||
|
if ( ! file_exists( $path ) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return get_plugin_data( $path, false, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
218
includes/class-robotstxt-mlp2-mlp5-detector-mlp5.php
Normal file
218
includes/class-robotstxt-mlp2-mlp5-detector-mlp5.php
Normal file
|
|
@ -0,0 +1,218 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MultilingualPress 5 detection service.
|
||||||
|
*
|
||||||
|
* Detects whether MultilingualPress 5 is installed (active or inactive),
|
||||||
|
* reads its plugin metadata, and identifies its database tables.
|
||||||
|
*
|
||||||
|
* MLP5 must be network-active for migration to proceed. Unlike MLP2,
|
||||||
|
* the plugin itself needs to be running so its API is available.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Detector_Mlp5
|
||||||
|
*
|
||||||
|
* Instantiate once to detect MLP5; all detection results are cached in
|
||||||
|
* instance properties to avoid repeated file or database reads.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* $mlp5 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp5();
|
||||||
|
* if ( $mlp5->is_active() ) { ... }
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Detector_Mlp5 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Known plugin basename for MultilingualPress 5 (commercial, Inpsyde).
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const PLUGIN_BASENAME = 'multilingualpress/multilingualpress.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolved MLP5 plugin basename, or empty string if not found on disk.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $plugin_file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin header data from get_plugin_data(), or empty array if unavailable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private array $plugin_data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Locates the MLP5 plugin file and loads its header data.
|
||||||
|
*/
|
||||||
|
public function __construct() {
|
||||||
|
$this->plugin_file = $this->find_plugin_file();
|
||||||
|
$this->plugin_data = $this->plugin_file ? $this->load_plugin_data() : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether MultilingualPress 5 is currently network-active.
|
||||||
|
*
|
||||||
|
* MLP5 must be active for migration to proceed; its API tables and
|
||||||
|
* internal state are only available when the plugin is running.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function is_active(): bool {
|
||||||
|
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '' !== $this->plugin_file && is_plugin_active_for_network( $this->plugin_file );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the MLP5 version string, or empty string if unavailable.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_version(): string {
|
||||||
|
return isset( $this->plugin_data['Version'] ) ? (string) $this->plugin_data['Version'] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the resolved MLP5 plugin basename, or empty string if not on disk.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_plugin_file(): string {
|
||||||
|
return $this->plugin_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the MLP5 site relations table name, or empty string if absent.
|
||||||
|
*
|
||||||
|
* MLP5 uses the same mlp_site_relations table name as MLP2.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_site_relations_table(): string {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$table = $wpdb->base_prefix . 'mlp_site_relations';
|
||||||
|
|
||||||
|
return $this->table_exists( $table ) ? $table : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the MLP5 relationship groups table name, or empty string if absent.
|
||||||
|
*
|
||||||
|
* MLP5 stores one row per group of related content here (id, type).
|
||||||
|
* The content_relations table references this table via relationship_id.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_relationships_table(): string {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$table = $wpdb->base_prefix . 'mlp_relationships';
|
||||||
|
|
||||||
|
return $this->table_exists( $table ) ? $table : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the MLP5 content relations table name, or empty string if absent.
|
||||||
|
*
|
||||||
|
* MLP5 uses mlp_content_relations (the newer name introduced in MLP2
|
||||||
|
* late versions and carried forward).
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_content_relations_table(): string {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$table = $wpdb->base_prefix . 'mlp_content_relations';
|
||||||
|
|
||||||
|
return $this->table_exists( $table ) ? $table : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all tables in the database that match the MLP table prefix pattern.
|
||||||
|
*
|
||||||
|
* @return string[] Array of full table names.
|
||||||
|
*/
|
||||||
|
public function get_all_tables(): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$like = $wpdb->esc_like( $wpdb->base_prefix . 'mlp_' ) . '%';
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$tables = $wpdb->get_col( $wpdb->prepare( 'SHOW TABLES LIKE %s', $like ) );
|
||||||
|
|
||||||
|
return is_array( $tables ) ? $tables : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether a given table exists in the database.
|
||||||
|
*
|
||||||
|
* @param string $table Full table name (including prefix).
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function table_exists( string $table ): bool {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
return (string) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) ) === $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locate the MLP5 plugin file on disk.
|
||||||
|
*
|
||||||
|
* Checks the known canonical basename first. If not found, scans all
|
||||||
|
* installed plugins for a plugin named "MultilingualPress" with a
|
||||||
|
* version of 3.0.0 or higher (MLP3+ series includes MLP5).
|
||||||
|
*
|
||||||
|
* @return string Plugin basename, or empty string if not found.
|
||||||
|
*/
|
||||||
|
private function find_plugin_file(): string {
|
||||||
|
if ( file_exists( WP_PLUGIN_DIR . '/' . self::PLUGIN_BASENAME ) ) {
|
||||||
|
return self::PLUGIN_BASENAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'get_plugins' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ( get_plugins() as $basename => $data ) {
|
||||||
|
if (
|
||||||
|
isset( $data['Name'], $data['Version'] ) &&
|
||||||
|
'MultilingualPress' === $data['Name'] &&
|
||||||
|
version_compare( (string) $data['Version'], '3.0.0', '>=' )
|
||||||
|
) {
|
||||||
|
return $basename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load plugin header data from the MLP5 main file.
|
||||||
|
*
|
||||||
|
* @return array Plugin data from get_plugin_data(), or empty array on failure.
|
||||||
|
*/
|
||||||
|
private function load_plugin_data(): array {
|
||||||
|
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = WP_PLUGIN_DIR . '/' . $this->plugin_file;
|
||||||
|
|
||||||
|
if ( ! file_exists( $path ) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
return get_plugin_data( $path, false, false );
|
||||||
|
}
|
||||||
|
}
|
||||||
290
includes/class-robotstxt-mlp2-mlp5-logger.php
Normal file
290
includes/class-robotstxt-mlp2-mlp5-logger.php
Normal file
|
|
@ -0,0 +1,290 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Migration log manager.
|
||||||
|
*
|
||||||
|
* Handles creation, insertion, retrieval, truncation, and CSV export
|
||||||
|
* of the migration log table.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Logger
|
||||||
|
*
|
||||||
|
* All queries in this class are intentionally direct — the log table is
|
||||||
|
* write-once per operation and must never be read from an object cache.
|
||||||
|
* Per-line DirectDatabaseQuery suppressions are applied throughout.
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Logger {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sitemeta key used to track the installed DB schema version.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const DB_VERSION_KEY = 'mlp_migrator_db_version';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the fully qualified log table name.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function table_name(): string {
|
||||||
|
global $wpdb;
|
||||||
|
return $wpdb->base_prefix . 'mlp_migrator_log';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create (or update) the log table via dbDelta().
|
||||||
|
*
|
||||||
|
* Safe to call multiple times — dbDelta() is idempotent and only alters
|
||||||
|
* the table when the schema has changed. The DB upgrader is responsible
|
||||||
|
* for calling this method and for updating the stored schema version.
|
||||||
|
*/
|
||||||
|
public static function create_table(): void {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$table = self::table_name();
|
||||||
|
$charset_collate = $wpdb->get_charset_collate();
|
||||||
|
|
||||||
|
// Note: dbDelta() requires two spaces before PRIMARY KEY.
|
||||||
|
$sql = "CREATE TABLE {$table} (
|
||||||
|
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
created_at datetime NOT NULL,
|
||||||
|
type varchar(20) NOT NULL,
|
||||||
|
context varchar(50) NOT NULL,
|
||||||
|
source_id bigint(20) unsigned DEFAULT NULL,
|
||||||
|
target_id bigint(20) unsigned DEFAULT NULL,
|
||||||
|
message text NOT NULL,
|
||||||
|
metadata longtext DEFAULT NULL,
|
||||||
|
PRIMARY KEY (id),
|
||||||
|
KEY type (type),
|
||||||
|
KEY context (context)
|
||||||
|
) {$charset_collate};";
|
||||||
|
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
||||||
|
dbDelta( $sql );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop the log table and remove the schema version option.
|
||||||
|
*
|
||||||
|
* Only called from uninstall.php when the user has explicitly opted in
|
||||||
|
* to data deletion via the plugin settings.
|
||||||
|
*/
|
||||||
|
public static function drop_table(): void {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$table = self::table_name();
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$wpdb->query( "DROP TABLE IF EXISTS {$table}" );
|
||||||
|
|
||||||
|
delete_site_option( self::DB_VERSION_KEY );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a log entry.
|
||||||
|
*
|
||||||
|
* @param string $type Entry type: 'success', 'skipped', or 'error'.
|
||||||
|
* @param string $context Operation context: 'site_relation', 'post_relation', 'term_relation', or 'cleanup'.
|
||||||
|
* @param int|null $source_id Source content or site ID, or null if not applicable.
|
||||||
|
* @param int|null $target_id Target content or site ID, or null if not applicable.
|
||||||
|
* @param string $message Human-readable description of the operation result.
|
||||||
|
* @param array $metadata Optional additional structured data (stored as JSON).
|
||||||
|
*
|
||||||
|
* @return int Inserted row ID, or 0 on failure.
|
||||||
|
*/
|
||||||
|
public static function log(
|
||||||
|
string $type,
|
||||||
|
string $context,
|
||||||
|
?int $source_id,
|
||||||
|
?int $target_id,
|
||||||
|
string $message,
|
||||||
|
array $metadata = array()
|
||||||
|
): int {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
|
||||||
|
$inserted = $wpdb->insert(
|
||||||
|
self::table_name(),
|
||||||
|
array(
|
||||||
|
'created_at' => current_time( 'mysql', true ),
|
||||||
|
'type' => $type,
|
||||||
|
'context' => $context,
|
||||||
|
'source_id' => $source_id,
|
||||||
|
'target_id' => $target_id,
|
||||||
|
'message' => $message,
|
||||||
|
'metadata' => empty( $metadata ) ? null : wp_json_encode( $metadata ),
|
||||||
|
),
|
||||||
|
array( '%s', '%s', '%s', '%d', '%d', '%s', '%s' )
|
||||||
|
);
|
||||||
|
|
||||||
|
return $inserted ? (int) $wpdb->insert_id : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve log entries.
|
||||||
|
*
|
||||||
|
* @param array $args {
|
||||||
|
* Optional. Query arguments.
|
||||||
|
*
|
||||||
|
* @type string $type Filter by type: 'success', 'skipped', or 'error'.
|
||||||
|
* @type string $context Filter by context: 'site_relation', 'post_relation', 'term_relation', or 'cleanup'.
|
||||||
|
* @type int $limit Maximum number of rows to return. Default 50.
|
||||||
|
* @type int $offset Row offset for pagination. Default 0.
|
||||||
|
* @type string $order Sort direction: 'ASC' or 'DESC'. Default 'DESC'.
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* @return array Array of row objects, or an empty array.
|
||||||
|
*/
|
||||||
|
public static function get_entries( array $args = array() ): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$args = wp_parse_args(
|
||||||
|
$args,
|
||||||
|
array(
|
||||||
|
'type' => '',
|
||||||
|
'context' => '',
|
||||||
|
'limit' => 50,
|
||||||
|
'offset' => 0,
|
||||||
|
'order' => 'DESC',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$table = self::table_name();
|
||||||
|
$order = 'ASC' === strtoupper( (string) $args['order'] ) ? 'ASC' : 'DESC';
|
||||||
|
$where = '';
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
if ( ! empty( $args['type'] ) ) {
|
||||||
|
$where .= ' AND type = %s';
|
||||||
|
$values[] = $args['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $args['context'] ) ) {
|
||||||
|
$where .= ' AND context = %s';
|
||||||
|
$values[] = $args['context'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$values[] = (int) $args['limit'];
|
||||||
|
$values[] = (int) $args['offset'];
|
||||||
|
|
||||||
|
// Table name and ORDER BY direction are hardcoded — not from user input.
|
||||||
|
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber
|
||||||
|
return (array) $wpdb->get_results(
|
||||||
|
$wpdb->prepare(
|
||||||
|
"SELECT * FROM {$table} WHERE 1=1{$where} ORDER BY id {$order} LIMIT %d OFFSET %d",
|
||||||
|
$values
|
||||||
|
)
|
||||||
|
);
|
||||||
|
// phpcs:enable
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count log entries.
|
||||||
|
*
|
||||||
|
* Accepts the same filter arguments as get_entries() except limit, offset, and order.
|
||||||
|
*
|
||||||
|
* @param array $args Optional. 'type' and/or 'context' filter keys.
|
||||||
|
*
|
||||||
|
* @return int Total count of matching entries.
|
||||||
|
*/
|
||||||
|
public static function count( array $args = array() ): int {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$table = self::table_name();
|
||||||
|
$where = '';
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
if ( ! empty( $args['type'] ) ) {
|
||||||
|
$where .= ' AND type = %s';
|
||||||
|
$values[] = $args['type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $args['context'] ) ) {
|
||||||
|
$where .= ' AND context = %s';
|
||||||
|
$values[] = $args['context'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $values ) ) {
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$table}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber, WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare
|
||||||
|
return (int) $wpdb->get_var(
|
||||||
|
$wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE 1=1{$where}", $values )
|
||||||
|
);
|
||||||
|
// phpcs:enable
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Truncate the log table.
|
||||||
|
*
|
||||||
|
* Removes all rows without dropping the table structure. Used when
|
||||||
|
* restarting a migration from scratch.
|
||||||
|
*/
|
||||||
|
public static function clear(): void {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$table = self::table_name();
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$wpdb->query( "TRUNCATE TABLE {$table}" );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export the full log as a CSV string.
|
||||||
|
*
|
||||||
|
* Columns: id, created_at, type, context, source_id, target_id, message, metadata.
|
||||||
|
* Rows are ordered by id ASC.
|
||||||
|
*
|
||||||
|
* @return string CSV content with a header row, or an empty string on failure.
|
||||||
|
*/
|
||||||
|
public static function export_csv(): string {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$table = self::table_name();
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$rows = $wpdb->get_results( "SELECT * FROM {$table} ORDER BY id ASC", ARRAY_A );
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen
|
||||||
|
$buffer = fopen( 'php://temp', 'r+' );
|
||||||
|
|
||||||
|
if ( false === $buffer ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
fputcsv( $buffer, array( 'id', 'created_at', 'type', 'context', 'source_id', 'target_id', 'message', 'metadata' ) );
|
||||||
|
|
||||||
|
if ( ! empty( $rows ) ) {
|
||||||
|
foreach ( $rows as $row ) {
|
||||||
|
fputcsv(
|
||||||
|
$buffer,
|
||||||
|
array(
|
||||||
|
$row['id'],
|
||||||
|
$row['created_at'],
|
||||||
|
$row['type'],
|
||||||
|
$row['context'],
|
||||||
|
$row['source_id'] ?? '',
|
||||||
|
$row['target_id'] ?? '',
|
||||||
|
$row['message'],
|
||||||
|
$row['metadata'] ?? '',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rewind( $buffer );
|
||||||
|
$csv = stream_get_contents( $buffer );
|
||||||
|
fclose( $buffer ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose
|
||||||
|
|
||||||
|
return is_string( $csv ) ? $csv : '';
|
||||||
|
}
|
||||||
|
}
|
||||||
197
includes/class-robotstxt-mlp2-mlp5-reader-content-relations.php
Normal file
197
includes/class-robotstxt-mlp2-mlp5-reader-content-relations.php
Normal file
|
|
@ -0,0 +1,197 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MLP2 content relations reader.
|
||||||
|
*
|
||||||
|
* Reads post and term relation data from the MLP2 backup content_relations
|
||||||
|
* table. Relations are grouped by (ml_source_blogid, ml_source_elementid)
|
||||||
|
* so that each group can be written as a single MLP5 relationship.
|
||||||
|
*
|
||||||
|
* MLP2 backup table schema (mlp2bak_content_relations or mlp2bak_relationships):
|
||||||
|
* ml_source_blogid INT -- source site ID
|
||||||
|
* ml_source_elementid INT -- source element (post/term) ID
|
||||||
|
* ml_blogid INT -- target site ID
|
||||||
|
* ml_elementid INT -- target element ID
|
||||||
|
* ml_type VARCHAR -- 'post' or 'term'
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Reader_Content_Relations
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Reader_Content_Relations {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count distinct source groups for a given type.
|
||||||
|
*
|
||||||
|
* @param string $type 'post' or 'term'.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function count_groups( string $type ): int {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
||||||
|
$table = $mlp2->get_content_relations_table();
|
||||||
|
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
list( $src_blog, $src_elem ) = self::source_columns( $mlp2, $table );
|
||||||
|
if ( '' === $src_blog ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$type_safe = ( 'term' === $type ) ? 'term' : 'post';
|
||||||
|
|
||||||
|
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
return (int) $wpdb->get_var(
|
||||||
|
$wpdb->prepare(
|
||||||
|
"SELECT COUNT(DISTINCT {$src_blog}, {$src_elem}) FROM `{$table}` WHERE ml_type = %s",
|
||||||
|
$type_safe
|
||||||
|
)
|
||||||
|
);
|
||||||
|
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a batch of distinct source groups, with all their translation members.
|
||||||
|
*
|
||||||
|
* Each returned element is:
|
||||||
|
* [
|
||||||
|
* 'type' => string, // 'post' or 'term'
|
||||||
|
* 'members' => [
|
||||||
|
* ['site_id' => int, 'element_id' => int],
|
||||||
|
* ...
|
||||||
|
* ]
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* The source element itself is always included as a member.
|
||||||
|
*
|
||||||
|
* @param string $type 'post' or 'term'.
|
||||||
|
* @param int $offset Offset into the distinct source list.
|
||||||
|
* @param int $limit Number of groups to return.
|
||||||
|
* @return array[]
|
||||||
|
*/
|
||||||
|
public static function get_groups_batch( string $type, int $offset, int $limit ): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
||||||
|
$table = $mlp2->get_content_relations_table();
|
||||||
|
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
list( $src_blog, $src_elem ) = self::source_columns( $mlp2, $table );
|
||||||
|
if ( '' === $src_blog ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$type_safe = ( 'term' === $type ) ? 'term' : 'post';
|
||||||
|
|
||||||
|
// Fetch a page of distinct sources.
|
||||||
|
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$sources = $wpdb->get_results(
|
||||||
|
$wpdb->prepare(
|
||||||
|
"SELECT DISTINCT {$src_blog} AS source_blog, {$src_elem} AS source_elem FROM `{$table}` WHERE ml_type = %s ORDER BY {$src_blog}, {$src_elem} LIMIT %d OFFSET %d",
|
||||||
|
$type_safe,
|
||||||
|
$limit,
|
||||||
|
$offset
|
||||||
|
),
|
||||||
|
ARRAY_A
|
||||||
|
);
|
||||||
|
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
|
||||||
|
if ( empty( $sources ) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$groups = array();
|
||||||
|
|
||||||
|
foreach ( $sources as $source ) {
|
||||||
|
$src_blog_id = (int) $source['source_blog'];
|
||||||
|
$src_elem_id = (int) $source['source_elem'];
|
||||||
|
|
||||||
|
// Fetch all translations for this source.
|
||||||
|
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$translations = $wpdb->get_results(
|
||||||
|
$wpdb->prepare(
|
||||||
|
"SELECT ml_blogid, ml_elementid FROM `{$table}` WHERE ml_type = %s AND {$src_blog} = %d AND {$src_elem} = %d",
|
||||||
|
$type_safe,
|
||||||
|
$src_blog_id,
|
||||||
|
$src_elem_id
|
||||||
|
),
|
||||||
|
ARRAY_A
|
||||||
|
);
|
||||||
|
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
|
||||||
|
// Build members: source + all translations (deduplicated).
|
||||||
|
$seen = array();
|
||||||
|
$members = array();
|
||||||
|
|
||||||
|
$source_key = $src_blog_id . ':' . $src_elem_id;
|
||||||
|
$seen[ $source_key ] = true;
|
||||||
|
$members[] = array(
|
||||||
|
'site_id' => $src_blog_id,
|
||||||
|
'element_id' => $src_elem_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( (array) $translations as $t ) {
|
||||||
|
$key = ( (int) $t['ml_blogid'] ) . ':' . ( (int) $t['ml_elementid'] );
|
||||||
|
if ( isset( $seen[ $key ] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$seen[ $key ] = true;
|
||||||
|
$members[] = array(
|
||||||
|
'site_id' => (int) $t['ml_blogid'],
|
||||||
|
'element_id' => (int) $t['ml_elementid'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( count( $members ) >= 2 ) {
|
||||||
|
$groups[] = array(
|
||||||
|
'type' => $type_safe,
|
||||||
|
'members' => $members,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect the source-blog and source-element column names.
|
||||||
|
*
|
||||||
|
* Returns ['', ''] when columns cannot be determined.
|
||||||
|
*
|
||||||
|
* @param Robotstxt_Mlp2_Mlp5_Detector_Mlp2 $mlp2 MLP2 detector.
|
||||||
|
* @param string $table Content relations table name.
|
||||||
|
* @return string[] [ $source_blog_col, $source_element_col ]
|
||||||
|
*/
|
||||||
|
private static function source_columns( Robotstxt_Mlp2_Mlp5_Detector_Mlp2 $mlp2, string $table ): array {
|
||||||
|
$cols = $mlp2->describe_table( $table );
|
||||||
|
|
||||||
|
$blog_col = '';
|
||||||
|
foreach ( array( 'ml_source_blogid', 'ml_blogid' ) as $c ) {
|
||||||
|
if ( isset( $cols[ $c ] ) ) {
|
||||||
|
$blog_col = $c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$elem_col = '';
|
||||||
|
foreach ( array( 'ml_source_elementid', 'ml_elementid' ) as $c ) {
|
||||||
|
if ( isset( $cols[ $c ] ) ) {
|
||||||
|
$elem_col = $c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array( $blog_col, $elem_col );
|
||||||
|
}
|
||||||
|
}
|
||||||
58
includes/class-robotstxt-mlp2-mlp5-reader-site-relations.php
Normal file
58
includes/class-robotstxt-mlp2-mlp5-reader-site-relations.php
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MLP2 site relations reader.
|
||||||
|
*
|
||||||
|
* Reads all site connection rows from the MLP2 backup site_relations table.
|
||||||
|
*
|
||||||
|
* MLP2 site_relations schema:
|
||||||
|
* site_1 INT UNSIGNED -- lower site ID
|
||||||
|
* site_2 INT UNSIGNED -- higher site ID
|
||||||
|
* PRIMARY KEY (site_1, site_2)
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Reader_Site_Relations
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Reader_Site_Relations {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all MLP2 site relation rows as an array of associative arrays.
|
||||||
|
*
|
||||||
|
* Each element has keys: site_1 (int), site_2 (int).
|
||||||
|
*
|
||||||
|
* @return array[]
|
||||||
|
*/
|
||||||
|
public static function get_all(): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
||||||
|
$table = $mlp2->get_site_relations_table();
|
||||||
|
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$rows = $wpdb->get_results( "SELECT site_1, site_2 FROM `{$table}`", ARRAY_A );
|
||||||
|
|
||||||
|
if ( ! is_array( $rows ) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
foreach ( $rows as $row ) {
|
||||||
|
$result[] = array(
|
||||||
|
'site_1' => (int) $row['site_1'],
|
||||||
|
'site_2' => (int) $row['site_2'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
390
includes/class-robotstxt-mlp2-mlp5-step-analysis.php
Normal file
390
includes/class-robotstxt-mlp2-mlp5-step-analysis.php
Normal file
|
|
@ -0,0 +1,390 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Wizard Step 2 — Analysis.
|
||||||
|
*
|
||||||
|
* Scans MLP2 backup tables and MLP5 tables to count records, detect
|
||||||
|
* orphaned content, and validate schema compatibility before migration.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Step_Analysis
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Step_Analysis {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the full analysis and return a structured result.
|
||||||
|
*
|
||||||
|
* @return array {
|
||||||
|
* @type int $site_relations_count MLP2 site relation rows.
|
||||||
|
* @type int $post_groups_count Distinct MLP2 post-relation groups (by source).
|
||||||
|
* @type int $term_groups_count Distinct MLP2 term-relation groups (by source).
|
||||||
|
* @type int[] $orphaned_site_ids Site IDs referenced in MLP2 that no longer exist.
|
||||||
|
* @type int $orphaned_posts_count Count of orphaned post references (sampled).
|
||||||
|
* @type int $orphaned_terms_count Count of orphaned term references (sampled).
|
||||||
|
* @type int $duplicate_relations Count of duplicate content relation rows.
|
||||||
|
* @type bool $mlp5_schema_ok True if MLP5 tables have expected columns.
|
||||||
|
* @type string $mlp5_schema_error Human-readable schema error, or empty string.
|
||||||
|
* @type string $mlp2_content_table Backup content relations table name.
|
||||||
|
* @type string $mlp2_site_table Backup site relations table name.
|
||||||
|
* @type string $mlp5_content_table MLP5 content relations table name.
|
||||||
|
* @type string $mlp5_site_table MLP5 site relations table name.
|
||||||
|
* @type string $mlp5_relationships_table MLP5 relationships group table name.
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public static function run(): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
||||||
|
$mlp5 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp5();
|
||||||
|
|
||||||
|
$mlp2_site_table = $mlp2->get_site_relations_table();
|
||||||
|
$mlp2_content_table = $mlp2->get_content_relations_table();
|
||||||
|
$mlp5_site_table = $mlp5->get_site_relations_table();
|
||||||
|
$mlp5_content_table = $mlp5->get_content_relations_table();
|
||||||
|
$mlp5_rel_table = $mlp5->get_relationships_table();
|
||||||
|
|
||||||
|
// --- Counts ---
|
||||||
|
$site_count = '';
|
||||||
|
if ( '' !== $mlp2_site_table ) {
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$site_count = (int) $wpdb->get_var( "SELECT COUNT(*) FROM `{$mlp2_site_table}`" );
|
||||||
|
}
|
||||||
|
|
||||||
|
$post_count = 0;
|
||||||
|
$term_count = 0;
|
||||||
|
if ( '' !== $mlp2_content_table ) {
|
||||||
|
$col = self::source_blog_col( $mlp2, $mlp2_content_table );
|
||||||
|
$id = self::source_element_col( $mlp2, $mlp2_content_table );
|
||||||
|
|
||||||
|
if ( '' !== $col && '' !== $id ) {
|
||||||
|
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$post_count = (int) $wpdb->get_var( "SELECT COUNT(DISTINCT {$col}, {$id}) FROM `{$mlp2_content_table}` WHERE ml_type = 'post'" );
|
||||||
|
$term_count = (int) $wpdb->get_var( "SELECT COUNT(DISTINCT {$col}, {$id}) FROM `{$mlp2_content_table}` WHERE ml_type = 'term'" );
|
||||||
|
// phpcs:enable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Orphaned sites ---
|
||||||
|
$orphaned_sites = self::detect_orphaned_sites( $mlp2_site_table );
|
||||||
|
|
||||||
|
// --- Orphaned posts/terms (sampled) ---
|
||||||
|
$orphaned_posts = self::detect_orphaned_content( $mlp2_content_table, 'post', 100 );
|
||||||
|
$orphaned_terms = self::detect_orphaned_content( $mlp2_content_table, 'term', 100 );
|
||||||
|
|
||||||
|
// --- Duplicates ---
|
||||||
|
$duplicates = self::count_duplicate_relations( $mlp2_content_table );
|
||||||
|
|
||||||
|
// --- MLP5 schema validation ---
|
||||||
|
list( $schema_ok, $schema_error ) = self::validate_mlp5_schema( $mlp5_site_table, $mlp5_content_table, $mlp5_rel_table, $mlp2, $mlp2_site_table, $mlp2_content_table );
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'site_relations_count' => (int) $site_count,
|
||||||
|
'post_groups_count' => $post_count,
|
||||||
|
'term_groups_count' => $term_count,
|
||||||
|
'orphaned_site_ids' => $orphaned_sites,
|
||||||
|
'orphaned_posts_count' => $orphaned_posts,
|
||||||
|
'orphaned_terms_count' => $orphaned_terms,
|
||||||
|
'duplicate_relations' => $duplicates,
|
||||||
|
'mlp5_schema_ok' => $schema_ok,
|
||||||
|
'mlp5_schema_error' => $schema_error,
|
||||||
|
'mlp2_content_table' => $mlp2_content_table,
|
||||||
|
'mlp2_site_table' => $mlp2_site_table,
|
||||||
|
'mlp5_content_table' => $mlp5_content_table,
|
||||||
|
'mlp5_site_table' => $mlp5_site_table,
|
||||||
|
'mlp5_relationships_table' => $mlp5_rel_table,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the Step 2 UI.
|
||||||
|
*/
|
||||||
|
public static function render(): void {
|
||||||
|
$data = Robotstxt_Mlp2_Mlp5_Wizard_State::get_step_data( 2 );
|
||||||
|
$ran = ! empty( $data );
|
||||||
|
$ran_ok = $ran && ! empty( $data['mlp5_schema_ok'] );
|
||||||
|
?>
|
||||||
|
<h2><?php esc_html_e( 'Step 2 — Analysis', 'robotstxt-mlp2-mlp5' ); ?></h2>
|
||||||
|
|
||||||
|
<?php if ( ! $ran ) : ?>
|
||||||
|
<p><?php esc_html_e( 'Click "Run Analysis" to scan the MLP2 backup database and validate MLP5 schema compatibility before migrating.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_analysis', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_step" />
|
||||||
|
<input type="hidden" name="mlp_migrator_step_action" value="2_run" />
|
||||||
|
<p><button type="submit" class="button button-primary"><?php esc_html_e( 'Run Analysis', 'robotstxt-mlp2-mlp5' ); ?></button></p>
|
||||||
|
</form>
|
||||||
|
<?php else : ?>
|
||||||
|
|
||||||
|
<?php if ( ! $data['mlp5_schema_ok'] ) : ?>
|
||||||
|
<div class="notice notice-error inline" style="margin:0 0 1em;">
|
||||||
|
<p><strong><?php esc_html_e( 'MLP5 schema incompatibility detected:', 'robotstxt-mlp2-mlp5' ); ?></strong> <?php echo esc_html( $data['mlp5_schema_error'] ); ?></p>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<table class="widefat striped" style="border:0;margin-bottom:1.5em;">
|
||||||
|
<thead><tr><th><?php esc_html_e( 'Category', 'robotstxt-mlp2-mlp5' ); ?></th><th><?php esc_html_e( 'Records found', 'robotstxt-mlp2-mlp5' ); ?></th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
<tr><td><?php esc_html_e( 'Site relations', 'robotstxt-mlp2-mlp5' ); ?></td><td><?php echo esc_html( number_format_i18n( (int) $data['site_relations_count'] ) ); ?></td></tr>
|
||||||
|
<tr><td><?php esc_html_e( 'Post relation groups', 'robotstxt-mlp2-mlp5' ); ?></td><td><?php echo esc_html( number_format_i18n( (int) $data['post_groups_count'] ) ); ?></td></tr>
|
||||||
|
<tr><td><?php esc_html_e( 'Term relation groups', 'robotstxt-mlp2-mlp5' ); ?></td><td><?php echo esc_html( number_format_i18n( (int) $data['term_groups_count'] ) ); ?></td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php if ( ! empty( $data['orphaned_site_ids'] ) || $data['orphaned_posts_count'] > 0 || $data['orphaned_terms_count'] > 0 || $data['duplicate_relations'] > 0 ) : ?>
|
||||||
|
<h3><?php esc_html_e( 'Conflicts (will be skipped and logged)', 'robotstxt-mlp2-mlp5' ); ?></h3>
|
||||||
|
<table class="widefat striped" style="border:0;margin-bottom:1.5em;">
|
||||||
|
<tbody>
|
||||||
|
<?php if ( ! empty( $data['orphaned_site_ids'] ) ) : ?>
|
||||||
|
<tr><td><?php esc_html_e( 'Orphaned sites', 'robotstxt-mlp2-mlp5' ); ?></td><td><?php echo esc_html( implode( ', ', array_map( 'intval', $data['orphaned_site_ids'] ) ) ); ?></td></tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ( $data['orphaned_posts_count'] > 0 ) : ?>
|
||||||
|
<tr><td><?php esc_html_e( 'Orphaned post references', 'robotstxt-mlp2-mlp5' ); ?></td><td><?php echo esc_html( number_format_i18n( (int) $data['orphaned_posts_count'] ) ); ?></td></tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ( $data['orphaned_terms_count'] > 0 ) : ?>
|
||||||
|
<tr><td><?php esc_html_e( 'Orphaned term references', 'robotstxt-mlp2-mlp5' ); ?></td><td><?php echo esc_html( number_format_i18n( (int) $data['orphaned_terms_count'] ) ); ?></td></tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ( $data['duplicate_relations'] > 0 ) : ?>
|
||||||
|
<tr><td><?php esc_html_e( 'Duplicate relation rows', 'robotstxt-mlp2-mlp5' ); ?></td><td><?php echo esc_html( number_format_i18n( (int) $data['duplicate_relations'] ) ); ?></td></tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" style="display:inline;">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_analysis', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_step" />
|
||||||
|
<input type="hidden" name="mlp_migrator_step_action" value="2_run" />
|
||||||
|
<button type="submit" class="button button-secondary"><?php esc_html_e( 'Re-run Analysis', 'robotstxt-mlp2-mlp5' ); ?></button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" style="display:inline;">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_step_2', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_step" />
|
||||||
|
<input type="hidden" name="mlp_migrator_step_action" value="2" />
|
||||||
|
<button type="submit" class="button button-primary"<?php echo $ran_ok ? '' : ' disabled'; ?>><?php esc_html_e( 'Next: Migrate Site Relations', 'robotstxt-mlp2-mlp5' ); ?></button>
|
||||||
|
</form>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Private helpers
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect orphaned site IDs in the MLP2 site relations table.
|
||||||
|
*
|
||||||
|
* @param string $table MLP2 backup site relations table name.
|
||||||
|
* @return int[] Site IDs that no longer exist in the network.
|
||||||
|
*/
|
||||||
|
private static function detect_orphaned_sites( string $table ): array {
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$rows = $wpdb->get_results( "SELECT site_1, site_2 FROM `{$table}`", ARRAY_A );
|
||||||
|
|
||||||
|
if ( empty( $rows ) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$ids = array();
|
||||||
|
foreach ( $rows as $row ) {
|
||||||
|
$ids[] = (int) $row['site_1'];
|
||||||
|
$ids[] = (int) $row['site_2'];
|
||||||
|
}
|
||||||
|
$ids = array_unique( $ids );
|
||||||
|
|
||||||
|
$existing = get_sites(
|
||||||
|
array(
|
||||||
|
'site__in' => $ids,
|
||||||
|
'fields' => 'ids',
|
||||||
|
'number' => count( $ids ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$existing = array_map( 'intval', $existing );
|
||||||
|
|
||||||
|
return array_values( array_diff( $ids, $existing ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample up to $sample content relation rows and count orphaned elements.
|
||||||
|
*
|
||||||
|
* @param string $table MLP2 backup content relations table name.
|
||||||
|
* @param string $type 'post' or 'term'.
|
||||||
|
* @param int $sample Maximum rows to inspect.
|
||||||
|
* @return int Count of orphaned references found in the sample.
|
||||||
|
*/
|
||||||
|
private static function detect_orphaned_content( string $table, string $type, int $sample ): int {
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$type_safe = ( 'term' === $type ) ? 'term' : 'post';
|
||||||
|
|
||||||
|
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$rows = $wpdb->get_results(
|
||||||
|
$wpdb->prepare(
|
||||||
|
"SELECT ml_blogid, ml_elementid FROM `{$table}` WHERE ml_type = %s LIMIT %d",
|
||||||
|
$type_safe,
|
||||||
|
$sample
|
||||||
|
),
|
||||||
|
ARRAY_A
|
||||||
|
);
|
||||||
|
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
|
||||||
|
if ( empty( $rows ) ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$orphans = 0;
|
||||||
|
foreach ( $rows as $row ) {
|
||||||
|
$site_id = (int) $row['ml_blogid'];
|
||||||
|
$element_id = (int) $row['ml_elementid'];
|
||||||
|
|
||||||
|
if ( ! get_site( $site_id ) ) {
|
||||||
|
++$orphans;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_to_blog( $site_id );
|
||||||
|
if ( 'term' === $type_safe ) {
|
||||||
|
$exists = (bool) get_term( $element_id );
|
||||||
|
} else {
|
||||||
|
$exists = (bool) get_post( $element_id );
|
||||||
|
}
|
||||||
|
restore_current_blog();
|
||||||
|
|
||||||
|
if ( ! $exists ) {
|
||||||
|
++$orphans;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $orphans;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count duplicate rows in the content relations table.
|
||||||
|
*
|
||||||
|
* @param string $table MLP2 backup content relations table name.
|
||||||
|
* @return int Count of duplicate rows.
|
||||||
|
*/
|
||||||
|
private static function count_duplicate_relations( string $table ): int {
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$total = (int) $wpdb->get_var( "SELECT COUNT(*) FROM `{$table}`" );
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$distinct = (int) $wpdb->get_var( "SELECT COUNT(*) FROM (SELECT DISTINCT ml_source_blogid, ml_source_elementid, ml_blogid, ml_elementid, ml_type FROM `{$table}`) AS d" );
|
||||||
|
|
||||||
|
return max( 0, $total - $distinct );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate that MLP5 tables have the expected columns.
|
||||||
|
*
|
||||||
|
* @param string $mlp5_site MLP5 site relations table.
|
||||||
|
* @param string $mlp5_content MLP5 content relations table.
|
||||||
|
* @param string $mlp5_rel MLP5 relationships table.
|
||||||
|
* @param Robotstxt_Mlp2_Mlp5_Detector_Mlp2 $mlp2 MLP2 detector.
|
||||||
|
* @param string $mlp2_site MLP2 backup site relations table.
|
||||||
|
* @param string $mlp2_content MLP2 backup content relations table.
|
||||||
|
* @return array [ bool $ok, string $error_message ]
|
||||||
|
*/
|
||||||
|
private static function validate_mlp5_schema(
|
||||||
|
string $mlp5_site,
|
||||||
|
string $mlp5_content,
|
||||||
|
string $mlp5_rel,
|
||||||
|
Robotstxt_Mlp2_Mlp5_Detector_Mlp2 $mlp2,
|
||||||
|
string $mlp2_site,
|
||||||
|
string $mlp2_content
|
||||||
|
): array {
|
||||||
|
if ( '' === $mlp5_site || '' === $mlp5_content ) {
|
||||||
|
return array( false, __( 'MLP5 tables not found. Ensure MultilingualPress 5 is active and has been initialized.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Site relations: expect site_1 and site_2 columns.
|
||||||
|
$site_cols = $mlp2->describe_table( $mlp5_site );
|
||||||
|
if ( ! isset( $site_cols['site_1'], $site_cols['site_2'] ) ) {
|
||||||
|
return array( false, sprintf( /* translators: %s: table name */ __( 'Table %s does not have expected columns (site_1, site_2).', 'robotstxt-mlp2-mlp5' ), $mlp5_site ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Content relations: expect relationship_id, site_id, content_id.
|
||||||
|
$content_cols = $mlp2->describe_table( $mlp5_content );
|
||||||
|
if ( ! isset( $content_cols['relationship_id'], $content_cols['site_id'], $content_cols['content_id'] ) ) {
|
||||||
|
return array( false, sprintf( /* translators: %s: table name */ __( 'Table %s does not have expected columns (relationship_id, site_id, content_id).', 'robotstxt-mlp2-mlp5' ), $mlp5_content ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relationships group table: expect id and type columns.
|
||||||
|
if ( '' !== $mlp5_rel ) {
|
||||||
|
$rel_cols = $mlp2->describe_table( $mlp5_rel );
|
||||||
|
if ( ! isset( $rel_cols['id'], $rel_cols['type'] ) ) {
|
||||||
|
return array( false, sprintf( /* translators: %s: table name */ __( 'Table %s does not have expected columns (id, type).', 'robotstxt-mlp2-mlp5' ), $mlp5_rel ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MLP2 backup: check the content table has the known columns.
|
||||||
|
if ( '' !== $mlp2_content ) {
|
||||||
|
$mlp2_cols = $mlp2->describe_table( $mlp2_content );
|
||||||
|
$required = array( 'ml_blogid', 'ml_elementid', 'ml_type' );
|
||||||
|
foreach ( $required as $col ) {
|
||||||
|
if ( ! isset( $mlp2_cols[ $col ] ) ) {
|
||||||
|
return array( false, sprintf( /* translators: 1: column name, 2: table name */ __( 'MLP2 backup table %2$s is missing expected column "%1$s". Schema may differ from expected.', 'robotstxt-mlp2-mlp5' ), $col, $mlp2_content ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array( true, '' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect the source-blog column name for the MLP2 content relations table.
|
||||||
|
*
|
||||||
|
* @param Robotstxt_Mlp2_Mlp5_Detector_Mlp2 $mlp2 MLP2 detector.
|
||||||
|
* @param string $table Content relations table name.
|
||||||
|
* @return string Column name or empty string.
|
||||||
|
*/
|
||||||
|
private static function source_blog_col( Robotstxt_Mlp2_Mlp5_Detector_Mlp2 $mlp2, string $table ): string {
|
||||||
|
$cols = $mlp2->describe_table( $table );
|
||||||
|
foreach ( array( 'ml_source_blogid', 'ml_blogid' ) as $candidate ) {
|
||||||
|
if ( isset( $cols[ $candidate ] ) ) {
|
||||||
|
return $candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect the source-element column name for the MLP2 content relations table.
|
||||||
|
*
|
||||||
|
* @param Robotstxt_Mlp2_Mlp5_Detector_Mlp2 $mlp2 MLP2 detector.
|
||||||
|
* @param string $table Content relations table name.
|
||||||
|
* @return string Column name or empty string.
|
||||||
|
*/
|
||||||
|
private static function source_element_col( Robotstxt_Mlp2_Mlp5_Detector_Mlp2 $mlp2, string $table ): string {
|
||||||
|
$cols = $mlp2->describe_table( $table );
|
||||||
|
foreach ( array( 'ml_source_elementid', 'ml_elementid' ) as $candidate ) {
|
||||||
|
if ( isset( $cols[ $candidate ] ) ) {
|
||||||
|
return $candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
194
includes/class-robotstxt-mlp2-mlp5-step-cleanup.php
Normal file
194
includes/class-robotstxt-mlp2-mlp5-step-cleanup.php
Normal file
|
|
@ -0,0 +1,194 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Wizard Step 6 — Optional Cleanup.
|
||||||
|
*
|
||||||
|
* Offers three independent cleanup actions:
|
||||||
|
* 1. Deactivate MultilingualPress 2 (if still active).
|
||||||
|
* 2. Drop all MLP2 backup tables ({prefix}mlp2bak_*).
|
||||||
|
* 3. Remove MLP2-related entries from wp_sitemeta.
|
||||||
|
*
|
||||||
|
* All actions require typing "DELETE" in a confirmation field and
|
||||||
|
* verifying a nonce. Actions are logged in the migration log.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Step_Cleanup
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Step_Cleanup {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deactivate MultilingualPress 2 if it is currently network-active.
|
||||||
|
*
|
||||||
|
* @return string 'success', 'skipped', or 'error'.
|
||||||
|
*/
|
||||||
|
public static function deactivate_mlp2(): string {
|
||||||
|
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
||||||
|
|
||||||
|
if ( ! $mlp2->is_active() ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'skipped', 'cleanup', null, null, __( 'MLP2 deactivation: plugin is already inactive.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
return 'skipped';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! function_exists( 'deactivate_plugins' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
deactivate_plugins( $mlp2->get_plugin_file(), true );
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'success', 'cleanup', null, null, __( 'MLP2 plugin deactivated network-wide.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
return 'success';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop all MLP2 backup tables ({prefix}mlp2bak_*).
|
||||||
|
*
|
||||||
|
* Each table drop is logged individually.
|
||||||
|
*
|
||||||
|
* @return array { @type int $dropped, @type int $errors }
|
||||||
|
*/
|
||||||
|
public static function drop_backup_tables(): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$tables = Robotstxt_Mlp2_Mlp5_Table_Preparer::get_backup_tables();
|
||||||
|
$dropped = 0;
|
||||||
|
$errors = 0;
|
||||||
|
|
||||||
|
foreach ( $tables as $table ) {
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$result = $wpdb->query( "DROP TABLE IF EXISTS `{$table}`" );
|
||||||
|
|
||||||
|
if ( false === $result ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'error', 'cleanup', null, null, sprintf( /* translators: %s: table name */ __( 'Failed to drop backup table: %s', 'robotstxt-mlp2-mlp5' ), $table ) );
|
||||||
|
++$errors;
|
||||||
|
} else {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'success', 'cleanup', null, null, sprintf( /* translators: %s: table name */ __( 'Backup table dropped: %s', 'robotstxt-mlp2-mlp5' ), $table ) );
|
||||||
|
++$dropped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'dropped' => $dropped,
|
||||||
|
'errors' => $errors,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete MLP2-related entries from wp_sitemeta.
|
||||||
|
*
|
||||||
|
* Removes all sitemeta keys whose name starts with 'mlp_' (MLP2 prefix).
|
||||||
|
*
|
||||||
|
* @return int Number of keys deleted.
|
||||||
|
*/
|
||||||
|
public static function remove_mlp2_sitemeta(): int {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$like = $wpdb->esc_like( 'mlp_' ) . '%';
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$keys = $wpdb->get_col(
|
||||||
|
$wpdb->prepare(
|
||||||
|
"SELECT meta_key FROM {$wpdb->sitemeta} WHERE meta_key LIKE %s AND site_id = %d",
|
||||||
|
$like,
|
||||||
|
get_current_network_id()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$deleted = 0;
|
||||||
|
foreach ( (array) $keys as $key ) {
|
||||||
|
if ( delete_site_option( $key ) ) {
|
||||||
|
++$deleted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'success', 'cleanup', null, null, sprintf( /* translators: %d: key count */ __( 'Removed %d MLP2 sitemeta entries.', 'robotstxt-mlp2-mlp5' ), $deleted ) );
|
||||||
|
return $deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the Step 6 UI.
|
||||||
|
*/
|
||||||
|
public static function render(): void {
|
||||||
|
$backup_tables = Robotstxt_Mlp2_Mlp5_Table_Preparer::get_backup_tables();
|
||||||
|
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
||||||
|
?>
|
||||||
|
<h2><?php esc_html_e( 'Step 6 — Cleanup (Optional)', 'robotstxt-mlp2-mlp5' ); ?></h2>
|
||||||
|
|
||||||
|
<div class="notice notice-success inline" style="margin:0 0 1.5em;">
|
||||||
|
<p><strong><?php esc_html_e( 'Migration complete!', 'robotstxt-mlp2-mlp5' ); ?></strong> <?php esc_html_e( 'MultilingualPress 5 is now configured with your migrated data. Verify that everything works before performing the optional cleanup below.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p><?php esc_html_e( 'The cleanup actions below are optional and irreversible. MultilingualPress 5 will work correctly whether or not you perform them.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_cleanup', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_step" />
|
||||||
|
<input type="hidden" name="mlp_migrator_step_action" value="6_cleanup" />
|
||||||
|
|
||||||
|
<table class="widefat" style="border:0;max-width:600px;margin-bottom:1.5em;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width:36px;"><input type="checkbox" id="cleanup_deactivate" name="cleanup_deactivate" value="1" /></td>
|
||||||
|
<td><label for="cleanup_deactivate">
|
||||||
|
<?php if ( $mlp2->is_active() ) : ?>
|
||||||
|
<strong><?php esc_html_e( 'Deactivate MultilingualPress 2 (network-wide)', 'robotstxt-mlp2-mlp5' ); ?></strong>
|
||||||
|
<?php else : ?>
|
||||||
|
<strong><?php esc_html_e( 'Deactivate MultilingualPress 2', 'robotstxt-mlp2-mlp5' ); ?></strong>
|
||||||
|
<em style="color:#888;"> — <?php esc_html_e( 'already inactive', 'robotstxt-mlp2-mlp5' ); ?></em>
|
||||||
|
<?php endif; ?>
|
||||||
|
</label></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><input type="checkbox" id="cleanup_drop_tables" name="cleanup_drop_tables" value="1" disabled /></td>
|
||||||
|
<td><label for="cleanup_drop_tables">
|
||||||
|
<strong><?php esc_html_e( 'Delete MLP2 backup database tables', 'robotstxt-mlp2-mlp5' ); ?></strong>
|
||||||
|
<span style="color:#888;"> (<?php echo esc_html( sprintf( /* translators: %d: table count */ _n( '%d table', '%d tables', count( $backup_tables ), 'robotstxt-mlp2-mlp5' ), count( $backup_tables ) ) ); ?>: <code><?php echo esc_html( implode( ', ', $backup_tables ) ); ?></code>)</span>
|
||||||
|
<br><em style="color:#d63638;"><?php esc_html_e( 'Irreversible. Only do this after verifying the migration in MLP5.', 'robotstxt-mlp2-mlp5' ); ?></em>
|
||||||
|
</label></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><input type="checkbox" id="cleanup_sitemeta" name="cleanup_sitemeta" value="1" /></td>
|
||||||
|
<td><label for="cleanup_sitemeta">
|
||||||
|
<strong><?php esc_html_e( 'Delete MLP2 network settings from wp_sitemeta', 'robotstxt-mlp2-mlp5' ); ?></strong>
|
||||||
|
</label></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label for="cleanup_confirm"><strong><?php esc_html_e( 'Type DELETE to confirm:', 'robotstxt-mlp2-mlp5' ); ?></strong></label><br>
|
||||||
|
<input type="text" id="cleanup_confirm" name="cleanup_confirm" value="" placeholder="DELETE" autocomplete="off" style="font-family:monospace;width:160px;margin-top:.25em;" />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<button type="submit" id="cleanup_submit" class="button button-primary" disabled>
|
||||||
|
<?php esc_html_e( 'Proceed with cleanup', 'robotstxt-mlp2-mlp5' ); ?>
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var chkDeactivate = document.getElementById('cleanup_deactivate');
|
||||||
|
var chkTables = document.getElementById('cleanup_drop_tables');
|
||||||
|
var inputConfirm = document.getElementById('cleanup_confirm');
|
||||||
|
var btnSubmit = document.getElementById('cleanup_submit');
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
chkTables.disabled = ! chkDeactivate.checked;
|
||||||
|
if ( ! chkDeactivate.checked ) { chkTables.checked = false; }
|
||||||
|
btnSubmit.disabled = inputConfirm.value !== 'DELETE';
|
||||||
|
}
|
||||||
|
|
||||||
|
chkDeactivate.addEventListener('change', update);
|
||||||
|
inputConfirm.addEventListener('input', update);
|
||||||
|
update();
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
342
includes/class-robotstxt-mlp2-mlp5-step-content-relations.php
Normal file
342
includes/class-robotstxt-mlp2-mlp5-step-content-relations.php
Normal file
|
|
@ -0,0 +1,342 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Wizard Step 4 — Content Relations Migration.
|
||||||
|
*
|
||||||
|
* Processes post and term relation groups in batches via AJAX.
|
||||||
|
* State (offsets, totals, completion) is persisted in Wizard_State step 4 data.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Step_Content_Relations
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Step_Content_Relations {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of groups to process per AJAX batch.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
const BATCH_SIZE = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run one batch of content relations.
|
||||||
|
*
|
||||||
|
* Reads the current offset from wizard state, processes BATCH_SIZE groups,
|
||||||
|
* updates state, and returns a progress snapshot.
|
||||||
|
*
|
||||||
|
* @return array Progress snapshot (see get_progress()).
|
||||||
|
*/
|
||||||
|
public static function run_batch(): array {
|
||||||
|
$state = Robotstxt_Mlp2_Mlp5_Wizard_State::get_step_data( 4 );
|
||||||
|
|
||||||
|
// Initialise totals on first call.
|
||||||
|
if ( empty( $state ) ) {
|
||||||
|
$state = array(
|
||||||
|
'post_total' => Robotstxt_Mlp2_Mlp5_Reader_Content_Relations::count_groups( 'post' ),
|
||||||
|
'term_total' => Robotstxt_Mlp2_Mlp5_Reader_Content_Relations::count_groups( 'term' ),
|
||||||
|
'post_offset' => 0,
|
||||||
|
'term_offset' => 0,
|
||||||
|
'post_done' => false,
|
||||||
|
'term_done' => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process posts first, then terms.
|
||||||
|
if ( ! $state['post_done'] ) {
|
||||||
|
$groups = Robotstxt_Mlp2_Mlp5_Reader_Content_Relations::get_groups_batch( 'post', (int) $state['post_offset'], self::BATCH_SIZE );
|
||||||
|
$state['post_offset'] += count( $groups );
|
||||||
|
self::process_groups( $groups );
|
||||||
|
|
||||||
|
if ( empty( $groups ) || (int) $state['post_offset'] >= (int) $state['post_total'] ) {
|
||||||
|
$state['post_done'] = true;
|
||||||
|
}
|
||||||
|
} elseif ( ! $state['term_done'] ) {
|
||||||
|
$groups = Robotstxt_Mlp2_Mlp5_Reader_Content_Relations::get_groups_batch( 'term', (int) $state['term_offset'], self::BATCH_SIZE );
|
||||||
|
$state['term_offset'] += count( $groups );
|
||||||
|
self::process_groups( $groups );
|
||||||
|
|
||||||
|
if ( empty( $groups ) || (int) $state['term_offset'] >= (int) $state['term_total'] ) {
|
||||||
|
$state['term_done'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Robotstxt_Mlp2_Mlp5_Wizard_State::set_step_data( 4, $state );
|
||||||
|
|
||||||
|
return self::build_progress( $state );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current progress snapshot without running any work.
|
||||||
|
*
|
||||||
|
* @return array {
|
||||||
|
* @type int $total Total groups to process.
|
||||||
|
* @type int $processed Groups processed so far.
|
||||||
|
* @type int $migrated Successfully written to MLP5.
|
||||||
|
* @type int $skipped Skipped (orphaned, already exists, etc.).
|
||||||
|
* @type int $errors Failed writes.
|
||||||
|
* @type bool $done True when all groups (post + term) have been processed.
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public static function get_progress(): array {
|
||||||
|
$state = Robotstxt_Mlp2_Mlp5_Wizard_State::get_step_data( 4 );
|
||||||
|
if ( empty( $state ) ) {
|
||||||
|
return array(
|
||||||
|
'total' => 0,
|
||||||
|
'processed' => 0,
|
||||||
|
'migrated' => 0,
|
||||||
|
'skipped' => 0,
|
||||||
|
'errors' => 0,
|
||||||
|
'done' => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return self::build_progress( $state );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the Step 4 UI.
|
||||||
|
*/
|
||||||
|
public static function render(): void {
|
||||||
|
$progress = self::get_progress();
|
||||||
|
$done = $progress['done'];
|
||||||
|
$nonce = wp_create_nonce( Robotstxt_Mlp2_Mlp5_Ajax::NONCE_ACTION );
|
||||||
|
?>
|
||||||
|
<h2><?php esc_html_e( 'Step 4 — Content Relations', 'robotstxt-mlp2-mlp5' ); ?></h2>
|
||||||
|
<p><?php esc_html_e( 'This step migrates all post and term relationships in batches. On large sites this can take several minutes. You can pause and resume at any time.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
|
||||||
|
<div id="mlp-progress-wrap" style="max-width:500px;margin-bottom:1.5em;">
|
||||||
|
<p id="mlp-progress-label">
|
||||||
|
<?php
|
||||||
|
printf(
|
||||||
|
/* translators: 1: processed count, 2: total count */
|
||||||
|
esc_html__( 'Processed %1$s of %2$s groups', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
'<strong id="mlp-processed">' . esc_html( number_format_i18n( $progress['processed'] ) ) . '</strong>',
|
||||||
|
'<strong id="mlp-total">' . esc_html( number_format_i18n( $progress['total'] ) ) . '</strong>'
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
<progress id="mlp-progress-bar" max="<?php echo esc_attr( (string) max( 1, $progress['total'] ) ); ?>" value="<?php echo esc_attr( (string) $progress['processed'] ); ?>" style="width:100%;height:20px;"></progress>
|
||||||
|
<table class="widefat striped" style="border:0;margin-top:.75em;">
|
||||||
|
<tbody>
|
||||||
|
<tr><td><?php esc_html_e( 'Migrated', 'robotstxt-mlp2-mlp5' ); ?></td><td id="mlp-migrated"><?php echo esc_html( number_format_i18n( $progress['migrated'] ) ); ?></td></tr>
|
||||||
|
<tr><td><?php esc_html_e( 'Skipped', 'robotstxt-mlp2-mlp5' ); ?></td><td id="mlp-skipped"><?php echo esc_html( number_format_i18n( $progress['skipped'] ) ); ?></td></tr>
|
||||||
|
<tr><td><?php esc_html_e( 'Errors', 'robotstxt-mlp2-mlp5' ); ?></td><td id="mlp-errors"><?php echo esc_html( number_format_i18n( $progress['errors'] ) ); ?></td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ( $done ) : ?>
|
||||||
|
<p style="color:#46b450;font-weight:600;"><?php esc_html_e( 'Content relations migration complete.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
<?php else : ?>
|
||||||
|
<p>
|
||||||
|
<button id="mlp-btn-start" class="button button-primary"><?php echo $progress['processed'] > 0 ? esc_html__( 'Resume', 'robotstxt-mlp2-mlp5' ) : esc_html__( 'Start', 'robotstxt-mlp2-mlp5' ); ?></button>
|
||||||
|
<button id="mlp-btn-pause" class="button" style="display:none;"><?php esc_html_e( 'Pause', 'robotstxt-mlp2-mlp5' ); ?></button>
|
||||||
|
<span id="mlp-status" style="margin-left:.75em;"></span>
|
||||||
|
</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ( $done ) : ?>
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_step_4', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_step" />
|
||||||
|
<input type="hidden" name="mlp_migrator_step_action" value="4" />
|
||||||
|
<p><button type="submit" class="button button-primary"><?php esc_html_e( 'Next: Verification', 'robotstxt-mlp2-mlp5' ); ?></button></p>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var ajaxUrl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php' ) ); ?>;
|
||||||
|
var nonce = <?php echo wp_json_encode( $nonce ); ?>;
|
||||||
|
var running = false;
|
||||||
|
|
||||||
|
function updateUI( data ) {
|
||||||
|
document.getElementById('mlp-processed').textContent = data.processed;
|
||||||
|
document.getElementById('mlp-total').textContent = data.total;
|
||||||
|
document.getElementById('mlp-migrated').textContent = data.migrated;
|
||||||
|
document.getElementById('mlp-skipped').textContent = data.skipped;
|
||||||
|
document.getElementById('mlp-errors').textContent = data.errors;
|
||||||
|
var bar = document.getElementById('mlp-progress-bar');
|
||||||
|
if ( bar ) { bar.max = Math.max(1, data.total); bar.value = data.processed; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function runBatch() {
|
||||||
|
if ( ! running ) { return; }
|
||||||
|
var body = new URLSearchParams({ action: 'mlp_migrator_run_batch', nonce: nonce });
|
||||||
|
fetch( ajaxUrl, { method: 'POST', body: body, credentials: 'same-origin' } )
|
||||||
|
.then( function(r) { return r.json(); } )
|
||||||
|
.then( function(res) {
|
||||||
|
if ( ! res.success ) {
|
||||||
|
document.getElementById('mlp-status').textContent = res.data.message || '<?php echo esc_js( __( 'Error during migration.', 'robotstxt-mlp2-mlp5' ) ); ?>';
|
||||||
|
running = false;
|
||||||
|
document.getElementById('mlp-btn-start').style.display = '';
|
||||||
|
document.getElementById('mlp-btn-pause').style.display = 'none';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateUI( res.data );
|
||||||
|
if ( res.data.done ) {
|
||||||
|
running = false;
|
||||||
|
document.getElementById('mlp-status').textContent = '<?php echo esc_js( __( 'Done! Reload the page to continue.', 'robotstxt-mlp2-mlp5' ) ); ?>';
|
||||||
|
document.getElementById('mlp-btn-start').style.display = 'none';
|
||||||
|
document.getElementById('mlp-btn-pause').style.display = 'none';
|
||||||
|
setTimeout( function() { window.location.reload(); }, 1500 );
|
||||||
|
} else {
|
||||||
|
runBatch();
|
||||||
|
}
|
||||||
|
} )
|
||||||
|
.catch( function() {
|
||||||
|
document.getElementById('mlp-status').textContent = '<?php echo esc_js( __( 'Network error. Click Resume to continue.', 'robotstxt-mlp2-mlp5' ) ); ?>';
|
||||||
|
running = false;
|
||||||
|
document.getElementById('mlp-btn-start').style.display = '';
|
||||||
|
document.getElementById('mlp-btn-pause').style.display = 'none';
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
var btnStart = document.getElementById('mlp-btn-start');
|
||||||
|
var btnPause = document.getElementById('mlp-btn-pause');
|
||||||
|
|
||||||
|
if ( btnStart ) {
|
||||||
|
btnStart.addEventListener( 'click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
running = true;
|
||||||
|
btnStart.style.display = 'none';
|
||||||
|
btnPause.style.display = '';
|
||||||
|
document.getElementById('mlp-status').textContent = '<?php echo esc_js( __( 'Running…', 'robotstxt-mlp2-mlp5' ) ); ?>';
|
||||||
|
runBatch();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
if ( btnPause ) {
|
||||||
|
btnPause.addEventListener( 'click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
running = false;
|
||||||
|
btnPause.style.display = 'none';
|
||||||
|
btnStart.style.display = '';
|
||||||
|
document.getElementById('mlp-status').textContent = '<?php echo esc_js( __( 'Paused.', 'robotstxt-mlp2-mlp5' ) ); ?>';
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
// Private helpers
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a set of groups and log the results.
|
||||||
|
*
|
||||||
|
* @param array[] $groups Groups from Reader_Content_Relations::get_groups_batch().
|
||||||
|
*/
|
||||||
|
private static function process_groups( array $groups ): void {
|
||||||
|
foreach ( $groups as $group ) {
|
||||||
|
$type = $group['type'];
|
||||||
|
$members = $group['members'];
|
||||||
|
|
||||||
|
// Idempotency: skip if the first member is already in MLP5.
|
||||||
|
$first = $members[0];
|
||||||
|
if ( Robotstxt_Mlp2_Mlp5_Writer_Content_Relations::pair_exists_in_mlp5( $first['site_id'], $first['element_id'] ) ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log(
|
||||||
|
'skipped',
|
||||||
|
'post_relation' === $type || 'post' === $type ? 'post_relation' : 'term_relation',
|
||||||
|
$first['site_id'],
|
||||||
|
$first['element_id'],
|
||||||
|
__( 'Relation already exists in MLP5 (idempotent skip).', 'robotstxt-mlp2-mlp5' )
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate members: skip those where site or content no longer exists.
|
||||||
|
$valid_members = array();
|
||||||
|
foreach ( $members as $m ) {
|
||||||
|
if ( ! get_site( $m['site_id'] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch_to_blog( $m['site_id'] );
|
||||||
|
if ( 'term' === $type ) {
|
||||||
|
$exists = (bool) get_term( $m['element_id'] );
|
||||||
|
} else {
|
||||||
|
$exists = (bool) get_post( $m['element_id'] );
|
||||||
|
}
|
||||||
|
restore_current_blog();
|
||||||
|
if ( $exists ) {
|
||||||
|
$valid_members[] = $m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( count( $valid_members ) < 2 ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log(
|
||||||
|
'skipped',
|
||||||
|
'term' === $type ? 'term_relation' : 'post_relation',
|
||||||
|
$first['site_id'],
|
||||||
|
$first['element_id'],
|
||||||
|
__( 'Fewer than 2 valid members after orphan check. Skipped.', 'robotstxt-mlp2-mlp5' )
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write to MLP5.
|
||||||
|
$context = 'term' === $type ? 'term_relation' : 'post_relation';
|
||||||
|
$written = Robotstxt_Mlp2_Mlp5_Writer_Content_Relations::create_group( $type, $valid_members );
|
||||||
|
|
||||||
|
if ( $written ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'success', $context, $first['site_id'], $first['element_id'], sprintf( /* translators: %d: member count */ __( 'Group migrated with %d members.', 'robotstxt-mlp2-mlp5' ), count( $valid_members ) ) );
|
||||||
|
} else {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'error', $context, $first['site_id'], $first['element_id'], __( 'Failed to write group to MLP5.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a progress snapshot from a state array.
|
||||||
|
*
|
||||||
|
* @param array $state Step 4 state array.
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function build_progress( array $state ): array {
|
||||||
|
$post_total = (int) ( $state['post_total'] ?? 0 );
|
||||||
|
$term_total = (int) ( $state['term_total'] ?? 0 );
|
||||||
|
$post_offset = (int) ( $state['post_offset'] ?? 0 );
|
||||||
|
$term_offset = (int) ( $state['term_offset'] ?? 0 );
|
||||||
|
$post_done = ! empty( $state['post_done'] );
|
||||||
|
$term_done = ! empty( $state['term_done'] );
|
||||||
|
|
||||||
|
$migrated = Robotstxt_Mlp2_Mlp5_Logger::count( array( 'type' => 'success' ) );
|
||||||
|
$skipped = Robotstxt_Mlp2_Mlp5_Logger::count( array( 'type' => 'skipped' ) );
|
||||||
|
$errors = Robotstxt_Mlp2_Mlp5_Logger::count( array( 'type' => 'error' ) );
|
||||||
|
|
||||||
|
// Subtract site_relation log entries (those belong to step 3).
|
||||||
|
$migrated -= Robotstxt_Mlp2_Mlp5_Logger::count(
|
||||||
|
array(
|
||||||
|
'type' => 'success',
|
||||||
|
'context' => 'site_relation',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$skipped -= Robotstxt_Mlp2_Mlp5_Logger::count(
|
||||||
|
array(
|
||||||
|
'type' => 'skipped',
|
||||||
|
'context' => 'site_relation',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$errors -= Robotstxt_Mlp2_Mlp5_Logger::count(
|
||||||
|
array(
|
||||||
|
'type' => 'error',
|
||||||
|
'context' => 'site_relation',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'total' => $post_total + $term_total,
|
||||||
|
'processed' => $post_offset + $term_offset,
|
||||||
|
'migrated' => max( 0, $migrated ),
|
||||||
|
'skipped' => max( 0, $skipped ),
|
||||||
|
'errors' => max( 0, $errors ),
|
||||||
|
'done' => $post_done && $term_done,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
142
includes/class-robotstxt-mlp2-mlp5-step-preflight.php
Normal file
142
includes/class-robotstxt-mlp2-mlp5-step-preflight.php
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Wizard Step 1 — Preflight checks.
|
||||||
|
*
|
||||||
|
* Verifies that the system is ready to run the migration:
|
||||||
|
* - MLP2 backup tables exist (preparation step was done)
|
||||||
|
* - MultilingualPress 5 is network-active
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Step_Preflight
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Step_Preflight {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run all preflight checks and return a structured result.
|
||||||
|
*
|
||||||
|
* @return array {
|
||||||
|
* @type bool $mlp2_tables_renamed Backup tables exist (rename step was done).
|
||||||
|
* @type bool $mlp2_original_present Original MLP2 tables still exist (rename not done).
|
||||||
|
* @type string[] $mlp2_backup_tables List of backup table names found.
|
||||||
|
* @type bool $mlp2_active MLP2 plugin is network-active (informational).
|
||||||
|
* @type string $mlp2_version MLP2 plugin version string, or empty.
|
||||||
|
* @type bool $mlp5_active MLP5 plugin is network-active.
|
||||||
|
* @type string $mlp5_version MLP5 plugin version string, or empty.
|
||||||
|
* @type bool $can_proceed True when migration may start.
|
||||||
|
* @type string[] $blocking_issues Human-readable blocking problem descriptions.
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public static function run(): array {
|
||||||
|
$mlp2 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp2();
|
||||||
|
$mlp5 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp5();
|
||||||
|
$backup_tables = Robotstxt_Mlp2_Mlp5_Table_Preparer::get_backup_tables();
|
||||||
|
$issues = array();
|
||||||
|
|
||||||
|
$tables_renamed = count( $backup_tables ) > 0;
|
||||||
|
$original_present = Robotstxt_Mlp2_Mlp5_Table_Preparer::has_original_tables();
|
||||||
|
$mlp5_active = $mlp5->is_active();
|
||||||
|
|
||||||
|
if ( ! $tables_renamed ) {
|
||||||
|
if ( $original_present ) {
|
||||||
|
$issues[] = __( 'MLP2 tables have not been renamed yet. Go back to the plugin status page and click "Rename MLP2 tables".', 'robotstxt-mlp2-mlp5' );
|
||||||
|
} else {
|
||||||
|
$issues[] = __( 'No MLP2 tables found (neither original nor backup). Restore your database from a backup before proceeding.', 'robotstxt-mlp2-mlp5' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $mlp5_active ) {
|
||||||
|
$issues[] = __( 'MultilingualPress 5 is not network-active. Activate it before running the migration.', 'robotstxt-mlp2-mlp5' );
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'mlp2_tables_renamed' => $tables_renamed,
|
||||||
|
'mlp2_original_present' => $original_present,
|
||||||
|
'mlp2_backup_tables' => $backup_tables,
|
||||||
|
'mlp2_active' => $mlp2->is_active(),
|
||||||
|
'mlp2_version' => $mlp2->get_version(),
|
||||||
|
'mlp5_active' => $mlp5_active,
|
||||||
|
'mlp5_version' => $mlp5->get_version(),
|
||||||
|
'can_proceed' => $tables_renamed && $mlp5_active,
|
||||||
|
'blocking_issues' => $issues,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the Step 1 UI.
|
||||||
|
*/
|
||||||
|
public static function render(): void {
|
||||||
|
$checks = self::run();
|
||||||
|
$can_proceed = $checks['can_proceed'];
|
||||||
|
?>
|
||||||
|
<h2><?php esc_html_e( 'Step 1 — Preflight Checks', 'robotstxt-mlp2-mlp5' ); ?></h2>
|
||||||
|
|
||||||
|
<table class="widefat striped" style="border:0;margin-bottom:1.5em;">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="width:60%"><?php esc_html_e( 'MLP2 backup tables (preparation done)', 'robotstxt-mlp2-mlp5' ); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php if ( $checks['mlp2_tables_renamed'] ) : ?>
|
||||||
|
<span style="color:#46b450;">✓ <?php echo esc_html( sprintf( /* translators: %d: table count */ _n( '%d table ready', '%d tables ready', count( $checks['mlp2_backup_tables'] ), 'robotstxt-mlp2-mlp5' ), count( $checks['mlp2_backup_tables'] ) ) ); ?></span>
|
||||||
|
<?php elseif ( $checks['mlp2_original_present'] ) : ?>
|
||||||
|
<span style="color:#d63638;">✗ <?php esc_html_e( 'Original tables still present — rename step not done', 'robotstxt-mlp2-mlp5' ); ?></span>
|
||||||
|
<?php else : ?>
|
||||||
|
<span style="color:#d63638;">✗ <?php esc_html_e( 'No MLP2 tables found', 'robotstxt-mlp2-mlp5' ); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php esc_html_e( 'MLP2 plugin (active — informational only)', 'robotstxt-mlp2-mlp5' ); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php if ( $checks['mlp2_active'] ) : ?>
|
||||||
|
<span style="color:#dba617;">⚠ <?php esc_html_e( 'Active — consider deactivating before proceeding', 'robotstxt-mlp2-mlp5' ); ?></span>
|
||||||
|
<?php else : ?>
|
||||||
|
<span style="color:#46b450;">✓ <?php esc_html_e( 'Inactive (expected)', 'robotstxt-mlp2-mlp5' ); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><?php esc_html_e( 'MultilingualPress 5 (network-active)', 'robotstxt-mlp2-mlp5' ); ?></td>
|
||||||
|
<td>
|
||||||
|
<?php if ( $checks['mlp5_active'] ) : ?>
|
||||||
|
<span style="color:#46b450;">✓ <?php echo esc_html( sprintf( /* translators: %s: version */ __( 'Active (v%s)', 'robotstxt-mlp2-mlp5' ), $checks['mlp5_version'] ) ); ?></span>
|
||||||
|
<?php else : ?>
|
||||||
|
<span style="color:#d63638;">✗ <?php esc_html_e( 'Not active', 'robotstxt-mlp2-mlp5' ); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<?php if ( ! empty( $checks['blocking_issues'] ) ) : ?>
|
||||||
|
<div class="notice notice-error inline" style="margin:0 0 1em;">
|
||||||
|
<ul style="margin:.5em 0 .5em 1em;list-style:disc;">
|
||||||
|
<?php foreach ( $checks['blocking_issues'] as $issue ) : ?>
|
||||||
|
<li><?php echo esc_html( $issue ); ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_step_1', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_step" />
|
||||||
|
<input type="hidden" name="mlp_migrator_step_action" value="1" />
|
||||||
|
<p>
|
||||||
|
<button type="submit" class="button button-primary"<?php echo $can_proceed ? '' : ' disabled'; ?>>
|
||||||
|
<?php esc_html_e( 'Next: Run Analysis', 'robotstxt-mlp2-mlp5' ); ?>
|
||||||
|
</button>
|
||||||
|
<?php if ( ! $can_proceed ) : ?>
|
||||||
|
<span style="margin-left:.75em;color:#d63638;"><?php esc_html_e( 'Resolve the issues above before continuing.', 'robotstxt-mlp2-mlp5' ); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
113
includes/class-robotstxt-mlp2-mlp5-step-site-relations.php
Normal file
113
includes/class-robotstxt-mlp2-mlp5-step-site-relations.php
Normal file
|
|
@ -0,0 +1,113 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Wizard Step 3 — Site Relations Migration.
|
||||||
|
*
|
||||||
|
* Reads all MLP2 backup site relations and writes them to MLP5,
|
||||||
|
* skipping orphaned or already-migrated pairs and logging all results.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Step_Site_Relations
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Step_Site_Relations {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the site relations migration.
|
||||||
|
*
|
||||||
|
* @return array {
|
||||||
|
* @type int $migrated Number of relations successfully written.
|
||||||
|
* @type int $skipped Number of relations skipped.
|
||||||
|
* @type int $errors Number of relations that failed.
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public static function run(): array {
|
||||||
|
$rows = Robotstxt_Mlp2_Mlp5_Reader_Site_Relations::get_all();
|
||||||
|
$orphaned_site_ids = array_map( 'intval', (array) ( Robotstxt_Mlp2_Mlp5_Wizard_State::get_step_data( 2 )['orphaned_site_ids'] ?? array() ) );
|
||||||
|
|
||||||
|
$migrated = 0;
|
||||||
|
$skipped = 0;
|
||||||
|
$errors = 0;
|
||||||
|
|
||||||
|
foreach ( $rows as $row ) {
|
||||||
|
$site_1 = $row['site_1'];
|
||||||
|
$site_2 = $row['site_2'];
|
||||||
|
|
||||||
|
// Skip orphaned sites.
|
||||||
|
if ( in_array( $site_1, $orphaned_site_ids, true ) || in_array( $site_2, $orphaned_site_ids, true ) ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'skipped', 'site_relation', $site_1, $site_2, __( 'One or both sites no longer exist in the network.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
++$skipped;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip if already exists in MLP5.
|
||||||
|
if ( Robotstxt_Mlp2_Mlp5_Writer_Site_Relations::relation_exists( $site_1, $site_2 ) ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'skipped', 'site_relation', $site_1, $site_2, __( 'Relation already exists in MLP5 (idempotent skip).', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
++$skipped;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write.
|
||||||
|
if ( Robotstxt_Mlp2_Mlp5_Writer_Site_Relations::write_relation( $site_1, $site_2 ) ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'success', 'site_relation', $site_1, $site_2, __( 'Site relation migrated successfully.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
++$migrated;
|
||||||
|
} else {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::log( 'error', 'site_relation', $site_1, $site_2, __( 'Failed to write site relation to MLP5.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
++$errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'migrated' => $migrated,
|
||||||
|
'skipped' => $skipped,
|
||||||
|
'errors' => $errors,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the Step 3 UI.
|
||||||
|
*/
|
||||||
|
public static function render(): void {
|
||||||
|
$data = Robotstxt_Mlp2_Mlp5_Wizard_State::get_step_data( 3 );
|
||||||
|
$ran = ! empty( $data );
|
||||||
|
?>
|
||||||
|
<h2><?php esc_html_e( 'Step 3 — Site Relations', 'robotstxt-mlp2-mlp5' ); ?></h2>
|
||||||
|
<p><?php esc_html_e( 'This step migrates site connections and language assignments from MLP2 to MLP5. It usually completes in seconds.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
|
||||||
|
<?php if ( $ran ) : ?>
|
||||||
|
<table class="widefat striped" style="border:0;max-width:400px;margin-bottom:1.5em;">
|
||||||
|
<tbody>
|
||||||
|
<tr><td><?php esc_html_e( 'Migrated', 'robotstxt-mlp2-mlp5' ); ?></td><td style="color:#46b450;font-weight:600;"><?php echo esc_html( number_format_i18n( (int) ( $data['migrated'] ?? 0 ) ) ); ?></td></tr>
|
||||||
|
<tr><td><?php esc_html_e( 'Skipped', 'robotstxt-mlp2-mlp5' ); ?></td><td><?php echo esc_html( number_format_i18n( (int) ( $data['skipped'] ?? 0 ) ) ); ?></td></tr>
|
||||||
|
<tr><td><?php esc_html_e( 'Errors', 'robotstxt-mlp2-mlp5' ); ?></td><td style="<?php echo (int) ( $data['errors'] ?? 0 ) > 0 ? 'color:#d63638;font-weight:600;' : ''; ?>"><?php echo esc_html( number_format_i18n( (int) ( $data['errors'] ?? 0 ) ) ); ?></td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" style="display:inline;">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_site_relations', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_step" />
|
||||||
|
<input type="hidden" name="mlp_migrator_step_action" value="3_run" />
|
||||||
|
<button type="submit" class="button button-<?php echo $ran ? 'secondary' : 'primary'; ?>">
|
||||||
|
<?php echo $ran ? esc_html__( 'Re-run Site Relations', 'robotstxt-mlp2-mlp5' ) : esc_html__( 'Start Site Relations Migration', 'robotstxt-mlp2-mlp5' ); ?>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
<?php if ( $ran ) : ?>
|
||||||
|
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" style="display:inline;">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_step_3', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_step" />
|
||||||
|
<input type="hidden" name="mlp_migrator_step_action" value="3" />
|
||||||
|
<button type="submit" class="button button-primary"><?php esc_html_e( 'Next: Content Relations', 'robotstxt-mlp2-mlp5' ); ?></button>
|
||||||
|
</form>
|
||||||
|
<?php endif; ?>
|
||||||
|
</p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
154
includes/class-robotstxt-mlp2-mlp5-step-verification.php
Normal file
154
includes/class-robotstxt-mlp2-mlp5-step-verification.php
Normal file
|
|
@ -0,0 +1,154 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Wizard Step 5 — Verification.
|
||||||
|
*
|
||||||
|
* Compares expected totals (from the Analysis step) with actual log counts
|
||||||
|
* and provides a downloadable CSV export of the full migration log.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Step_Verification
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Step_Verification {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the verification summary.
|
||||||
|
*
|
||||||
|
* @return array[] Rows keyed by context with expected/migrated/skipped/errors.
|
||||||
|
*/
|
||||||
|
public static function get_summary(): array {
|
||||||
|
$analysis = Robotstxt_Mlp2_Mlp5_Wizard_State::get_step_data( 2 );
|
||||||
|
|
||||||
|
$contexts = array(
|
||||||
|
'site_relation' => array(
|
||||||
|
'label' => __( 'Site Relations', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
'expected' => (int) ( $analysis['site_relations_count'] ?? 0 ),
|
||||||
|
),
|
||||||
|
'post_relation' => array(
|
||||||
|
'label' => __( 'Post Relations', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
'expected' => (int) ( $analysis['post_groups_count'] ?? 0 ),
|
||||||
|
),
|
||||||
|
'term_relation' => array(
|
||||||
|
'label' => __( 'Term Relations', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
'expected' => (int) ( $analysis['term_groups_count'] ?? 0 ),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$summary = array();
|
||||||
|
foreach ( $contexts as $context => $meta ) {
|
||||||
|
$summary[ $context ] = array(
|
||||||
|
'label' => $meta['label'],
|
||||||
|
'expected' => $meta['expected'],
|
||||||
|
'migrated' => Robotstxt_Mlp2_Mlp5_Logger::count(
|
||||||
|
array(
|
||||||
|
'type' => 'success',
|
||||||
|
'context' => $context,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'skipped' => Robotstxt_Mlp2_Mlp5_Logger::count(
|
||||||
|
array(
|
||||||
|
'type' => 'skipped',
|
||||||
|
'context' => $context,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'errors' => Robotstxt_Mlp2_Mlp5_Logger::count(
|
||||||
|
array(
|
||||||
|
'type' => 'error',
|
||||||
|
'context' => $context,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the CSV export request.
|
||||||
|
*
|
||||||
|
* Must be called on network_admin_init when the export GET param is present.
|
||||||
|
*/
|
||||||
|
public static function maybe_export_csv(): void {
|
||||||
|
check_admin_referer( 'mlp_migrator_export_log', 'mlp_export_nonce' );
|
||||||
|
|
||||||
|
if ( ! current_user_can( 'manage_network' ) ) {
|
||||||
|
wp_die( esc_html__( 'You do not have permission to export the log.', 'robotstxt-mlp2-mlp5' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$csv = Robotstxt_Mlp2_Mlp5_Logger::export_csv();
|
||||||
|
|
||||||
|
header( 'Content-Type: text/csv; charset=UTF-8' );
|
||||||
|
header( 'Content-Disposition: attachment; filename="mlp-migration-log.csv"' );
|
||||||
|
header( 'Pragma: no-cache' );
|
||||||
|
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||||
|
echo $csv;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the Step 5 UI.
|
||||||
|
*/
|
||||||
|
public static function render(): void {
|
||||||
|
$summary = self::get_summary();
|
||||||
|
$export_url = wp_nonce_url(
|
||||||
|
admin_url( 'admin-post.php?action=mlp_migrator_export_log' ),
|
||||||
|
'mlp_migrator_export_log',
|
||||||
|
'mlp_export_nonce'
|
||||||
|
);
|
||||||
|
?>
|
||||||
|
<h2><?php esc_html_e( 'Step 5 — Verification', 'robotstxt-mlp2-mlp5' ); ?></h2>
|
||||||
|
<p><?php esc_html_e( 'Compare expected totals (from the Analysis step) with actual migration results. Download the full log before proceeding to cleanup.', 'robotstxt-mlp2-mlp5' ); ?></p>
|
||||||
|
|
||||||
|
<table class="widefat striped" style="border:0;margin-bottom:1.5em;">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><?php esc_html_e( 'Category', 'robotstxt-mlp2-mlp5' ); ?></th>
|
||||||
|
<th><?php esc_html_e( 'Expected', 'robotstxt-mlp2-mlp5' ); ?></th>
|
||||||
|
<th><?php esc_html_e( 'Migrated', 'robotstxt-mlp2-mlp5' ); ?></th>
|
||||||
|
<th><?php esc_html_e( 'Skipped', 'robotstxt-mlp2-mlp5' ); ?></th>
|
||||||
|
<th><?php esc_html_e( 'Errors', 'robotstxt-mlp2-mlp5' ); ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ( $summary as $row ) : ?>
|
||||||
|
<?php
|
||||||
|
$color = '#46b450'; // Green.
|
||||||
|
if ( (int) $row['errors'] > 0 ) {
|
||||||
|
$color = '#dba617'; // Amber.
|
||||||
|
}
|
||||||
|
if ( 0 === (int) $row['migrated'] && (int) $row['expected'] > 0 ) {
|
||||||
|
$color = '#d63638'; // Red.
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<tr style="border-left:4px solid <?php echo esc_attr( $color ); ?>;">
|
||||||
|
<td><?php echo esc_html( $row['label'] ); ?></td>
|
||||||
|
<td><?php echo esc_html( number_format_i18n( (int) $row['expected'] ) ); ?></td>
|
||||||
|
<td><?php echo esc_html( number_format_i18n( (int) $row['migrated'] ) ); ?></td>
|
||||||
|
<td><?php echo esc_html( number_format_i18n( (int) $row['skipped'] ) ); ?></td>
|
||||||
|
<td><?php echo esc_html( number_format_i18n( (int) $row['errors'] ) ); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a href="<?php echo esc_url( $export_url ); ?>" class="button button-secondary">
|
||||||
|
<?php esc_html_e( 'Download log (CSV)', 'robotstxt-mlp2-mlp5' ); ?>
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
|
||||||
|
<?php wp_nonce_field( 'mlp_migrator_step_5', 'mlp_migrator_nonce' ); ?>
|
||||||
|
<input type="hidden" name="action" value="mlp_migrator_step" />
|
||||||
|
<input type="hidden" name="mlp_migrator_step_action" value="5" />
|
||||||
|
<p><button type="submit" class="button button-primary"><?php esc_html_e( 'Next: Cleanup', 'robotstxt-mlp2-mlp5' ); ?></button></p>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
||||||
250
includes/class-robotstxt-mlp2-mlp5-table-preparer.php
Normal file
250
includes/class-robotstxt-mlp2-mlp5-table-preparer.php
Normal file
|
|
@ -0,0 +1,250 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Table preparation service.
|
||||||
|
*
|
||||||
|
* MultilingualPress 5 refuses to network-activate when it detects tables
|
||||||
|
* with the original MLP2 prefix ({base_prefix}mlp_*). This class renames
|
||||||
|
* those tables to a backup prefix ({base_prefix}mlp2bak_*) so that MLP5
|
||||||
|
* can activate cleanly. The migration wizard then reads from the renamed
|
||||||
|
* backup tables.
|
||||||
|
*
|
||||||
|
* Original name pattern : {base_prefix}mlp_{suffix}
|
||||||
|
* Backup name pattern : {base_prefix}mlp2bak_{suffix}
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Table_Preparer
|
||||||
|
*
|
||||||
|
* All methods are static. No instantiation required.
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Table_Preparer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table name fragment (after base_prefix) that identifies original MLP2 tables.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const ORIGINAL_FRAGMENT = 'mlp_';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table name fragment (after base_prefix) used for renamed backup copies.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const BACKUP_FRAGMENT = 'mlp2bak_';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table suffixes (after base_prefix + ORIGINAL_FRAGMENT) that belong to
|
||||||
|
* this plugin and must never be renamed to backup.
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
const PLUGIN_TABLE_SUFFIXES = array( 'migrator_log' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the backup table name for a given original MLP2 table.
|
||||||
|
*
|
||||||
|
* @param string $original_table Full original table name (including base_prefix).
|
||||||
|
* @return string Backup table name, or empty string if not a valid MLP2 table.
|
||||||
|
*/
|
||||||
|
public static function backup_name( string $original_table ): string {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$orig_prefix = $wpdb->base_prefix . self::ORIGINAL_FRAGMENT;
|
||||||
|
|
||||||
|
if ( ! str_starts_with( $original_table, $orig_prefix ) ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $wpdb->base_prefix . self::BACKUP_FRAGMENT . substr( $original_table, strlen( $orig_prefix ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the original table name for a given backup table.
|
||||||
|
*
|
||||||
|
* @param string $backup_table Full backup table name (including base_prefix).
|
||||||
|
* @return string Original table name, or empty string if not a backup table.
|
||||||
|
*/
|
||||||
|
public static function original_name( string $backup_table ): string {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$bak_prefix = $wpdb->base_prefix . self::BACKUP_FRAGMENT;
|
||||||
|
|
||||||
|
if ( ! str_starts_with( $backup_table, $bak_prefix ) ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $wpdb->base_prefix . self::ORIGINAL_FRAGMENT . substr( $backup_table, strlen( $bak_prefix ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all tables in the database with the original MLP2 prefix.
|
||||||
|
*
|
||||||
|
* @return string[] Array of full table names.
|
||||||
|
*/
|
||||||
|
public static function get_original_tables(): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$like = $wpdb->esc_like( $wpdb->base_prefix . self::ORIGINAL_FRAGMENT ) . '%';
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$tables = $wpdb->get_col( $wpdb->prepare( 'SHOW TABLES LIKE %s', $like ) );
|
||||||
|
|
||||||
|
return is_array( $tables ) ? $tables : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all tables in the database with the backup prefix.
|
||||||
|
*
|
||||||
|
* @return string[] Array of full table names.
|
||||||
|
*/
|
||||||
|
public static function get_backup_tables(): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$like = $wpdb->esc_like( $wpdb->base_prefix . self::BACKUP_FRAGMENT ) . '%';
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$tables = $wpdb->get_col( $wpdb->prepare( 'SHOW TABLES LIKE %s', $like ) );
|
||||||
|
|
||||||
|
return is_array( $tables ) ? $tables : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether any original MLP2 tables exist in the database.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function has_original_tables(): bool {
|
||||||
|
return count( self::get_original_tables() ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether any backup (renamed) MLP2 tables exist in the database.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function has_backup_tables(): bool {
|
||||||
|
return count( self::get_backup_tables() ) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rename all original MLP2 tables to their backup equivalents.
|
||||||
|
*
|
||||||
|
* Tables that already have a backup copy are skipped. Tables that cannot
|
||||||
|
* be converted to a valid backup name are recorded as errors.
|
||||||
|
*
|
||||||
|
* @return array {
|
||||||
|
* @type string[] $renamed Tables successfully renamed.
|
||||||
|
* @type string[] $skipped Tables skipped (backup name already exists).
|
||||||
|
* @type string[] $errors Tables that could not be renamed.
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public static function rename_to_backup(): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$result = array(
|
||||||
|
'renamed' => array(),
|
||||||
|
'skipped' => array(),
|
||||||
|
'errors' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( self::get_original_tables() as $table ) {
|
||||||
|
$backup = self::backup_name( $table );
|
||||||
|
|
||||||
|
if ( '' === $backup ) {
|
||||||
|
$result['errors'][] = $table;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip tables that belong to this plugin.
|
||||||
|
$suffix = substr( $table, strlen( $wpdb->base_prefix . self::ORIGINAL_FRAGMENT ) );
|
||||||
|
if ( in_array( $suffix, self::PLUGIN_TABLE_SUFFIXES, true ) ) {
|
||||||
|
$result['skipped'][] = $table;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( self::table_exists( $backup ) ) {
|
||||||
|
$result['skipped'][] = $table;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$renamed = $wpdb->query( "RENAME TABLE `{$table}` TO `{$backup}`" );
|
||||||
|
|
||||||
|
if ( false === $renamed ) {
|
||||||
|
$result['errors'][] = $table;
|
||||||
|
} else {
|
||||||
|
$result['renamed'][] = $table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restore backup tables to their original names.
|
||||||
|
*
|
||||||
|
* Intended as a recovery mechanism if the rename needs to be undone before
|
||||||
|
* MLP5 has been activated. Tables whose original name already exists in the
|
||||||
|
* database are skipped.
|
||||||
|
*
|
||||||
|
* @return array {
|
||||||
|
* @type string[] $restored Tables successfully restored.
|
||||||
|
* @type string[] $skipped Tables skipped (original name already exists).
|
||||||
|
* @type string[] $errors Tables that could not be restored.
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
public static function restore_from_backup(): array {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$result = array(
|
||||||
|
'restored' => array(),
|
||||||
|
'skipped' => array(),
|
||||||
|
'errors' => array(),
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( self::get_backup_tables() as $table ) {
|
||||||
|
$original = self::original_name( $table );
|
||||||
|
|
||||||
|
if ( '' === $original ) {
|
||||||
|
$result['errors'][] = $table;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( self::table_exists( $original ) ) {
|
||||||
|
$result['skipped'][] = $table;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
$restored = $wpdb->query( "RENAME TABLE `{$table}` TO `{$original}`" );
|
||||||
|
|
||||||
|
if ( false === $restored ) {
|
||||||
|
$result['errors'][] = $table;
|
||||||
|
} else {
|
||||||
|
$result['restored'][] = $table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether a table exists in the database.
|
||||||
|
*
|
||||||
|
* @param string $table Full table name.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function table_exists( string $table ): bool {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
return (string) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) ) === $table;
|
||||||
|
}
|
||||||
|
}
|
||||||
151
includes/class-robotstxt-mlp2-mlp5-wizard-state.php
Normal file
151
includes/class-robotstxt-mlp2-mlp5-wizard-state.php
Normal file
|
|
@ -0,0 +1,151 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Migration wizard state manager.
|
||||||
|
*
|
||||||
|
* Persists the wizard's current step, per-step data, and completion flags
|
||||||
|
* in a single network option. All public methods handle serialization
|
||||||
|
* and defaults internally.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Wizard_State
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Wizard_State {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sitemeta key used to store the wizard state.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const OPTION_KEY = 'mlp_migrator_wizard_state';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total number of wizard steps.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
const TOTAL_STEPS = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached state array.
|
||||||
|
*
|
||||||
|
* @var array|null
|
||||||
|
*/
|
||||||
|
private static ?array $cache = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the current wizard step (1–6). Defaults to 1 if no state exists.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function get_current_step(): int {
|
||||||
|
$state = self::load();
|
||||||
|
$step = isset( $state['step'] ) ? (int) $state['step'] : 1;
|
||||||
|
return max( 1, min( self::TOTAL_STEPS, $step ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current wizard step.
|
||||||
|
*
|
||||||
|
* @param int $step Step number (1–6).
|
||||||
|
*/
|
||||||
|
public static function set_step( int $step ): void {
|
||||||
|
$state = self::load();
|
||||||
|
$state['step'] = max( 1, min( self::TOTAL_STEPS, $step ) );
|
||||||
|
self::save( $state );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return stored data for a specific step.
|
||||||
|
*
|
||||||
|
* @param int $step Step number (1–6).
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function get_step_data( int $step ): array {
|
||||||
|
$state = self::load();
|
||||||
|
$key = 'step_' . $step . '_data';
|
||||||
|
return isset( $state[ $key ] ) && is_array( $state[ $key ] ) ? $state[ $key ] : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store data for a specific step.
|
||||||
|
*
|
||||||
|
* @param int $step Step number (1–6).
|
||||||
|
* @param array $data Arbitrary data to store.
|
||||||
|
*/
|
||||||
|
public static function set_step_data( int $step, array $data ): void {
|
||||||
|
$state = self::load();
|
||||||
|
$state[ 'step_' . $step . '_data' ] = $data;
|
||||||
|
self::save( $state );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge data into an existing step's stored data.
|
||||||
|
*
|
||||||
|
* @param int $step Step number (1–6).
|
||||||
|
* @param array $data Data to merge (existing keys are overwritten).
|
||||||
|
*/
|
||||||
|
public static function merge_step_data( int $step, array $data ): void {
|
||||||
|
$existing = self::get_step_data( $step );
|
||||||
|
self::set_step_data( $step, array_merge( $existing, $data ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark a step as complete.
|
||||||
|
*
|
||||||
|
* @param int $step Step number (1–6).
|
||||||
|
*/
|
||||||
|
public static function mark_step_complete( int $step ): void {
|
||||||
|
$state = self::load();
|
||||||
|
$state[ 'step_' . $step . '_complete' ] = true;
|
||||||
|
self::save( $state );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether a step has been marked complete.
|
||||||
|
*
|
||||||
|
* @param int $step Step number (1–6).
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function is_step_complete( int $step ): bool {
|
||||||
|
$state = self::load();
|
||||||
|
return ! empty( $state[ 'step_' . $step . '_complete' ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the wizard by deleting the network option entirely.
|
||||||
|
*/
|
||||||
|
public static function reset(): void {
|
||||||
|
delete_site_option( self::OPTION_KEY );
|
||||||
|
self::$cache = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load (and cache) the state array from the network option.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function load(): array {
|
||||||
|
if ( null === self::$cache ) {
|
||||||
|
$raw = get_site_option( self::OPTION_KEY, array() );
|
||||||
|
self::$cache = is_array( $raw ) ? $raw : array();
|
||||||
|
}
|
||||||
|
return self::$cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persist the state array to the network option.
|
||||||
|
*
|
||||||
|
* @param array $state State to persist.
|
||||||
|
*/
|
||||||
|
private static function save( array $state ): void {
|
||||||
|
self::$cache = $state;
|
||||||
|
update_site_option( self::OPTION_KEY, $state );
|
||||||
|
}
|
||||||
|
}
|
||||||
120
includes/class-robotstxt-mlp2-mlp5-writer-content-relations.php
Normal file
120
includes/class-robotstxt-mlp2-mlp5-writer-content-relations.php
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MLP5 content relations writer.
|
||||||
|
*
|
||||||
|
* Creates relationship groups in MLP5 from MLP2 source data.
|
||||||
|
*
|
||||||
|
* MLP5 schema:
|
||||||
|
* mlp_relationships (id BIGINT PK AUTO_INCREMENT, type VARCHAR(36))
|
||||||
|
* mlp_content_relations (relationship_id BIGINT, site_id BIGINT, content_id BIGINT, PK(relationship_id, site_id))
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Writer_Content_Relations
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Writer_Content_Relations {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether any MLP5 relationship already references a given (site_id, content_id) pair.
|
||||||
|
*
|
||||||
|
* Used for idempotency: if the pair is already in MLP5, the group is skipped.
|
||||||
|
*
|
||||||
|
* @param int $site_id Site ID.
|
||||||
|
* @param int $content_id Post or term ID.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function pair_exists_in_mlp5( int $site_id, int $content_id ): bool {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$mlp5 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp5();
|
||||||
|
$table = $mlp5->get_content_relations_table();
|
||||||
|
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$found = (int) $wpdb->get_var(
|
||||||
|
$wpdb->prepare(
|
||||||
|
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
"SELECT COUNT(*) FROM `{$table}` WHERE site_id = %d AND content_id = %d",
|
||||||
|
$site_id,
|
||||||
|
$content_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $found > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a relationship group in MLP5 for the given members.
|
||||||
|
*
|
||||||
|
* Inserts one row into mlp_relationships and one row per member into
|
||||||
|
* mlp_content_relations. Wrapped in a transaction for atomicity.
|
||||||
|
*
|
||||||
|
* @param string $type WordPress content type: post type slug or taxonomy name.
|
||||||
|
* Pass 'post' for standard posts, 'term' for terms.
|
||||||
|
* @param array[] $members Array of ['site_id' => int, 'element_id' => int].
|
||||||
|
* @return bool True on success, false on any DB error.
|
||||||
|
*/
|
||||||
|
public static function create_group( string $type, array $members ): bool {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$mlp5 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp5();
|
||||||
|
$rel_table = $mlp5->get_relationships_table();
|
||||||
|
$cont_table = $mlp5->get_content_relations_table();
|
||||||
|
|
||||||
|
if ( '' === $rel_table || '' === $cont_table ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$wpdb->query( 'START TRANSACTION' );
|
||||||
|
|
||||||
|
// Insert relationship group.
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$inserted = $wpdb->insert(
|
||||||
|
$rel_table,
|
||||||
|
array( 'type' => $type ),
|
||||||
|
array( '%s' )
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( false === $inserted ) {
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$wpdb->query( 'ROLLBACK' );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$relationship_id = (int) $wpdb->insert_id;
|
||||||
|
|
||||||
|
// Insert each member.
|
||||||
|
foreach ( $members as $member ) {
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$ok = $wpdb->insert(
|
||||||
|
$cont_table,
|
||||||
|
array(
|
||||||
|
'relationship_id' => $relationship_id,
|
||||||
|
'site_id' => (int) $member['site_id'],
|
||||||
|
'content_id' => (int) $member['element_id'],
|
||||||
|
),
|
||||||
|
array( '%d', '%d', '%d' )
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( false === $ok ) {
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$wpdb->query( 'ROLLBACK' );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$wpdb->query( 'COMMIT' );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
96
includes/class-robotstxt-mlp2-mlp5-writer-site-relations.php
Normal file
96
includes/class-robotstxt-mlp2-mlp5-writer-site-relations.php
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MLP5 site relations writer.
|
||||||
|
*
|
||||||
|
* Writes site connection rows to the MLP5 site_relations table.
|
||||||
|
*
|
||||||
|
* MLP5 site_relations schema (identical to MLP2):
|
||||||
|
* site_1 INT UNSIGNED -- lower site ID
|
||||||
|
* site_2 INT UNSIGNED -- higher site ID
|
||||||
|
* PRIMARY KEY (site_1, site_2)
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5_Writer_Site_Relations
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5_Writer_Site_Relations {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether a site relation already exists in MLP5.
|
||||||
|
*
|
||||||
|
* @param int $site_1 First site ID (will be normalised to lower).
|
||||||
|
* @param int $site_2 Second site ID.
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function relation_exists( int $site_1, int $site_2 ): bool {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$mlp5 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp5();
|
||||||
|
$table = $mlp5->get_site_relations_table();
|
||||||
|
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalise: site_1 must be the lower value.
|
||||||
|
if ( $site_1 > $site_2 ) {
|
||||||
|
list( $site_1, $site_2 ) = array( $site_2, $site_1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$found = $wpdb->get_var(
|
||||||
|
$wpdb->prepare(
|
||||||
|
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
||||||
|
"SELECT COUNT(*) FROM `{$table}` WHERE site_1 = %d AND site_2 = %d",
|
||||||
|
$site_1,
|
||||||
|
$site_2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return (int) $found > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a site relation to MLP5.
|
||||||
|
*
|
||||||
|
* Normalises site IDs (smaller value in site_1) before inserting.
|
||||||
|
* Returns false if the target table does not exist.
|
||||||
|
*
|
||||||
|
* @param int $site_1 First site ID.
|
||||||
|
* @param int $site_2 Second site ID.
|
||||||
|
* @return bool True on success, false on failure.
|
||||||
|
*/
|
||||||
|
public static function write_relation( int $site_1, int $site_2 ): bool {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$mlp5 = new Robotstxt_Mlp2_Mlp5_Detector_Mlp5();
|
||||||
|
$table = $mlp5->get_site_relations_table();
|
||||||
|
|
||||||
|
if ( '' === $table ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalise.
|
||||||
|
if ( $site_1 > $site_2 ) {
|
||||||
|
list( $site_1, $site_2 ) = array( $site_2, $site_1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
|
||||||
|
$result = $wpdb->insert(
|
||||||
|
$table,
|
||||||
|
array(
|
||||||
|
'site_1' => $site_1,
|
||||||
|
'site_2' => $site_2,
|
||||||
|
),
|
||||||
|
array( '%d', '%d' )
|
||||||
|
);
|
||||||
|
|
||||||
|
return false !== $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
115
includes/class-robotstxt-mlp2-mlp5.php
Normal file
115
includes/class-robotstxt-mlp2-mlp5.php
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Main plugin bootstrap class.
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Mlp2_Mlp5
|
||||||
|
*
|
||||||
|
* Bootstraps the MLP2 to MLP5 Migrator plugin. Handles activation,
|
||||||
|
* deactivation, Multisite-only enforcement, and text domain loading.
|
||||||
|
*/
|
||||||
|
class Robotstxt_Mlp2_Mlp5 {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Absolute path to the main plugin file.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $plugin_file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the plugin.
|
||||||
|
*
|
||||||
|
* @param string $plugin_file Absolute path to the main plugin file.
|
||||||
|
*/
|
||||||
|
public static function init( string $plugin_file ): void {
|
||||||
|
$instance = new self( $plugin_file );
|
||||||
|
$instance->register_hooks();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $plugin_file Absolute path to the main plugin file.
|
||||||
|
*/
|
||||||
|
private function __construct( string $plugin_file ) {
|
||||||
|
$this->plugin_file = $plugin_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register WordPress hooks.
|
||||||
|
*/
|
||||||
|
private function register_hooks(): void {
|
||||||
|
register_activation_hook( $this->plugin_file, array( $this, 'activate' ) );
|
||||||
|
register_deactivation_hook( $this->plugin_file, array( $this, 'deactivate' ) );
|
||||||
|
add_action( 'admin_notices', array( $this, 'multisite_notice' ) );
|
||||||
|
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
|
||||||
|
// Run pending DB upgrades on every request after a plugin update.
|
||||||
|
add_action( 'plugins_loaded', array( 'Robotstxt_Mlp2_Mlp5_Db_Upgrader', 'maybe_upgrade' ) );
|
||||||
|
// Register AJAX handlers for the batch migration runner.
|
||||||
|
Robotstxt_Mlp2_Mlp5_Ajax::register();
|
||||||
|
// Register the Network Admin page (network_admin_menu hook fires inside).
|
||||||
|
Robotstxt_Mlp2_Mlp5_Admin_Page::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin activation callback.
|
||||||
|
*
|
||||||
|
* Prevents activation on non-Multisite installations. On Multisite,
|
||||||
|
* creates the migration log table.
|
||||||
|
*/
|
||||||
|
public function activate(): void {
|
||||||
|
if ( ! is_multisite() ) {
|
||||||
|
deactivate_plugins( plugin_basename( $this->plugin_file ), true );
|
||||||
|
wp_die(
|
||||||
|
esc_html__( 'MLP2 to MLP5 Migrator requires a WordPress Multisite installation.', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
esc_html__( 'Plugin Activation Error', 'robotstxt-mlp2-mlp5' ),
|
||||||
|
array( 'back_link' => true )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Robotstxt_Mlp2_Mlp5_Db_Upgrader::maybe_upgrade();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin deactivation callback.
|
||||||
|
*/
|
||||||
|
public function deactivate(): void {
|
||||||
|
// Reserved for future cleanup on deactivation.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display an admin notice when the plugin is loaded on a non-Multisite installation.
|
||||||
|
*
|
||||||
|
* Belt-and-suspenders guard in case the plugin ends up loaded outside of
|
||||||
|
* the network activation flow.
|
||||||
|
*/
|
||||||
|
public function multisite_notice(): void {
|
||||||
|
if ( is_multisite() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(
|
||||||
|
'<div class="notice notice-error"><p>%s</p></div>',
|
||||||
|
esc_html__( 'MLP2 to MLP5 Migrator requires a WordPress Multisite installation and has been deactivated.', 'robotstxt-mlp2-mlp5' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the plugin text domain for internationalization.
|
||||||
|
*/
|
||||||
|
public function load_textdomain(): void {
|
||||||
|
load_plugin_textdomain(
|
||||||
|
'robotstxt-mlp2-mlp5',
|
||||||
|
false,
|
||||||
|
dirname( plugin_basename( $this->plugin_file ) ) . '/languages'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
languages/robotstxt-mlp2-mlp5-es_ES.mo
Normal file
BIN
languages/robotstxt-mlp2-mlp5-es_ES.mo
Normal file
Binary file not shown.
474
languages/robotstxt-mlp2-mlp5-es_ES.po
Normal file
474
languages/robotstxt-mlp2-mlp5-es_ES.po
Normal file
|
|
@ -0,0 +1,474 @@
|
||||||
|
# Spanish (Spain) translation for MLP2 to MLP5 (by ROBOTSTXT)
|
||||||
|
# Copyright (C) 2026 ROBOTSTXT
|
||||||
|
# This file is distributed under the GPL-3.0-or-later.
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: MLP2 to MLP5 (by ROBOTSTXT) 1.0.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/robotstxt-mlp2-mlp5\n"
|
||||||
|
"POT-Creation-Date: 2026-02-27T09:58:57+00:00\n"
|
||||||
|
"PO-Revision-Date: 2026-02-27 10:00+0000\n"
|
||||||
|
"Last-Translator: ROBOTSTXT <info@robotstxt.es>\n"
|
||||||
|
"Language-Team: Spanish (Spain) <es@li.org>\n"
|
||||||
|
"Language: es_ES\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
"X-Generator: Manual\n"
|
||||||
|
"X-Domain: robotstxt-mlp2-mlp5\n"
|
||||||
|
|
||||||
|
#. Plugin Name of the plugin
|
||||||
|
msgid "MLP2 to MLP5 Migrator"
|
||||||
|
msgstr "MLP2 to MLP5 (by ROBOTSTXT)"
|
||||||
|
|
||||||
|
#. Plugin URI of the plugin
|
||||||
|
msgid "https://git.robotstxt.es/ROBOTSTXT/robotstxt-mlp2-mlp5"
|
||||||
|
msgstr "https://git.robotstxt.es/ROBOTSTXT/robotstxt-mlp2-mlp5"
|
||||||
|
|
||||||
|
#. Description of the plugin
|
||||||
|
msgid "Guided, safe, and reversible migration from MultilingualPress 2 to MultilingualPress 5."
|
||||||
|
msgstr "Migración guiada, segura y reversible de MultilingualPress 2 a MultilingualPress 5."
|
||||||
|
|
||||||
|
#. Author of the plugin
|
||||||
|
msgid "ROBOTSTXT"
|
||||||
|
msgstr "ROBOTSTXT"
|
||||||
|
|
||||||
|
#. Author URI of the plugin
|
||||||
|
msgid "https://git.robotstxt.es/ROBOTSTXT"
|
||||||
|
msgstr "https://git.robotstxt.es/ROBOTSTXT"
|
||||||
|
|
||||||
|
msgid "MLP Migrator"
|
||||||
|
msgstr "MLP Migrator"
|
||||||
|
|
||||||
|
msgid "You do not have permission to perform this action."
|
||||||
|
msgstr "No tienes permiso para realizar esta acción."
|
||||||
|
|
||||||
|
msgid "You do not have permission to access this page."
|
||||||
|
msgstr "No tienes permiso para acceder a esta página."
|
||||||
|
|
||||||
|
msgid "You do not have permission to export the log."
|
||||||
|
msgstr "No tienes permiso para exportar el registro."
|
||||||
|
|
||||||
|
msgid "Preflight"
|
||||||
|
msgstr "Comprobaciones previas"
|
||||||
|
|
||||||
|
msgid "Analysis"
|
||||||
|
msgstr "Análisis"
|
||||||
|
|
||||||
|
msgid "Site Relations"
|
||||||
|
msgstr "Relaciones de sitios"
|
||||||
|
|
||||||
|
msgid "Content Relations"
|
||||||
|
msgstr "Relaciones de contenido"
|
||||||
|
|
||||||
|
msgid "Verification"
|
||||||
|
msgstr "Verificación"
|
||||||
|
|
||||||
|
msgid "Cleanup"
|
||||||
|
msgstr "Limpieza"
|
||||||
|
|
||||||
|
msgid "Reset migration (start over)"
|
||||||
|
msgstr "Reiniciar migración (empezar de nuevo)"
|
||||||
|
|
||||||
|
msgid "This will reset the wizard to Step 1 and clear the migration log. It does not modify MLP5 data."
|
||||||
|
msgstr "Esto restablecerá el asistente al Paso 1 y borrará el registro de migración. No modifica los datos de MLP5."
|
||||||
|
|
||||||
|
msgid "Reset wizard"
|
||||||
|
msgstr "Reiniciar asistente"
|
||||||
|
|
||||||
|
msgid "System status"
|
||||||
|
msgstr "Estado del sistema"
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table renamed successfully."
|
||||||
|
msgid_plural "%d tables renamed successfully."
|
||||||
|
msgstr[0] "%d tabla renombrada correctamente."
|
||||||
|
msgstr[1] "%d tablas renombradas correctamente."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table could not be renamed. Check database permissions."
|
||||||
|
msgid_plural "%d tables could not be renamed. Check database permissions."
|
||||||
|
msgstr[0] "%d tabla no pudo renombrarse. Comprueba los permisos de la base de datos."
|
||||||
|
msgstr[1] "%d tablas no pudieron renombrarse. Comprueba los permisos de la base de datos."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table restored to original name."
|
||||||
|
msgid_plural "%d tables restored to original names."
|
||||||
|
msgstr[0] "%d tabla restaurada a su nombre original."
|
||||||
|
msgstr[1] "%d tablas restauradas a sus nombres originales."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table could not be restored. Check database permissions."
|
||||||
|
msgid_plural "%d tables could not be restored. Check database permissions."
|
||||||
|
msgstr[0] "%d tabla no pudo restaurarse. Comprueba los permisos de la base de datos."
|
||||||
|
msgstr[1] "%d tablas no pudieron restaurarse. Comprueba los permisos de la base de datos."
|
||||||
|
|
||||||
|
msgid "Wizard reset. You can start the migration from Step 1."
|
||||||
|
msgstr "Asistente reiniciado. Puedes iniciar la migración desde el Paso 1."
|
||||||
|
|
||||||
|
msgid "Cleanup completed."
|
||||||
|
msgstr "Limpieza completada."
|
||||||
|
|
||||||
|
msgid "Cleanup confirmation invalid. Type DELETE exactly."
|
||||||
|
msgstr "Confirmación de limpieza inválida. Escribe DELETE exactamente."
|
||||||
|
|
||||||
|
msgid "Action required: MLP2 tables must be renamed before MultilingualPress 5 can be activated."
|
||||||
|
msgstr "Acción requerida: las tablas de MLP2 deben renombrarse antes de activar MultilingualPress 5."
|
||||||
|
|
||||||
|
msgid "MLP2 tables renamed. Now go to Network Admin > Plugins and activate MultilingualPress 5."
|
||||||
|
msgstr "Tablas de MLP2 renombradas. Ve a Administración de red > Plugins y activa MultilingualPress 5."
|
||||||
|
|
||||||
|
msgid "Warning: both original and backup MLP2 tables were found. Investigate before proceeding."
|
||||||
|
msgstr "Advertencia: se encontraron tanto las tablas originales como las de copia de seguridad de MLP2. Investiga antes de continuar."
|
||||||
|
|
||||||
|
msgid "No MLP2 tables found. Migration cannot proceed. Restore your database from a backup."
|
||||||
|
msgstr "No se encontraron tablas de MLP2. La migración no puede continuar. Restaura tu base de datos desde una copia de seguridad."
|
||||||
|
|
||||||
|
msgid "System Status"
|
||||||
|
msgstr "Estado del sistema"
|
||||||
|
|
||||||
|
msgid "MLP2 tables (original names)"
|
||||||
|
msgstr "Tablas de MLP2 (nombres originales)"
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table — must be renamed"
|
||||||
|
msgid_plural "%d tables — must be renamed"
|
||||||
|
msgstr[0] "%d tabla — debe renombrarse"
|
||||||
|
msgstr[1] "%d tablas — deben renombrarse"
|
||||||
|
|
||||||
|
msgid "None"
|
||||||
|
msgstr "Ninguna"
|
||||||
|
|
||||||
|
msgid "MLP2 tables (backup copies)"
|
||||||
|
msgstr "Tablas de MLP2 (copias de seguridad)"
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "%d backup table ready"
|
||||||
|
msgid_plural "%d backup tables ready"
|
||||||
|
msgstr[0] "%d tabla de copia de seguridad lista"
|
||||||
|
msgstr[1] "%d tablas de copia de seguridad listas"
|
||||||
|
|
||||||
|
msgid "Not yet renamed"
|
||||||
|
msgstr "Aún no renombradas"
|
||||||
|
|
||||||
|
msgid "MultilingualPress 5 (network-active)"
|
||||||
|
msgstr "MultilingualPress 5 (activo en red)"
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Active (v%s)"
|
||||||
|
msgstr "Activo (v%s)"
|
||||||
|
|
||||||
|
msgid "Not active"
|
||||||
|
msgstr "No activo"
|
||||||
|
|
||||||
|
msgid "Step 1 — Rename MLP2 Tables"
|
||||||
|
msgstr "Paso 1 — Renombrar tablas de MLP2"
|
||||||
|
|
||||||
|
msgid "MultilingualPress 5 cannot activate while the original MLP2 table names are present. Click below to rename them to temporary backup copies ({prefix}mlp2bak_*). This is safe and fully reversible."
|
||||||
|
msgstr "MultilingualPress 5 no puede activarse mientras existan los nombres originales de las tablas de MLP2. Haz clic abajo para renombrarlas a copias de seguridad temporales ({prefix}mlp2bak_*). Esta operación es segura y totalmente reversible."
|
||||||
|
|
||||||
|
msgid "Rename MLP2 tables (prepare for MLP5 activation)"
|
||||||
|
msgstr "Renombrar tablas de MLP2 (preparar para activar MLP5)"
|
||||||
|
|
||||||
|
msgid "Step 2 — Activate MultilingualPress 5"
|
||||||
|
msgstr "Paso 2 — Activar MultilingualPress 5"
|
||||||
|
|
||||||
|
msgid "MLP2 tables have been renamed. MultilingualPress 5 can now be activated without the old-version compatibility error."
|
||||||
|
msgstr "Las tablas de MLP2 han sido renombradas. MultilingualPress 5 ya puede activarse sin el error de compatibilidad de versión antigua."
|
||||||
|
|
||||||
|
msgid "Go to Network Admin › Plugins"
|
||||||
|
msgstr "Ir a Administración de red › Plugins"
|
||||||
|
|
||||||
|
msgid "Emergency: restore original MLP2 table names"
|
||||||
|
msgstr "Emergencia: restaurar nombres originales de tablas MLP2"
|
||||||
|
|
||||||
|
msgid "This renames backup tables back to their original MLP2 names. Only use this before MLP5 has been activated."
|
||||||
|
msgstr "Esto restaura las tablas de copia de seguridad a sus nombres originales de MLP2. Úsalo solo antes de que MLP5 haya sido activado."
|
||||||
|
|
||||||
|
msgid "Restore original table names"
|
||||||
|
msgstr "Restaurar nombres de tabla originales"
|
||||||
|
|
||||||
|
msgid "Step 2 — Analysis"
|
||||||
|
msgstr "Paso 2 — Análisis"
|
||||||
|
|
||||||
|
msgid "Click \"Run Analysis\" to scan the MLP2 backup database and validate MLP5 schema compatibility before migrating."
|
||||||
|
msgstr "Haz clic en «Ejecutar análisis» para analizar la base de datos de copia de seguridad de MLP2 y validar la compatibilidad del esquema de MLP5 antes de migrar."
|
||||||
|
|
||||||
|
msgid "Run Analysis"
|
||||||
|
msgstr "Ejecutar análisis"
|
||||||
|
|
||||||
|
msgid "MLP5 schema incompatibility detected:"
|
||||||
|
msgstr "Incompatibilidad de esquema MLP5 detectada:"
|
||||||
|
|
||||||
|
msgid "Category"
|
||||||
|
msgstr "Categoría"
|
||||||
|
|
||||||
|
msgid "Records found"
|
||||||
|
msgstr "Registros encontrados"
|
||||||
|
|
||||||
|
msgid "Site relations"
|
||||||
|
msgstr "Relaciones de sitios"
|
||||||
|
|
||||||
|
msgid "Post relation groups"
|
||||||
|
msgstr "Grupos de relaciones de entradas"
|
||||||
|
|
||||||
|
msgid "Term relation groups"
|
||||||
|
msgstr "Grupos de relaciones de términos"
|
||||||
|
|
||||||
|
msgid "Conflicts (will be skipped and logged)"
|
||||||
|
msgstr "Conflictos (se omitirán y registrarán)"
|
||||||
|
|
||||||
|
msgid "Orphaned sites"
|
||||||
|
msgstr "Sitios huérfanos"
|
||||||
|
|
||||||
|
msgid "Orphaned post references"
|
||||||
|
msgstr "Referencias de entradas huérfanas"
|
||||||
|
|
||||||
|
msgid "Orphaned term references"
|
||||||
|
msgstr "Referencias de términos huérfanas"
|
||||||
|
|
||||||
|
msgid "Duplicate relation rows"
|
||||||
|
msgstr "Filas de relaciones duplicadas"
|
||||||
|
|
||||||
|
msgid "Re-run Analysis"
|
||||||
|
msgstr "Volver a ejecutar análisis"
|
||||||
|
|
||||||
|
msgid "Next: Migrate Site Relations"
|
||||||
|
msgstr "Siguiente: migrar relaciones de sitios"
|
||||||
|
|
||||||
|
msgid "MLP5 tables not found. Ensure MultilingualPress 5 is active and has been initialized."
|
||||||
|
msgstr "No se encontraron las tablas de MLP5. Asegúrate de que MultilingualPress 5 está activo e inicializado."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Table %s does not have expected columns (site_1, site_2)."
|
||||||
|
msgstr "La tabla %s no tiene las columnas esperadas (site_1, site_2)."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Table %s does not have expected columns (relationship_id, site_id, content_id)."
|
||||||
|
msgstr "La tabla %s no tiene las columnas esperadas (relationship_id, site_id, content_id)."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Table %s does not have expected columns (id, type)."
|
||||||
|
msgstr "La tabla %s no tiene las columnas esperadas (id, type)."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "MLP2 backup table %2$s is missing expected column \"%1$s\". Schema may differ from expected."
|
||||||
|
msgstr "La tabla de copia de seguridad de MLP2 %2$s no tiene la columna esperada «%1$s». El esquema puede diferir del esperado."
|
||||||
|
|
||||||
|
msgid "MLP2 deactivation: plugin is already inactive."
|
||||||
|
msgstr "Desactivación de MLP2: el plugin ya estaba inactivo."
|
||||||
|
|
||||||
|
msgid "MLP2 plugin deactivated network-wide."
|
||||||
|
msgstr "Plugin MLP2 desactivado en toda la red."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Failed to drop backup table: %s"
|
||||||
|
msgstr "Error al eliminar la tabla de copia de seguridad: %s"
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Backup table dropped: %s"
|
||||||
|
msgstr "Tabla de copia de seguridad eliminada: %s"
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Removed %d MLP2 sitemeta entries."
|
||||||
|
msgstr "Se eliminaron %d entradas de sitemeta de MLP2."
|
||||||
|
|
||||||
|
msgid "Step 6 — Cleanup (Optional)"
|
||||||
|
msgstr "Paso 6 — Limpieza (opcional)"
|
||||||
|
|
||||||
|
msgid "Migration complete!"
|
||||||
|
msgstr "¡Migración completada!"
|
||||||
|
|
||||||
|
msgid "MultilingualPress 5 is now configured with your migrated data. Verify that everything works before performing the optional cleanup below."
|
||||||
|
msgstr "MultilingualPress 5 está ahora configurado con tus datos migrados. Verifica que todo funciona antes de realizar la limpieza opcional a continuación."
|
||||||
|
|
||||||
|
msgid "The cleanup actions below are optional and irreversible. MultilingualPress 5 will work correctly whether or not you perform them."
|
||||||
|
msgstr "Las acciones de limpieza a continuación son opcionales e irreversibles. MultilingualPress 5 funcionará correctamente tanto si las realizas como si no."
|
||||||
|
|
||||||
|
msgid "Deactivate MultilingualPress 2 (network-wide)"
|
||||||
|
msgstr "Desactivar MultilingualPress 2 (en toda la red)"
|
||||||
|
|
||||||
|
msgid "Deactivate MultilingualPress 2"
|
||||||
|
msgstr "Desactivar MultilingualPress 2"
|
||||||
|
|
||||||
|
msgid "already inactive"
|
||||||
|
msgstr "ya inactivo"
|
||||||
|
|
||||||
|
msgid "Delete MLP2 backup database tables"
|
||||||
|
msgstr "Eliminar tablas de copia de seguridad de MLP2"
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table"
|
||||||
|
msgid_plural "%d tables"
|
||||||
|
msgstr[0] "%d tabla"
|
||||||
|
msgstr[1] "%d tablas"
|
||||||
|
|
||||||
|
msgid "Irreversible. Only do this after verifying the migration in MLP5."
|
||||||
|
msgstr "Irreversible. Hazlo solo tras verificar la migración en MLP5."
|
||||||
|
|
||||||
|
msgid "Delete MLP2 network settings from wp_sitemeta"
|
||||||
|
msgstr "Eliminar configuración de red de MLP2 de wp_sitemeta"
|
||||||
|
|
||||||
|
msgid "Type DELETE to confirm:"
|
||||||
|
msgstr "Escribe DELETE para confirmar:"
|
||||||
|
|
||||||
|
msgid "Proceed with cleanup"
|
||||||
|
msgstr "Proceder con la limpieza"
|
||||||
|
|
||||||
|
msgid "Step 4 — Content Relations"
|
||||||
|
msgstr "Paso 4 — Relaciones de contenido"
|
||||||
|
|
||||||
|
msgid "This step migrates all post and term relationships in batches. On large sites this can take several minutes. You can pause and resume at any time."
|
||||||
|
msgstr "Este paso migra todas las relaciones de entradas y términos en lotes. En sitios grandes puede tardar varios minutos. Puedes pausar y reanudar en cualquier momento."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Processed %1$s of %2$s groups"
|
||||||
|
msgstr "Procesados %1$s de %2$s grupos"
|
||||||
|
|
||||||
|
msgid "Migrated"
|
||||||
|
msgstr "Migrados"
|
||||||
|
|
||||||
|
msgid "Skipped"
|
||||||
|
msgstr "Omitidos"
|
||||||
|
|
||||||
|
msgid "Errors"
|
||||||
|
msgstr "Errores"
|
||||||
|
|
||||||
|
msgid "Content relations migration complete."
|
||||||
|
msgstr "Migración de relaciones de contenido completada."
|
||||||
|
|
||||||
|
msgid "Resume"
|
||||||
|
msgstr "Reanudar"
|
||||||
|
|
||||||
|
msgid "Start"
|
||||||
|
msgstr "Iniciar"
|
||||||
|
|
||||||
|
msgid "Pause"
|
||||||
|
msgstr "Pausar"
|
||||||
|
|
||||||
|
msgid "Next: Verification"
|
||||||
|
msgstr "Siguiente: verificación"
|
||||||
|
|
||||||
|
msgid "Error during migration."
|
||||||
|
msgstr "Error durante la migración."
|
||||||
|
|
||||||
|
msgid "Done! Reload the page to continue."
|
||||||
|
msgstr "¡Completado! Recarga la página para continuar."
|
||||||
|
|
||||||
|
msgid "Network error. Click Resume to continue."
|
||||||
|
msgstr "Error de red. Haz clic en Reanudar para continuar."
|
||||||
|
|
||||||
|
msgid "Running…"
|
||||||
|
msgstr "Ejecutando…"
|
||||||
|
|
||||||
|
msgid "Paused."
|
||||||
|
msgstr "Pausado."
|
||||||
|
|
||||||
|
msgid "Relation already exists in MLP5 (idempotent skip)."
|
||||||
|
msgstr "La relación ya existe en MLP5 (omisión idempotente)."
|
||||||
|
|
||||||
|
msgid "Fewer than 2 valid members after orphan check. Skipped."
|
||||||
|
msgstr "Menos de 2 miembros válidos tras la comprobación de huérfanos. Omitido."
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "Group migrated with %d members."
|
||||||
|
msgstr "Grupo migrado con %d miembros."
|
||||||
|
|
||||||
|
msgid "Failed to write group to MLP5."
|
||||||
|
msgstr "Error al escribir el grupo en MLP5."
|
||||||
|
|
||||||
|
msgid "MLP2 tables have not been renamed yet. Go back to the plugin status page and click \"Rename MLP2 tables\"."
|
||||||
|
msgstr "Las tablas de MLP2 aún no se han renombrado. Vuelve a la página de estado del plugin y haz clic en «Renombrar tablas de MLP2»."
|
||||||
|
|
||||||
|
msgid "No MLP2 tables found (neither original nor backup). Restore your database from a backup before proceeding."
|
||||||
|
msgstr "No se encontraron tablas de MLP2 (ni originales ni de copia de seguridad). Restaura tu base de datos desde una copia de seguridad antes de continuar."
|
||||||
|
|
||||||
|
msgid "MultilingualPress 5 is not network-active. Activate it before running the migration."
|
||||||
|
msgstr "MultilingualPress 5 no está activo en red. Actívalo antes de ejecutar la migración."
|
||||||
|
|
||||||
|
msgid "Step 1 — Preflight Checks"
|
||||||
|
msgstr "Paso 1 — Comprobaciones previas"
|
||||||
|
|
||||||
|
msgid "MLP2 backup tables (preparation done)"
|
||||||
|
msgstr "Tablas de copia de seguridad de MLP2 (preparación completada)"
|
||||||
|
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table ready"
|
||||||
|
msgid_plural "%d tables ready"
|
||||||
|
msgstr[0] "%d tabla lista"
|
||||||
|
msgstr[1] "%d tablas listas"
|
||||||
|
|
||||||
|
msgid "Original tables still present — rename step not done"
|
||||||
|
msgstr "Tablas originales aún presentes — paso de renombrado no completado"
|
||||||
|
|
||||||
|
msgid "No MLP2 tables found"
|
||||||
|
msgstr "No se encontraron tablas de MLP2"
|
||||||
|
|
||||||
|
msgid "MLP2 plugin (active — informational only)"
|
||||||
|
msgstr "Plugin MLP2 (activo — solo informativo)"
|
||||||
|
|
||||||
|
msgid "Active — consider deactivating before proceeding"
|
||||||
|
msgstr "Activo — considera desactivarlo antes de continuar"
|
||||||
|
|
||||||
|
msgid "Inactive (expected)"
|
||||||
|
msgstr "Inactivo (esperado)"
|
||||||
|
|
||||||
|
msgid "Next: Run Analysis"
|
||||||
|
msgstr "Siguiente: ejecutar análisis"
|
||||||
|
|
||||||
|
msgid "Resolve the issues above before continuing."
|
||||||
|
msgstr "Resuelve los problemas anteriores antes de continuar."
|
||||||
|
|
||||||
|
msgid "One or both sites no longer exist in the network."
|
||||||
|
msgstr "Uno o ambos sitios ya no existen en la red."
|
||||||
|
|
||||||
|
msgid "Site relation migrated successfully."
|
||||||
|
msgstr "Relación de sitios migrada correctamente."
|
||||||
|
|
||||||
|
msgid "Failed to write site relation to MLP5."
|
||||||
|
msgstr "Error al escribir la relación de sitios en MLP5."
|
||||||
|
|
||||||
|
msgid "Step 3 — Site Relations"
|
||||||
|
msgstr "Paso 3 — Relaciones de sitios"
|
||||||
|
|
||||||
|
msgid "This step migrates site connections and language assignments from MLP2 to MLP5. It usually completes in seconds."
|
||||||
|
msgstr "Este paso migra las conexiones de sitios y las asignaciones de idioma de MLP2 a MLP5. Suele completarse en segundos."
|
||||||
|
|
||||||
|
msgid "Re-run Site Relations"
|
||||||
|
msgstr "Volver a ejecutar relaciones de sitios"
|
||||||
|
|
||||||
|
msgid "Start Site Relations Migration"
|
||||||
|
msgstr "Iniciar migración de relaciones de sitios"
|
||||||
|
|
||||||
|
msgid "Next: Content Relations"
|
||||||
|
msgstr "Siguiente: relaciones de contenido"
|
||||||
|
|
||||||
|
msgid "Post Relations"
|
||||||
|
msgstr "Relaciones de entradas"
|
||||||
|
|
||||||
|
msgid "Term Relations"
|
||||||
|
msgstr "Relaciones de términos"
|
||||||
|
|
||||||
|
msgid "Step 5 — Verification"
|
||||||
|
msgstr "Paso 5 — Verificación"
|
||||||
|
|
||||||
|
msgid "Compare expected totals (from the Analysis step) with actual migration results. Download the full log before proceeding to cleanup."
|
||||||
|
msgstr "Compara los totales esperados (del paso de Análisis) con los resultados reales de la migración. Descarga el registro completo antes de proceder a la limpieza."
|
||||||
|
|
||||||
|
msgid "Expected"
|
||||||
|
msgstr "Esperados"
|
||||||
|
|
||||||
|
msgid "Download log (CSV)"
|
||||||
|
msgstr "Descargar registro (CSV)"
|
||||||
|
|
||||||
|
msgid "Next: Cleanup"
|
||||||
|
msgstr "Siguiente: limpieza"
|
||||||
|
|
||||||
|
msgid "MLP2 to MLP5 Migrator requires a WordPress Multisite installation."
|
||||||
|
msgstr "MLP2 to MLP5 (by ROBOTSTXT) requiere una instalación de WordPress Multisitio."
|
||||||
|
|
||||||
|
msgid "Plugin Activation Error"
|
||||||
|
msgstr "Error de activación del plugin"
|
||||||
|
|
||||||
|
msgid "MLP2 to MLP5 Migrator requires a WordPress Multisite installation and has been deactivated."
|
||||||
|
msgstr "MLP2 to MLP5 (by ROBOTSTXT) requiere una instalación de WordPress Multisitio y ha sido desactivado."
|
||||||
649
languages/robotstxt-mlp2-mlp5.pot
Normal file
649
languages/robotstxt-mlp2-mlp5.pot
Normal file
|
|
@ -0,0 +1,649 @@
|
||||||
|
# Copyright (C) 2026 ROBOTSTXT
|
||||||
|
# This file is distributed under the GPL-3.0-or-later.
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: MLP2 to MLP5 (by ROBOTSTXT) 1.0.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/robotstxt-mlp2-mlp5\n"
|
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"POT-Creation-Date: 2026-02-27T10:21:22+00:00\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"X-Generator: WP-CLI 2.12.0\n"
|
||||||
|
"X-Domain: robotstxt-mlp2-mlp5\n"
|
||||||
|
|
||||||
|
#. Plugin Name of the plugin
|
||||||
|
#: robotstxt-mlp2-mlp5.php
|
||||||
|
msgid "MLP2 to MLP5 (by ROBOTSTXT)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. Plugin URI of the plugin
|
||||||
|
#: robotstxt-mlp2-mlp5.php
|
||||||
|
msgid "https://git.robotstxt.es/ROBOTSTXT/robotstxt-mlp2-mlp5"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. Description of the plugin
|
||||||
|
#: robotstxt-mlp2-mlp5.php
|
||||||
|
msgid "Guided, safe, and reversible migration from MultilingualPress 2 to MultilingualPress 5."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. Author of the plugin
|
||||||
|
#: robotstxt-mlp2-mlp5.php
|
||||||
|
msgid "ROBOTSTXT"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. Author URI of the plugin
|
||||||
|
#: robotstxt-mlp2-mlp5.php
|
||||||
|
msgid "https://git.robotstxt.es/ROBOTSTXT"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:61
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:290
|
||||||
|
msgid "MLP2 to MLP5 Migrator"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:62
|
||||||
|
msgid "MLP Migrator"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:90
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:107
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:131
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:254
|
||||||
|
msgid "You do not have permission to perform this action."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:271
|
||||||
|
msgid "You do not have permission to access this page."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:321
|
||||||
|
msgid "Preflight"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:322
|
||||||
|
msgid "Analysis"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:323
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:30
|
||||||
|
msgid "Site Relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:324
|
||||||
|
msgid "Content Relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:325
|
||||||
|
msgid "Verification"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:326
|
||||||
|
msgid "Cleanup"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:383
|
||||||
|
msgid "Reset migration (start over)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:385
|
||||||
|
msgid "This will reset the wizard to Step 1 and clear the migration log. It does not modify MLP5 data."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:389
|
||||||
|
msgid "Reset wizard"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:398
|
||||||
|
msgid "System status"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %d: number of renamed tables
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:419
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table renamed successfully."
|
||||||
|
msgid_plural "%d tables renamed successfully."
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#. translators: %d: number of tables that could not be renamed
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:424
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table could not be renamed. Check database permissions."
|
||||||
|
msgid_plural "%d tables could not be renamed. Check database permissions."
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#. translators: %d: number of restored tables
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:429
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table restored to original name."
|
||||||
|
msgid_plural "%d tables restored to original names."
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#. translators: %d: number of tables that could not be restored
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:434
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table could not be restored. Check database permissions."
|
||||||
|
msgid_plural "%d tables could not be restored. Check database permissions."
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:437
|
||||||
|
msgid "Wizard reset. You can start the migration from Step 1."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:440
|
||||||
|
msgid "Cleanup completed."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:443
|
||||||
|
msgid "Cleanup confirmation invalid. Type DELETE exactly."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:458
|
||||||
|
msgid "Action required: MLP2 tables must be renamed before MultilingualPress 5 can be activated."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:461
|
||||||
|
msgid "MLP2 tables renamed. Now go to Network Admin > Plugins and activate MultilingualPress 5."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:464
|
||||||
|
msgid "Warning: both original and backup MLP2 tables were found. Investigate before proceeding."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:467
|
||||||
|
msgid "No MLP2 tables found. Migration cannot proceed. Restore your database from a backup."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:494
|
||||||
|
msgid "System Status"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:498
|
||||||
|
msgid "MLP2 tables (original names)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %d: number of tables
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:501
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table — must be renamed"
|
||||||
|
msgid_plural "%d tables — must be renamed"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:503
|
||||||
|
msgid "None"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:508
|
||||||
|
msgid "MLP2 tables (backup copies)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %d: number of backup tables
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:511
|
||||||
|
#, php-format
|
||||||
|
msgid "%d backup table ready"
|
||||||
|
msgid_plural "%d backup tables ready"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:513
|
||||||
|
msgid "Not yet renamed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:518
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:105
|
||||||
|
msgid "MultilingualPress 5 (network-active)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %s: version
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:521
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:108
|
||||||
|
#, php-format
|
||||||
|
msgid "Active (v%s)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:523
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:110
|
||||||
|
msgid "Not active"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:544
|
||||||
|
msgid "Step 1 — Rename MLP2 Tables"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:545
|
||||||
|
msgid "MultilingualPress 5 cannot activate while the original MLP2 table names are present. Click below to rename them to temporary backup copies ({prefix}mlp2bak_*). This is safe and fully reversible."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:549
|
||||||
|
msgid "Rename MLP2 tables (prepare for MLP5 activation)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:558
|
||||||
|
msgid "Step 2 — Activate MultilingualPress 5"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:559
|
||||||
|
msgid "MLP2 tables have been renamed. MultilingualPress 5 can now be activated without the old-version compatibility error."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:560
|
||||||
|
msgid "Go to Network Admin › Plugins"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:569
|
||||||
|
msgid "Emergency: restore original MLP2 table names"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:571
|
||||||
|
msgid "This renames backup tables back to their original MLP2 names. Only use this before MLP5 has been activated."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-admin-page.php:575
|
||||||
|
msgid "Restore original table names"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:112
|
||||||
|
msgid "Step 2 — Analysis"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:115
|
||||||
|
msgid "Click \"Run Analysis\" to scan the MLP2 backup database and validate MLP5 schema compatibility before migrating."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:120
|
||||||
|
msgid "Run Analysis"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:126
|
||||||
|
msgid "MLP5 schema incompatibility detected:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:131
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:111
|
||||||
|
msgid "Category"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:131
|
||||||
|
msgid "Records found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:133
|
||||||
|
msgid "Site relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:134
|
||||||
|
msgid "Post relation groups"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:135
|
||||||
|
msgid "Term relation groups"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:140
|
||||||
|
msgid "Conflicts (will be skipped and logged)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:144
|
||||||
|
msgid "Orphaned sites"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:147
|
||||||
|
msgid "Orphaned post references"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:150
|
||||||
|
msgid "Orphaned term references"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:153
|
||||||
|
msgid "Duplicate relation rows"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:164
|
||||||
|
msgid "Re-run Analysis"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:171
|
||||||
|
msgid "Next: Migrate Site Relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:320
|
||||||
|
msgid "MLP5 tables not found. Ensure MultilingualPress 5 is active and has been initialized."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %s: table name
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:326
|
||||||
|
#, php-format
|
||||||
|
msgid "Table %s does not have expected columns (site_1, site_2)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %s: table name
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:332
|
||||||
|
#, php-format
|
||||||
|
msgid "Table %s does not have expected columns (relationship_id, site_id, content_id)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %s: table name
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:339
|
||||||
|
#, php-format
|
||||||
|
msgid "Table %s does not have expected columns (id, type)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: 1: column name, 2: table name
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-analysis.php:349
|
||||||
|
#, php-format
|
||||||
|
msgid "MLP2 backup table %2$s is missing expected column \"%1$s\". Schema may differ from expected."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:34
|
||||||
|
msgid "MLP2 deactivation: plugin is already inactive."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:43
|
||||||
|
msgid "MLP2 plugin deactivated network-wide."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %s: table name
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:66
|
||||||
|
#, php-format
|
||||||
|
msgid "Failed to drop backup table: %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %s: table name
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:69
|
||||||
|
#, php-format
|
||||||
|
msgid "Backup table dropped: %s"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %d: key count
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:108
|
||||||
|
#, php-format
|
||||||
|
msgid "Removed %d MLP2 sitemeta entries."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:119
|
||||||
|
msgid "Step 6 — Cleanup (Optional)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:122
|
||||||
|
msgid "Migration complete!"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:122
|
||||||
|
msgid "MultilingualPress 5 is now configured with your migrated data. Verify that everything works before performing the optional cleanup below."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:125
|
||||||
|
msgid "The cleanup actions below are optional and irreversible. MultilingualPress 5 will work correctly whether or not you perform them."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:138
|
||||||
|
msgid "Deactivate MultilingualPress 2 (network-wide)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:140
|
||||||
|
msgid "Deactivate MultilingualPress 2"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:141
|
||||||
|
msgid "already inactive"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:148
|
||||||
|
msgid "Delete MLP2 backup database tables"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %d: table count
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:149
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table"
|
||||||
|
msgid_plural "%d tables"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#. translators: %d: table count
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:150
|
||||||
|
msgid "Irreversible. Only do this after verifying the migration in MLP5."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:156
|
||||||
|
msgid "Delete MLP2 network settings from wp_sitemeta"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:163
|
||||||
|
msgid "Type DELETE to confirm:"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-cleanup.php:169
|
||||||
|
msgid "Proceed with cleanup"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:109
|
||||||
|
msgid "Step 4 — Content Relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:110
|
||||||
|
msgid "This step migrates all post and term relationships in batches. On large sites this can take several minutes. You can pause and resume at any time."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: 1: processed count, 2: total count
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:117
|
||||||
|
#, php-format
|
||||||
|
msgid "Processed %1$s of %2$s groups"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:126
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:85
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:113
|
||||||
|
msgid "Migrated"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:127
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:86
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:114
|
||||||
|
msgid "Skipped"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:128
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:87
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:115
|
||||||
|
msgid "Errors"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:134
|
||||||
|
msgid "Content relations migration complete."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:137
|
||||||
|
msgid "Resume"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:137
|
||||||
|
msgid "Start"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:138
|
||||||
|
msgid "Pause"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:148
|
||||||
|
msgid "Next: Verification"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:175
|
||||||
|
msgid "Error during migration."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:184
|
||||||
|
msgid "Done! Reload the page to continue."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:193
|
||||||
|
msgid "Network error. Click Resume to continue."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:209
|
||||||
|
msgid "Running…"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:219
|
||||||
|
msgid "Paused."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:249
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:50
|
||||||
|
msgid "Relation already exists in MLP5 (idempotent skip)."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:278
|
||||||
|
msgid "Fewer than 2 valid members after orphan check. Skipped."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %d: member count
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:288
|
||||||
|
#, php-format
|
||||||
|
msgid "Group migrated with %d members."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-content-relations.php:290
|
||||||
|
msgid "Failed to write group to MLP5."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:48
|
||||||
|
msgid "MLP2 tables have not been renamed yet. Go back to the plugin status page and click \"Rename MLP2 tables\"."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:50
|
||||||
|
msgid "No MLP2 tables found (neither original nor backup). Restore your database from a backup before proceeding."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:55
|
||||||
|
msgid "MultilingualPress 5 is not network-active. Activate it before running the migration."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:78
|
||||||
|
msgid "Step 1 — Preflight Checks"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:83
|
||||||
|
msgid "MLP2 backup tables (preparation done)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. translators: %d: table count
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:86
|
||||||
|
#, php-format
|
||||||
|
msgid "%d table ready"
|
||||||
|
msgid_plural "%d tables ready"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:88
|
||||||
|
msgid "Original tables still present — rename step not done"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:90
|
||||||
|
msgid "No MLP2 tables found"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:95
|
||||||
|
msgid "MLP2 plugin (active — informational only)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:98
|
||||||
|
msgid "Active — consider deactivating before proceeding"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:100
|
||||||
|
msgid "Inactive (expected)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:133
|
||||||
|
msgid "Next: Run Analysis"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-preflight.php:136
|
||||||
|
msgid "Resolve the issues above before continuing."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:43
|
||||||
|
msgid "One or both sites no longer exist in the network."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:57
|
||||||
|
msgid "Site relation migrated successfully."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:60
|
||||||
|
msgid "Failed to write site relation to MLP5."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:79
|
||||||
|
msgid "Step 3 — Site Relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:80
|
||||||
|
msgid "This step migrates site connections and language assignments from MLP2 to MLP5. It usually completes in seconds."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:98
|
||||||
|
msgid "Re-run Site Relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:98
|
||||||
|
msgid "Start Site Relations Migration"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-site-relations.php:107
|
||||||
|
msgid "Next: Content Relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:34
|
||||||
|
msgid "Post Relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:38
|
||||||
|
msgid "Term Relations"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:81
|
||||||
|
msgid "You do not have permission to export the log."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:105
|
||||||
|
msgid "Step 5 — Verification"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:106
|
||||||
|
msgid "Compare expected totals (from the Analysis step) with actual migration results. Download the full log before proceeding to cleanup."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:112
|
||||||
|
msgid "Expected"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:142
|
||||||
|
msgid "Download log (CSV)"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5-step-verification.php:150
|
||||||
|
msgid "Next: Cleanup"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5.php:72
|
||||||
|
msgid "MLP2 to MLP5 Migrator requires a WordPress Multisite installation."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5.php:73
|
||||||
|
msgid "Plugin Activation Error"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: includes/class-robotstxt-mlp2-mlp5.php:101
|
||||||
|
msgid "MLP2 to MLP5 Migrator requires a WordPress Multisite installation and has been deactivated."
|
||||||
|
msgstr ""
|
||||||
397
readme.txt
Normal file
397
readme.txt
Normal file
|
|
@ -0,0 +1,397 @@
|
||||||
|
=== MLP2 to MLP5 (by ROBOTSTXT) ===
|
||||||
|
Contributors: javiercasares, robotstxt
|
||||||
|
Tags: multisite, multilingual, multilingualpress, migration, mlp
|
||||||
|
Requires at least: 6.7
|
||||||
|
Tested up to: 6.9
|
||||||
|
Stable tag: 1.0.0
|
||||||
|
Requires PHP: 8.2
|
||||||
|
Version: 1.0.0
|
||||||
|
License: GPL-3.0-or-later
|
||||||
|
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
Network: true
|
||||||
|
|
||||||
|
Guided, safe, and reversible migration from MultilingualPress 2 to MultilingualPress 5 for WordPress Multisite.
|
||||||
|
|
||||||
|
== Description ==
|
||||||
|
|
||||||
|
MLP2 to MLP5 (by ROBOTSTXT) provides a guided, safe, and reversible migration path from MultilingualPress 2 (free) to MultilingualPress 5 (premium) on WordPress Multisite.
|
||||||
|
|
||||||
|
MultilingualPress 5 has a completely different architecture from version 2, making a direct upgrade impossible without losing all site connections and content relationships. This plugin bridges that gap with a preparation step and a six-step wizard that migrates your data without modifying or deleting the original MLP2 data at any point during the process.
|
||||||
|
|
||||||
|
**What this plugin migrates:**
|
||||||
|
|
||||||
|
* Site connections (which network sites are linked to each other)
|
||||||
|
* Language assignments (which language/locale is assigned to each site)
|
||||||
|
* Post relationships (pages, posts, and custom post types linked across sites)
|
||||||
|
* Term relationships (categories, tags, and custom taxonomy terms linked across sites)
|
||||||
|
|
||||||
|
**Key features:**
|
||||||
|
|
||||||
|
* Works with MultilingualPress 2 deactivated — only its database tables need to exist
|
||||||
|
* Safely renames MLP2 tables so that MultilingualPress 5 can activate without errors
|
||||||
|
* Fully idempotent — safe to pause and resume without creating duplicates
|
||||||
|
* Complete migration log with CSV export
|
||||||
|
* Optional cleanup step to remove MLP2 backup tables and network settings after a successful migration
|
||||||
|
|
||||||
|
== Before You Begin ==
|
||||||
|
|
||||||
|
Read this section carefully before starting the migration. Skipping steps or performing them out of order will result in a failed migration.
|
||||||
|
|
||||||
|
=== Why the Order Matters ===
|
||||||
|
|
||||||
|
MultilingualPress 5 **refuses to activate** if it detects tables with the original MLP2 naming pattern (`{prefix}mlp_*`) in the database. It shows a blocking error and does not activate. You cannot dismiss this error by ignoring it.
|
||||||
|
|
||||||
|
The correct sequence is:
|
||||||
|
|
||||||
|
1. Install this migrator plugin first (while MLP2 tables still exist under their original names).
|
||||||
|
2. Use the migrator to rename the MLP2 tables to temporary backup copies.
|
||||||
|
3. Only then install and activate MultilingualPress 5.
|
||||||
|
4. Run the migration wizard.
|
||||||
|
|
||||||
|
This plugin exists precisely to manage this sequence safely.
|
||||||
|
|
||||||
|
=== Requirements ===
|
||||||
|
|
||||||
|
* WordPress Multisite 6.7 or higher
|
||||||
|
* PHP 8.2 – 8.5
|
||||||
|
* MultilingualPress 5 installed and network-activated (after the preparation step below)
|
||||||
|
* MultilingualPress 2 database tables present in the database (the plugin itself may be deactivated or uninstalled)
|
||||||
|
|
||||||
|
=== Critical Rules ===
|
||||||
|
|
||||||
|
1. **Never install MLP5 before running the table-rename step in this plugin.** MLP5 will refuse to activate.
|
||||||
|
2. **Do not delete MLP2 tables before running the migration.** The migrator reads directly from those tables.
|
||||||
|
3. **Do not run any MLP5 database reset or cleanup.** Let the migrator handle the transition.
|
||||||
|
4. **Always create a full backup before starting.** The migration is non-destructive, but a backup is mandatory.
|
||||||
|
|
||||||
|
== Installation ==
|
||||||
|
|
||||||
|
This plugin is not distributed via the WordPress Plugin Directory. Install it manually.
|
||||||
|
|
||||||
|
=== Manual Installation ===
|
||||||
|
|
||||||
|
1. Download the plugin ZIP file.
|
||||||
|
2. In your WordPress Network Admin, go to **Plugins > Add New > Upload Plugin**.
|
||||||
|
3. Upload the ZIP file and click **Install Now**.
|
||||||
|
4. Click **Network Activate**.
|
||||||
|
|
||||||
|
Do not activate this plugin on a per-site basis. It must be network-activated.
|
||||||
|
|
||||||
|
== Using the Plugin ==
|
||||||
|
|
||||||
|
=== Complete Step-by-Step Migration Guide ===
|
||||||
|
|
||||||
|
Follow these steps in exact order. Do not skip any step, and do not proceed to the next step until the current one is complete.
|
||||||
|
|
||||||
|
**This guide covers the primary scenario: MultilingualPress 2 was deactivated (for example, due to PHP 8.4 incompatibility) and its database tables remain in the database.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Step 0 — Create a Full Backup (Mandatory) =
|
||||||
|
|
||||||
|
Before doing anything else, create a complete backup of your WordPress database and all files.
|
||||||
|
|
||||||
|
Using WP-CLI:
|
||||||
|
|
||||||
|
wp db export backup-before-mlp-migration.sql --add-drop-table
|
||||||
|
|
||||||
|
Using a backup plugin (e.g., UpdraftPlus, BackWPup) or your hosting control panel are also valid options.
|
||||||
|
|
||||||
|
**Do not proceed without a backup. This step is not optional.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Step 1 — Deactivate MultilingualPress 2 =
|
||||||
|
|
||||||
|
If MultilingualPress 2 is still active on your network:
|
||||||
|
|
||||||
|
1. Go to **Network Admin > Plugins**.
|
||||||
|
2. Find MultilingualPress 2 in the list.
|
||||||
|
3. Click **Network Deactivate**.
|
||||||
|
|
||||||
|
**Do not click "Delete".** The plugin files may be removed later, but the database tables must remain intact for the migration. Deleting the plugin only removes PHP files — the tables are preserved.
|
||||||
|
|
||||||
|
If MultilingualPress 2 was already deactivated (for example, because it is incompatible with your current PHP version), skip this step. The database tables remain in place regardless.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Step 2 — Install and Activate MLP2 to MLP5 Migrator =
|
||||||
|
|
||||||
|
Install this plugin before installing MultilingualPress 5.
|
||||||
|
|
||||||
|
1. Download the MLP2 to MLP5 Migrator ZIP.
|
||||||
|
2. Go to **Network Admin > Plugins > Add New > Upload Plugin**.
|
||||||
|
3. Upload the ZIP and click **Install Now**.
|
||||||
|
4. Click **Network Activate**.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Step 3 — Rename MLP2 Tables =
|
||||||
|
|
||||||
|
This step makes it possible for MultilingualPress 5 to activate. Without it, MLP5 will show a blocking error and refuse to start.
|
||||||
|
|
||||||
|
1. Go to **Network Admin > Settings > MLP Migrator**.
|
||||||
|
2. The page will detect your MLP2 tables and show the current system state.
|
||||||
|
3. Click **"Rename MLP2 tables (prepare for MLP5 activation)"**.
|
||||||
|
4. The plugin renames all `{prefix}mlp_*` tables to `{prefix}mlp2bak_*` backup copies.
|
||||||
|
5. The page reloads and shows: *"MLP2 tables renamed. Now go to Network Admin > Plugins and activate MultilingualPress 5."*
|
||||||
|
|
||||||
|
Your data is safe. The tables have been renamed, not deleted. Nothing has been modified.
|
||||||
|
|
||||||
|
If you need to undo this step (for example, if you decide not to proceed), use the **"Restore original table names"** link at the bottom of the page.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Step 4 — Install and Activate MultilingualPress 5 =
|
||||||
|
|
||||||
|
Now that the MLP2 tables have been renamed, MultilingualPress 5 can activate without errors.
|
||||||
|
|
||||||
|
1. Obtain the MultilingualPress 5 ZIP from your license provider.
|
||||||
|
2. Go to **Network Admin > Plugins > Add New > Upload Plugin**.
|
||||||
|
3. Upload the MultilingualPress 5 ZIP file and click **Install Now**.
|
||||||
|
4. Click **Network Activate**.
|
||||||
|
|
||||||
|
MultilingualPress 5 should activate cleanly. If it still shows a compatibility error, return to **Network Admin > Settings > MLP Migrator** to verify that the rename step completed successfully.
|
||||||
|
|
||||||
|
If MLP5 was already installed and network-activated (not possible if MLP2 tables were in their original state — see above), skip this step.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Step 5 — Run the Migration Wizard =
|
||||||
|
|
||||||
|
Go to **Network Admin > Settings > MLP Migrator**.
|
||||||
|
|
||||||
|
The page will confirm that the system is ready (backup tables found + MLP5 active). The wizard has six steps. Each step must be completed before the next one becomes available.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Wizard Step 1 — Preflight Checks =
|
||||||
|
|
||||||
|
The wizard automatically checks:
|
||||||
|
|
||||||
|
* **MLP2 backup tables detected** — verifies that the renamed MLP2 tables exist. This is the primary requirement.
|
||||||
|
* **MultilingualPress 5 active** — verifies that MLP5 is network-activated.
|
||||||
|
|
||||||
|
**If backup tables are not found:** Return to Step 3 and run the rename step. If original MLP2 tables are no longer present either, the tables may have been deleted — restore from your backup.
|
||||||
|
|
||||||
|
**If MLP5 is not active:** Activate it first (see Step 4).
|
||||||
|
|
||||||
|
**If MLP2 is still active:** An amber warning is shown recommending you deactivate it before continuing (see Step 1). The wizard still allows you to proceed.
|
||||||
|
|
||||||
|
A backup reminder is displayed. Confirm that you completed Step 0 before clicking **Next**.
|
||||||
|
|
||||||
|
Click **Next** to proceed to Step 2.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Wizard Step 2 — Analysis =
|
||||||
|
|
||||||
|
Click **Run Analysis** to scan the MLP2 backup database.
|
||||||
|
|
||||||
|
The wizard will display:
|
||||||
|
|
||||||
|
* Number of site connections found in MLP2
|
||||||
|
* Number of post relationships found in MLP2
|
||||||
|
* Number of term relationships found in MLP2
|
||||||
|
* Detected conflicts:
|
||||||
|
* **Orphaned sites** — sites referenced in MLP2 that no longer exist in the network
|
||||||
|
* **Orphaned posts** — posts referenced in MLP2 that no longer exist on their site
|
||||||
|
* **Orphaned terms** — terms referenced in MLP2 that no longer exist on their site
|
||||||
|
* **Duplicate relations** — duplicate rows in MLP2 tables
|
||||||
|
|
||||||
|
Conflicts are not blocking. They will be automatically skipped and logged during the migration with a clear explanation in the migration log.
|
||||||
|
|
||||||
|
Review the summary to understand what will be migrated. Click **Next** to proceed to Step 3.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Wizard Step 3 — Site Relations =
|
||||||
|
|
||||||
|
Click **Start** to migrate site connections and language assignments.
|
||||||
|
|
||||||
|
The wizard reads all site connections from the MLP2 backup tables and writes them to MultilingualPress 5 in the correct format. Language/locale assignments for each site are also migrated.
|
||||||
|
|
||||||
|
This step usually completes in seconds. Results are displayed as:
|
||||||
|
|
||||||
|
* **Migrated** — successfully written to MLP5
|
||||||
|
* **Skipped** — already existed in MLP5, or referenced a site that no longer exists
|
||||||
|
* **Errors** — failed to write; check the migration log for details
|
||||||
|
|
||||||
|
Errors at this step are rare. If you see errors, download the log at Step 5 and review before continuing.
|
||||||
|
|
||||||
|
Click **Next** to proceed to Step 4.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Wizard Step 4 — Content Relations =
|
||||||
|
|
||||||
|
This step migrates all post and term relationships. On large sites with thousands of relationships, this step can take several minutes.
|
||||||
|
|
||||||
|
Click **Start** to begin. A progress bar updates in real time showing:
|
||||||
|
|
||||||
|
* Total relationships to process
|
||||||
|
* Migrated (successfully written to MLP5)
|
||||||
|
* Skipped (orphaned content, duplicates, or already migrated)
|
||||||
|
* Errors
|
||||||
|
|
||||||
|
**If you need to pause:**
|
||||||
|
|
||||||
|
1. Click **Pause** — the current position is saved automatically.
|
||||||
|
2. You can close the browser or leave the page.
|
||||||
|
3. Return to **Network Admin > Settings > MLP Migrator** at any time.
|
||||||
|
4. Click **Resume** to continue from exactly where you stopped.
|
||||||
|
|
||||||
|
No data will be duplicated if you pause and resume. The migration is fully idempotent.
|
||||||
|
|
||||||
|
Wait for the progress bar to reach 100% before continuing. Click **Next** to proceed to Step 5.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Wizard Step 5 — Verification =
|
||||||
|
|
||||||
|
The wizard displays a comparison report showing, for each category (site relations, post relations, term relations):
|
||||||
|
|
||||||
|
* **Expected** — count from the analysis in Step 2
|
||||||
|
* **Migrated** — successfully written to MLP5
|
||||||
|
* **Skipped** — omitted with a reason (see log)
|
||||||
|
* **Errors** — failed operations
|
||||||
|
|
||||||
|
Color coding:
|
||||||
|
|
||||||
|
* Green — migrated count matches expected and errors are zero
|
||||||
|
* Amber — some errors occurred; review the log
|
||||||
|
* Red — nothing was migrated despite records being expected; action may be required
|
||||||
|
|
||||||
|
Click **Download log (CSV)** to save the full migration log to your computer. **Save this file.** It is the only permanent record of what happened during the migration.
|
||||||
|
|
||||||
|
Review the report carefully. If the error count is unexpectedly high, stop here and investigate before proceeding to cleanup.
|
||||||
|
|
||||||
|
Click **Next** to proceed to Step 6.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Wizard Step 6 — Cleanup (Optional) =
|
||||||
|
|
||||||
|
This step is optional. MultilingualPress 5 will work correctly whether or not you perform the cleanup.
|
||||||
|
|
||||||
|
Three independent cleanup actions are offered:
|
||||||
|
|
||||||
|
1. **Deactivate MultilingualPress 2 (network-wide)** — if MLP2 is still active, this deactivates it.
|
||||||
|
|
||||||
|
2. **Delete MLP2 backup database tables** — permanently drops all `{prefix}mlp2bak_*` tables from the database. **This action is irreversible.** Only proceed if:
|
||||||
|
* You have verified that the migration completed successfully in Step 5
|
||||||
|
* You have a backup from Step 0
|
||||||
|
* You have downloaded the migration log
|
||||||
|
|
||||||
|
3. **Delete MultilingualPress 2 network settings** — removes MLP2-related entries from `wp_sitemeta`.
|
||||||
|
|
||||||
|
**To proceed with cleanup:**
|
||||||
|
|
||||||
|
1. Select the checkboxes for the actions you want to perform.
|
||||||
|
2. Note: option 2 (delete tables) is only available if option 1 (deactivate) is also selected.
|
||||||
|
3. Type `DELETE` (exactly, in uppercase) in the confirmation field.
|
||||||
|
4. Click **Proceed with cleanup**.
|
||||||
|
|
||||||
|
If you do not type `DELETE` exactly, the button remains disabled and no action will be taken.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Step 6 — Verify MultilingualPress 5 =
|
||||||
|
|
||||||
|
After the wizard completes:
|
||||||
|
|
||||||
|
1. Browse your multisite network and verify that content is properly linked across sites in MultilingualPress 5.
|
||||||
|
2. Go to **Network Admin > Sites** and check each site's language assignment in MLP5.
|
||||||
|
3. Visit the frontend and confirm that the language switcher works correctly.
|
||||||
|
4. Check a few posts and verify that their translations are correctly linked in MLP5.
|
||||||
|
|
||||||
|
If something looks wrong, compare against the migration log (Wizard Step 5). Do not delete the backup tables until you are satisfied with the result.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
= Step 7 — Deactivate the Migrator Plugin (Optional) =
|
||||||
|
|
||||||
|
Once you have confirmed that MLP5 is fully working:
|
||||||
|
|
||||||
|
1. Go to **Network Admin > Plugins**.
|
||||||
|
2. Find "MLP2 to MLP5 Migrator" and click **Network Deactivate**.
|
||||||
|
3. Click **Delete** to remove the plugin files.
|
||||||
|
|
||||||
|
The migration log table is preserved in the database unless you have enabled the "Delete migration log on uninstall" option in the plugin settings.
|
||||||
|
|
||||||
|
== Frequently Asked Questions ==
|
||||||
|
|
||||||
|
= Does MultilingualPress 2 need to be active during migration? =
|
||||||
|
|
||||||
|
No. MultilingualPress 2 only needs its database tables to still be present in the database. The plugin itself can be deactivated or even uninstalled. This is the primary expected scenario — for example, when MLP2 was deactivated because it is incompatible with PHP 8.4.
|
||||||
|
|
||||||
|
= Why does MultilingualPress 5 show a blocking error and refuse to activate? =
|
||||||
|
|
||||||
|
MLP5 detects the presence of tables named `{prefix}mlp_*` and refuses to activate, showing the message: *"It seems that an old version of MultilingualPress is installed in this website."* This is a hard block, not a warning. Use the **Rename MLP2 tables** action in this plugin (Step 3 above) before attempting to activate MLP5.
|
||||||
|
|
||||||
|
= Can I pause and resume the migration? =
|
||||||
|
|
||||||
|
Yes. The content relations step (Wizard Step 4) supports pause and resume. If the browser is closed or the server times out, return to the wizard and click Resume. No data will be duplicated — the migration is fully idempotent.
|
||||||
|
|
||||||
|
= What does "Skipped" mean in the results? =
|
||||||
|
|
||||||
|
Skipped records are normal and expected. Common reasons:
|
||||||
|
|
||||||
|
* The relationship already exists in MLP5 (idempotency)
|
||||||
|
* The post or term no longer exists on one of the linked sites
|
||||||
|
* The site was deleted from the network after the MLP2 data was created
|
||||||
|
* A locale string used in MLP2 is not recognized by MLP5
|
||||||
|
|
||||||
|
All skipped records are logged with a specific reason. Download the CSV log from Wizard Step 5 to review them.
|
||||||
|
|
||||||
|
= Is it safe to run the migration more than once? =
|
||||||
|
|
||||||
|
Yes. Running the migration multiple times will not create duplicate data in MLP5. Records already migrated are detected and logged as "Skipped".
|
||||||
|
|
||||||
|
= What are the {prefix}mlp2bak_* tables? =
|
||||||
|
|
||||||
|
These are the renamed copies of your original MLP2 tables. This plugin renames them from `{prefix}mlp_*` to `{prefix}mlp2bak_*` during Step 3. The data is untouched — only the table names change. These backup tables are what the migration wizard reads from. You can safely delete them after a successful migration using Wizard Step 6.
|
||||||
|
|
||||||
|
= What data is modified or deleted during migration? =
|
||||||
|
|
||||||
|
None during the migration itself. The preparation step (Step 3) renames tables but does not modify any data. The optional cleanup in Wizard Step 6 is the only action that deletes data, and it requires explicit confirmation by typing "DELETE".
|
||||||
|
|
||||||
|
= Can I use this plugin without MultilingualPress 5 installed? =
|
||||||
|
|
||||||
|
You can install this plugin and run the table-rename step (Step 3) without MLP5 present. However, MLP5 must be installed and network-activated before running the migration wizard. The wizard will not allow you to proceed to Step 2 without it.
|
||||||
|
|
||||||
|
= What PHP versions are supported? =
|
||||||
|
|
||||||
|
PHP 8.2 through 8.5. Note that MultilingualPress 2 is not compatible with PHP 8.4 or higher, which is the most common reason to use this migrator.
|
||||||
|
|
||||||
|
== Compatibility ==
|
||||||
|
|
||||||
|
* WordPress: 6.7 – 6.9
|
||||||
|
* PHP: 8.2 – 8.5
|
||||||
|
* Requires: MultilingualPress 5 (premium, any recent version)
|
||||||
|
* Compatible with: MultilingualPress 2 (latest release from WordPress.org)
|
||||||
|
|
||||||
|
== Changelog ==
|
||||||
|
|
||||||
|
= 1.0.0 =
|
||||||
|
|
||||||
|
_Release date: 2026-02-27_
|
||||||
|
|
||||||
|
* First production release. Complete six-step migration wizard.
|
||||||
|
* Table preparation, preflight checks, analysis, site relations, content relations (AJAX batch), verification with CSV export, and optional cleanup.
|
||||||
|
* Supports `multilingual_linked` as alternative MLP2 content relations table.
|
||||||
|
* Spanish (es_ES) translation included.
|
||||||
|
|
||||||
|
= Previous versions =
|
||||||
|
|
||||||
|
See the full changelog at changelog.txt.
|
||||||
|
|
||||||
|
== Compliance ==
|
||||||
|
|
||||||
|
This plugin adheres to the following security measures and review protocols for each version:
|
||||||
|
|
||||||
|
* [WordPress Plugin Handbook](https://developer.wordpress.org/plugins/)
|
||||||
|
* [WordPress Plugin Security](https://developer.wordpress.org/plugins/wordpress-org/plugin-security/)
|
||||||
|
* [WordPress APIs Security](https://developer.wordpress.org/apis/security/)
|
||||||
|
* [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards)
|
||||||
|
* [Plugin Check (PCP)](https://wordpress.org/plugins/plugin-check/)
|
||||||
59
robotstxt-mlp2-mlp5.php
Normal file
59
robotstxt-mlp2-mlp5.php
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Plugin Name: MLP2 to MLP5 (by ROBOTSTXT)
|
||||||
|
* Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-mlp2-mlp5
|
||||||
|
* Description: Guided, safe, and reversible migration from MultilingualPress 2 to MultilingualPress 5.
|
||||||
|
* Version: 1.0.0
|
||||||
|
* Author: ROBOTSTXT
|
||||||
|
* Author URI: https://git.robotstxt.es/ROBOTSTXT
|
||||||
|
* License: GPL-3.0-or-later
|
||||||
|
* License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
*
|
||||||
|
* Requires at least: 6.7
|
||||||
|
* Requires PHP: 8.2
|
||||||
|
* Network: true
|
||||||
|
* Text Domain: robotstxt-mlp2-mlp5
|
||||||
|
* Domain Path: /languages
|
||||||
|
* Gitea Plugin URI: ROBOTSTXT/robotstxt-mlp2-mlp5
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current database schema version.
|
||||||
|
*
|
||||||
|
* Increment this constant whenever a new version of the plugin alters any
|
||||||
|
* database table. The DB upgrader compares this value with the version stored
|
||||||
|
* in the `mlp_migrator_db_version` sitemeta key and runs any pending upgrade
|
||||||
|
* routines automatically on the next request after a plugin update.
|
||||||
|
*/
|
||||||
|
define( 'ROBOTSTXT_MLP2_MLP5_VERSION', '1.0.0' );
|
||||||
|
define( 'ROBOTSTXT_MLP2_MLP5_DB_VERSION', '1.0' );
|
||||||
|
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-logger.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-db-upgrader.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-table-preparer.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-detector-mlp2.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-detector-mlp5.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-wizard-state.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-step-preflight.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-step-analysis.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-reader-site-relations.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-writer-site-relations.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-step-site-relations.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-reader-content-relations.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-writer-content-relations.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-step-content-relations.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-step-verification.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-step-cleanup.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-ajax.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-admin-page.php';
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5.php';
|
||||||
|
require_once __DIR__ . '/robotstxt-updater.php';
|
||||||
|
|
||||||
|
Robotstxt_Mlp2_Mlp5::init( __FILE__ );
|
||||||
|
Robotstxt_Updater::init( __FILE__ );
|
||||||
383
robotstxt-updater.php
Normal file
383
robotstxt-updater.php
Normal file
|
|
@ -0,0 +1,383 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Generic JSON-based updater for ROBOTSTXT plugins.
|
||||||
|
*
|
||||||
|
* This file is designed to be copied to any ROBOTSTXT plugin.
|
||||||
|
* It auto-configures itself by reading the plugin headers.
|
||||||
|
*
|
||||||
|
* @package ROBOTSTXT
|
||||||
|
* @version 1.0.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! class_exists( 'Robotstxt_Updater' ) ) {
|
||||||
|
/**
|
||||||
|
* Class Robotstxt_Updater
|
||||||
|
*
|
||||||
|
* Generic updater that works with any plugin.
|
||||||
|
* Reads plugin headers and constructs update URL automatically.
|
||||||
|
*/
|
||||||
|
class Robotstxt_Updater {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin file path.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $plugin_file_path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin basename (e.g., 'my-plugin/my-plugin.php').
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $plugin_basename;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin slug (directory name).
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $plugin_slug;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remote JSON URL.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $json_url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache key.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $cache_key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin headers.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private array $plugin_data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the updater.
|
||||||
|
*
|
||||||
|
* Usage in your main plugin file:
|
||||||
|
* require_once __DIR__ . '/robotstxt-updater.php';
|
||||||
|
* Robotstxt_Updater::init( __FILE__ );
|
||||||
|
*
|
||||||
|
* @param string $plugin_file_path Absolute path to the main plugin file.
|
||||||
|
*/
|
||||||
|
public static function init( string $plugin_file_path ): void {
|
||||||
|
$instance = new self( $plugin_file_path );
|
||||||
|
$instance->register();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $plugin_file_path Absolute path to the main plugin file.
|
||||||
|
*/
|
||||||
|
private function __construct( string $plugin_file_path ) {
|
||||||
|
$this->plugin_file_path = $plugin_file_path;
|
||||||
|
$this->plugin_basename = plugin_basename( $plugin_file_path );
|
||||||
|
$this->plugin_slug = dirname( $this->plugin_basename );
|
||||||
|
$this->plugin_data = $this->get_plugin_data();
|
||||||
|
$this->json_url = $this->build_json_url();
|
||||||
|
$this->cache_key = 'robotstxt_updater_' . md5( $this->plugin_basename );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register WordPress hooks.
|
||||||
|
*/
|
||||||
|
private function register(): void {
|
||||||
|
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'inject_update_info' ) );
|
||||||
|
add_filter( 'plugins_api', array( $this, 'provide_plugin_details' ), 10, 3 );
|
||||||
|
add_action( 'admin_init', array( $this, 'handle_cache_clear' ) );
|
||||||
|
add_action( 'robotstxt_updater_clear_cache', array( $this, 'clear_cache' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get plugin headers.
|
||||||
|
*
|
||||||
|
* @return array Plugin data.
|
||||||
|
*/
|
||||||
|
private function get_plugin_data(): array {
|
||||||
|
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||||
|
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
return get_plugin_data( $this->plugin_file_path, false, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build JSON URL from plugin headers.
|
||||||
|
*
|
||||||
|
* Tries to use "Gitea Plugin URI" header to construct the URL.
|
||||||
|
* Falls back to Plugin URI if Gitea URI is not available.
|
||||||
|
*
|
||||||
|
* @return string JSON URL.
|
||||||
|
*/
|
||||||
|
private function build_json_url(): string {
|
||||||
|
// Try Gitea Plugin URI (format: "OWNER/REPO" or full URL).
|
||||||
|
if ( ! empty( $this->plugin_data['Gitea Plugin URI'] ) ) {
|
||||||
|
$gitea_uri = $this->plugin_data['Gitea Plugin URI'];
|
||||||
|
|
||||||
|
// If it's already a full URL, use it.
|
||||||
|
if ( str_starts_with( $gitea_uri, 'http' ) ) {
|
||||||
|
// Extract base URL and construct JSON path.
|
||||||
|
return rtrim( $gitea_uri, '/' ) . '/raw/branch/main/update.json';
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's in format "OWNER/REPO", construct full URL.
|
||||||
|
if ( preg_match( '#^[^/]+/[^/]+$#', $gitea_uri ) ) {
|
||||||
|
return "https://git.robotstxt.es/{$gitea_uri}/raw/branch/main/update.json";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: try to extract from Plugin URI.
|
||||||
|
if ( ! empty( $this->plugin_data['PluginURI'] ) ) {
|
||||||
|
$plugin_uri = $this->plugin_data['PluginURI'];
|
||||||
|
if ( str_contains( $plugin_uri, 'git.robotstxt.es' ) ) {
|
||||||
|
return rtrim( $plugin_uri, '/' ) . '/raw/branch/main/update.json';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last resort: construct from plugin slug.
|
||||||
|
return "https://git.robotstxt.es/ROBOTSTXT/{$this->plugin_slug}/raw/branch/main/update.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inject update info into WP's plugin update transient.
|
||||||
|
*
|
||||||
|
* @param object|mixed $transient The update_plugins transient.
|
||||||
|
*
|
||||||
|
* @return object The modified transient.
|
||||||
|
*/
|
||||||
|
public function inject_update_info( $transient ) {
|
||||||
|
if ( ! is_object( $transient ) ) {
|
||||||
|
$transient = new stdClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $transient->checked ) || ! is_array( $transient->checked ) ) {
|
||||||
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $transient->checked[ $this->plugin_basename ] ) ) {
|
||||||
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current_version = $transient->checked[ $this->plugin_basename ];
|
||||||
|
$remote = $this->get_remote_data();
|
||||||
|
|
||||||
|
if ( empty( $remote['version'] ) || empty( $remote['download_url'] ) ) {
|
||||||
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $this->is_compatible( $remote ) ) {
|
||||||
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version_compare( $remote['version'], $current_version, '>' ) ) {
|
||||||
|
$update = (object) array(
|
||||||
|
'slug' => $remote['slug'] ?? $this->plugin_slug,
|
||||||
|
'plugin' => $this->plugin_basename,
|
||||||
|
'new_version' => $remote['version'],
|
||||||
|
'url' => $remote['homepage'] ?? $this->plugin_data['PluginURI'] ?? '',
|
||||||
|
'package' => $remote['download_url'],
|
||||||
|
'tested' => $remote['tested'] ?? '',
|
||||||
|
'requires' => $remote['requires'] ?? '',
|
||||||
|
'requires_php' => $remote['requires_php'] ?? '',
|
||||||
|
);
|
||||||
|
|
||||||
|
$transient->response[ $this->plugin_basename ] = $update;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $transient;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide "View details" modal content.
|
||||||
|
*
|
||||||
|
* @param false|object|array $result The result object or array.
|
||||||
|
* @param string $action The type of information being requested.
|
||||||
|
* @param object $args Plugin API arguments.
|
||||||
|
*
|
||||||
|
* @return false|object The plugin information object or false.
|
||||||
|
*/
|
||||||
|
public function provide_plugin_details( $result, string $action, object $args ) {
|
||||||
|
if ( 'plugin_information' !== $action ) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( empty( $args->slug ) || $args->slug !== $this->plugin_slug ) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$remote = $this->get_remote_data();
|
||||||
|
|
||||||
|
if ( empty( $remote['version'] ) ) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (object) array(
|
||||||
|
'name' => $remote['name'] ?? $this->plugin_data['Name'] ?? $this->plugin_slug,
|
||||||
|
'slug' => $remote['slug'] ?? $this->plugin_slug,
|
||||||
|
'version' => $remote['version'],
|
||||||
|
'author' => $remote['author'] ?? $this->plugin_data['Author'] ?? '',
|
||||||
|
'homepage' => $remote['homepage'] ?? $this->plugin_data['PluginURI'] ?? '',
|
||||||
|
'requires' => $remote['requires'] ?? '',
|
||||||
|
'tested' => $remote['tested'] ?? '',
|
||||||
|
'requires_php' => $remote['requires_php'] ?? '',
|
||||||
|
'sections' => array(
|
||||||
|
'description' => $remote['description'] ?? $this->plugin_data['Description'] ?? '',
|
||||||
|
'changelog' => $remote['changelog'] ?? '',
|
||||||
|
),
|
||||||
|
'download_link' => $remote['download_url'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get remote data with caching and HMAC signature verification.
|
||||||
|
*
|
||||||
|
* @return array Remote data.
|
||||||
|
*/
|
||||||
|
private function get_remote_data(): array {
|
||||||
|
$cached = get_site_transient( $this->cache_key );
|
||||||
|
|
||||||
|
// Verify HMAC signature if AUTH_SALT is defined and cache has signature.
|
||||||
|
if ( false !== $cached && defined( 'AUTH_SALT' ) && '' !== AUTH_SALT ) {
|
||||||
|
if ( is_array( $cached ) && isset( $cached['signature'], $cached['data'] ) ) {
|
||||||
|
$expected_sig = hash_hmac( 'sha256', $this->cache_key . serialize( $cached['data'] ), AUTH_SALT );
|
||||||
|
|
||||||
|
if ( hash_equals( $expected_sig, $cached['signature'] ) ) {
|
||||||
|
// Signature valid, return data.
|
||||||
|
return is_array( $cached['data'] ) ? $cached['data'] : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Signature invalid, delete corrupted cache.
|
||||||
|
delete_site_transient( $this->cache_key );
|
||||||
|
$cached = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no valid cache, fetch fresh data.
|
||||||
|
if ( false === $cached ) {
|
||||||
|
$remote = $this->fetch_json();
|
||||||
|
|
||||||
|
// Store with HMAC signature if AUTH_SALT is available.
|
||||||
|
if ( defined( 'AUTH_SALT' ) && '' !== AUTH_SALT ) {
|
||||||
|
$payload = array(
|
||||||
|
'data' => $remote ?: array(),
|
||||||
|
'timestamp' => time(),
|
||||||
|
'signature' => hash_hmac( 'sha256', $this->cache_key . serialize( $remote ?: array() ), AUTH_SALT ),
|
||||||
|
);
|
||||||
|
set_site_transient( $this->cache_key, $payload, 6 * HOUR_IN_SECONDS );
|
||||||
|
} else {
|
||||||
|
// Fallback to standard caching.
|
||||||
|
set_site_transient( $this->cache_key, $remote ?: array(), 6 * HOUR_IN_SECONDS );
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_array( $remote ) ? $remote : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Legacy cache format without signature (backward compatibility).
|
||||||
|
return is_array( $cached ) ? $cached : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch JSON from remote URL.
|
||||||
|
*
|
||||||
|
* @return array Decoded JSON data.
|
||||||
|
*/
|
||||||
|
private function fetch_json(): array {
|
||||||
|
$response = wp_remote_get(
|
||||||
|
$this->json_url,
|
||||||
|
array(
|
||||||
|
'timeout' => 10,
|
||||||
|
'headers' => array(
|
||||||
|
'Accept' => 'application/json',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( is_wp_error( $response ) ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$code = (int) wp_remote_retrieve_response_code( $response );
|
||||||
|
if ( $code < 200 || $code >= 300 ) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = wp_remote_retrieve_body( $response );
|
||||||
|
$data = json_decode( $body, true );
|
||||||
|
|
||||||
|
return is_array( $data ) ? $data : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check compatibility.
|
||||||
|
*
|
||||||
|
* @param array $remote Remote data.
|
||||||
|
*
|
||||||
|
* @return bool True if compatible.
|
||||||
|
*/
|
||||||
|
private function is_compatible( array $remote ): bool {
|
||||||
|
if ( ! empty( $remote['requires_php'] ) ) {
|
||||||
|
if ( version_compare( PHP_VERSION, $remote['requires_php'], '<' ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $remote['requires'] ) ) {
|
||||||
|
if ( version_compare( get_bloginfo( 'version' ), $remote['requires'], '<' ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle manual cache clear via URL parameter.
|
||||||
|
*/
|
||||||
|
public function handle_cache_clear(): void {
|
||||||
|
// Check if this is a cache clear request first.
|
||||||
|
$clear_cache = filter_input( INPUT_GET, 'robotstxt_clear_update_cache', FILTER_UNSAFE_RAW );
|
||||||
|
if ( null === $clear_cache ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is a cache clear request - now verify nonce.
|
||||||
|
$nonce_raw = filter_input( INPUT_GET, '_wpnonce', FILTER_UNSAFE_RAW );
|
||||||
|
$nonce = $nonce_raw ? sanitize_text_field( wp_unslash( $nonce_raw ) ) : '';
|
||||||
|
|
||||||
|
if ( ! wp_verify_nonce( $nonce, 'robotstxt_clear_update_cache' ) ) {
|
||||||
|
wp_die( esc_html__( 'Security check failed', 'robotstxt-smtp' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check permissions.
|
||||||
|
if ( ! current_user_can( 'update_plugins' ) ) {
|
||||||
|
wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'robotstxt-smtp' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->clear_cache();
|
||||||
|
wp_safe_redirect( remove_query_arg( array( 'robotstxt_clear_update_cache', '_wpnonce' ) ) );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear update cache.
|
||||||
|
*/
|
||||||
|
public function clear_cache(): void {
|
||||||
|
delete_site_transient( $this->cache_key );
|
||||||
|
delete_site_transient( 'update_plugins' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
uninstall.php
Normal file
24
uninstall.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Plugin uninstall handler.
|
||||||
|
*
|
||||||
|
* Executed when the plugin is deleted from the WordPress admin.
|
||||||
|
* By default, all plugin data is preserved on uninstall. Users can opt in
|
||||||
|
* to data deletion via the plugin settings screen (network option
|
||||||
|
* `mlp_migrator_delete_on_uninstall`, default: false).
|
||||||
|
*
|
||||||
|
* @package Robotstxt_Mlp2_Mlp5
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( ! defined( 'ABSPATH' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once __DIR__ . '/includes/class-robotstxt-mlp2-mlp5-logger.php';
|
||||||
|
|
||||||
|
// Only delete data when the user has explicitly opted in.
|
||||||
|
if ( get_site_option( 'mlp_migrator_delete_on_uninstall', false ) ) {
|
||||||
|
Robotstxt_Mlp2_Mlp5_Logger::drop_table();
|
||||||
|
delete_site_option( 'mlp_migrator_delete_on_uninstall' );
|
||||||
|
delete_site_option( 'mlp_migrator_wizard_state' );
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue