WordPress Coding Standards compliance update. Stable Tag 2.5.10. Package version: 2.5.11d0.

git-svn-id: https://plugins.svn.wordpress.org/footnotes/trunk@2486043 b8457f37-d9ea-0310-8a92-e5e31aec5664
This commit is contained in:
pewgeuges 2021-03-03 18:58:03 +00:00
parent dfcbdc6adc
commit daf0a8612f
32 changed files with 4838 additions and 3664 deletions

37
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,37 @@
**footnotes** welcomes contributions!
Please follow these guidelines when contributing, as it will give your pull
request the best chance of being accepted:
# Requesting Features/Reporting Bugs
- To request a new feature or to report a bug, create an
[Issue](https://github.com/markcheret/footnotes/issues/new/choose) and choose
the correct template
# Contributing Code
- **footnotes** uses [GitHub Flow](https://githubflow.github.io/)
- branch off of `main` to start developing (`git checkout -b <your branch>`)
- ensure that your new branch has a descriptive name
- create a remote copy of your new branch (`git push`)
- create a draft [pull request](https://github.com/markcheret/footnotes/compare)
to merge your branch with `main` — tag any related Issues, and if they are
assigned to a Project board, this will automatically move them into the
In Progress bucket
- when you think you're finished, un-draft your pull request — if the PR is
assigned to a Project board, this will automatically move it and any related
Issues into the Review in progress bucket
# Commits
- **footnotes** uses [Conventional Commits](https://www.conventionalcommits.org)
- keep individual commits as small as possible
# Versioning
- **footnotes** uses [Semantic Versioning](https://semver.org/)
# Translating
- Translations are welcome!

674
LICENSE Normal file
View 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>.

68
README.md Normal file
View file

@ -0,0 +1,68 @@
![footnotes](https://raw.githubusercontent.com/markcheret/footnotes/main/img/footnotes.png)
# footnotes
## Description
Featured on [wpmudev](http://premium.wpmudev.org/blog/12-surprisingly-useful-wordpress-plugins-you-dont-know-about/) --- cheers for the review, folks!
**footnotes** aims to be the all-in-one solution for displaying an automatically generated list of references on your Page or Post. The Plugin ships with a set of defaults while also empowering you to control how your footnotes are being displayed.
**footnotes** gives you the ability to display well-formatted footnotes on your WordPress Pages and Posts — those footnotes we know from offline publishing.
## Getting Started
1. Read the contributing guidelines
1. Clone this repository (`git clone git@github.com:markcheret/footnotes.git`)
- We recommend that you use [VVV](https://varyingvagrantvagrants.org/) for your development environment
1. Install [Composer](https://getcomposer.org/download/), if you don't have it already
1. Install dependencies (`composer install`)
1. Create a new branch from `main` (`git checkout -b <your-descriptive-branch-name>`)
1. When you're finished, commit your changes to the remote version of your branch
and submit a [pull request](https://github.com/markcheret/footnotes/pulls).
## Checking WP Coding Standard Compliance
1. Run PHP_CodeSniffer on the file(s) you want to check (`./vendor/bin/phpcs --standard="WordPress" --colors --encoding=utf-8 -n -p <file(s)>`)
1. (If applicable) run the PHP Code Beautifier and Formatter to attempt to automatically fix any errors (`./vendor/bin/phpcbf --standard="WordPress" --encoding=utf-8 -p <file(s)>`)
- Add the `-n` flag to ignore warnings (i.e., show only errors)
- Add the `-s` flag to show sniff codes (used for disabling errors in the code with `phpcs disable:<sniff code>` — MAKE SURE THAT YOU HAVE `phpcs enable` AT THE EARLIEST POINT POSSIBLE, and provide a justification for disabling the sniff code)
- You can run either across the entire project by adding the argument `--ignore=*/vendor/*` and targetting the file `./**/*.php`
- You may have to enable double-wildcards in your console first (`shopt -s globstar`)
## Updating Documentation
1. Install [phpDocumentor](https://phpdoc.org/)
1. Run it (`phpDocumentor -d . -t docs`)
## Testing
Unit tests are TODO.
## Main Features
- Fully customizable **footnotes** start and end shortcodes;
- Styled tooltips supporting hyperlinks display **footnotes** or a dedicated text;
- Responsive *Reference Container* at the end or positioned by shortcode;
- Display the **footnotes** *Reference Container* inside a Widget;
- Wide choice of numbering styles;
- Freely configurable and optional backlink symbol;
- Configure the **footnotes'** appearance by dashboard settings and Custom CSS style rules;
- Button in both the Visual and the Text editor to add shortcodes around selection.
## Example Usage
These are a few examples of possible ways to delimit footnotes:
1. Your awesome text((with an awesome footnote))
2. Your awesome text[ref]with an awesome footnote[/ref]
3. Your awesome text`<fn>`with an awesome footnote`</fn>`
4. Your awesome text`custom-shortcode`with an awesome footnote`custom-shortcode`
## Where to get footnotes?
The current version is available on the [WordPress.org Plugin Directory](https://wordpress.org/plugins/footnotes/).
## Acknowledgements
Huge thanks to every **footnotes user**, contributor, bug reporter, feature requester and fan!

19
SECURITY.md Normal file
View file

@ -0,0 +1,19 @@
# Security Policy
## Supported Versions
Use this section to tell people about which versions of your project are
currently being supported with security updates.
| Version | Supported |
| ------- | ------------------ |
| 2.x.x | :white_check_mark: |
| 1.x.x | :x: |
## Reporting a Vulnerability
To securely report a vulnerability, please DO NOT post on the WordPress
Support Forum or create an Issue on this repository.
Please email [mark@cheret.de](mailto:mark@cheret.de) privately with the
full details of the vulnerability.

View file

@ -1,51 +1,44 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName
/**
* Includes the Plugin Constants class to load all Plugin constant vars like Plugin name, etc.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*
* Edited for:
* 2.0.4 add Public Plugin name for dashboard heading 2020-11-01T0452+0100
*
* Last modified: 2021-02-18T2027+0100
* @package footnotes
* @since 1.5.0
* @date 12.09.14 10:56
*
* @since 2.0.4 add Public Plugin name for dashboard heading 2020-11-01T0452+0100
*/
/**
* Contains all Plugin Constants. Contains no Method or Property.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Config {
/**
* Internal Plugin name.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_PLUGIN_NAME = "footnotes";
const C_STR_PLUGIN_NAME = 'footnotes';
/**
* Public Plugin name.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*
*
* edited classes for v2.0.4
*/
const C_STR_PLUGIN_PUBLIC_NAME = '<span class="footnotes_logo footnotes_logo_part1">foot</span><span class="footnotes_logo footnotes_logo_part2">notes</span>';
/**
* Public Plugin name for dashboard heading
*
*
* After properly displaying in dashboard headings until WPv5.4, the above started
* in WPv5.5 being torn apart as if the headline was text-align:justify and not
* in WPv5.5 being torn apart as if the headline was text-align:justify and not
* the last line. That ugly display bug badly affected the plugins communication.
* The only working solution found so far is using position:fixed in one heading
* that isnt translated, and dropping the logo in another, translatable heading.
@ -58,7 +51,6 @@ class MCI_Footnotes_Config {
/**
* Html tag for the LOVE symbol.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
@ -75,7 +67,6 @@ class MCI_Footnotes_Config {
/**
* Short code to DON'T display the 'LOVE ME' slug on certain pages.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/

View file

@ -3,20 +3,16 @@
* Includes the Convert Class.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*
* Edited:
* @package footnotes
* @since 1.5.0
* @date 12.09.14 10:56
*
* @since 2.2.0 add lowercase Roman 2020-12-12T1540+0100
*
* Last modified: 2020-12-12T1541+0100
*/
/**
* Converts data types and Footnotes specific values.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Convert {
@ -24,30 +20,29 @@ class MCI_Footnotes_Convert {
/**
* Converts a integer into the user-defined counter style for the footnotes.
*
* @author Stefan Herndler
* @since 1.5.0
* @param int $p_int_Index Index to be converted.
* @param string $p_str_ConvertStyle Style of the new/converted Index.
* @param int $p_int_index Index to be converted.
* @param string $p_str_convert_style Style of the new/converted Index.
* @return string Converted Index as string in the defined counter style.
*
*
* Edited:
* @since 2.2.0 lowercase Roman numerals supported
*/
public static function Index($p_int_Index, $p_str_ConvertStyle = "arabic_plain") {
switch ($p_str_ConvertStyle) {
case "romanic":
return self::toRomanic($p_int_Index, true);
case "roman_low":
return self::toRomanic($p_int_Index, false);
case "latin_high":
return self::toLatin($p_int_Index, true);
case "latin_low":
return self::toLatin($p_int_Index, false);
case "arabic_leading":
return self::toArabicLeading($p_int_Index);
case "arabic_plain":
public static function index( $p_int_index, $p_str_convert_style = 'arabic_plain' ) {
switch ( $p_str_convert_style ) {
case 'romanic':
return self::to_romanic( $p_int_index, true );
case 'roman_low':
return self::to_romanic( $p_int_index, false );
case 'latin_high':
return self::to_latin( $p_int_index, true );
case 'latin_low':
return self::to_latin( $p_int_index, false );
case 'arabic_leading':
return self::to_arabic_leading( $p_int_index );
case 'arabic_plain':
default:
return $p_int_Index;
return $p_int_index;
}
}
@ -55,175 +50,174 @@ class MCI_Footnotes_Convert {
* Converts an integer into latin ascii characters, either lower or upper-case.
* Function available from A to ZZ ( means 676 footnotes at 1 page possible).
*
* @author Stefan Herndler
* @since 1.0-gamma
* @param int $p_int_Value Value/Index to be converted.
* @param bool $p_bool_UpperCase True to convert the value to upper case letter, otherwise to lower case.
* @param int $p_int_value Value/Index to be converted.
* @param bool $p_bool_upper_case True to convert the value to upper case letter, otherwise to lower case.
* @return string
*/
private static function toLatin($p_int_Value, $p_bool_UpperCase) {
// output string
$l_str_Return = "";
$l_int_Offset = 0;
// check if the value is higher then 26 = Z
while ($p_int_Value > 26) {
// increase offset and reduce counter
$l_int_Offset++;
$p_int_Value -= 26;
private static function to_latin( $p_int_value, $p_bool_upper_case ) {
// Output string.
$l_str_return = '';
$l_int_offset = 0;
// Check if the value is higher then 26 = Z.
while ( $p_int_value > 26 ) {
// Increase offset and reduce counter.
$l_int_offset++;
$p_int_value -= 26;
}
// if offset set (more then Z), then add a new letter in front
if ($l_int_Offset > 0) {
$l_str_Return = chr($l_int_Offset + 64);
// If offset set (more then Z), then add a new letter in front.
if ( $l_int_offset > 0 ) {
$l_str_return = chr( $l_int_offset + 64 );
}
// add the origin letter
$l_str_Return .= chr($p_int_Value + 64);
// return the latin character representing the integer
if ($p_bool_UpperCase) {
return strtoupper($l_str_Return);
// Add the origin letter.
$l_str_return .= chr( $p_int_value + 64 );
// Return the latin character representing the integer.
if ( $p_bool_upper_case ) {
return strtoupper( $l_str_return );
}
return strtolower($l_str_Return);
return strtolower( $l_str_return );
}
/**
* Converts an integer to a leading-0 integer.
*
* @author Stefan Herndler
* @since 1.0-gamma
* @param int $p_int_Value Value/Index to be converted.
* @param int $p_int_value Value/Index to be converted.
* @return string Value with a leading zero.
*/
private static function toArabicLeading($p_int_Value) {
// add a leading 0 if number lower then 10
if ($p_int_Value < 10) {
return "0" . $p_int_Value;
private static function to_arabic_leading( $p_int_value ) {
// Add a leading 0 if number lower then 10.
if ( $p_int_value < 10 ) {
return '0' . $p_int_value;
}
return $p_int_Value;
return $p_int_value;
}
/**
* Converts an integer to a romanic letter.
*
* @author Stefan Herndler
* @since 1.0-gamma
* @param int $p_int_Value Value/Index to be converted.
* @param int $p_int_value Value/Index to be converted.
* @param bool $p_bool_upper_case Whether to uppercase.
* @return string
*
*
* Edited:
* @since 2.2.0 optionally lowercase (code from Latin) 2020-12-12T1538+0100
*/
private static function toRomanic($p_int_Value, $p_bool_UpperCase) {
// table containing all necessary romanic letters
$l_arr_RomanicLetters = array(
'M' => 1000,
private static function to_romanic( $p_int_value, $p_bool_upper_case ) {
// Table containing all necessary romanic letters.
$l_arr_romanic_letters = array(
'M' => 1000,
'CM' => 900,
'D' => 500,
'D' => 500,
'CD' => 400,
'C' => 100,
'C' => 100,
'XC' => 90,
'L' => 50,
'L' => 50,
'XL' => 40,
'X' => 10,
'X' => 10,
'IX' => 9,
'V' => 5,
'V' => 5,
'IV' => 4,
'I' => 1
'I' => 1,
);
// return value
$l_str_Return = '';
// iterate through integer value until it is reduced to 0
while ($p_int_Value > 0) {
foreach ($l_arr_RomanicLetters as $l_str_Romanic => $l_int_Arabic) {
if ($p_int_Value >= $l_int_Arabic) {
$p_int_Value -= $l_int_Arabic;
$l_str_Return .= $l_str_Romanic;
// Return value.
$l_str_return = '';
// Iterate through integer value until it is reduced to 0.
while ( $p_int_value > 0 ) {
foreach ( $l_arr_romanic_letters as $l_str_romanic => $l_int_arabic ) {
if ( $p_int_value >= $l_int_arabic ) {
$p_int_value -= $l_int_arabic;
$l_str_return .= $l_str_romanic;
break;
}
}
}
// return romanic letters as string
if ($p_bool_UpperCase) {
return strtoupper($l_str_Return);
// Return romanic letters as string.
if ( $p_bool_upper_case ) {
return strtoupper( $l_str_return );
}
return strtolower($l_str_Return);
return strtolower( $l_str_return );
}
/**
* Converts a string depending on its value to a boolean.
*
* @author Stefan Herndler
* @since 1.0-beta
* @param string $p_str_Value String to be converted to boolean.
* @param string $p_str_value String to be converted to boolean.
* @return bool Boolean representing the string.
*/
public static function toBool($p_str_Value) {
// convert string to lower-case to make it easier
$p_str_Value = strtolower($p_str_Value);
// check if string seems to contain a "true" value
switch ($p_str_Value) {
case "checked":
case "yes":
case "true":
case "on":
case "1":
public static function to_bool( $p_str_value ) {
// Convert string to lower-case to make it easier.
$p_str_value = strtolower( $p_str_value );
// Check if string seems to contain a "true" value.
switch ( $p_str_value ) {
case 'checked':
case 'yes':
case 'true':
case 'on':
case '1':
return true;
}
// nothing found that says "true", so we return false
// Nothing found that says "true", so we return false.
return false;
}
/**
* Get a html Array short code depending on Arrow-Array key index.
*
* @author Stefan Herndler
* @since 1.3.2
* @param int $p_int_Index Index representing the Arrow. If empty all Arrows are specified.
* @param int $p_int_index Index representing the Arrow. If empty all Arrows are specified.
* @return array|string Array of all Arrows if Index is empty otherwise html tag of a specific arrow.
*/
public static function getArrow($p_int_Index = -1) {
// define all possible arrows
$l_arr_Arrows = array("&#8593;", "&#8613;", "&#8607;", "&#8617;", "&#8626;", "&#8629;", "&#8657;", "&#8673;", "&#8679;", "&#65514;");
// convert index to an integer
if (!is_int($p_int_Index)) {
$p_int_Index = intval($p_int_Index);
public static function get_arrow( $p_int_index = -1 ) {
// Define all possible arrows.
$l_arr_arrows = array( '&#8593;', '&#8613;', '&#8607;', '&#8617;', '&#8626;', '&#8629;', '&#8657;', '&#8673;', '&#8679;', '&#65514;' );
// Convert index to an integer.
if ( ! is_int( $p_int_index ) ) {
$p_int_index = intval( $p_int_index );
}
// return the whole arrow array
if ($p_int_Index < 0 || $p_int_Index > count($l_arr_Arrows)) {
return $l_arr_Arrows;
// Return the whole arrow array.
if ( $p_int_index < 0 || $p_int_index > count( $l_arr_arrows ) ) {
return $l_arr_arrows;
}
// return a single arrow
return $l_arr_Arrows[$p_int_Index];
// Return a single arrow.
return $l_arr_arrows[ $p_int_index ];
}
// phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_var_dump
// phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_print_r
/**
* Displays a Variable.
*
* @author Stefan Herndler
* @since 1.5.0
* @param mixed $p_mixed_Value
* @param mixed $p_mixed_value The variable to display.
* @return void
*/
public static function debug($p_mixed_Value) {
if (empty($p_mixed_Value)) {
var_dump($p_mixed_Value);
public static function debug( $p_mixed_value ) {
if ( empty( $p_mixed_value ) ) {
var_dump( $p_mixed_value );
} else if (is_array($p_mixed_Value)) {
printf("<pre>");
print_r($p_mixed_Value);
printf("</pre>");
} elseif ( is_array( $p_mixed_value ) ) {
printf( '<pre>' );
print_r( $p_mixed_value );
printf( '</pre>' );
} else if (is_object($p_mixed_Value)) {
printf("<pre>");
print_r($p_mixed_Value);
printf("</pre>");
} elseif ( is_object( $p_mixed_value ) ) {
printf( '<pre>' );
print_r( $p_mixed_value );
printf( '</pre>' );
} else if (is_numeric($p_mixed_Value) || is_int($p_mixed_Value)) {
var_dump($p_mixed_Value);
} elseif ( is_numeric( $p_mixed_value ) || is_int( $p_mixed_value ) ) {
var_dump( $p_mixed_value );
} else if (is_date($p_mixed_Value)) {
var_dump($p_mixed_Value);
} elseif ( is_date( $p_mixed_value ) ) {
var_dump( $p_mixed_value );
} else {
var_dump($p_mixed_Value);
var_dump( $p_mixed_value );
}
echo "<br/>";
echo '<br/>';
}
// phpcs:disable
}

View file

@ -1,17 +1,16 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
/**
* Includes the Plugin settings menu.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:26
* @package footnotes
* @since 1.5.0
* @date 12.09.14 10:26
*/
/**
* Handles the Settings interface of the Plugin.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Layout_Init {
@ -19,68 +18,60 @@ class MCI_Footnotes_Layout_Init {
/**
* Slug for the Plugin main menu.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_MAIN_MENU_SLUG = "mfmmf";
const C_STR_MAIN_MENU_SLUG = 'mfmmf';
/**
* Plugin main menu name.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_MAIN_MENU_TITLE = "ManFisher";
const C_STR_MAIN_MENU_TITLE = 'ManFisher';
/**
* Contains layout engine sub classes.
*
* @author Stefan Herndler
* @since 1.5.0
* @var array
*/
private $a_arr_SubPageClasses = array();
private $a_arr_sub_page_classes = array();
/**
* Class Constructor. Initializes all WordPress hooks for the Plugin Settings.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function __construct() {
// iterate through each class define in the current script
foreach(get_declared_classes() as $l_str_ClassName) {
// accept only child classes of the layout engine
if(is_subclass_of($l_str_ClassName, 'MCI_Footnotes_LayoutEngine')) {
/** @var MCI_Footnotes_LayoutEngine $l_obj_Class */
$l_obj_Class = new $l_str_ClassName();
// append new instance of the layout engine sub class
$this->a_arr_SubPageClasses[$l_obj_Class->getPriority()] = $l_obj_Class;
foreach ( get_declared_classes() as $l_str_class_name ) {
if ( is_subclass_of( $l_str_class_name, 'MCI_Footnotes_Layout_Engine' ) ) {
$l_obj_class = new $l_str_class_name();
// Append new instance of the layout engine sub class.
$this->a_arr_sub_page_classes[ $l_obj_class->get_priority() ] = $l_obj_class;
}
}
ksort($this->a_arr_SubPageClasses);
ksort( $this->a_arr_sub_page_classes );
// register hooks/actions
add_action('admin_init', array($this, 'initializeSettings'));
add_action('admin_menu', array($this, 'registerMainMenu'));
// register AJAX callbacks for Plugin information
add_action("wp_ajax_nopriv_footnotes_getPluginInfo", array($this, "getPluginMetaInformation"));
add_action("wp_ajax_footnotes_getPluginInfo", array($this, "getPluginMetaInformation"));
// Register hooks/actions.
add_action( 'admin_init', array( $this, 'initialize_settings' ) );
add_action( 'admin_menu', array( $this, 'register_main_menu' ) );
// Register AJAX callbacks for Plugin information.
add_action( 'wp_ajax_nopriv_footnotes_get_plugin_info', array( $this, 'get_plugin_meta_information' ) );
add_action( 'wp_ajax_footnotes_get_plugin_info', array( $this, 'get_plugin_meta_information' ) );
}
/**
* Initializes all sub pages and registers the settings.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function initializeSettings() {
MCI_Footnotes_Settings::instance()->RegisterSettings();
// iterate though each sub class of the layout engine and register their sections
/** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */
foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) {
$l_obj_LayoutEngineSubClass->registerSections();
public function initialize_settings() {
MCI_Footnotes_Settings::instance()->register_settings();
// Iterate though each sub class of the layout engine and register their sections.
foreach ( $this->a_arr_sub_page_classes as $l_obj_layout_engine_sub_class ) {
$l_obj_layout_engine_sub_class->register_sections();
}
}
@ -88,125 +79,129 @@ class MCI_Footnotes_Layout_Init {
* Registers the new main menu for the WordPress dashboard.
* Registers all sub menu pages for the new main menu.
*
* @author Stefan Herndler
* @since 1.5.0
* @see http://codex.wordpress.org/Function_Reference/add_menu_page
*/
public function registerMainMenu() {
public function register_main_menu() {
global $menu;
// iterate through each main menu
foreach($menu as $l_arr_MainMenu) {
// iterate through each main menu attribute
foreach($l_arr_MainMenu as $l_str_Attribute) {
// main menu already added, append sub pages and stop
if ($l_str_Attribute == self::C_STR_MAIN_MENU_SLUG) {
$this->registerSubPages();
// Iterate through each main menu.
foreach ( $menu as $l_arr_main_menu ) {
// 3terate through each main menu attribute.
foreach ( $l_arr_main_menu as $l_str_attribute ) {
// Main menu already added, append sub pages and stop.
if ( self::C_STR_MAIN_MENU_SLUG === $l_str_attribute ) {
$this->register_sub_pages();
return;
}
}
}
// add a new main menu page to the WordPress dashboard
// Add a new main menu page to the WordPress dashboard.
add_menu_page(
self::C_STR_MAIN_MENU_TITLE, // page title
self::C_STR_MAIN_MENU_TITLE, // menu title
'manage_options', // capability
self::C_STR_MAIN_MENU_SLUG, // menu slug
array($this, "displayOtherPlugins"), // function
plugins_url('footnotes/img/main-menu.png'), // icon url
null // position
self::C_STR_MAIN_MENU_TITLE, // Page title.
self::C_STR_MAIN_MENU_TITLE, // Menu title.
'manage_options', // Capability.
self::C_STR_MAIN_MENU_SLUG, // Menu slug.
array( $this, 'display_other_plugins' ), // Function.
plugins_url( 'footnotes/img/main-menu.png' ), // Icon URL.
null // Position.
);
$this->registerSubPages();
$this->register_sub_pages();
}
/**
* Registers all SubPages for this Plugin.
*
* @author Stefan Herndler
* @since 1.5.0
*/
private function registerSubPages() {
// first registered sub menu page MUST NOT contain a unique slug suffix
// iterate though each sub class of the layout engine and register their sub page
/** @var MCI_Footnotes_LayoutEngine $l_obj_LayoutEngineSubClass */
foreach($this->a_arr_SubPageClasses as $l_obj_LayoutEngineSubClass) {
$l_obj_LayoutEngineSubClass->registerSubPage();
private function register_sub_pages() {
// First registered sub menu page MUST NOT contain a unique slug suffix.
// Iterate though each sub class of the layout engine and register their sub page.
foreach ( $this->a_arr_sub_page_classes as $l_obj_layout_engine_sub_class ) {
$l_obj_layout_engine_sub_class->register_sub_page();
}
}
/**
* Displays other Plugins from the developers.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function displayOtherPlugins() {
printf("<br/><br/>");
// load template file
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "manfisher");
echo $l_obj_Template->getContent();
public function display_other_plugins() {
printf( '<br/><br/>' );
// Load template file.
$l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'manfisher' );
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $l_obj_template->get_content();
// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
printf('<em>visit <a href="https://cheret.de/plugins/footnotes-2/" target="_blank">Mark Cheret</a></em>');
printf("<br/><br/>");
printf( '<em>visit <a href="https://cheret.de/plugins/footnotes-2/" target="_blank">Mark Cheret</a></em>' );
printf( '<br/><br/>' );
printf('</div>');
printf( '</div>' );
}
// phpcs:disable WordPress.Security.NonceVerification.Missing
/**
* AJAX call. returns a JSON string containing meta information about a specific WordPress Plugin.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function getPluginMetaInformation() {
// get plugin internal name from POST data
$l_str_PluginName = array_key_exists("plugin", $_POST) ? $_POST["plugin"] : null;
if (empty($l_str_PluginName)) {
echo json_encode(array("error" => "Plugin name invalid."));
public function get_plugin_meta_information() {
// TODO: add nonce verification.
// Get plugin internal name from POST data.
if ( isset( $_POST['plugin'] ) ) {
$l_str_plugin_name = wp_unslash( $_POST['plugin'] );
}
if ( empty( $l_str_plugin_name ) ) {
echo wp_json_encode( array( 'error' => 'Plugin name invalid.' ) );
exit;
}
$l_str_Url = "https://api.wordpress.org/plugins/info/1.0/".$l_str_PluginName.".json";
// call URL and collect data
$l_arr_Response = wp_remote_get($l_str_Url);
// check if response is valid
if (is_wp_error($l_arr_Response)) {
echo json_encode(array("error" => "Error receiving Plugin Information from WordPress."));
$l_str_url = 'https://api.wordpress.org/plugins/info/1.0/' . $l_str_plugin_name . '.json';
// Call URL and collect data.
$l_arr_response = wp_remote_get( $l_str_url );
// Check if response is valid.
if ( is_wp_error( $l_arr_response ) ) {
echo wp_json_encode( array( 'error' => 'Error receiving Plugin Information from WordPress.' ) );
exit;
}
if (!array_key_exists("body", $l_arr_Response)) {
echo json_encode(array("error" => "Error reading WordPress API response message."));
if ( ! array_key_exists( 'body', $l_arr_response ) ) {
echo wp_json_encode( array( 'error' => 'Error reading WordPress API response message.' ) );
exit;
}
// get the body of the response
$l_str_Response = $l_arr_Response["body"];
// get plugin object
$l_arr_Plugin = json_decode($l_str_Response, true);
if (empty($l_arr_Plugin)) {
echo json_encode(array("error" => "Error reading Plugin meta information.<br/>URL: " . $l_str_Url . "<br/>Response: " . $l_str_Response));
// Get the body of the response.
$l_str_response = $l_arr_response['body'];
// Get plugin object.
$l_arr_plugin = json_decode( $l_str_response, true );
if ( empty( $l_arr_plugin ) ) {
echo wp_json_encode( array( 'error' => 'Error reading Plugin meta information.<br/>URL: ' . $l_str_url . '<br/>Response: ' . $l_str_response ) );
exit;
}
$l_int_NumRatings = array_key_exists("num_ratings", $l_arr_Plugin) ? intval($l_arr_Plugin["num_ratings"]) : 0;
$l_int_Rating = array_key_exists("rating", $l_arr_Plugin) ? floatval($l_arr_Plugin["rating"]) : 0.0;
$l_int_Stars = round(5 * $l_int_Rating / 100.0, 1);
$l_int_num_ratings = array_key_exists( 'num_ratings', $l_arr_plugin ) ? intval( $l_arr_plugin['num_ratings'] ) : 0;
$l_int_rating = array_key_exists( 'rating', $l_arr_plugin ) ? floatval( $l_arr_plugin['rating'] ) : 0.0;
$l_int_stars = round( 5 * $l_int_rating / 100.0, 1 );
// return Plugin information as JSON encoded string
echo json_encode(
// Return Plugin information as JSON encoded string.
echo wp_json_encode(
array(
"error" => "",
"PluginDescription" => array_key_exists("short_description", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["short_description"]) : "Error reading Plugin information",
"PluginAuthor" => array_key_exists("author", $l_arr_Plugin) ? html_entity_decode($l_arr_Plugin["author"]) : "unknown",
"PluginRatingText" => $l_int_Stars . " " . __("rating based on", MCI_Footnotes_Config::C_STR_PLUGIN_NAME) . " " . $l_int_NumRatings . " " . __("ratings", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"PluginRating1" => $l_int_Stars >= 0.5 ? "star-full" : "star-empty",
"PluginRating2" => $l_int_Stars >= 1.5 ? "star-full" : "star-empty",
"PluginRating3" => $l_int_Stars >= 2.5 ? "star-full" : "star-empty",
"PluginRating4" => $l_int_Stars >= 3.5 ? "star-full" : "star-empty",
"PluginRating5" => $l_int_Stars >= 4.5 ? "star-full" : "star-empty",
"PluginRating" => $l_int_NumRatings,
"PluginLastUpdated" => array_key_exists("last_updated", $l_arr_Plugin) ? $l_arr_Plugin["last_updated"] : "unknown",
"PluginDownloads" => array_key_exists("downloaded", $l_arr_Plugin) ? $l_arr_Plugin["downloaded"] : "---"
'error' => '',
'PluginDescription' => array_key_exists( 'short_description', $l_arr_plugin ) ? html_entity_decode( $l_arr_plugin['short_description'] ) : 'Error reading Plugin information',
'PluginAuthor' => array_key_exists( 'author', $l_arr_plugin ) ? html_entity_decode( $l_arr_plugin['author'] ) : 'unknown',
'PluginRatingText' => $l_int_stars . ' ' . __( 'rating based on', 'footnotes' ) . ' ' . $l_int_num_ratings . ' ' . __( 'ratings', 'footnotes' ),
'PluginRating1' => $l_int_stars >= 0.5 ? 'star-full' : 'star-empty',
'PluginRating2' => $l_int_stars >= 1.5 ? 'star-full' : 'star-empty',
'PluginRating3' => $l_int_stars >= 2.5 ? 'star-full' : 'star-empty',
'PluginRating4' => $l_int_stars >= 3.5 ? 'star-full' : 'star-empty',
'PluginRating5' => $l_int_stars >= 4.5 ? 'star-full' : 'star-empty',
'PluginRating' => $l_int_num_ratings,
'PluginLastUpdated' => array_key_exists( 'last_updated', $l_arr_plugin ) ? $l_arr_plugin['last_updated'] : 'unknown',
'PluginDownloads' => array_key_exists( 'downloaded', $l_arr_plugin ) ? $l_arr_plugin['downloaded'] : '---',
)
);
exit;
}
// phpcs:enable WordPress.Security.NonceVerification.Missing
}

View file

@ -1,12 +1,11 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.EscapeOutput.OutputNotEscaped
/**
* Includes Layout Engine for the admin dashboard.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*
* @lastmodified 2021-02-18T2021+0100
* @package footnotes
* @since 1.5.0
* @date 12.09.14 10:56
*
* @since 2.1.2 add versioning of settings.css for cache busting 2020-11-19T1456+0100
* @since 2.1.4 automate passing version number for cache busting 2020-11-30T0648+0100
@ -16,182 +15,170 @@
* @since 2.5.5 Bugfix: Stylesheets: minify to shrink the carbon footprint, increase speed and implement best practice, thanks to @docteurfitness issue report.
*/
/**
* Layout Engine for the administration dashboard.
*
* @author Stefan Herndler
* @since 1.5.0
*/
abstract class MCI_Footnotes_LayoutEngine {
abstract class MCI_Footnotes_Layout_Engine {
/**
* Stores the Hook connection string for the child sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @var null|string
*/
protected $a_str_SubPageHook = null;
protected $a_str_sub_page_hook = null;
/**
* Stores all Sections for the child sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @var array
*/
protected $a_arr_Sections = array();
protected $a_arr_sections = array();
/**
* Returns a Priority index. Lower numbers have a higher Priority.
*
* @author Stefan Herndler
* @since 1.5.0
* @return int
*/
abstract public function getPriority();
abstract public function get_priority();
/**
* Returns the unique slug of the child sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
abstract protected function getSubPageSlug();
abstract protected function get_sub_page_slug();
/**
* Returns the title of the child sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
abstract protected function getSubPageTitle();
abstract protected function get_sub_page_title();
/**
* Returns an array of all registered sections for a sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return array
*/
abstract protected function getSections();
abstract protected function get_sections();
/**
* Returns an array of all registered meta boxes.
*
* @author Stefan Herndler
* @since 1.5.0
* @return array
*/
abstract protected function getMetaBoxes();
abstract protected function get_meta_boxes();
/**
* Returns an array describing a sub page section.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_ID Unique ID suffix.
* @param string $p_str_Title Title of the section.
* @param int $p_int_SettingsContainerIndex Settings Container Index.
* @param bool $p_bool_hasSubmitButton Should a Submit Button be displayed for this section, default: true.
* @param string $p_str_id Unique ID suffix.
* @param string $p_str_title Title of the section.
* @param int $p_int_settings_container_index Settings Container Index.
* @param bool $p_bool_has_submit_button Should a Submit Button be displayed for this section, default: true.
* @return array Array describing the section.
*/
protected function addSection($p_str_ID, $p_str_Title, $p_int_SettingsContainerIndex, $p_bool_hasSubmitButton = true) {
return array("id" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_ID, "title" => $p_str_Title, "submit" => $p_bool_hasSubmitButton, "container" => $p_int_SettingsContainerIndex);
protected function add_section( $p_str_id, $p_str_title, $p_int_settings_container_index, $p_bool_has_submit_button = true ) {
return array(
'id' => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_id,
'title' => $p_str_title,
'submit' => $p_bool_has_submit_button,
'container' => $p_int_settings_container_index,
);
}
/**
* Returns an array describing a meta box.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_SectionID Parent Section ID.
* @param string $p_str_ID Unique ID suffix.
* @param string $p_str_Title Title for the meta box.
* @param string $p_str_CallbackFunctionName Class method name for callback.
* @param string $p_str_section_id Parent Section ID.
* @param string $p_str_id Unique ID suffix.
* @param string $p_str_title Title for the meta box.
* @param string $p_str_callback_function_name Class method name for callback.
* @return array meta box description to be able to append a meta box to the output.
*/
protected function addMetaBox($p_str_SectionID, $p_str_ID, $p_str_Title, $p_str_CallbackFunctionName) {
protected function add_meta_box( $p_str_section_id, $p_str_id, $p_str_title, $p_str_callback_function_name ) {
return array(
"parent" => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . "-" . $p_str_SectionID,
"id" => $p_str_ID,
"title" => $p_str_Title,
"callback" => $p_str_CallbackFunctionName
'parent' => MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '-' . $p_str_section_id,
'id' => $p_str_id,
'title' => $p_str_title,
'callback' => $p_str_callback_function_name,
);
}
/**
* Registers a sub page.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function registerSubPage() {
public function register_sub_page() {
global $submenu;
// any sub menu for our main menu exists
if (array_key_exists(plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG), $submenu)) {
// iterate through all sub menu entries of the ManFisher main menu
foreach($submenu[plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG)] as $l_arr_SubMenu) {
if ($l_arr_SubMenu[2] == plugin_basename(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug())) {
// remove that sub menu and add it again to move it to the bottom
remove_submenu_page(MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG .$this->getSubPageSlug());
if ( array_key_exists( plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG ), $submenu ) ) {
foreach ( $submenu[ plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG ) ] as $l_arr_sub_menu ) {
if ( plugin_basename( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug() ) === $l_arr_sub_menu[2] ) {
remove_submenu_page( MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug() );
}
}
}
$this->a_str_SubPageHook = add_submenu_page(
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG, // parent slug
$this->getSubPageTitle(), // page title
$this->getSubPageTitle(), // menu title
'manage_options', // capability
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), // menu slug
array($this, 'displayContent') // function
$this->a_str_sub_page_hook = add_submenu_page(
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG,
$this->get_sub_page_title(),
$this->get_sub_page_title(),
'manage_options',
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug(),
array( $this, 'display_content' )
);
}
/**
* Registers all sections for a sub page.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function registerSections() {
// iterate through each section
foreach($this->getSections() as $l_arr_Section) {
// append tab to the tab-array
$this->a_arr_Sections[$l_arr_Section["id"]] = $l_arr_Section;
public function register_sections() {
foreach ( $this->get_sections() as $l_arr_section ) {
// Append tab to the tab-array.
$this->a_arr_sections[ $l_arr_section['id'] ] = $l_arr_section;
add_settings_section(
$l_arr_Section["id"], // unique id
"", //$l_arr_Section["title"], // title
array($this, 'Description'), // callback function for the description
$l_arr_Section["id"] // parent sub page slug
$l_arr_section['id'],
'',
array( $this, 'Description' ),
$l_arr_section['id']
);
$this->registerMetaBoxes($l_arr_Section["id"]);
$this->register_meta_boxes( $l_arr_section['id'] );
}
}
/**
* Registers all Meta boxes for a sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_ParentID Parent section unique id.
* @param string $p_str_parent_id Parent section unique id.
*/
private function registerMetaBoxes($p_str_ParentID) {
// iterate through each meta box
foreach($this->getMetaBoxes() as $l_arr_MetaBox) {
if ($l_arr_MetaBox["parent"] != $p_str_ParentID) {
private function register_meta_boxes( $p_str_parent_id ) {
// Iterate through each meta box.
foreach ( $this->get_meta_boxes() as $l_arr_meta_box ) {
if ( $p_str_parent_id !== $l_arr_meta_box['parent'] ) {
continue;
}
add_meta_box(
$p_str_ParentID. "-" . $l_arr_MetaBox["id"], // unique id
$l_arr_MetaBox["title"], // meta box title
array($this, $l_arr_MetaBox["callback"]), // callback function to display (echo) the content
$p_str_ParentID, // post type = parent section id
'main' // context
$p_str_parent_id . '-' . $l_arr_meta_box['id'],
$l_arr_meta_box['title'],
array( $this, $l_arr_meta_box['callback'] ),
$p_str_parent_id,
'main'
);
}
}
@ -199,17 +186,12 @@ abstract class MCI_Footnotes_LayoutEngine {
/**
* Append javascript and css files for specific sub page.
*
* @author Stefan Herndler
* @since 1.5.0
*/
private function appendScripts() {
// enable meta boxes layout and close functionality
wp_enqueue_script('postbox');
// add WordPress color picker layout
wp_enqueue_style('wp-color-picker');
// add WordPress color picker function
wp_enqueue_script('wp-color-picker');
private function append_scripts() {
wp_enqueue_script( 'postbox' );
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
/**
* Registers and enqueues the dashboard stylesheet.
@ -239,314 +221,341 @@ abstract class MCI_Footnotes_LayoutEngine {
}
wp_enqueue_style('mci-footnotes-admin');
wp_enqueue_style( 'mci-footnotes-admin' );
}
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/**
* Displays the content of specific sub page.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function displayContent() {
// register and enqueue scripts and styling
$this->appendScripts();
// get current section
reset($this->a_arr_Sections);
$l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections);
$l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID];
// store settings
$l_bool_SettingsUpdated = false;
if (array_key_exists("save-settings", $_POST)) {
if ($_POST["save-settings"] == "save") {
unset($_POST["save-settings"]);
unset($_POST["submit"]);
$l_bool_SettingsUpdated = $this->saveSettings();
public function display_content() {
$this->append_scripts();
// TODO: add nonce verification.
// Get the current section.
reset( $this->a_arr_sections );
$l_str_active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->a_arr_sections );
$l_arr_active_section = $this->a_arr_sections[ $l_str_active_section_id ];
// Store settings.
$l_bool_settings_updated = false;
if ( array_key_exists( 'save-settings', $_POST ) ) {
if ( 'save' === $_POST['save-settings'] ) {
unset( $_POST['save-settings'] );
unset( $_POST['submit'] );
$l_bool_settings_updated = $this->save_settings();
}
}
// display all sections and highlight the active section
// Display all sections and highlight the active section.
echo '<div class="wrap">';
echo '<h2 class="nav-tab-wrapper">';
// iterate through all register sections
foreach ($this->a_arr_Sections as $l_str_ID => $l_arr_Description) {
// Iterate through all register sections.
foreach ( $this->a_arr_sections as $l_str_id => $l_arr_description ) {
$l_str_tab_active = ( $l_str_id === $l_arr_active_section['id'] ) ? ' nav-tab-active' : '';
echo sprintf(
'<a class="nav-tab%s" href="?page=%s&t=%s">%s</a>',
$l_arr_ActiveSection["id"] == $l_str_ID ? ' nav-tab-active' : '',
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->getSubPageSlug(), $l_str_ID, $l_arr_Description["title"]
( $l_str_id === $l_arr_active_section['id'] ) ? ' nav-tab-active' : '',
MCI_Footnotes_Layout_Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug(),
$l_str_id,
$l_arr_description['title']
);
}
echo '</h2><br/>';
if ($l_bool_SettingsUpdated) {
echo sprintf('<div id="message" class="updated">%s</div>', __("Settings saved", MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
if ( $l_bool_settings_updated ) {
echo sprintf( '<div id="message" class="updated">%s</div>', __( 'Settings saved', 'footnotes' ) );
}
// form to submit the active section
// Form to submit the active section.
echo '<!--suppress HtmlUnknownTarget --><form method="post" action="">';
//settings_fields($l_arr_ActiveSection["container"]);
echo '<input type="hidden" name="save-settings" value="save" />';
// outputs the settings field of the active section
do_settings_sections($l_arr_ActiveSection["id"]);
do_meta_boxes($l_arr_ActiveSection["id"], 'main', NULL);
// Outputs the settings field of the active section.
do_settings_sections( $l_arr_active_section['id'] );
do_meta_boxes( $l_arr_active_section['id'], 'main', null );
// add submit button to active section if defined
if ($l_arr_ActiveSection["submit"]) {
// Add submit button to active section if defined.
if ( $l_arr_active_section['submit'] ) {
submit_button();
}
// close the form to submit data
echo '</form>';
// close container for the settings page
echo '</div>';
// output special javascript for the expand/collapse function of the meta boxes
// Echo JavaScript for the expand/collapse function of the meta boxes.
echo '<script type="text/javascript">';
echo "jQuery(document).ready(function ($) {";
echo 'jQuery(document).ready(function ($) {';
echo 'jQuery(".mfmmf-color-picker").wpColorPicker();';
echo "jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');";
echo "postboxes.add_postbox_toggles('" . $this->a_str_SubPageHook . "');";
echo "});";
echo "postboxes.add_postbox_toggles('" . $this->a_str_sub_page_hook . "');";
echo '});';
echo '</script>';
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/**
* Save all Plugin settings.
*
* @author Stefan Herndler
* @since 1.5.0
* @return bool
*/
private function saveSettings() {
$l_arr_newSettings = array();
// get current section
reset($this->a_arr_Sections);
$l_str_ActiveSectionID = isset($_GET['t']) ? $_GET['t'] : key($this->a_arr_Sections);
$l_arr_ActiveSection = $this->a_arr_Sections[$l_str_ActiveSectionID];
private function save_settings() {
$l_arr_new_settings = array();
// iterate through each value that has to be in the specific container
foreach(MCI_Footnotes_Settings::instance()->getDefaults($l_arr_ActiveSection["container"]) as $l_str_Key => $l_mixed_Value) {
// setting is available in the POST array, use it
if (array_key_exists($l_str_Key, $_POST)) {
$l_arr_newSettings[$l_str_Key] = $_POST[$l_str_Key];
// TODO: add nonce verification.
// Get current section.
reset( $this->a_arr_sections );
$l_str_active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : key( $this->a_arr_sections );
$l_arr_active_section = $this->a_arr_sections[ $l_str_active_section_id ];
foreach ( MCI_Footnotes_Settings::instance()->get_defaults( $l_arr_active_section['container'] ) as $l_str_key => $l_mixed_value ) {
if ( array_key_exists( $l_str_key, $_POST ) ) {
$l_arr_new_settings[ $l_str_key ] = wp_unslash( $_POST[ $l_str_key ] );
} else {
// setting is not defined in the POST array, define it to avoid the Default value
$l_arr_newSettings[$l_str_Key] = "";
// Setting is not defined in the POST array, define it to avoid the Default value.
$l_arr_new_settings[ $l_str_key ] = '';
}
}
// update settings
return MCI_Footnotes_Settings::instance()->saveOptions($l_arr_ActiveSection["container"], $l_arr_newSettings);
// Update settings.
return MCI_Footnotes_Settings::instance()->save_options( $l_arr_active_section['container'], $l_arr_new_settings );
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
/**
* Output the Description of a section. May be overwritten in any section.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function Description() {
// default no description will be displayed
public function description() {
// Default no description will be displayed.
}
/**
* Loads specific setting and returns an array with the keys [id, name, value].
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_SettingKeyName Settings Array key name.
* @param string $p_str_setting_key_name Settings Array key name.
* @return array Contains Settings ID, Settings Name and Settings Value.
*/
protected function LoadSetting($p_str_SettingKeyName) {
// get current section
reset($this->a_arr_Sections);
$p_arr_Return = array();
$p_arr_Return["id"] = sprintf('%s', $p_str_SettingKeyName);
$p_arr_Return["name"] = sprintf('%s', $p_str_SettingKeyName);
$p_arr_Return["value"] = esc_attr(MCI_Footnotes_Settings::instance()->get($p_str_SettingKeyName));
return $p_arr_Return;
protected function load_setting( $p_str_setting_key_name ) {
// Get current section.
reset( $this->a_arr_sections );
$p_arr_return = array();
$p_arr_return['id'] = sprintf( '%s', $p_str_setting_key_name );
$p_arr_return['name'] = sprintf( '%s', $p_str_setting_key_name );
$p_arr_return['value'] = MCI_Footnotes_Settings::instance()->get( $p_str_setting_key_name );
return $p_arr_return;
}
/**
* Returns a line break to start a new line.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function addNewline() {
protected function add_newline() {
return '<br/>';
}
/**
* Returns a line break to have a space between two lines.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function addLineSpace() {
protected function add_line_space() {
return '<br/><br/>';
}
/**
* Returns a simple text inside html <span> text.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_Text Message to be surrounded with simple html tag (span).
* @param string $p_str_text Message to be surrounded with simple html tag (span).
* @return string
*/
protected function addText($p_str_Text) {
return sprintf('<span>%s</span>', $p_str_Text);
protected function add_text( $p_str_text ) {
return sprintf( '<span>%s</span>', $p_str_text );
}
/**
* Returns the html tag for an input/select label.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_SettingName Name of the Settings key to connect the Label with the input/select field.
* @param string $p_str_Caption Label caption.
* @param string $p_str_setting_name Name of the Settings key to connect the Label with the input/select field.
* @param string $p_str_caption Label caption.
* @return string
*
* Edited 2020-12-01T0159+0100..
* @since 2.1.6 no colon
*/
protected function addLabel($p_str_SettingName, $p_str_Caption) {
if (empty($p_str_Caption)) {
return "";
protected function add_label( $p_str_setting_name, $p_str_caption ) {
if ( empty( $p_str_caption ) ) {
return '';
}
// remove the colon causing localization issues with French,
// and with languages not using punctuation at all,
// and with languages using other punctuation marks instead of colon,
// e.g. Greek using a raised dot.
// In French, colon is preceded by a space, forcibly non-breaking,
// and narrow per new school.
// Add colon to label strings for inclusion in localization.
// Colon after label is widely preferred best practice, mandatory per style guides.
// <https://softwareengineering.stackexchange.com/questions/234546/colons-in-internationalized-ui>
return sprintf('<label for="%s">%s</label>', $p_str_SettingName, $p_str_Caption);
// ^ here deleted colon 2020-12-08T1546+0100
/*
* Remove the colon causing localization issues with French, and with
* languages not using punctuation at all, and with languages using other
* punctuation marks instead of colon, e.g. Greek using a raised dot.
* In French, colon is preceded by a space, forcibly non-breaking, and
* narrow per new school.
* Add colon to label strings for inclusion in localization. Colon after
* label is widely preferred best practice, mandatory per
* [style guides](https://softwareengineering.stackexchange.com/questions/234546/colons-in-internationalized-ui).
*/
return sprintf( '<label for="%s">%s</label>', $p_str_setting_name, $p_str_caption );
}
/**
* Returns the html tag for an input [type = text].
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_SettingName Name of the Settings key to pre load the input field.
* @param int $p_str_MaxLength Maximum length of the input, default 999 characters.
* @param bool $p_bool_Readonly Set the input to be read only, default false.
* @param bool $p_bool_Hidden Set the input to be hidden, default false.
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
* @param int $p_str_max_length Maximum length of the input, default 999 characters.
* @param bool $p_bool_readonly Set the input to be read only, default false.
* @param bool $p_bool_hidden Set the input to be hidden, default false.
* @return string
*/
protected function addTextBox($p_str_SettingName, $p_str_MaxLength = 999, $p_bool_Readonly = false, $p_bool_Hidden = false) {
$l_str_Style = "";
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
if ($p_bool_Hidden) {
$l_str_Style .= 'display:none;';
protected function add_text_box( $p_str_setting_name, $p_str_max_length = 999, $p_bool_readonly = false, $p_bool_hidden = false ) {
$l_str_style = '';
// Collect data for given settings field.
$l_arr_data = $this->load_setting( $p_str_setting_name );
if ( $p_bool_hidden ) {
$l_str_style .= 'display:none;';
}
return sprintf('<input type="text" name="%s" id="%s" maxlength="%d" style="%s" value="%s" %s/>',
$l_arr_Data["name"], $l_arr_Data["id"], $p_str_MaxLength,
$l_str_Style, $l_arr_Data["value"], $p_bool_Readonly ? 'readonly="readonly"' : '');
return sprintf(
'<input type="text" name="%s" id="%s" maxlength="%d" style="%s" value="%s" %s/>',
$l_arr_data['name'],
$l_arr_data['id'],
$p_str_max_length,
$l_str_style,
$l_arr_data['value'],
$p_bool_readonly ? 'readonly="readonly"' : ''
);
}
/**
* Returns the html tag for an input [type = checkbox].
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_SettingName Name of the Settings key to pre load the input field.
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
* @return string
*/
protected function addCheckbox($p_str_SettingName) {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
return sprintf('<input type="checkbox" name="%s" id="%s" %s/>',
$l_arr_Data["name"], $l_arr_Data["id"],
MCI_Footnotes_Convert::toBool($l_arr_Data["value"]) ? 'checked="checked"' : '');
protected function add_checkbox( $p_str_setting_name ) {
// Collect data for given settings field.
$l_arr_data = $this->load_setting( $p_str_setting_name );
return sprintf(
'<input type="checkbox" name="%s" id="%s" %s/>',
$l_arr_data['name'],
$l_arr_data['id'],
MCI_Footnotes_Convert::to_bool( $l_arr_data['value'] ) ? 'checked="checked"' : ''
);
}
/**
* Returns the html tag for a select box.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_SettingName Name of the Settings key to pre select the current value.
* @param array $p_arr_Options Possible options to be selected.
* @param string $p_str_setting_name Name of the Settings key to pre select the current value.
* @param array $p_arr_options Possible options to be selected.
* @return string
*/
protected function addSelectBox($p_str_SettingName, $p_arr_Options) {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
$l_str_Options = "";
protected function add_select_box( $p_str_setting_name, $p_arr_options ) {
// Collect data for given settings field.
$l_arr_data = $this->load_setting( $p_str_setting_name );
$l_str_options = '';
/* loop through all array keys */
foreach ($p_arr_Options as $l_str_Value => $l_str_Caption) {
$l_str_Options .= sprintf('<option value="%s" %s>%s</option>',
$l_str_Value,
$l_arr_Data["value"] == $l_str_Value ? "selected" : "",
$l_str_Caption);
foreach ( $p_arr_options as $l_str_value => $l_str_caption ) {
$l_str_options .= sprintf(
'<option value="%s" %s>%s</option>',
$l_str_value,
$l_str_value === $l_arr_data['value'] ? 'selected' : '',
$l_str_caption
);
}
return sprintf('<select name="%s" id="%s">%s</select>',
$l_arr_Data["name"], $l_arr_Data["id"], $l_str_Options);
return sprintf(
'<select name="%s" id="%s">%s</select>',
$l_arr_data['name'],
$l_arr_data['id'],
$l_str_options
);
}
/**
* Returns the html tag for a text area.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_SettingName Name of the Settings key to pre fill the text area.
* @param string $p_str_setting_name Name of the Settings key to pre fill the text area.
* @return string
*/
protected function addTextArea($p_str_SettingName) {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
return sprintf('<textarea name="%s" id="%s">%s</textarea>',
$l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]);
protected function add_textarea( $p_str_setting_name ) {
// Collect data for given settings field.
$l_arr_data = $this->load_setting( $p_str_setting_name );
return sprintf(
'<textarea name="%s" id="%s">%s</textarea>',
$l_arr_data['name'],
$l_arr_data['id'],
$l_arr_data['value']
);
}
/**
* Returns the html tag for an input [type = text] with color selection class.
*
* @author Stefan Herndler
* @since 1.5.6
* @param string $p_str_SettingName Name of the Settings key to pre load the input field.
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
* @return string
*/
protected function addColorSelection($p_str_SettingName) {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
return sprintf('<input type="text" name="%s" id="%s" class="mfmmf-color-picker" value="%s"/>',
$l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"]);
protected function add_color_selection( $p_str_setting_name ) {
// Collect data for given settings field.
$l_arr_data = $this->load_setting( $p_str_setting_name );
return sprintf(
'<input type="text" name="%s" id="%s" class="mfmmf-color-picker" value="%s"/>',
$l_arr_data['name'],
$l_arr_data['id'],
$l_arr_data['value']
);
}
/**
* Returns the html tag for an input [type = num].
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_SettingName Name of the Settings key to pre load the input field.
* @param int $p_in_Min Minimum value.
* @param int $p_int_Max Maximum value.
* @param bool $p_bool_Deci true if 0.1 steps and floating to string, false if integer (default)
* @param string $p_str_setting_name Name of the Settings key to pre load the input field.
* @param int $p_in_min Minimum value.
* @param int $p_int_max Maximum value.
* @param bool $p_bool_deci true if 0.1 steps and floating to string, false if integer (default).
* @return string
*
* Edited:
* @since 2.1.4 step argument and number_format() to allow decimals 2020-12-03T0631+0100..2020-12-12T1110+0100
*/
protected function addNumBox($p_str_SettingName, $p_in_Min, $p_int_Max, $p_bool_Deci = false ) {
// collect data for given settings field
$l_arr_Data = $this->LoadSetting($p_str_SettingName);
protected function add_num_box( $p_str_setting_name, $p_in_min, $p_int_max, $p_bool_deci = false ) {
// Collect data for given settings field.
$l_arr_data = $this->load_setting( $p_str_setting_name );
if ($p_bool_Deci) {
$l_str_Value = number_format(floatval($l_arr_Data["value"]), 1);
return sprintf('<input type="number" name="%s" id="%s" value="%s" step="0.1" min="%d" max="%d"/>',
$l_arr_Data["name"], $l_arr_Data["id"], $l_str_Value, $p_in_Min, $p_int_Max);
if ( $p_bool_deci ) {
$l_str_value = number_format( floatval( $l_arr_data['value'] ), 1 );
return sprintf(
'<input type="number" name="%s" id="%s" value="%s" step="0.1" min="%d" max="%d"/>',
$l_arr_data['name'],
$l_arr_data['id'],
$l_str_value,
$p_in_min,
$p_int_max
);
} else {
return sprintf('<input type="number" name="%s" id="%s" value="%d" min="%d" max="%d"/>',
$l_arr_Data["name"], $l_arr_Data["id"], $l_arr_Data["value"], $p_in_Min, $p_int_Max);
return sprintf(
'<input type="number" name="%s" id="%s" value="%d" min="%d" max="%d"/>',
$l_arr_data['name'],
$l_arr_data['id'],
$l_arr_data['value'],
$p_in_min,
$p_int_max
);
}
}
} // end of class
}

View file

@ -1,140 +1,147 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.EscapeOutput.OutputNotEscaped
/**
* Includes the Plugin Class to display Diagnostics.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 14:47
* @package footnotes
* @since 1.5.0
* @date 14.09.14 14:47
*/
/**
* Displays Diagnostics of the web server, PHP and WordPress.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_LayoutEngine {
class MCI_Footnotes_Layout_Diagnostics extends MCI_Footnotes_Layout_Engine {
/**
* Returns a Priority index. Lower numbers have a higher Priority.
*
* @author Stefan Herndler
* @since 1.5.0
* @return int
*/
public function getPriority() {
public function get_priority() {
return 999;
}
/**
* Returns the unique slug of the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getSubPageSlug() {
return "-diagnostics";
protected function get_sub_page_slug() {
return '-diagnostics';
}
/**
* Returns the title of the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getSubPageTitle() {
return __("Diagnostics", MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
protected function get_sub_page_title() {
return __( 'Diagnostics', 'footnotes' );
}
/**
* Returns an array of all registered sections for the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return array
*/
protected function getSections() {
protected function get_sections() {
return array(
$this->addSection("diagnostics", __("Diagnostics", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), null, false)
$this->add_section( 'diagnostics', __( 'Diagnostics', 'footnotes' ), null, false ),
);
}
/**
* Returns an array of all registered meta boxes for each section of the sub page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return array
*/
protected function getMetaBoxes() {
protected function get_meta_boxes() {
return array(
$this->addMetaBox("diagnostics", "diagnostics", __("Displays information about the web server, PHP and WordPress", MCI_Footnotes_Config::C_STR_PLUGIN_NAME), "Diagnostics")
$this->add_meta_box( 'diagnostics', 'diagnostics', __( 'Displays information about the web server, PHP and WordPress', 'footnotes' ), 'Diagnostics' ),
);
}
/**
* Displays a diagnostics about the web server, php and WordPress.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function Diagnostics() {
global $wp_version;
$l_str_PhpExtensions = "";
// iterate through each PHP extension
foreach (get_loaded_extensions() as $l_int_Index => $l_str_Extension) {
if ($l_int_Index > 0) {
$l_str_PhpExtensions .= ' | ';
$l_str_php_extensions = '';
// Iterate through each PHP extension.
foreach ( get_loaded_extensions() as $l_int_index => $l_str_extension ) {
if ( $l_int_index > 0 ) {
$l_str_php_extensions .= ' | ';
}
$l_str_PhpExtensions .= $l_str_Extension . ' ' . phpversion($l_str_Extension);
$l_str_php_extensions .= $l_str_extension . ' ' . phpversion( $l_str_extension );
}
/** @var WP_Theme $l_obj_CurrentTheme */
$l_obj_CurrentTheme = wp_get_theme();
$l_obj_current_theme = wp_get_theme();
$l_str_WordPressPlugins = "";
// iterate through each installed WordPress Plugin
foreach (get_plugins() as $l_arr_Plugin) {
$l_str_WordPressPlugins .= '<tr>';
$l_str_WordPressPlugins .= '<td>' . $l_arr_Plugin["Name"] . '</td>';
$l_str_WordPressPlugins .= '<td>' . $l_arr_Plugin["Version"] . ' [' . $l_arr_Plugin["PluginURI"] . ']' . '</td>';
$l_str_WordPressPlugins .= '</tr>';
$l_str_wordpress_plugins = '';
// Iterate through each installed WordPress Plugin.
foreach ( get_plugins() as $l_arr_plugin ) {
$l_str_wordpress_plugins .= '<tr>';
$l_str_wordpress_plugins .= '<td>' . $l_arr_plugin['Name'] . '</td>';
// phpcs:disable Generic.Strings.UnnecessaryStringConcat.Found
$l_str_wordpress_plugins .= '<td>' . $l_arr_plugin['Version'] . ' [' . $l_arr_plugin['PluginURI'] . ']' . '</td>';
// phpcs:enable Generic.Strings.UnnecessaryStringConcat.Found
$l_str_wordpress_plugins .= '</tr>';
}
// load template file
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "diagnostics");
// replace all placeholders
$l_obj_Template->replace(
// Load template file.
$l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'diagnostics' );
if ( ! isset( $_SERVER['SERVER_NAME'] ) ) {
die;
} else {
$l_str_server_name = wp_unslash( $_SERVER['SERVER_NAME'] );
}
if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
die;
} else {
$l_str_http_user_agent = wp_unslash( $_SERVER['HTTP_USER_AGENT'] );
}
// Replace all placeholders.
$l_obj_template->replace(
array(
"label-server" => __("Server name", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"server" => $_SERVER["SERVER_NAME"],
'label-server' => __( 'Server name', 'footnotes' ),
'server' => $l_str_server_name,
"label-php" => __("PHP version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"php" => phpversion(),
'label-php' => __( 'PHP version', 'footnotes' ),
'php' => phpversion(),
"label-user-agent" => __("User agent", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"user-agent" => $_SERVER["HTTP_USER_AGENT"],
'label-user-agent' => __( 'User agent', 'footnotes' ),
'user-agent' => $l_str_http_user_agent,
"label-max-execution-time" => __("Max execution time", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"max-execution-time" => ini_get('max_execution_time') . ' ' . __('seconds', MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
'label-max-execution-time' => __( 'Max execution time', 'footnotes' ),
'max-execution-time' => ini_get( 'max_execution_time' ) . ' ' . __( 'seconds', 'footnotes' ),
"label-memory-limit" => __("Memory limit", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"memory-limit" => ini_get('memory_limit'),
'label-memory-limit' => __( 'Memory limit', 'footnotes' ),
'memory-limit' => ini_get( 'memory_limit' ),
"label-php-extensions" => __("PHP extensions", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"php-extensions" => $l_str_PhpExtensions,
'label-php-extensions' => __( 'PHP extensions', 'footnotes' ),
'php-extensions' => $l_str_php_extensions,
"label-wordpress" => __("WordPress version", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"wordpress" => $wp_version,
'label-wordpress' => __( 'WordPress version', 'footnotes' ),
'wordpress' => $wp_version,
"label-theme" => __("Active Theme", MCI_Footnotes_Config::C_STR_PLUGIN_NAME),
"theme" => $l_obj_CurrentTheme->get("Name") . " " . $l_obj_CurrentTheme->get("Version") . ", " . $l_obj_CurrentTheme->get("Author"). " [" . $l_obj_CurrentTheme->get("AuthorURI") . "]",
'label-theme' => __( 'Active Theme', 'footnotes' ),
'theme' => $l_obj_current_theme->get( 'Name' ) . ' ' . $l_obj_current_theme->get( 'Version' ) . ', ' . $l_obj_current_theme->get( 'Author' ) . ' [' . $l_obj_current_theme->get( 'AuthorURI' ) . ']',
"plugins" => $l_str_WordPressPlugins
'plugins' => $l_str_wordpress_plugins,
)
);
// display template with replaced placeholders
echo $l_obj_Template->getContent();
// Display template with replaced placeholders.
echo $l_obj_template->get_content();
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,19 +1,18 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName, WordPress.Security.EscapeOutput.OutputNotEscaped
/**
* Handles all WordPress hooks of this Plugin.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*
* Edited:
* @since 2.2.0 2020-12-12T1223+0100
* @package footnotes
* @since 1.5.0
* @date 12.09.14 10:56
*
* @since 2.2.0 (TBD) 2020-12-12T1223+0100
*/
/**
* Registers all WordPress Hooks and executes them on demand.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Hooks {
@ -21,74 +20,68 @@ class MCI_Footnotes_Hooks {
/**
* Registers all WordPress hooks.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function registerHooks() {
register_activation_hook(dirname(__FILE__) . "/../footnotes.php", array("MCI_Footnotes_Hooks", "activatePlugin"));
register_deactivation_hook(dirname(__FILE__) . "/../footnotes.php", array("MCI_Footnotes_Hooks", "deactivatePlugin"));
register_uninstall_hook(dirname(__FILE__) . "/../footnotes.php", array("MCI_Footnotes_Hooks", "uninstallPlugin"));
public static function register_hooks() {
register_activation_hook( dirname( __FILE__ ) . '/../footnotes.php', array( 'MCI_Footnotes_Hooks', 'activate_plugin' ) );
register_deactivation_hook( dirname( __FILE__ ) . '/../footnotes.php', array( 'MCI_Footnotes_Hooks', 'deactivate_plugin' ) );
register_uninstall_hook( dirname( __FILE__ ) . '/../footnotes.php', array( 'MCI_Footnotes_Hooks', 'uninstall_plugin' ) );
}
/**
* Executed when the Plugin gets activated.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function activatePlugin() {
// currently unused
public static function activate_plugin() {
// Currently unused.
}
/**
* Executed when the Plugin gets deactivated.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function deactivatePlugin() {
// currently unused
public static function deactivate_plugin() {
// Currently unused.
}
/**
* Executed when the Plugin gets uninstalled.
*
* @author Stefan Herndler
* @since 1.5.0
*
* Edit: ClearAll didnt actually work.
* @since 2.2.0 this function is not called any longer when deleting the plugin
*
* @since 2.2.0 this function is not called any longer when deleting the plugin.
* Note: clear_all() didnt actually work.
* @see class/settings.php
*/
public static function uninstallPlugin() {
// WordPress User has to be logged in
if (!is_user_logged_in()) {
wp_die(__('You must be logged in to run this script.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
public static function uninstall_plugin() {
// WordPress User has to be logged in.
if ( ! is_user_logged_in() ) {
wp_die( __( 'You must be logged in to run this script.', 'footnotes' ) );
}
// WordPress User needs the permission to (un)install plugins
if (!current_user_can('install_plugins')) {
wp_die(__('You do not have permission to run this script.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
// WordPress User needs the permission to (un)install plugins.
if ( ! current_user_can( 'install_plugins' ) ) {
wp_die( __( 'You do not have permission to run this script.', 'footnotes' ) );
}
// deletes all settings and restore the default values
// MCI_Footnotes_Settings::instance()->ClearAll();
}
/**
* Add Links to the Plugin in the "installed Plugins" page.
*
* @author Stefan Herndler
* @since 1.5.0
* @param array $p_arr_Links Current Links.
* @param string $p_str_PluginFileName Plugins init file name.
* @param array $p_arr_links Current Links.
* @param string $p_str_plugin_file_name Plugins init file name.
* @return array
*/
public static function PluginLinks($p_arr_Links, $p_str_PluginFileName) {
// append link to the WordPress Plugin page
$p_arr_Links[] = sprintf('<a href="http://wordpress.org/support/plugin/footnotes" target="_blank">%s</a>', __('Support', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
// append link to the Settings page
$p_arr_Links[] = sprintf('<a href="%s">%s</a>', admin_url('admin.php?page=mfmmf-footnotes'), __('Settings', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
// append link to the PlayPal Donate function
$p_arr_Links[] = sprintf('<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ" target="_blank">%s</a>', __('Donate', MCI_Footnotes_Config::C_STR_PLUGIN_NAME));
// return new links
return $p_arr_Links;
public static function plugin_links( $p_arr_links, $p_str_plugin_file_name ) {
// Append link to the WordPress Plugin page.
$p_arr_links[] = sprintf( '<a href="http://wordpress.org/support/plugin/footnotes" target="_blank">%s</a>', __( 'Support', 'footnotes' ) );
// Append link to the settings page.
$p_arr_links[] = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=mfmmf-footnotes' ), __( 'Settings', 'footnotes' ) );
// Append link to the PayPal donate function.
$p_arr_links[] = sprintf( '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ" target="_blank">%s</a>', __( 'Donate', 'footnotes' ) );
// Return new links.
return $p_arr_links;
}
}

View file

@ -1,13 +1,11 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName
/**
* Includes the main Class of the Plugin.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 12.09.14 10:56
*
*
* @lastmodified 2021-02-19T2031+0100
* @package footnotes
* @since 1.5.0
* @date 12.09.14 10:56
*
* @since 1.6.5 Bugfix: Improve widgets registration, thanks to @felipelavinz code contribution.
* @since 1.6.5 Update: Fix for deprecated PHP function create_function(), thanks to @psykonevro @daliasued bug reports, thanks to @felipelavinz code contribution.
@ -27,7 +25,6 @@
/**
* Entry point of the Plugin. Loads the Dashboard and executes the Task.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes {
@ -35,79 +32,77 @@ class MCI_Footnotes {
/**
* Reference to the Plugin Task object.
*
* @author Stefan Herndler
* @since 1.5.0
* @var null|MCI_Footnotes_Task
*/
public $a_obj_Task = null;
public $a_obj_task = null;
/**
* Template process and script / stylesheet load optimization.
*
* - Bugfix: Templates: optimize template load and processing based on settings, thanks to @misfist code contribution.
*
* @since 2.4.0
* @date 2021-01-04T1355+0100
*
* @author Patrizia Lutz @misfist
*
* @link https://wordpress.org/support/topic/template-override-filter/#post-13864301
* @link https://github.com/misfist/footnotes/releases/tag/2.4.0d3 repository
* @link https://github.com/misfist/footnotes/compare/2.4.0%E2%80%A62.4.0d3 diff
* Idenfifies whether tooltips are enabled. Actual value depends on settings.
*
* @contributor Patrizia Lutz @misfist
* @var bool
*
* Streamline process depending on tooltip enabled status.
* Load tooltip inline script only if jQuery tooltips are enabled.
* Actual value depends on settings.
* @todo Refactor to have defines and assignments only in this class,
* then re-use these properties also in class/task.php (and elsewhere).
* Account for priority level issues. These properties must be assigned before
* the hooks—whose priority level may be configured to 0—are called in class/task.php.
*/
public static $a_bool_TooltipsEnabled = false;
public static $a_bool_AlternativeTooltipsEnabled = false;
public static $a_bool_tooltips_enabled = false;
/**
* Idenfifies whether alternative tooltips are enabled. Actual value depends
* on settings.
*
* @contributor Patrizia Lutz @misfist
* @var bool
*
* @todo Refactor to have defines only here, and use assignments also in class/task.php.
*/
public static $a_bool_alternative_tooltips_enabled = false;
/**
* Executes the Plugin.
*
* @author Stefan Herndler
* @since 1.5.0
*
*
* - Bugfix: Improve widgets registration, thanks to @felipelavinz code contribution.
*
* @since 1.6.5
*
* @contributor @felipelavinz
* @link https://github.com/benleyjyc/footnotes/commit/87173d2980c7ff90e12ffee94ca7153e11163793
* @date 2020-02-25
* @link https://github.com/media-competence-institute/footnotes/commit/87173d2980c7ff90e12ffee94ca7153e11163793
*
* @see self::initializeWidgets()
* @see self::initialize_widgets()
*/
public function run() {
// register language
MCI_Footnotes_Language::registerHooks();
// register Button hooks
MCI_Footnotes_WYSIWYG::registerHooks();
// register general hooks
MCI_Footnotes_Hooks::registerHooks();
// Register language.
MCI_Footnotes_Language::register_hooks();
// Register Button hooks.
MCI_Footnotes_WYSIWYG::register_hooks();
// Register general hooks.
MCI_Footnotes_Hooks::register_hooks();
// initialize the Plugin Dashboard
$this->initializeDashboard();
// initialize the Plugin Task
$this->initializeTask();
// Initialize the Plugin Dashboard.
$this->initialize_dashboard();
// Initialize the Plugin Task.
$this->initialize_task();
// Register all Public Stylesheets and Scripts
add_action('init', array($this, 'registerPublic'));
// Enqueue all Public Stylesheets and Scripts
add_action('wp_enqueue_scripts', array($this, 'registerPublic'));
// Register all Widgets of the Plugin.
add_action('widgets_init', array($this, 'initializeWidgets'));
// Register all Public Stylesheets and Scripts.
add_action( 'init', array( $this, 'register_public' ) );
// Enqueue all Public Stylesheets and Scripts.
add_action( 'wp_enqueue_scripts', array( $this, 'register_public' ) );
// Register all Widgets of the Plugin..
add_action( 'widgets_init', array( $this, 'initialize_widgets' ) );
}
/**
* Initializes all Widgets of the Plugin.
*
* @author Stefan Herndler
* @since 1.5.0
*
*
* - Update: Fix for deprecated PHP function create_function(), thanks to @psykonevro @daliasued bug reports, thanks to @felipelavinz code contribution
*
* @since 1.6.5
@ -129,37 +124,34 @@ class MCI_Footnotes {
* and use the bare register_widget() here.
* @see self::run()
*
* Also, the visibility of initializeWidgets() is not private any longer.
* Also, the visibility of initialize_widgets() is not private any longer.
*/
public function initializeWidgets() {
register_widget( "MCI_Footnotes_Widget_ReferenceContainer" );
public function initialize_widgets() {
register_widget( 'MCI_Footnotes_Widget_Reference_container' );
}
/**
* Initializes the Dashboard of the Plugin and loads them.
*
* @author Stefan Herndler
* @since 1.5.0
*/
private function initializeDashboard() {
private function initialize_dashboard() {
new MCI_Footnotes_Layout_Init();
}
/**
* Initializes the Plugin Task and registers the Task hooks.
*
* @author Stefan Herndler
* @since 1.5.0
*/
private function initializeTask() {
$this->a_obj_Task = new MCI_Footnotes_Task();
$this->a_obj_Task->registerHooks();
private function initialize_task() {
$this->a_obj_task = new MCI_Footnotes_Task();
$this->a_obj_task->register_hooks();
}
/**
* Registers and enqueues scripts and stylesheets to the public pages.
*
* @author Stefan Herndler
* @since 1.5.0
*
* @since 2.0.0 Update: Tooltips: fix disabling bug by loading jQuery UI library, thanks to @rajinderverma @ericcorbett2 @honlapdavid @mmallett bug reports, thanks to @vonpiernik code contribution.
@ -168,7 +160,7 @@ class MCI_Footnotes {
* @since 2.1.4 automate passing version number for cache busting 2020-11-30T0646+0100
* @since 2.1.4 optionally enqueue an extra stylesheet 2020-12-04T2231+0100
*/
public function registerPublic() {
public function register_public() {
/**
* Enqueues external scripts.
@ -181,10 +173,10 @@ class MCI_Footnotes {
*
* The condition about tooltips was missing, only the not-alternative-tooltips part was present.
*/
// set conditions re-used for stylesheet enqueuing:
self::$a_bool_TooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ENABLED ) );
self::$a_bool_AlternativeTooltipsEnabled = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE ) );
$l_str_ScriptMode = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE);
// Set conditions re-used for stylesheet enqueuing.
self::$a_bool_tooltips_enabled = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ENABLED ) );
self::$a_bool_alternative_tooltips_enabled = MCI_Footnotes_Convert::to_bool( MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_MOUSE_OVER_BOX_ALTERNATIVE ) );
$l_str_script_mode = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_REFERENCE_CONTAINER_SCRIPT_MODE );
/**
* Enqueues the jQuery library registered by WordPress.
@ -195,68 +187,79 @@ class MCI_Footnotes {
*
* @reporter @hopper87it
* @link https://wordpress.org/support/topic/footnotes-wp-rocket/
*
*
* jQuery is also used for animated scrolling, so it was loaded by default.
* The function wp_enqueue_script() avoids loading the same library multiple times.
* After adding the alternative reference container, jQuery has become optional,
* but still enabled by default.
*/
if ( $l_str_ScriptMode == 'jquery' || ( self::$a_bool_TooltipsEnabled && ! self::$a_bool_AlternativeTooltipsEnabled ) ) {
if ( 'jquery' === $l_str_script_mode || ( self::$a_bool_tooltips_enabled && ! self::$a_bool_alternative_tooltips_enabled ) ) {
wp_enqueue_script( 'jquery' );
}
if ( self::$a_bool_TooltipsEnabled && ! self::$a_bool_AlternativeTooltipsEnabled ) {
if ( self::$a_bool_tooltips_enabled && ! self::$a_bool_alternative_tooltips_enabled ) {
/**
* Enqueues the jQuery Tools library shipped with the plugin.
*
* redacted jQuery.browser, completed minification;
* see full header in js/jquery.tools.js
* added versioning 2020-11-18T2150+0100
* not use '-js' in the handle, is appended automatically
* Redacted jQuery.browser, completed minification;
* see full header in js/jquery.tools.js.
*
* Add versioning.
*
* @since 2.1.2
* @date 2020-11-18T2150+0100
*
* No '-js' in the handle, is appended automatically.
*
* Deferring to the footer breaks jQuery tooltip display.
* @date 2021-02-23T1105+0100
*/
wp_enqueue_script(
'mci-footnotes-jquery-tools',
plugins_url('footnotes/js/jquery.tools.min.js'),
plugins_url( 'footnotes/js/jquery.tools.min.js' ),
array(),
'1.2.7.redacted.2'
'1.2.7.redacted.2',
false
);
/**
* Registers jQuery UI from the JavaScript Content Delivery Network.
*
* - Update: Tooltips: fix disabling bug by loading jQuery UI library, thanks to @rajinderverma @ericcorbett2 @honlapdavid @mmallett bug reports, thanks to @vonpiernik code contribution.
*
* @since 2.0.0
* Alternatively, fetch jQuery UI from cdnjs.cloudflare.com:
* @since 2.0.0 add jQueryUI from Cloudflare 2020-10-26T1907+0100
* Used to add jQuery UI following @vonpiernik:
* <https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13456762>:
*
*
* jQueryUI re-enables the tooltip infobox disabled when WPv5.5 was released.
*
* Updated for v2.0.4 by adding jQuery UI from WordPress following @check2020de:
* <https://wordpress.org/support/topic/gdpr-issue-with-jquery/>
* See <https://wordpress.stackexchange.com/questions/273986/correct-way-to-enqueue-jquery-ui>
*
* This was enabled in Footnotes v2.0.0 through v2.0.3.
* Re-added for 2.0.9d1 / 2.1.1d0 to look whether it can fix a broken tooltip display. 2020-11-07T1601+0100/2020-11-08T2246+0100
*/
//wp_register_script( 'jQueryUI', 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js', null, null, false ); // in header 2020-11-09T2003+0100
//wp_enqueue_script( 'jQueryUI' );
/**
* This is then needed instead of the above first instance:
* Add jQuery Tools and finish adding jQueryUI: 2020-11-08T1638+0100/2020-11-08T2246+0100
*/
//wp_enqueue_script('mci-footnotes-js-jquery-tools', plugins_url('../js/jquery.tools.min.js', __FILE__), ['jQueryUI']);
/**
* Enqueues some jQuery UI libraries registered by WordPress.
*
* @since 2.0.4 add jQuery UI from WordPress 2020-11-01T1902+0100
* - Update: Tooltips: fix disabling bug by loading jQuery UI library, thanks to @rajinderverma @ericcorbett2 @honlapdavid @mmallett bug reports, thanks to @vonpiernik code contribution.
*
* @since 2.0.0
*
* @reporter @rajinderverma
* @link https://wordpress.org/support/topic/tooltip-hover-not-showing/
*
* @reporter @ericcorbett2
* @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13324142
*
* @reporter @honlapdavid
* @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13355421
*
* @reporter @mmallett
* @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13445437
*
* Fetch jQuery UI from cdnjs.cloudflare.com.
* @since 2.0.0
* @date 2020-10-26T1907+0100
* @contributor @vonpiernik
* @link https://wordpress.org/support/topic/tooltip-hover-not-showing/#post-13456762
*
* jQueryUI re-enables the tooltip infobox disabled when WPv5.5 was released. * @since 2.1.2
*
* - Update: Libraries: Load jQuery UI from WordPress, thanks to @check2020de issue report.
*
* @since 2.0.4
* @date 2020-11-01T1902+0100
* @reporter @check2020de
* @link https://wordpress.org/support/topic/gdpr-issue-with-jquery/
* @link https://wordpress.stackexchange.com/questions/273986/correct-way-to-enqueue-jquery-ui
*
* If alternative tooltips are enabled, these libraries are not needed.
*/
wp_enqueue_script( 'jquery-ui-core' );
@ -308,34 +311,43 @@ class MCI_Footnotes {
* The media scope argument 'all' is the default.
* No need to use '-css' in the handle, as this is appended automatically.
*/
// set tooltip mode for use in stylesheet name:
if ( self::$a_bool_TooltipsEnabled ) {
if ( self::$a_bool_AlternativeTooltipsEnabled ) {
$l_str_TooltipMode = 'al';
$l_str_TComplement = 'ternative-tooltips';
// Set tooltip mode for use in stylesheet name.
if ( self::$a_bool_tooltips_enabled ) {
if ( self::$a_bool_alternative_tooltips_enabled ) {
$l_str_tooltip_mode_short = 'al';
$l_str_tooltip_mode_rest = 'ternative-tooltips';
} else {
$l_str_TooltipMode = 'jq';
$l_str_TComplement = 'uery-tooltips';
$l_str_tooltip_mode_short = 'jq';
$l_str_tooltip_mode_rest = 'uery-tooltips';
}
} else {
$l_str_TooltipMode = 'no';
$l_str_TComplement = '-tooltips';
$l_str_tooltip_mode_short = 'no';
$l_str_tooltip_mode_rest = '-tooltips';
}
// set basic responsive page layout mode for use in stylesheet name:
$l_str_PageLayoutOption = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT);
switch ( $l_str_PageLayoutOption ) {
case "reference-container": $l_str_LayoutMode = '1'; break;
case "entry-content" : $l_str_LayoutMode = '2'; break;
case "main-content" : $l_str_LayoutMode = '3'; break;
case "none": default: $l_str_LayoutMode = '0'; break;
// Set basic responsive page layout mode for use in stylesheet name.
$l_str_page_layout_option = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT );
switch ( $l_str_page_layout_option ) {
case 'reference-container':
$l_str_layout_mode = '1';
break;
case 'entry-content':
$l_str_layout_mode = '2';
break;
case 'main-content':
$l_str_layout_mode = '3';
break;
case 'none':
default:
$l_str_layout_mode = '0';
break;
}
// enqueue the tailored united minified stylesheet:
// Enqueue the tailored united minified stylesheet.
wp_enqueue_style(
'mci-footnotes-' . $l_str_TooltipMode . $l_str_TComplement . '-pagelayout-' . $l_str_PageLayoutOption,
'mci-footnotes-' . $l_str_tooltip_mode_short . $l_str_tooltip_mode_rest . '-pagelayout-' . $l_str_page_layout_option,
plugins_url(
MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/footnotes-' . $l_str_TooltipMode . 'ttbrpl' . $l_str_LayoutMode . '.min.css'
MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/footnotes-' . $l_str_tooltip_mode_short . 'ttbrpl' . $l_str_layout_mode . '.min.css'
),
array(),
C_STR_FOOTNOTES_VERSION,
@ -356,12 +368,12 @@ class MCI_Footnotes {
wp_enqueue_style( 'mci-footnotes-tooltips', plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips.css' ), array(), C_STR_FOOTNOTES_VERSION );
wp_enqueue_style( 'mci-footnotes-alternative', plugins_url( MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-tooltips-alternative.css' ), array(), C_STR_FOOTNOTES_VERSION );
$l_str_PageLayoutOption = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT);
if ($l_str_PageLayoutOption != 'none') {
$l_str_page_layout_option = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_PAGE_LAYOUT_SUPPORT );
if ( 'none' !== $l_str_page_layout_option ) {
wp_enqueue_style(
'mci-footnotes-layout-' . $l_str_PageLayoutOption,
'mci-footnotes-layout-' . $l_str_page_layout_option,
plugins_url(
MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-layout-' . $l_str_PageLayoutOption . '.css'
MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/css/dev-layout-' . $l_str_page_layout_option . '.css'
),
array(),
C_STR_FOOTNOTES_VERSION,

View file

@ -1,13 +1,11 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName
/**
* Loads text domain of current or default language for localization.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 17:47
*
*
* @lastmodified 2021-02-18T2028+0100
* @package footnotes
* @since 1.5.0
* @date 14.09.14 17:47
*
* @since 2.0.0 Bugfix: Localization: correct function call apply_filters() with all required arguments after PHP 7.1 promoted warning to error, thanks to @matkus2 bug report and code contribution.
* @since 2.1.6 Bugfix: Localization: conform to WordPress plugin language file name scheme, thanks to @nikelaos bug report.
@ -16,7 +14,6 @@
/**
* Loads text domain of current or default language for localization.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Language {
@ -24,18 +21,16 @@ class MCI_Footnotes_Language {
/**
* Register WordPress Hook.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function registerHooks() {
add_action('plugins_loaded', array("MCI_Footnotes_Language", "loadTextDomain"));
public static function register_hooks() {
add_action( 'plugins_loaded', array( 'MCI_Footnotes_Language', 'load_text_domain' ) );
}
/**
* Loads the text domain for current WordPress language if exists.
* Otherwise fallback "en_GB" will be loaded.
*
* @author Stefan Herndler
* @since 1.5.0
*
*
@ -47,7 +42,7 @@ class MCI_Footnotes_Language {
* @contributor @matkus2
* @link https://wordpress.org/support/topic/error-missing-parameter-if-using-php-7-1-or-later/
*
* Add 3rd (empty) argument in apply_filters() to prevent PHP from throwing an error:
* Add 3rd (empty) argument in apply_filters() to prevent PHP from throwing an error.
* “Fatal error: Uncaught ArgumentCountError: Too few arguments to function apply_filters()
*
* Yet get_locale() is defined w/o parameters in wp-includes/l10n.php:30, and
@ -57,7 +52,7 @@ class MCI_Footnotes_Language {
* But apply_filters() is defined with a 3rd parameter (and w/o the first one) in
* wp-includes/class-wp-hook.php:264, as public function apply_filters( $value, $args ).
*
* Taking it all together, probably the full function definition would be:
* Taking it all together, probably the full function definition would be
* public function apply_filters( $tag, $value, $args ).
* In the case of get_locale(), $args is empty.
*
@ -65,22 +60,21 @@ class MCI_Footnotes_Language {
* @link https://www.php.net/manual/en/migration71.incompatible.php
* @link https://www.php.net/manual/en/migration71.incompatible.php#migration71.incompatible.too-few-arguments-exception
*/
public static function loadTextDomain() {
public static function load_text_domain() {
// if language file with localization exists:
// If language file with localization exists.
if ( self::load( apply_filters( 'plugin_locale', get_locale(), '' ) ) ) {
return;
}
// else fall back to British English:
self::load( "en_GB" );
// Else fall back to British English.
self::load( 'en_GB' );
}
/**
* Loads a specific text domain.
*
* @author Stefan Herndler
* @since 1.5.1
* @param string $p_str_LanguageCode Language Code to load a specific text domain.
* @param string $p_str_language_code Language Code to load a specific text domain.
* @return bool
*
*
@ -92,16 +86,14 @@ class MCI_Footnotes_Language {
* @reporter @nikelaos
* @link https://wordpress.org/support/topic/more-feature-ideas/
*
* That is done by using load_plugin_textdomain():
* That is done by using load_plugin_textdomain().
* “The .mo file should be named based on the text domain with a dash, and then the locale exactly.
* @see wp-includes/l10n.php:857
*/
private static function load($p_str_LanguageCode) {
private static function load( $p_str_language_code ) {
return load_plugin_textdomain(
MCI_Footnotes_Config::C_STR_PLUGIN_NAME,
// This argument only fills the gap left by a deprecated argument (since WP2.7):
false,
// The plugin basedir is provided; trailing slash would be clipped:
MCI_Footnotes_Config::C_STR_PLUGIN_NAME . '/languages'
);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,39 +1,20 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName
/**
* Includes the Template Engine to load and handle all Template files of the Plugin.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 10:58
* @package footnotes
* @since 1.5.0
* @date 14.09.14 10:58
*
*
* @lastmodified 2021-02-18T2024+0100
*
* @since 2.0.3 prettify reference container template
* @since 2.0.3 replace tab with a space
* @since 2.0.3 replace 2 spaces with 1
* @since 2.0.4 collapse multiple spaces
* @since 2.0.6 prettify other templates (footnote, tooltip script, ref container row)
* @since 2.2.6 delete a space before a closing pointy bracket
*
* @since 2.2.6 support for custom templates in fixed location, while failing to add filter thanks to @misfist 2020-12-19T0606+0100
* @link https://wordpress.org/support/topic/template-override-filter/
*
* @since 2.4.0 templates may be in active theme, thanks to @misfist
* @link https://wordpress.org/support/topic/template-override-filter/#post-13846598
*
* @since 2.5.0 Enable template location stack, contributed by @misfist
* @link https://wordpress.org/support/topic/template-override-filter/#post-13864301
*
* @since 2.5.4 collapse HTML comments and PHP/JS docblocks (only)
* @since 2.2.6 Adding: Templates: support for custom templates in sibling folder, thanks to @misfist issue report.
* @since 2.5.0 Adding: Templates: Enable template location stack, thanks to @misfist code contribution.
*/
/**
* Handles each Template file for the Plugin Frontend (e.g. Settings Dashboard, Public pages, ...).
* Loads a template file, replaces all Placeholders and returns the replaced file content.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Template {
@ -41,43 +22,38 @@ class MCI_Footnotes_Template {
/**
* Directory name for dashboard templates.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_DASHBOARD = "dashboard";
const C_STR_DASHBOARD = 'dashboard';
/**
* Directory name for public templates.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
const C_STR_PUBLIC = "public";
const C_STR_PUBLIC = 'public';
/**
* Contains the content of the template after initialize.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
private $a_str_OriginalContent = "";
private $a_str_original_content = '';
/**
* Contains the content of the template after initialize with replaced place holders.
*
* @author Stefan Herndler
* @since 1.5.0
* @var string
*/
private $a_str_ReplacedContent = "";
private $a_str_replaced_content = '';
/**
* Plugin Directory
*
* @author Patrizia Lutz @misfist
* @since 2.4.0d3
*
* @var string
@ -87,42 +63,39 @@ class MCI_Footnotes_Template {
/**
* Class Constructor. Reads and loads the template file without replace any placeholder.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_FileType Template file type (take a look on the Class constants).
* @param string $p_str_FileName Template file name inside the Template directory without the file extension.
* @param string $p_str_Extension Optional Template file extension (default: html)
* @param string $p_str_file_type Template file type (take a look on the Class constants).
* @param string $p_str_file_name Template file name inside the Template directory without the file extension.
* @param string $p_str_extension Optional Template file extension (default: html).
*
* - Adding: Templates: support for custom templates in sibling folder, thanks to @misfist issue report.
*
* @since 2.2.6 support for custom templates 2020-12-19T0606+0100
* @since 2.2.6
* @date 2020-12-19T0606+0100
*
* @reporter @misfist
* @link https://wordpress.org/support/topic/template-override-filter/
*
* @since 2.4.0 look for custom template in the active theme first, thanks to @misfist
* @link https://wordpress.org/support/topic/template-override-filter/#post-13846598
*/
public function __construct($p_str_FileType, $p_str_FileName, $p_str_Extension = "html") {
// no template file type and/or file name set
if (empty($p_str_FileType) || empty($p_str_FileName)) {
public function __construct( $p_str_file_type, $p_str_file_name, $p_str_extension = 'html' ) {
// No template file type and/or file name set.
if ( empty( $p_str_file_type ) || empty( $p_str_file_name ) ) {
return;
}
/**
* Define plugin root path
* Define plugin root path.
*
* @since 2.4.0d3
*
* @author Patrizia Lutz @misfist
*/
$this->plugin_directory = plugin_dir_path( dirname( __FILE__ ) );
/**
* Modularize functions
* Modularize functions.
*
* @since 2.4.0d3
*
* @author Patrizia Lutz @misfist
*/
if( $template = $this->get_template( $p_str_FileType, $p_str_FileName, $p_str_Extension ) ) {
$template = $this->get_template( $p_str_file_type, $p_str_file_name, $p_str_extension );
if ( $template ) {
$this->process_template( $template );
} else {
return;
@ -133,124 +106,125 @@ class MCI_Footnotes_Template {
/**
* Replace all placeholders specified in array.
*
* @author Stefan Herndler
* @since 1.5.0
* @param array $p_arr_Placeholders Placeholders (key = placeholder, value = value).
* @param array $p_arr_placeholders Placeholders (key = placeholder, value = value).
* @return bool True on Success, False if Placeholders invalid.
*/
public function replace($p_arr_Placeholders) {
// no placeholders set
if (empty($p_arr_Placeholders)) {
public function replace( $p_arr_placeholders ) {
// No placeholders set.
if ( empty( $p_arr_placeholders ) ) {
return false;
}
// template content is empty
if (empty($this->a_str_ReplacedContent)) {
// Template content is empty.
if ( empty( $this->a_str_replaced_content ) ) {
return false;
}
// iterate through each placeholder and replace it with its value
foreach($p_arr_Placeholders as $l_str_Placeholder => $l_str_Value) {
$this->a_str_ReplacedContent = str_replace("[[" . $l_str_Placeholder . "]]", $l_str_Value, $this->a_str_ReplacedContent);
// Iterate through each placeholder and replace it with its value.
foreach ( $p_arr_placeholders as $l_str_placeholder => $l_str_value ) {
$this->a_str_replaced_content = str_replace( '[[' . $l_str_placeholder . ']]', $l_str_value, $this->a_str_replaced_content );
}
// success
// Success.
return true;
}
/**
* Reloads the original content of the template file.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public function reload() {
$this->a_str_ReplacedContent = $this->a_str_OriginalContent;
$this->a_str_replaced_content = $this->a_str_original_content;
}
/**
* Returns the content of the template file with replaced placeholders.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string Template content with replaced placeholders.
*/
public function getContent() {
return $this->a_str_ReplacedContent;
public function get_content() {
return $this->a_str_replaced_content;
}
/**
* Process template file
*
* @author Patrizia Lutz @misfist
* Process template file.
*
* @since 2.4.0d3
*
* @param string $template
* @param string $template The template to be processed.
* @return void
*
*
* @since 2.0.3 replace tab with a space
* @since 2.0.3 replace 2 spaces with 1
* @since 2.0.4 collapse multiple spaces
* @since 2.2.6 delete a space before a closing pointy bracket
* @since 2.5.4 collapse HTML comments and PHP/JS docblocks (only)
* @since 2.0.3 Replace tab with a space.
* @since 2.0.3 Replace 2 spaces with 1.
* @since 2.0.4 Collapse multiple spaces.
* @since 2.2.6 Delete a space before a closing pointy bracket.
* @since 2.5.4 Collapse HTML comments and PHP/JS docblocks (only).
*/
public function process_template( $template ) {
$this->a_str_OriginalContent = preg_replace( '#<!--.+?-->#s', "", file_get_contents( $template ) );
$this->a_str_OriginalContent = preg_replace( '#/\*\*.+?\*/#s', "", $this->a_str_OriginalContent );
$this->a_str_OriginalContent = str_replace( "\n", "", $this->a_str_OriginalContent );
$this->a_str_OriginalContent = str_replace( "\r", "", $this->a_str_OriginalContent );
$this->a_str_OriginalContent = str_replace( "\t", " ", $this->a_str_OriginalContent );
$this->a_str_OriginalContent = preg_replace( '# +#', " ", $this->a_str_OriginalContent );
$this->a_str_OriginalContent = str_replace( " >", ">", $this->a_str_OriginalContent );
// phpcs:disable WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$this->a_str_original_content = preg_replace( '#<!--.+?-->#s', '', file_get_contents( $template ) );
// phpcs:enable
$this->a_str_original_content = preg_replace( '#/\*\*.+?\*/#s', '', $this->a_str_original_content );
$this->a_str_original_content = str_replace( "\n", '', $this->a_str_original_content );
$this->a_str_original_content = str_replace( "\r", '', $this->a_str_original_content );
$this->a_str_original_content = str_replace( "\t", ' ', $this->a_str_original_content );
$this->a_str_original_content = preg_replace( '# +#', ' ', $this->a_str_original_content );
$this->a_str_original_content = str_replace( ' >', '>', $this->a_str_original_content );
$this->reload();
}
/**
* Get the template
* Get the template.
*
* @author Patrizia Lutz @misfist
* - Adding: Templates: Enable template location stack, thanks to @misfist code contribution.
*
* @since 2.4.0d3
* @since 2.4.0d3 Contribution.
* @since 2.5.0 Release.
*
* @param string $p_str_FileType
* @param string $p_str_FileName
* @param string $p_str_Extension
* @contributor @misfist
* @link https://wordpress.org/support/topic/template-override-filter/#post-13864301
*
* @param string $p_str_file_type The file type of the template.
* @param string $p_str_file_name The file name of the template.
* @param string $p_str_extension The file extension of the template.
* @return mixed false | template path
*/
public function get_template( $p_str_FileType, $p_str_FileName, $p_str_Extension = "html" ) {
public function get_template( $p_str_file_type, $p_str_file_name, $p_str_extension = 'html' ) {
$located = false;
/**
* The directory change be modified
* @usage to change location of templates to `template_parts/footnotes/':
* The directory can be changed.
*
* @usage to change location of templates to 'template_parts/footnotes/':
* add_filter( 'mci_footnotes_template_directory', function( $directory ) {
* return 'template_parts/footnotes/;
* return 'template_parts/footnotes/';
* } );
*/
$template_directory = apply_filters( 'mci_footnotes_template_directory', 'footnotes/templates/' );
$custom_directory = apply_filters( 'mci_footnotes_custom_template_directory', 'footnotes-custom/' );
$template_name = $p_str_FileType . '/' . $p_str_FileName . '.' . $p_str_Extension;
$custom_directory = apply_filters( 'mci_footnotes_custom_template_directory', 'footnotes-custom/' );
$template_name = $p_str_file_type . '/' . $p_str_file_name . '.' . $p_str_extension;
/**
* Look in active (child) theme
* Look in active theme.
*/
if ( file_exists( trailingslashit( get_stylesheet_directory() ) . $template_directory . $template_name ) ) {
$located = trailingslashit( get_stylesheet_directory() ) . $template_directory . $template_name;
/**
* Look in parent theme
*/
/**
* Look in parent theme in case active is child.
*/
} elseif ( file_exists( trailingslashit( get_template_directory() ) . $template_directory . $template_name ) ) {
$located = trailingslashit( get_template_directory() ) . $template_directory . $template_name;
/**
* Look in custom directory
*/
/**
* Look in custom plugin directory.
*/
} elseif ( file_exists( trailingslashit( WP_PLUGIN_DIR ) . $custom_directory . 'templates/' . $template_name ) ) {
$located = trailingslashit( WP_PLUGIN_DIR ) . $custom_directory . 'templates/' . $template_name;
/**
* Look in plugin
*/
/**
* Fall back to the templates shipped with the plugin.
*/
} elseif ( file_exists( $this->plugin_directory . 'templates/' . $template_name ) ) {
$located = $this->plugin_directory . 'templates/' . $template_name;
}
@ -258,4 +232,4 @@ class MCI_Footnotes_Template {
return $located;
}
} // end of class
}

View file

@ -1,14 +1,12 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName
/**
* Widget base.
*
* @filesource
* @author Stefan Herndler
* @package footnotes
* @since 1.5.0
* @date 14.09.14 14:30
*
* @lastmodified 2021-02-18T0306+0100
* @date 2021-02-18T0240+0100
*
* @since 1.6.4 Update: replace deprecated function WP_Widget() with recommended __construct(), thanks to @dartiss code contribution.
*/
@ -21,68 +19,69 @@
* @author Stefan Herndler
* @since 1.5.0
*/
abstract class MCI_Footnotes_WidgetBase extends WP_Widget {
abstract class MCI_Footnotes_Widget_Base extends WP_Widget {
/**
* Returns an unique ID as string used for the Widget Base ID.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
abstract protected function getID();
abstract protected function get_id();
/**
* Returns the Public name of child Widget to be displayed in the Configuration page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
abstract protected function getName();
abstract protected function get_name();
/**
* Returns the Description of the child widget.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
abstract protected function getDescription();
abstract protected function get_description();
/**
* Returns the width of the Widget. Default width is 250 pixel.
*
* @author Stefan Herndler
* @since 1.5.0
* @return int
*/
protected function getWidgetWidth() {
protected function get_widget_width() {
return 250;
}
/**
* Class Constructor. Registers the child Widget to WordPress.
*
* @author Stefan Herndler
* @since 1.5.0
*
*
* - Update: replace deprecated function WP_Widget() with recommended __construct(), thanks to @dartiss code contribution.
*
*
* @since 1.6.4
* @contributor @dartiss
* @link https://plugins.trac.wordpress.org/browser/footnotes/trunk/class/widgets/base.php?rev=1445720
* “The called constructor method for WP_Widget in MCI_Footnotes_Widget_ReferenceContainer is deprecated since version 4.3.0! Use __construct() instead.
*/
public function __construct() {
$l_arr_WidgetOptions = array("classname" => __CLASS__, "description" => $this->getDescription());
$l_arr_ControlOptions = array("id_base" => strtolower($this->getID()), "width" => $this->getWidgetWidth());
// registers the Widget
$l_arr_widget_options = array(
'classname' => __CLASS__,
'description' => $this->get_description(),
);
$l_arr_control_options = array(
'id_base' => strtolower( $this->get_id() ),
'width' => $this->get_widget_width(),
);
// Registers the Widget.
parent::__construct(
strtolower($this->getID()), // unique ID for the widget, has to be lowercase
$this->getName(), // Plugin name to be displayed
$l_arr_WidgetOptions, // Optional Widget Options
$l_arr_ControlOptions // Optional Widget Control Options
);
strtolower( $this->get_id() ), // Unique ID for the widget, has to be lowercase.
$this->get_name(), // Plugin name to be displayed.
$l_arr_widget_options, // Optional Widget Options.
$l_arr_control_options // Optional Widget Control Options.
);
}
}

View file

@ -1,85 +1,81 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName, WordPress.Security.EscapeOutput.OutputNotEscaped
/**
* Includes the Plugin Widget to put the Reference Container to the Widget area.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 14:26
*
* Edited 2.2.0 2020-12-12T2131+0100
* @package footnotes
* @since 1.5.0
* @date 14.09.14 14:26
*
* @since 2.2.0 (TBD) 2020-12-12T2131+0100
*/
/**
* Registers a Widget to put the Reference Container to the widget area.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_Widget_ReferenceContainer extends MCI_Footnotes_WidgetBase {
class MCI_Footnotes_Widget_Reference_Container extends MCI_Footnotes_Widget_Base {
/**
* Returns an unique ID as string used for the Widget Base ID.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getID() {
return "footnotes_widget";
protected function get_id() {
return 'footnotes_widget';
}
/**
* Returns the Public name of the Widget to be displayed in the Configuration page.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*/
protected function getName() {
protected function get_name() {
return MCI_Footnotes_Config::C_STR_PLUGIN_NAME;
}
/**
* Returns the Description of the child widget.
*
* @author Stefan Herndler
* @since 1.5.0
* @return string
*
*
* Edit: curly quotes 2.2.0 2020-12-12T2130+0100
*/
protected function getDescription() {
return __('The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
protected function get_description() {
return __( 'The widget defines the position of the reference container if set to “widget area”.', 'footnotes' );
}
/**
* Outputs the Settings of the Widget.
*
* @author Stefan Herndler
* @since 1.5.0
* @param mixed $instance
* @param mixed $instance The instance of the widget.
* @return void
*
*
* Edit: curly quotes 2.2.0 2020-12-12T2130+0100
*/
public function form($instance) {
echo __('The widget defines the position of the reference container if set to “widget area”.', MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
public function form( $instance ) {
echo __( 'The widget defines the position of the reference container if set to “widget area”.', 'footnotes' );
}
/**
* Outputs the Content of the Widget.
*
* @author Stefan Herndler
* @since 1.5.0
* @param mixed $args
* @param mixed $instance
* @param mixed $args The widget's arguments.
* @param mixed $instance The instance of the widget.
*/
public function widget($args, $instance) {
global $g_obj_MCI_Footnotes;
// reference container positioning is set to "widget area"
if (MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION) == "widget") {
echo $g_obj_MCI_Footnotes->a_obj_Task->ReferenceContainer();
public function widget( $args, $instance ) {
global $g_obj_mci_footnotes;
// Reference container positioning is set to "widget area".
if ( 'widget' === MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_REFERENCE_CONTAINER_POSITION ) ) {
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $g_obj_mci_footnotes->a_obj_task->Reference_Container();
// phpcs:enable
}
}
}

View file

@ -1,83 +1,92 @@
<?php
<?php // phpcs:disable WordPress.Files.FileName.InvalidClassFileName
/**
* Includes the Class to handle the WYSIWYG-Buttons.
*
* @filesource
* @author Stefan Herndler
* @since 1.5.0 14.09.14 17:30
* @package footnotes
* @since 1.5.0
* @date 14.09.14 17:30
*/
/**
* Handles the WSYIWYG-Buttons.
*
* @author Stefan Herndler
* @since 1.5.0
*/
class MCI_Footnotes_WYSIWYG {
public static function registerHooks() {
add_filter("mce_buttons", array("MCI_Footnotes_WYSIWYG", "newVisualEditorButton"));
add_action("admin_print_footer_scripts", array("MCI_Footnotes_WYSIWYG", "newPlainTextEditorButton"));
/**
* Registers Button hooks.
*
* @return void
*/
public static function register_hooks() {
add_filter( 'mce_buttons', array( 'MCI_Footnotes_WYSIWYG', 'new_visual_editor_button' ) );
add_action( 'admin_print_footer_scripts', array( 'MCI_Footnotes_WYSIWYG', 'new_plain_text_editor_button' ) );
add_filter("mce_external_plugins", array("MCI_Footnotes_WYSIWYG", "includeScripts"));
add_filter( 'mce_external_plugins', array( 'MCI_Footnotes_WYSIWYG', 'include_scripts' ) );
add_action("wp_ajax_nopriv_footnotes_getTags", array("MCI_Footnotes_WYSIWYG", "ajaxCallback"));
add_action("wp_ajax_footnotes_getTags", array("MCI_Footnotes_WYSIWYG", "ajaxCallback"));
add_action( 'wp_ajax_nopriv_footnotes_get_tags', array( 'MCI_Footnotes_WYSIWYG', 'ajax_callback' ) );
add_action( 'wp_ajax_footnotes_get_tags', array( 'MCI_Footnotes_WYSIWYG', 'ajax_callback' ) );
}
/**
* Append a new Button to the WYSIWYG editor of Posts and Pages.
*
* @author Stefan Herndler
* @since 1.5.0
* @param array $p_arr_Buttons pre defined Buttons from WordPress.
* @param array $p_arr_buttons pre defined Buttons from WordPress.
* @return array
*/
public static function newVisualEditorButton($p_arr_Buttons) {
array_push($p_arr_Buttons, MCI_Footnotes_Config::C_STR_PLUGIN_NAME);
return $p_arr_Buttons;
public static function new_visual_editor_button( $p_arr_buttons ) {
array_push( $p_arr_buttons, MCI_Footnotes_Config::C_STR_PLUGIN_NAME );
return $p_arr_buttons;
}
/**
* Add a new button to the plain text editor.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function newPlainTextEditorButton() {
$l_obj_Template = new MCI_Footnotes_Template(MCI_Footnotes_Template::C_STR_DASHBOARD, "editor-button");
echo $l_obj_Template->getContent();
public static function new_plain_text_editor_button() {
$l_obj_template = new MCI_Footnotes_Template( MCI_Footnotes_Template::C_STR_DASHBOARD, 'editor-button' );
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo $l_obj_template->get_content();
// phpcs:enable
}
/**
* Includes the Plugins WYSIWYG editor script.
*
* @author Stefan Herndler
* @since 1.5.0
* @param array $p_arr_Plugins Scripts to be included to the editor.
* @param array $p_arr_plugins Scripts to be included to the editor.
* @return array
*/
public static function includeScripts($p_arr_Plugins) {
$p_arr_Plugins[MCI_Footnotes_Config::C_STR_PLUGIN_NAME] = plugins_url('/../js/wysiwyg-editor.js', __FILE__);
return $p_arr_Plugins;
public static function include_scripts( $p_arr_plugins ) {
$p_arr_plugins[ MCI_Footnotes_Config::C_STR_PLUGIN_NAME ] = plugins_url( '/../js/wysiwyg-editor.js', __FILE__ );
return $p_arr_plugins;
}
/**
* AJAX Callback function when the Footnotes Button is clicked. Either in the Plain text or Visual editor.
* Returns an JSON encoded array with the Footnotes start and end short code.
*
* @author Stefan Herndler
* @since 1.5.0
*/
public static function ajaxCallback() {
// get start and end tag for the footnotes short code
$l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START);
$l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END);
if ($l_str_StartingTag == "userdefined" || $l_str_EndingTag == "userdefined") {
$l_str_StartingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED);
$l_str_EndingTag = MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED);
public static function ajax_callback() {
// Get start and end tag for the footnotes short code.
$l_str_starting_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START );
$l_str_ending_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END );
if ( 'userdefined' === $l_str_starting_tag || 'userdefined' === $l_str_ending_tag ) {
$l_str_starting_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_START_USER_DEFINED );
$l_str_ending_tag = MCI_Footnotes_Settings::instance()->get( MCI_Footnotes_Settings::C_STR_FOOTNOTES_SHORT_CODE_END_USER_DEFINED );
}
echo json_encode(array("start" => htmlspecialchars($l_str_StartingTag), "end" => htmlspecialchars($l_str_EndingTag)));
echo wp_json_encode(
array(
'start' => htmlspecialchars( $l_str_starting_tag ),
'end' => htmlspecialchars( $l_str_ending_tag ),
)
);
exit;
}
}

11
composer.json Normal file
View file

@ -0,0 +1,11 @@
{
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"wp-coding-standards/wpcs": "^2.3"
},
"scripts": {
"post-install-cmd": [
"bash _tools/setup.sh"
]
}
}

196
composer.lock generated Normal file
View file

@ -0,0 +1,196 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3a147d50695956de52f7cbf827b47830",
"packages": [],
"packages-dev": [
{
"name": "dealerdirect/phpcodesniffer-composer-installer",
"version": "v0.7.1",
"source": {
"type": "git",
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
"reference": "fe390591e0241955f22eb9ba327d137e501c771c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c",
"reference": "fe390591e0241955f22eb9ba327d137e501c771c",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0 || ^2.0",
"php": ">=5.3",
"squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0"
},
"require-dev": {
"composer/composer": "*",
"phpcompatibility/php-compatibility": "^9.0",
"sensiolabs/security-checker": "^4.1.0"
},
"type": "composer-plugin",
"extra": {
"class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
},
"autoload": {
"psr-4": {
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Franck Nijhof",
"email": "franck.nijhof@dealerdirect.com",
"homepage": "http://www.frenck.nl",
"role": "Developer / IT Manager"
}
],
"description": "PHP_CodeSniffer Standards Composer Installer Plugin",
"homepage": "http://www.dealerdirect.com",
"keywords": [
"PHPCodeSniffer",
"PHP_CodeSniffer",
"code quality",
"codesniffer",
"composer",
"installer",
"phpcs",
"plugin",
"qa",
"quality",
"standard",
"standards",
"style guide",
"stylecheck",
"tests"
],
"support": {
"issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues",
"source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer"
},
"time": "2020-12-07T18:04:37+00:00"
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.5.8",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4",
"reference": "9d583721a7157ee997f235f327de038e7ea6dac4",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"bin": [
"bin/phpcs",
"bin/phpcbf"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Greg Sherwood",
"role": "lead"
}
],
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
"keywords": [
"phpcs",
"standards"
],
"support": {
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
},
"time": "2020-10-23T02:01:07+00:00"
},
{
"name": "wp-coding-standards/wpcs",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/WordPress/WordPress-Coding-Standards.git",
"reference": "7da1894633f168fe244afc6de00d141f27517b62"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62",
"reference": "7da1894633f168fe244afc6de00d141f27517b62",
"shasum": ""
},
"require": {
"php": ">=5.4",
"squizlabs/php_codesniffer": "^3.3.1"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6",
"phpcompatibility/php-compatibility": "^9.0",
"phpcsstandards/phpcsdevtools": "^1.0",
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
},
"type": "phpcodesniffer-standard",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Contributors",
"homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors"
}
],
"description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
"keywords": [
"phpcs",
"standards",
"wordpress"
],
"support": {
"issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues",
"source": "https://github.com/WordPress/WordPress-Coding-Standards",
"wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki"
},
"time": "2020-05-13T23:57:56+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.0.0"
}

61
contrib/pre-commit Normal file
View file

@ -0,0 +1,61 @@
#!/bin/sh
# Modified from: https://github.com/bjornjohansen/wp-pre-commit-hook
# Also: https://softdiscover.com/wordpress/perfect-setup-for-a-wordpress-project-development/
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
'
SFILES="$1"
IFS=$oIFS
fi
SFILES=${SFILES:-$STAGED_FILES_CMD}
echo "Checking PHP Lint..."
for FILE in $SFILES
do
php -l -d display_errors=0 $PROJECT/$FILE
if [ $? != 0 ]
then
echo "Fix the error before commit."
exit 1
fi
FILES="$FILES $PROJECT/$FILE"
done
if [ -f "$PROJECT/phpcs.ruleset.xml" ]
then
RULESET="$PROJECT/phpcs.ruleset.xml"
elif [ -f "$PROJECT/phpcs.xml.dist" ]
then
RULESET="$PROJECT/phpcs.xml.dist"
else
RULESET="WordPress"
fi
if [ "$FILES" != "" ]
then
echo "Checking Code Standard Compliance, using $RULESET as ruleset standard..."
./vendor/bin/phpcs --standard="$RULESET" --colors --encoding=utf-8 -n -p $FILES
if [ $? != 0 ]
then
echo "Coding standards errors have been detected. Running phpcbf..."
./vendor/bin/phpcbf --standard="$RULESET" --encoding=utf-8 -n -p $FILES
git add $FILES
echo "Running Code Sniffer again..."
./vendor/bin/phpcs --standard="$RULESET" --colors --encoding=utf-8 -n -p $FILES
if [ $? != 0 ]
then
echo "Errors found not fixable automatically. You need to manually fix them."
exit 1
fi
fi
fi
exit $?

View file

@ -17,4 +17,4 @@ the currently used one should be one of those templates and pre-defined styles o
== TODO ==
- Statistics: How many Footnotes in each post/page
- Convert from other Footnote Plugins (e.g. ' ((' from Civil Footnotes)
- Anonymous stats to the developers
- Anonymous stats to the developers

View file

@ -1,26 +1,27 @@
<?php
/*
Plugin Name: footnotes
Plugin URI: https://wordpress.org/plugins/footnotes/
Description: time to bring footnotes to your website! footnotes are known from offline publishing and everybody takes them for granted when reading a magazine.
Author: Mark Cheret
Version: 2.5.10
Author URI: http://cheret.de/plugins/footnotes-2/
Text Domain: footnotes
Domain Path: /languages
*/
/*
* Copyright 2021 Mark Cheret (email: mark@cheret.de)
/**
* Plugin Name: footnotes
* Plugin URI: https://wordpress.org/plugins/footnotes/
* Description: time to bring footnotes to your website! footnotes are known from offline publishing and everybody takes them for granted when reading a magazine.
* Author: Mark Cheret
* Version: 2.5.11d0
* Author URI: http://cheret.de/plugins/footnotes-2/
* Text Domain: footnotes
* Domain Path: /languages
*
* @package footnotes
* @copyright 2021 Mark Cheret (email: mark@cheret.de)
*/
/**
* Version number for stylesheet cache busting.
*
* @since 2.1.4
* @since 2.5.3 (Hungarian)
* @var str
* @lastmodified 2021-03-01T1203+0100
* @lastmodified 2021-03-03T1951+0100
*/
define( 'C_STR_FOOTNOTES_VERSION', '2.5.10' );
define( 'C_STR_FOOTNOTES_VERSION', '2.5.11d0' );
/*
LICENSE NOTICE
@ -41,34 +42,34 @@ define( 'C_STR_FOOTNOTES_VERSION', '2.5.10' );
/**
* Plugins main PHP file.
*
*
* @filesource
* @author Stefan Herndler
* @package footnotes
* @since 0.0.1
*/
// Get all common classes and functions
require_once(dirname(__FILE__) . "/includes.php");
// Get all common classes and functions.
require_once dirname( __FILE__ ) . '/includes.php';
// add Plugin Links to the "installed plugins" page
// Add Plugin Links to the "installed plugins" page.
$l_str_plugin_file = 'footnotes/footnotes.php';
add_filter("plugin_action_links_{$l_str_plugin_file}", array("MCI_Footnotes_Hooks", "PluginLinks"), 10, 2);
add_filter( "plugin_action_links_{$l_str_plugin_file}", array( 'MCI_Footnotes_Hooks', 'plugin_links' ), 10, 2 );
// initialize the Plugin
$g_obj_MCI_Footnotes = new MCI_Footnotes();
// run the Plugin
$g_obj_MCI_Footnotes->run();
// Initialize the Plugin.
$g_obj_mci_footnotes = new MCI_Footnotes();
// Run the Plugin.
$g_obj_mci_footnotes->run();
/**
* Sets the stylesheet enqueuing mode for production.
*
*
* @since 2.5.5
* @var bool
* @see class/init.php
*
*
* In production, a minified CSS file tailored to the settings is enqueued.
*
*
* Developing stylesheets is meant to be easier when this is set to false.
* WARNING: This facility designed for development must NOT be used in production.
*/
*/
define( 'C_BOOL_CSS_PRODUCTION_MODE', true );

View file

@ -3,35 +3,37 @@
* Includes all common files.
*
* @filesource
* @author Stefan Herndler
* @package footnotes
* @since 1.5.0 14.09.14 13:40
*/
/**
* Requires (require_once) all *.php files inside a specific Directory.
* Requires (`require_once`) all `*.php` files inside a specific Directory.
*
* @author Stefan Herndler
* @since 1.5.0
* @param string $p_str_Directory Absolute Directory path to lookup for *.php files
* @param string $p_str_directory Absolute Directory path to lookup for `*.php` files.
*/
function MCI_Footnotes_requirePhpFiles($p_str_Directory) {
// append slash at the end of the Directory if not exist
if (substr($p_str_Directory, -1) != "/") {
$p_str_Directory .= "/";
function mci_footnotes_require_php_files( $p_str_directory ) {
// Append slash at the end of the Directory if not exist.
if ( '/' !== substr( $p_str_directory, -1 ) ) {
$p_str_directory .= '/';
}
// get all PHP files inside Directory
$l_arr_Files = scandir($p_str_Directory);
// iterate through each class
foreach ($l_arr_Files as $l_str_FileName) {
// skip all non *.php files
if (strtolower(substr($l_str_FileName, -4)) != ".php") {
// Get all PHP files inside Directory.
$l_arr_files = scandir( $p_str_directory );
// Iterate through each class.
foreach ( $l_arr_files as $l_str_file_name ) {
// Skip all non-PHP files.
if ( '.php' !== strtolower( substr( $l_str_file_name, -4 ) ) ) {
continue;
}
// phpcs:disable Generic.Commenting.DocComment.MissingShort
/** @noinspection PhpIncludeInspection */
require_once($p_str_Directory . $l_str_FileName);
require_once $p_str_directory . $l_str_file_name;
// phpcs:enable
}
}
MCI_Footnotes_requirePhpFiles(dirname(__FILE__) . "/class");
MCI_Footnotes_requirePhpFiles(dirname(__FILE__) . "/class/dashboard");
MCI_Footnotes_requirePhpFiles(dirname(__FILE__) . "/class/widgets");
mci_footnotes_require_php_files( dirname( __FILE__ ) . '/class' );
mci_footnotes_require_php_files( dirname( __FILE__ ) . '/class/dashboard' );
mci_footnotes_require_php_files( dirname( __FILE__ ) . '/class/widgets' );

View file

@ -671,4 +671,4 @@ 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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

1264
readme.txt

File diff suppressed because it is too large Load diff

View file

@ -1,2 +1,2 @@
<input type="button" class="button button-primary" value="[[caption]]"
onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ');" />
onclick="window.open('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6Z6CZDW8PPBBJ');" />

View file

@ -14,4 +14,4 @@
<div style="text-align:center;">
[[information]]
</div>
</div>

View file

@ -8,4 +8,4 @@
<h2 style="margin: 0;color: rgb(64, 64, 64); line-height: 36px; font-size: 24px; ">the ManFisher menu</h2>
<p style="margin: 0 0 9px; font-size: 13px; line-height: 18px;">Will soon disappear as the company name changed and I believe it's overbearing to have that menu for such a simple function as footnotes</p>
</div>
</div>

View file

@ -54,7 +54,7 @@
type: 'POST',
url: '/wp-admin/admin-ajax.php',
data: {
action: 'footnotes_getPluginInfo',
action: 'footnotes_get_plugin_info',
plugin: '[[plugin-name]]'
},
dataType: 'json',

View file

@ -4,8 +4,8 @@
-->
<span
class="footnote_referrer relative"
onmouseover="footnoteTooltipShow('footnote_plugin_tooltip_text_[[post_id]]_[[container_id]]_[[note_id]]')"
onmouseout="footnoteTooltipHide('footnote_plugin_tooltip_text_[[post_id]]_[[container_id]]_[[note_id]]')"
onmouseover="footnote_tooltip_show('footnote_plugin_tooltip_text_[[post_id]]_[[container_id]]_[[note_id]]')"
onmouseout="footnote_tooltip_hide('footnote_plugin_tooltip_text_[[post_id]]_[[container_id]]_[[note_id]]')"
><[[link-span]]
onclick="footnote_moveToAnchor_[[post_id]]_[[container_id]]('footnote_plugin_reference_[[post_id]]_[[container_id]]_[[note_id]]');"
[[hard-link]]
@ -17,7 +17,7 @@
>[[anchor-element]]<span
id="footnote_plugin_tooltip_text_[[post_id]]_[[container_id]]_[[note_id]]"
class="footnote_tooltip position hidden"
onmouseout="footnoteTooltipHide('footnote_plugin_tooltip_text_[[post_id]]_[[container_id]]_[[note_id]]')"
onmouseout="footnote_tooltip_hide('footnote_plugin_tooltip_text_[[post_id]]_[[container_id]]_[[note_id]]')"
[[style]]
>[[text]]</span
></span