Initial commit

This commit is contained in:
Felix Förtsch
2020-10-20 14:39:50 +02:00
commit 648ded8896
1225 changed files with 216511 additions and 0 deletions

20
README.md Normal file
View File

@@ -0,0 +1,20 @@
# WordPress Dev Env
This repo uses `docker-compose` to set up a local WordPress development environmant. It contains a few plugins that are useful during WordPress plugin development, such as QueryMonitor and wp-crontrol. Furthermore it contains the boilerplate plugin [https://github.com/DevinVinson/wppb-demo-plugin](https://github.com/DevinVinson/wppb-demo-plugin).
## Installation
`docker-compose up -d` creates a docker stack containing the following:
- Database from `mariadb:latest`, published on `localhost:7001`
- Adminer from `adminer:latest`, published on `localhost:7002`
- WordPress from `wordpress:latest`, published on `localhost:7000` using the database on `localhost:7001`
- wp-cli instance to setup the WordPress instance
The wp-cli setup script contains a slight delay (`sleep 10`) before it starts setting up WordPress, because the database does not respond instantly during setup. After the setup has finished, you can log into the WordPress stack on `localhost:7000/wp-admin` using user: `admin` and password: `admin`.
The two folders `wordpress_plugins` and `wordpress_themes` are linked into the container stack and are therefore accessible for WordPress. You can do your plugin and theme development direct in these folders.
## Removal
To remove the stack simply use `docker-compose down -v`. This cleans up the docker stack and removes the named volumes and networks.

70
docker-compose.yml Normal file
View File

@@ -0,0 +1,70 @@
version: "3.8"
services:
db:
image: mariadb:latest
ports:
- 7001:3306
networks:
- wordpress-dev-env
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- 7000:80
networks:
- wordpress-dev-env
volumes:
- wp_data:/var/www/html/
- ./wordpress_plugins:/var/www/html/wp-content/plugins/
- ./wordpress_themes:/var/www/html/wp-content/themes/
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DEBUG: 1
wordpress-cli:
depends_on:
- db
- wordpress
image: wordpress:cli
user: xfs
command: >
/bin/sh -c '
sleep 10;
wp core install --path="/var/www/html" --url="http://localhost:7000" --title="Local Wordpress By Docker" --admin_user=admin --admin_password=admin --admin_email=foo@bar.com
'
networks:
- wordpress-dev-env
volumes:
- wp_data:/var/www/html/
adminer:
depends_on:
- db
image: adminer:latest
restart: always
ports:
- 7002:8080
networks:
- wordpress-dev-env
networks:
wordpress-dev-env:
volumes:
db_data:
wp_data:

View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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
<http://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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -0,0 +1,6 @@
# ajax-autocomplete
DEMO Wordpress Ajax jQuery textbox autocomplete, data source from custom table.
# Instructions
1. Download, install and activate this wordpress plugin
2. Put [test-form] shortcode to any post or page to test it out.

View File

@@ -0,0 +1,67 @@
<?php
/*
* Plugin Name: Ajax Autocomplete
* Plugin URI: https://github.com/hiendnguyen/ajax-autocomplete
* Description: DEMO Wordpress Ajax jQuery textbox autocomplete, data source from custom table. Put [test-form] shortcode to any post or page to test it out.
* Version: 0.1
* Author: Hien D. Nguyen
* Author URI: https://vndeveloper.com/
* License: GPL3+
*/
if (!defined('ABSPATH')) exit;
// Plugin activation: Create sample db table and insert test data
register_activation_hook(basename(dirname(__FILE__)) . '/' . basename(__FILE__), 'activate');
function activate() {
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
$table = $wpdb->prefix . 'testing_table';
$query = "CREATE TABLE IF NOT EXISTS {$table} (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(128),
PRIMARY KEY (id)
)$charset_collate;";
dbDelta($query);
// Insert test data
$wpdb->insert($table, array('name' => 'LogiTech'));
$wpdb->insert($table, array('name' => 'Apple'));
$wpdb->insert($table, array('name' => 'Dell'));
$wpdb->insert($table, array('name' => 'Google'));
}
// Enqueue js, css
add_action('wp_enqueue_scripts', 'mysite_js');
function mysite_js() {
// $wp_scripts = wp_scripts();
// wp_enqueue_style('jquery_ui_css','http://ajax.googleapis.com/ajax/libs/jqueryui/' . $wp_scripts->registered['jquery-ui-core']->ver . '/themes/flick/jquery-ui.css');
wp_enqueue_script('mysitejs', plugins_url('/assets/js/frontend.js', __FILE__));
wp_localize_script('mysitejs', 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php')));
}
add_shortcode('test-form', 'test_form');
function test_form($args, $content = '') {
ob_start();
include(plugin_dir_path(__FILE__) . 'includes/forms/test-form.php');
return ob_get_clean();
}
add_action('wp_ajax_nopriv_myautocomplete', 'ajax_autocomplete');
add_action('wp_ajax_myautocomplete', 'ajax_autocomplete');
function ajax_autocomplete() {
global $wpdb;
$table = $wpdb->prefix . 'testing_table';
//$table = 'sensw_mdr_wohngegend';
$results = $wpdb->get_results("SELECT name FROM " . $table . " WHERE name LIKE '%" . $_POST['keyword'] . "%'");
$items = array();
if (!empty($results)) {
foreach ($results as $result) {
$items[] = $result->name;
}
}
echo json_encode($items);
die();
}

View File

@@ -0,0 +1,21 @@
jQuery(document).ready(function($) {
$('input[name=testing]').autocomplete({
source: function(request, response){
$.ajax({
type: "POST",
url: ajax_object.ajax_url,
data: {
action: 'myautocomplete',
keyword: $('input[name=testing]').val(),
},
success:function(data) {
console.log(data);
response(JSON.parse(data));
},
error: function(errorThrown){
console.log(errorThrown);
}
})
},
});
})

View File

@@ -0,0 +1,3 @@
<form >
<input type="text" name="testing">
</form>

View File

@@ -0,0 +1,34 @@
# Only allow direct access to specific Web-available files.
# Apache 2.2
<IfModule !mod_authz_core.c>
Order Deny,Allow
Deny from all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
# Akismet CSS and JS
<FilesMatch "^(form\.js|akismet\.js|akismet\.css)$">
<IfModule !mod_authz_core.c>
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>
# Akismet images
<FilesMatch "^logo-full-2x\.png$">
<IfModule !mod_authz_core.c>
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</FilesMatch>

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and 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 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,662 @@
.wp-admin.jetpack_page_akismet-key-config, .wp-admin.settings_page_akismet-key-config {
background-color:#f3f6f8;
}
#submitted-on {
position: relative;
}
#the-comment-list .author .akismet-user-comment-count {
display: inline;
}
#the-comment-list .author a span {
text-decoration: none;
color: #999;
}
#the-comment-list .author a span.akismet-span-link {
text-decoration: inherit;
color: inherit;
}
#the-comment-list .akismet_remove_url {
margin-left: 3px;
color: #999;
padding: 2px 3px 2px 0;
}
#the-comment-list .akismet_remove_url:hover {
color: #A7301F;
font-weight: bold;
padding: 2px 2px 2px 0;
}
#dashboard_recent_comments .akismet-status {
display: none;
}
.akismet-status {
float: right;
}
.akismet-status a {
color: #AAA;
font-style: italic;
}
table.comments td.comment p a {
text-decoration: underline;
}
table.comments td.comment p a:after {
content: attr(href);
color: #aaa;
display: inline-block; /* Show the URL without the link's underline extending under it. */
padding: 0 1ex; /* Because it's inline block, we can't just use spaces in the content: attribute to separate it from the link text. */
}
.mshot-arrow {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right: 10px solid #5C5C5C;
position: absolute;
left: -6px;
top: 91px;
}
.mshot-container {
background: #5C5C5C;
position: absolute;
top: -94px;
padding: 7px;
width: 450px;
height: 338px;
z-index: 20000;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-border-radius: 6px;
}
.akismet-mshot {
position: absolute;
z-index: 100;
}
.akismet-mshot .mshot-image {
margin: 0;
height: 338px;
width: 450px;
}
.checkforspam {
display: inline-block !important;
}
.checkforspam-spinner {
display: inline-block;
margin-top: 7px;
}
.akismet-right {
float: right;
}
.akismet-card .akismet-right {
margin: 1em 0;
}
.akismet-alert-text {
color: #dd3d36;
font-weight: bold;
font-size: 120%;
margin-top: .5rem;
}
.akismet-alert {
border: 1px solid #e5e5e5;
padding: 0.4em 1em 1.4em 1em;
border-radius: 3px;
-webkit-border-radius: 3px;
border-width: 1px;
border-style: solid;
}
.akismet-alert h3.akismet-key-status {
color: #fff;
margin: 1em 0 0.5em 0;
}
.akismet-alert.akismet-critical {
background-color: #993300;
}
.akismet-alert.akismet-active {
background-color: #649316;
}
.akismet-alert p.akismet-key-status {
font-size: 24px;
}
.akismet-alert p.akismet-description {
color:#fff;
font-size: 14px;
margin: 0 0;
font-style: normal;
}
.akismet-alert p.akismet-description a,
.akismet-alert p.akismet-description a,
.akismet-alert p.akismet-description a,
.akismet-alert p.akismet-description a {
color: #fff;
}
.akismet-new-snapshot {
margin-top: 1em;
padding: 1em;
text-align: center;
background: #fff;
}
.akismet-new-snapshot h3 {
background: #f5f5f5;
color: #888;
font-size: 11px;
margin: 0;
padding: 3px;
}
.new-snapspot ul {
font-size: 12px;
width: 100%;
}
.akismet-new-snapshot ul li {
color: #999;
float: left;
font-size: 11px;
padding: 0 20px;
text-transform: uppercase;
width: 33%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
}
.akismet-new-snapshot ul li:first-child,
.akismet-new-snapshot ul li:nth-child(2) {
border-right:1px dotted #ccc;
}
.akismet-new-snapshot ul li span {
color: #52accc;
display: block;
font-size: 32px;
font-weight: lighter;
line-height: 1.5em;
}
.akismet-settings th:first-child {
vertical-align: top;
padding-top: 15px;
}
.akismet-settings th.akismet-api-key {
vertical-align: middle;
padding-top: 0;
}
.akismet-settings input[type=text] {
width: 75%;
}
.akismet-settings span.akismet-note{
float: left;
padding-left: 23px;
font-size: 75%;
margin-top: -10px;
}
/**
* For the activation notice on the plugins page.
*/
#akismet_setup_prompt {
background: none;
border: none;
margin: 0;
padding: 0;
width: 100%;
}
.akismet_activate {
border: 1px solid #4F800D;
padding: 5px;
margin: 15px 0;
background: #83AF24;
background-image: -webkit-gradient(linear, 0% 0, 80% 100%, from(#83AF24), to(#4F800D));
background-image: -moz-linear-gradient(80% 100% 120deg, #4F800D, #83AF24);
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-border-radius: 3px;
position: relative;
overflow: hidden;
}
.akismet_activate .aa_a {
position: absolute;
top: -5px;
right: 10px;
font-size: 140px;
color: #769F33;
font-family: Georgia, "Times New Roman", Times, serif;
}
.akismet_activate .aa_button {
font-weight: bold;
border: 1px solid #029DD6;
border-top: 1px solid #06B9FD;
font-size: 15px;
text-align: center;
padding: 9px 0 8px 0;
color: #FFF;
background: #029DD6;
background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1));
background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6);
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-border-radius: 2px;
width: 100%;
cursor: pointer;
margin: 0;
}
.akismet_activate .aa_button:hover {
text-decoration: none !important;
border: 1px solid #029DD6;
border-bottom: 1px solid #00A8EF;
font-size: 15px;
text-align: center;
padding: 9px 0 8px 0;
color: #F0F8FB;
background: #0079B1;
background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#0079B1), to(#0092BF));
background-image: -moz-linear-gradient(0% 100% 90deg, #0092BF, #0079B1);
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-border-radius: 2px;
}
.akismet_activate .aa_button_border {
border: 1px solid #006699;
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-border-radius: 2px;
background: #029DD6;
background-image: -webkit-gradient(linear, 0% 0, 0% 100%, from(#029DD6), to(#0079B1));
background-image: -moz-linear-gradient(0% 100% 90deg, #0079B1, #029DD6);
}
.akismet_activate .aa_button_container {
box-sizing: border-box;
display: inline-block;
background: #DEF1B8;
padding: 5px;
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-border-radius: 2px;
width: 266px;
}
.akismet_activate .aa_description {
position: absolute;
top: 22px;
left: 285px;
margin-left: 25px;
color: #E5F2B1;
font-size: 15px;
}
.akismet_activate .aa_description strong {
color: #FFF;
font-weight: normal;
}
@media (max-width: 550px) {
.akismet_activate .aa_a {
display: none;
}
.akismet_activate .aa_button_container {
width: 100%;
}
}
@media (max-width: 782px) {
.akismet_activate {
min-width: 0;
}
}
@media (max-width: 850px) {
#akismet_setup_prompt .aa_description {
display: none;
}
.akismet_activate {
min-width: 0;
}
}
.jetpack_page_akismet-key-config #wpcontent, .settings_page_akismet-key-config #wpcontent {
padding-left: 0;
}
.akismet-masthead {
background-color:#fff;
text-align:center;
box-shadow:0 1px 0 rgba(200,215,225,0.5),0 1px 2px #e9eff3
}
@media (max-width: 45rem) {
.akismet-masthead {
padding:0 1.25rem
}
}
.akismet-masthead__inside-container {
padding:.375rem 0;
margin:0 auto;
width:100%;
max-width:45rem;
text-align: left;
}
.akismet-masthead__logo-container {
padding:.3125rem 0 0
}
.akismet-masthead__logo {
width:10.375rem;
height:1.8125rem;
}
.akismet-masthead__logo-link {
display:inline-block;
outline:none;
vertical-align:middle
}
.akismet-masthead__logo-link:focus {
line-height:0;
box-shadow:0 0 0 2px #78dcfa
}
.akismet-masthead__logo-link+code {
margin:0 10px;
padding:5px 9px;
border-radius:2px;
background:#e6ecf1;
color:#647a88
}
.akismet-masthead__links {
display:-ms-flexbox;
display:flex;
-ms-flex-flow:row wrap;
flex-flow:row wrap;
-ms-flex:2 50%;
flex:2 50%;
-ms-flex-pack:end;
justify-content:flex-end;
margin:0
}
@media (max-width: 480px) {
.akismet-masthead__links {
padding-right:.625rem
}
}
.akismet-masthead__link-li {
margin:0;
padding:0
}
.akismet-masthead__link {
font-style:normal;
color:#0087be;
padding:.625rem;
display:inline-block
}
.akismet-masthead__link:visited {
color:#0087be
}
.akismet-masthead__link:active,.akismet-masthead__link:hover {
color:#00aadc
}
.akismet-masthead__link:hover {
text-decoration:underline
}
.akismet-masthead__link .dashicons {
display:none
}
@media (max-width: 480px) {
.akismet-masthead__link:hover,.akismet-masthead__link:active {
text-decoration:none
}
.akismet-masthead__link .dashicons {
display:block;
font-size:1.75rem
}
.akismet-masthead__link span+span {
display:none
}
}
.akismet-masthead__link-li:last-of-type .akismet-masthead__link {
padding-right:0
}
.akismet-lower {
margin: 0 auto;
text-align: left;
max-width: 45rem;
padding: 1.5rem;
}
.akismet-lower .notice {
margin-bottom: 2rem;
}
.akismet-card {
margin-top: 1rem;
margin-bottom: 0;
position: relative;
margin: 0 auto 0.625rem auto;
box-sizing: border-box;
background: white;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
}
.akismet-card:after, .akismet-card .inside:after, .akismet-masthead__logo-container:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.akismet-card .inside {
padding: 1.5rem;
padding-top: 1rem;
}
.akismet-card .akismet-card-actions {
margin-top: 1rem;
}
.jetpack_page_akismet-key-config .update-nag, .settings_page_akismet-key-config .update-nag {
display: none;
}
.akismet-masthead .akismet-right {
line-height: 2.125rem;
font-size: 0.9rem;
}
.akismet-box {
box-sizing: border-box;
background: white;
border: 1px solid rgba(200, 215, 225, 0.5);
}
.akismet-box h2, .akismet-box h3 {
padding: 1.5rem 1.5rem .5rem 1.5rem;
margin: 0;
}
.akismet-box p {
padding: 0 1.5rem 1.5rem 1.5rem;
margin: 0;
}
.akismet-jetpack-email {
font-style: oblique;
}
.akismet-jetpack-gravatar {
padding: 0 0 0 1.5rem;
float: left;
margin-right: 1rem;
width: 54px;
height: 54px;
}
.akismet-box p:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.akismet-box .akismet-right {
padding-right: 1.5rem;
}
.akismet-boxes .akismet-box {
margin-bottom: 0;
padding: 0;
margin-top: -1px;
}
.akismet-boxes .akismet-box:last-child {
margin-bottom: 1.5rem;
}
.akismet-boxes .akismet-box:first-child {
margin-top: 1.5rem;
}
.akismet-box-header {
max-width: 700px;
margin: 0 auto 40px auto;
line-height: 1.5;
}
.akismet-box-header h2 {
margin: 1.5rem 10% 0;
font-size: 1.375rem;
font-weight: 700;
color: #000;
}
.akismet-box .centered {
text-align: center;
}
.akismet-enter-api-key-box {
margin: 1.5rem 0;
}
.akismet-box .enter-api-key {
display: none;
margin-top: 1.5rem;
}
.akismet-box .akismet-toggles {
margin: 3rem 0;
}
.akismet-box .akismet-ak-connect, .akismet-box .toggle-jp-connect {
display: none;
}
.akismet-box .enter-api-key p {
padding: 0 1.5rem;
}
.akismet-button, .akismet-button:hover, .akismet-button:visited {
background: white;
border-color: #c8d7e1;
border-style: solid;
border-width: 1px 1px 2px;
color: #2e4453;
cursor: pointer;
display: inline-block;
margin: 0;
outline: 0;
overflow: hidden;
font-size: 14px;
font-weight: 500;
text-overflow: ellipsis;
text-decoration: none;
vertical-align: top;
box-sizing: border-box;
font-size: 14px;
line-height: 21px;
border-radius: 4px;
padding: 7px 14px 9px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.akismet-button:hover {
border-color: #a8bece;
}
.akismet-button:active {
border-width: 2px 1px 1px;
}
.akismet-is-primary, .akismet-is-primary:hover, .akismet-is-primary:visited {
background: #00aadc;
border-color: #0087be;
color: white;
}
.akismet-is-primary:hover, .akismet-is-primary:focus {
border-color: #005082;
}
.akismet-is-primary:hover {
border-color: #005082;
}
.akismet-section-header {
position: relative;
margin: 0 auto 0.625rem auto;
padding: 1rem;
box-sizing: border-box;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
background: #ffffff;
width: 100%;
padding-top: 0.6875rem;
padding-bottom: 0.6875rem;
display: flex;
}
.akismet-section-header__label {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
-ms-flex-positive: 1;
flex-grow: 1;
line-height: 1.75rem;
position: relative;
font-size: 0.875rem;
color: #4f748e;
}
.akismet-section-header__actions {
line-height: 1.75rem;
}
.akismet-setup-instructions {
text-align: center;
}
.akismet-setup-instructions form {
padding-bottom: 1.5rem;
}

View File

@@ -0,0 +1,350 @@
jQuery( function ( $ ) {
var mshotRemovalTimer = null;
var mshotSecondTryTimer = null
var mshotThirdTryTimer = null
var mshotEnabledLinkSelector = 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a';
$('.akismet-status').each(function () {
var thisId = $(this).attr('commentid');
$(this).prependTo('#comment-' + thisId + ' .column-comment');
});
$('.akismet-user-comment-count').each(function () {
var thisId = $(this).attr('commentid');
$(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
});
akismet_enable_comment_author_url_removal();
$( '#the-comment-list' ).on( 'click', '.akismet_remove_url', function () {
var thisId = $(this).attr('commentid');
var data = {
action: 'comment_author_deurl',
_wpnonce: WPAkismet.comment_author_url_nonce,
id: thisId
};
$.ajax({
url: ajaxurl,
type: 'POST',
data: data,
beforeSend: function () {
// Removes "x" link
$("a[commentid='"+ thisId +"']").hide();
// Show temp status
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) );
},
success: function (response) {
if (response) {
// Show status/undo link
$("#author_comment_url_"+ thisId)
.attr('cid', thisId)
.addClass('akismet_undo_link_removal')
.html(
$( '<span/>' ).text( WPAkismet.strings['URL removed'] )
)
.append( ' ' )
.append(
$( '<span/>' )
.text( WPAkismet.strings['(undo)'] )
.addClass( 'akismet-span-link' )
);
}
}
});
return false;
}).on( 'click', '.akismet_undo_link_removal', function () {
var thisId = $(this).attr('cid');
var thisUrl = $(this).attr('href');
var data = {
action: 'comment_author_reurl',
_wpnonce: WPAkismet.comment_author_url_nonce,
id: thisId,
url: thisUrl
};
$.ajax({
url: ajaxurl,
type: 'POST',
data: data,
beforeSend: function () {
// Show temp status
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) );
},
success: function (response) {
if (response) {
// Add "x" link
$("a[commentid='"+ thisId +"']").show();
// Show link. Core strips leading http://, so let's do that too.
$("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) );
}
}
});
return false;
});
// Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
if ( "enable_mshots" in WPAkismet && WPAkismet.enable_mshots ) {
$( '#the-comment-list' ).on( 'mouseover', mshotEnabledLinkSelector, function () {
clearTimeout( mshotRemovalTimer );
if ( $( '.akismet-mshot' ).length > 0 ) {
if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) {
// The preview is already showing for this link.
return;
}
else {
// A new link is being hovered, so remove the old preview.
$( '.akismet-mshot' ).remove();
}
}
clearTimeout( mshotSecondTryTimer );
clearTimeout( mshotThirdTryTimer );
var thisHref = $( this ).attr( 'href' );
var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="' + akismet_mshot_url( thisHref ) + '" width="450" height="338" class="mshot-image" /></div>' );
mShot.data( 'link', this );
var offset = $( this ).offset();
mShot.offset( {
left : Math.min( $( window ).width() - 475, offset.left + $( this ).width() + 10 ), // Keep it on the screen if the link is near the edge of the window.
top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness
} );
// These retries appear to be superfluous if .mshot-image has already loaded, but it's because mShots
// can return a "Generating thumbnail..." image if it doesn't have a thumbnail ready, so we need
// to retry to see if we can get the newly generated thumbnail.
mshotSecondTryTimer = setTimeout( function () {
mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 2 ) );
}, 6000 );
mshotThirdTryTimer = setTimeout( function () {
mShot.find( '.mshot-image' ).attr( 'src', akismet_mshot_url( thisHref, 3 ) );
}, 12000 );
$( 'body' ).append( mShot );
} ).on( 'mouseout', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () {
mshotRemovalTimer = setTimeout( function () {
clearTimeout( mshotSecondTryTimer );
clearTimeout( mshotThirdTryTimer );
$( '.akismet-mshot' ).remove();
}, 200 );
} ).on( 'mouseover', 'tr', function () {
// When the mouse hovers over a comment row, begin preloading mshots for any links in the comment or the comment author.
var linksToPreloadMshotsFor = $( this ).find( mshotEnabledLinkSelector );
linksToPreloadMshotsFor.each( function () {
// Don't attempt to preload an mshot for a single link twice. Browser caching should cover this, but in case of
// race conditions, save a flag locally when we've begun trying to preload one.
if ( ! $( this ).data( 'akismet-mshot-preloaded' ) ) {
akismet_preload_mshot( $( this ).attr( 'href' ) );
$( this ).data( 'akismet-mshot-preloaded', true );
}
} );
} );
}
$( '.checkforspam.enable-on-load' ).click( function( e ) {
if ( $( this ).hasClass( 'ajax-disabled' ) ) {
// Akismet hasn't been configured yet. Allow the user to proceed to the button's link.
return;
}
e.preventDefault();
if ( $( this ).hasClass( 'button-disabled' ) ) {
window.location.href = $( this ).data( 'success-url' ).replace( '__recheck_count__', 0 ).replace( '__spam_count__', 0 );
return;
}
$('.checkforspam').addClass('button-disabled').addClass( 'checking' );
$('.checkforspam-spinner').addClass( 'spinner' ).addClass( 'is-active' );
akismet_check_for_spam(0, 100);
});
$( '.checkforspam.enable-on-load' ).removeClass( 'button-disabled' );
var spam_count = 0;
var recheck_count = 0;
function akismet_check_for_spam(offset, limit) {
var check_for_spam_buttons = $( '.checkforspam' );
var nonce = check_for_spam_buttons.data( 'nonce' );
// We show the percentage complete down to one decimal point so even queues with 100k
// pending comments will show some progress pretty quickly.
var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10;
// Update the progress counter on the "Check for Spam" button.
$( '.checkforspam' ).text( check_for_spam_buttons.data( 'progress-label' ).replace( '%1$s', percentage_complete ) );
$.post(
ajaxurl,
{
'action': 'akismet_recheck_queue',
'offset': offset,
'limit': limit,
'nonce': nonce
},
function(result) {
if ( 'error' in result ) {
// An error is only returned in the case of a missing nonce, so we don't need the actual error message.
window.location.href = check_for_spam_buttons.data( 'failure-url' );
return;
}
recheck_count += result.counts.processed;
spam_count += result.counts.spam;
if (result.counts.processed < limit) {
window.location.href = check_for_spam_buttons.data( 'success-url' ).replace( '__recheck_count__', recheck_count ).replace( '__spam_count__', spam_count );
}
else {
// Account for comments that were caught as spam and moved out of the queue.
akismet_check_for_spam(offset + limit - result.counts.spam, limit);
}
}
);
}
if ( "start_recheck" in WPAkismet && WPAkismet.start_recheck ) {
$( '.checkforspam' ).click();
}
if ( typeof MutationObserver !== 'undefined' ) {
// Dynamically add the "X" next the the author URL links when a comment is quick-edited.
var comment_list_container = document.getElementById( 'the-comment-list' );
if ( comment_list_container ) {
var observer = new MutationObserver( function ( mutations ) {
for ( var i = 0, _len = mutations.length; i < _len; i++ ) {
if ( mutations[i].addedNodes.length > 0 ) {
akismet_enable_comment_author_url_removal();
// Once we know that we'll have to check for new author links, skip the rest of the mutations.
break;
}
}
} );
observer.observe( comment_list_container, { attributes: true, childList: true, characterData: true } );
}
}
function akismet_enable_comment_author_url_removal() {
$( '#the-comment-list' )
.find( 'tr.comment, tr[id ^= "comment-"]' )
.find( '.column-author a[href^="http"]:first' ) // Ignore mailto: links, which would be the comment author's email.
.each(function () {
if ( $( this ).parent().find( '.akismet_remove_url' ).length > 0 ) {
return;
}
var linkHref = $(this).attr( 'href' );
// Ignore any links to the current domain, which are diagnostic tools, like the IP address link
// or any other links another plugin might add.
var currentHostParts = document.location.href.split( '/' );
var currentHost = currentHostParts[0] + '//' + currentHostParts[2] + '/';
if ( linkHref.indexOf( currentHost ) != 0 ) {
var thisCommentId = $(this).parents('tr:first').attr('id').split("-");
$(this)
.attr("id", "author_comment_url_"+ thisCommentId[1])
.after(
$( '<a href="#" class="akismet_remove_url">x</a>' )
.attr( 'commentid', thisCommentId[1] )
.attr( 'title', WPAkismet.strings['Remove this URL'] )
);
}
});
}
/**
* Generate an mShot URL if given a link URL.
*
* @param string linkUrl
* @param int retry If retrying a request, the number of the retry.
* @return string The mShot URL;
*/
function akismet_mshot_url( linkUrl, retry ) {
var mshotUrl = '//s0.wordpress.com/mshots/v1/' + encodeURIComponent( linkUrl ) + '?w=900';
if ( retry ) {
mshotUrl += '&r=' + encodeURIComponent( retry );
}
return mshotUrl;
}
/**
* Begin loading an mShot preview of a link.
*
* @param string linkUrl
*/
function akismet_preload_mshot( linkUrl ) {
var img = new Image();
img.src = akismet_mshot_url( linkUrl );
}
$( '.akismet-could-be-primary' ).each( function () {
var form = $( this ).closest( 'form' );
form.data( 'initial-state', form.serialize() );
form.on( 'change keyup', function () {
var self = $( this );
var submit_button = self.find( '.akismet-could-be-primary' );
if ( self.serialize() != self.data( 'initial-state' ) ) {
submit_button.addClass( 'akismet-is-primary' );
}
else {
submit_button.removeClass( 'akismet-is-primary' );
}
} );
} );
/**
* Shows the Enter API key form
*/
$( '.akismet-enter-api-key-box a' ).on( 'click', function ( e ) {
e.preventDefault();
var div = $( '.enter-api-key' );
div.show( 500 );
div.find( 'input[name=key]' ).focus();
$( this ).hide();
} );
/**
* Hides the Connect with Jetpack form | Shows the Activate Akismet Account form
*/
$( 'a.toggle-ak-connect' ).on( 'click', function ( e ) {
e.preventDefault();
$( '.akismet-ak-connect' ).slideToggle('slow');
$( 'a.toggle-ak-connect' ).hide();
$( '.akismet-jp-connect' ).hide();
$( 'a.toggle-jp-connect' ).show();
} );
/**
* Shows the Connect with Jetpack form | Hides the Activate Akismet Account form
*/
$( 'a.toggle-jp-connect' ).on( 'click', function ( e ) {
e.preventDefault();
$( '.akismet-jp-connect' ).slideToggle('slow');
$( 'a.toggle-jp-connect' ).hide();
$( '.akismet-ak-connect' ).hide();
$( 'a.toggle-ak-connect' ).show();
} );
});

View File

@@ -0,0 +1,30 @@
var ak_js = document.getElementById( "ak_js" );
if ( ! ak_js ) {
ak_js = document.createElement( 'input' );
ak_js.setAttribute( 'id', 'ak_js' );
ak_js.setAttribute( 'name', 'ak_js' );
ak_js.setAttribute( 'type', 'hidden' );
}
else {
ak_js.parentNode.removeChild( ak_js );
}
ak_js.setAttribute( 'value', ( new Date() ).getTime() );
var commentForm = document.getElementById( 'commentform' );
if ( commentForm ) {
commentForm.appendChild( ak_js );
}
else {
var replyRowContainer = document.getElementById( 'replyrow' );
if ( replyRowContainer ) {
var children = replyRowContainer.getElementsByTagName( 'td' );
if ( children.length > 0 ) {
children[0].appendChild( ak_js );
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -0,0 +1,66 @@
<?php
/**
* @package Akismet
*/
/*
Plugin Name: Akismet Anti-Spam
Plugin URI: https://akismet.com/
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. It keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
Version: 4.1.6
Author: Automattic
Author URI: https://automattic.com/wordpress-plugins/
License: GPLv2 or later
Text Domain: akismet
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Copyright 2005-2015 Automattic, Inc.
*/
// Make sure we don't expose any info if called directly
if ( !function_exists( 'add_action' ) ) {
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
exit;
}
define( 'AKISMET_VERSION', '4.1.6' );
define( 'AKISMET__MINIMUM_WP_VERSION', '4.0' );
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'AKISMET_DELETE_LIMIT', 100000 );
register_activation_hook( __FILE__, array( 'Akismet', 'plugin_activation' ) );
register_deactivation_hook( __FILE__, array( 'Akismet', 'plugin_deactivation' ) );
require_once( AKISMET__PLUGIN_DIR . 'class.akismet.php' );
require_once( AKISMET__PLUGIN_DIR . 'class.akismet-widget.php' );
require_once( AKISMET__PLUGIN_DIR . 'class.akismet-rest-api.php' );
add_action( 'init', array( 'Akismet', 'init' ) );
add_action( 'rest_api_init', array( 'Akismet_REST_API', 'init' ) );
if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
require_once( AKISMET__PLUGIN_DIR . 'class.akismet-admin.php' );
add_action( 'init', array( 'Akismet_Admin', 'init' ) );
}
//add wrapper class around deprecated akismet functions that are referenced elsewhere
require_once( AKISMET__PLUGIN_DIR . 'wrapper.php' );
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once( AKISMET__PLUGIN_DIR . 'class.akismet-cli.php' );
}

View File

@@ -0,0 +1,418 @@
=== Akismet Anti-Spam ===
== Archived Changelog Entries ==
This file contains older changelog entries, so we can keep the size of the standard WordPress readme.txt file reasonable.
For the latest changes, please see the "Changelog" section of the [readme.txt file](https://plugins.svn.wordpress.org/akismet/trunk/readme.txt).
= 4.0.8 =
*Release Date - 19 June 2018*
* Improved the grammar and consistency of the in-admin privacy related notes (notice and config).
* Revised in-admin explanation of the comment form privacy notice to make its usage clearer.
* Added `rel="nofollow noopener"` to the comment form privacy notice to improve SEO and security.
= 4.0.7 =
*Release Date - 28 May 2018*
* Based on user feedback, the link on "Learn how your comment data is processed." in the optional privacy notice now has a `target` of `_blank` and opens in a new tab/window.
* Updated the in-admin privacy notice to use the term "comment" instead of "contact" in "Akismet can display a notice to your users under your comment forms."
* Only show in-admin privacy notice if Akismet has an API Key configured
= 4.0.6 =
*Release Date - 26 May 2018*
* Moved away from using `empty( get_option() )` to instantiating a variable to be compatible with older versions of PHP (5.3, 5.4, etc).
= 4.0.5 =
*Release Date - 26 May 2018*
* Corrected version number after tagging. Sorry...
= 4.0.4 =
*Release Date - 26 May 2018*
* Added a hook to provide Akismet-specific privacy information for a site's privacy policy.
* Added tools to control the display of a privacy related notice under comment forms.
* Fixed HTML in activation failure message to close META and HEAD tag properly.
* Fixed a bug that would sometimes prevent Akismet from being correctly auto-configured.
= 4.0.3 =
*Release Date - 19 February 2018*
* Added a scheduled task to remove entries in wp_commentmeta that no longer have corresponding comments in wp_comments.
* Added a new `akismet_batch_delete_count` action to the batch delete methods for people who'd like to keep track of the numbers of records being processed by those methods.
= 4.0.2 =
*Release Date - 18 December 2017*
* Fixed a bug that could cause Akismet to recheck a comment that has already been manually approved or marked as spam.
* Fixed a bug that could cause Akismet to claim that some comments are still waiting to be checked when no comments are waiting to be checked.
= 4.0.1 =
*Release Date - 6 November 2017*
* Fixed a bug that could prevent some users from connecting Akismet via their Jetpack connection.
* Ensured that any pending Akismet-related events are unscheduled if the plugin is deactivated.
* Allow some JavaScript to be run asynchronously to avoid affecting page render speeds.
= 4.0 =
*Release Date - 19 September 2017*
* Added REST API endpoints for configuring Akismet and retrieving stats.
* Increased the minimum supported WordPress version to 4.0.
* Added compatibility with comments submitted via the REST API.
* Improved the progress indicator on the "Check for Spam" button.
= 3.3.4 =
*Release Date - 3 August 2017*
* Disabled Akismet's debug log output by default unless AKISMET_DEBUG is defined.
* URL previews now begin preloading when the mouse moves near them in the comments section of wp-admin.
* When a comment is caught by the Comment Blacklist, Akismet will always allow it to stay in the trash even if it is spam as well.
* Fixed a bug that was preventing an error from being shown when a site can't reach Akismet's servers.
= 3.3.3 =
*Release Date - 13 July 2017*
* Reduced amount of bandwidth used by the URL Preview feature.
* Improved the admin UI when the API key is manually pre-defined for the site.
* Removed a workaround for WordPress installations older than 3.3 that will improve Akismet's compatibility with other plugins.
* The number of spam blocked that is displayed on the WordPress dashboard will now be more accurate and updated more frequently.
* Fixed a bug in the Akismet widget that could cause PHP warnings.
= 3.3.2 =
*Release Date - 10 May 2017*
* Fixed a bug causing JavaScript errors in some browsers.
= 3.3.1 =
*Release Date - 2 May 2017*
* Improve performance by only requesting the akismet_comment_nonce option when absolutely necessary.
* Fixed two bugs that could cause PHP warnings.
* Fixed a bug that was preventing the "Remove author URL" feature from working after a comment was edited using "Quick Edit."
* Fixed a bug that was preventing the URL preview feature from working after a comment was edited using "Quick Edit."
= 3.3 =
*Release Date - 23 February 2017*
* Updated the Akismet admin pages with a new clean design.
* Fixed bugs preventing the `akismet_add_comment_nonce` and `akismet_update_alert` wrapper functions from working properly.
* Fixed bug preventing the loading indicator from appearing when re-checking all comments for spam.
* Added a progress indicator to the "Check for Spam" button.
* Added a success message after manually rechecking the Pending queue for spam.
= 3.2 =
*Release Date - 6 September 2016*
* Added a WP-CLI module. You can now check comments and recheck the moderation queue from the command line.
* Stopped using the deprecated jQuery function `.live()`.
* Fixed a bug in `remove_comment_author_url()` and `add_comment_author_url()` that could generate PHP notices.
* Fixed a bug that could cause an infinite loop for sites with very very very large comment IDs.
* Fixed a bug that could cause the Akismet widget title to be blank.
= 3.1.11 =
*Release Date - 12 May 2016*
* Fixed a bug that could cause the "Check for Spam" button to skip some comments.
* Fixed a bug that could prevent some spam submissions from being sent to Akismet.
* Updated all links to use https:// when possible.
* Disabled Akismet debug logging unless WP_DEBUG and WP_DEBUG_LOG are both enabled.
= 3.1.10 =
*Release Date - 1 April 2016*
* Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
* Fixed a bug that could have resulted in comments that were caught by the core WordPress comment blacklist not to have a corresponding History entry.
* Fixed a bug that could have caused avoidable PHP warnings in the error log.
= 3.1.9 =
*Release Date - 28 March 2016*
* Add compatibility with Jetpack so that Jetpack can automatically configure Akismet settings when appropriate.
* Fixed a bug preventing some comment data from being sent to Akismet.
= 3.1.8 =
*Release Date - 4 March 2016*
* Fixed a bug preventing Akismet from being used with some plugins that rewrite admin URLs.
* Reduced the amount of bandwidth used on Akismet API calls
* Reduced the amount of space Akismet uses in the database
* Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
= 3.1.7 =
*Release Date - 4 January 2016*
* Added documentation for the 'akismet_comment_nonce' filter.
* The post-install activation button is now accessible to screen readers and keyboard-only users.
* Fixed a bug that was preventing the "Remove author URL" feature from working in WordPress 4.4
= 3.1.6 =
*Release Date - 14 December 2015*
* Improve the notices shown after activating Akismet.
* Update some strings to allow for the proper plural forms in all languages.
= 3.1.5 =
*Release Date - 13 October 2015*
* Closes a potential XSS vulnerability.
= 3.1.4 =
*Release Date - 24 September 2015*
* Fixed a bug that was preventing some users from automatically connecting using Jetpack if they didn't have a current Akismet subscription.
* Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
* Error messages and instructions have been simplified to be more understandable.
* Link previews are enabled for all links inside comments, not just the author's website link.
= 3.1.3 =
*Release Date - 6 July 2015*
* Notify users when their account status changes after previously being successfully set up. This should help any users who are seeing blank Akismet settings screens.
= 3.1.2 =
*Release Date - 7 June 2015*
* Reduced the amount of space Akismet uses in the commentmeta table.
* Fixed a bug where some comments with quotes in the author name weren't getting history entries
* Pre-emptive security improvements to ensure that the Akismet plugin can't be used by attackers to compromise a WordPress installation.
* Better UI for the key entry field: allow whitespace to be included at the beginning or end of the key and strip it out automatically when the form is submitted.
* When deactivating the plugin, notify the Akismet API so the site can be marked as inactive.
* Clearer error messages.
= 3.1.1 =
*Release Date - 17th March, 2015*
* Improvements to the "Remove comment author URL" JavaScript
* Include the pingback pre-check from the 2.6 branch.
= 3.1 =
*Release Date - 11th March, 2015*
* Use HTTPS by default for all requests to Akismet.
* Fix for a situation where Akismet might strip HTML from a comment.
= 3.0.4 =
*Release Date - 11th December, 2014*
* Fix to make .htaccess compatible with Apache 2.4.
* Fix to allow removal of https author URLs.
* Fix to avoid stripping part of the author URL when removing and re-adding.
* Removed the "Check for Spam" button from the "Trash" and "Approved" queues, where it would have no effect.
* Allow automatic API key configuration when Jetpack is installed and connected to a WordPress.com account
= 3.0.3 =
*Release Date - 3rd November, 2014*
* Fix for sending the wrong data to delete_comment action that could have prevented old spam comments from being deleted.
* Added a filter to disable logging of Akismet debugging information.
* Added a filter for the maximum comment age when deleting old spam comments.
* Added a filter for the number per batch when deleting old spam comments.
* Removed the "Check for Spam" button from the Spam folder.
= 3.0.2 =
*Release Date - 18th August, 2014*
* Performance improvements.
* Fixed a bug that could truncate the comment data being sent to Akismet for checking.
= 3.0.1 =
*Release Date - 9th July, 2014*
* Removed dependency on PHP's fsockopen function
* Fix spam/ham reports to work when reported outside of the WP dashboard, e.g., from Notifications or the WP app
* Remove jQuery dependency for comment form JavaScript
* Remove unnecessary data from some Akismet comment meta
* Suspended keys will now result in all comments being put in moderation, not spam.
= 3.0.0 =
*Release Date - 15th April, 2014*
* Move Akismet to Settings menu
* Drop Akismet Stats menu
* Add stats snapshot to Akismet settings
* Add Akismet subscription details and status to Akismet settings
* Add contextual help for each page
* Improve Akismet setup to use Jetpack to automate plugin setup
* Fix "Check for Spam" to use AJAX to avoid page timing out
* Fix Akismet settings page to be responsive
* Drop legacy code
* Tidy up CSS and Javascript
* Replace the old discard setting with a new "discard pervasive spam" feature.
= 2.6.0 =
*Release Date - 18th March, 2014*
* Add ajax paging to the check for spam button to handle large volumes of comments
* Optimize javascript and add localization support
* Fix bug in link to spam comments from right now dashboard widget
* Fix bug with deleting old comments to avoid timeouts dealing with large volumes of comments
* Include X-Pingback-Forwarded-For header in outbound WordPress pingback verifications
* Add pre-check for pingbacks, to stop spam before an outbound verification request is made
= 2.5.9 =
*Release Date - 1st August, 2013*
* Update 'Already have a key' link to redirect page rather than depend on javascript
* Fix some non-translatable strings to be translatable
* Update Activation banner in plugins page to redirect user to Akismet config page
= 2.5.8 =
*Release Date - 20th January, 2013*
* Simplify the activation process for new users
* Remove the reporter_ip parameter
* Minor preventative security improvements
= 2.5.7 =
*Release Date - 13th December, 2012*
* FireFox Stats iframe preview bug
* Fix mshots preview when using https
* Add .htaccess to block direct access to files
* Prevent some PHP notices
* Fix Check For Spam return location when referrer is empty
* Fix Settings links for network admins
* Fix prepare() warnings in WP 3.5
= 2.5.6 =
*Release Date - 26th April, 2012*
* Prevent retry scheduling problems on sites where wp_cron is misbehaving
* Preload mshot previews
* Modernize the widget code
* Fix a bug where comments were not held for moderation during an error condition
* Improve the UX and display when comments are temporarily held due to an error
* Make the Check For Spam button force a retry when comments are held due to an error
* Handle errors caused by an invalid key
* Don't retry comments that are too old
* Improve error messages when verifying an API key
= 2.5.5 =
*Release Date - 11th January, 2012*
* Add nonce check for comment author URL remove action
* Fix the settings link
= 2.5.4 =
*Release Date - 5th January, 2012*
* Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it
* Added author URL quick removal functionality
* Added mShot preview on Author URL hover
* Added empty index.php to prevent directory listing
* Move wp-admin menu items under Jetpack, if it is installed
* Purge old Akismet comment meta data, default of 15 days
= 2.5.3 =
*Release Date - 8th Febuary, 2011*
* Specify the license is GPL v2 or later
* Fix a bug that could result in orphaned commentmeta entries
* Include hotfix for WordPress 3.0.5 filter issue
= 2.5.2 =
*Release Date - 14th January, 2011*
* Properly format the comment count for author counts
* Look for super admins on multisite installs when looking up user roles
* Increase the HTTP request timeout
* Removed padding for author approved count
* Fix typo in function name
* Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side.
= 2.5.1 =
*Release Date - 17th December, 2010*
* Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
* Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
* Fixed padding bug in "author" column of posts screen
* Added margin-top to "cleared by ..." badges on dashboard
* Fix possible error when calling akismet_cron_recheck()
* Fix more PHP warnings
* Clean up XHTML warnings for comment nonce
* Fix for possible condition where scheduled comment re-checks could get stuck
* Clean up the comment meta details after deleting a comment
* Only show the status badge if the comment status has been changed by someone/something other than Akismet
* Show a 'History' link in the row-actions
* Translation fixes
* Reduced font-size on author name
* Moved "flagged by..." notification to top right corner of comment container and removed heavy styling
* Hid "flagged by..." notification while on dashboard
= 2.5.0 =
*Release Date - 7th December, 2010*
* Track comment actions under 'Akismet Status' on the edit comment screen
* Fix a few remaining deprecated function calls ( props Mike Glendinning )
* Use HTTPS for the stats IFRAME when wp-admin is using HTTPS
* Use the WordPress HTTP class if available
* Move the admin UI code to a separate file, only loaded when needed
* Add cron retry feature, to replace the old connectivity check
* Display Akismet status badge beside each comment
* Record history for each comment, and display it on the edit page
* Record the complete comment as originally submitted in comment_meta, to use when reporting spam and ham
* Highlight links in comment content
* New option, "Show the number of comments you've approved beside each comment author."
* New option, "Use a nonce on the comment form."
= 2.4.0 =
*Release Date - 23rd August, 2010*
* Spell out that the license is GPLv2
* Fix PHP warnings
* Fix WordPress deprecated function calls
* Fire the delete_comment action when deleting comments
* Move code specific for older WP versions to legacy.php
* General code clean up
= 2.3.0 =
*Release Date - 5th June, 2010*
* Fix "Are you sure" nonce message on config screen in WPMU
* Fix XHTML compliance issue in sidebar widget
* Change author link; remove some old references to WordPress.com accounts
* Localize the widget title (core ticket #13879)
= 2.2.9 =
*Release Date - 2nd June, 2010*
* Eliminate a potential conflict with some plugins that may cause spurious reports
= 2.2.8 =
*Release Date - 27th May, 2010*
* Fix bug in initial comment check for ipv6 addresses
* Report comments as ham when they are moved from spam to moderation
* Report comments as ham when clicking undo after spam
* Use transition_comment_status action when available instead of older actions for spam/ham submissions
* Better diagnostic messages when PHP network functions are unavailable
* Better handling of comments by logged-in users
= 2.2.7 =
*Release Date - 17th December, 2009*
* Add a new AKISMET_VERSION constant
* Reduce the possibility of over-counting spam when another spam filter plugin is in use
* Disable the connectivity check when the API key is hard-coded for WPMU
= 2.2.6 =
*Release Date - 20th July, 2009*
* Fix a global warning introduced in 2.2.5
* Add changelog and additional readme.txt tags
* Fix an array conversion warning in some versions of PHP
* Support a new WPCOM_API_KEY constant for easier use with WordPress MU
= 2.2.5 =
*Release Date - 13th July, 2009*
* Include a new Server Connectivity diagnostic check, to detect problems caused by firewalls
= 2.2.4 =
*Release Date - 3rd June, 2009*
* Fixed a key problem affecting the stats feature in WordPress MU
* Provide additional blog information in Akismet API calls

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,185 @@
<?php
WP_CLI::add_command( 'akismet', 'Akismet_CLI' );
/**
* Filter spam comments.
*/
class Akismet_CLI extends WP_CLI_Command {
/**
* Checks one or more comments against the Akismet API.
*
* ## OPTIONS
* <comment_id>...
* : The ID(s) of the comment(s) to check.
*
* [--noaction]
* : Don't change the status of the comment. Just report what Akismet thinks it is.
*
* ## EXAMPLES
*
* wp akismet check 12345
*
* @alias comment-check
*/
public function check( $args, $assoc_args ) {
foreach ( $args as $comment_id ) {
if ( isset( $assoc_args['noaction'] ) ) {
// Check the comment, but don't reclassify it.
$api_response = Akismet::check_db_comment( $comment_id, 'wp-cli' );
}
else {
$api_response = Akismet::recheck_comment( $comment_id, 'wp-cli' );
}
if ( 'true' === $api_response ) {
WP_CLI::line( sprintf( __( "Comment #%d is spam.", 'akismet' ), $comment_id ) );
}
else if ( 'false' === $api_response ) {
WP_CLI::line( sprintf( __( "Comment #%d is not spam.", 'akismet' ), $comment_id ) );
}
else {
if ( false === $api_response ) {
WP_CLI::error( __( "Failed to connect to Akismet.", 'akismet' ) );
}
else if ( is_wp_error( $api_response ) ) {
WP_CLI::warning( sprintf( __( "Comment #%d could not be checked.", 'akismet' ), $comment_id ) );
}
}
}
}
/**
* Recheck all comments in the Pending queue.
*
* ## EXAMPLES
*
* wp akismet recheck_queue
*
* @alias recheck-queue
*/
public function recheck_queue() {
$batch_size = 100;
$start = 0;
$total_counts = array();
do {
$result_counts = Akismet_Admin::recheck_queue_portion( $start, $batch_size );
if ( $result_counts['processed'] > 0 ) {
foreach ( $result_counts as $key => $count ) {
if ( ! isset( $total_counts[ $key ] ) ) {
$total_counts[ $key ] = $count;
}
else {
$total_counts[ $key ] += $count;
}
}
$start += $batch_size;
$start -= $result_counts['spam']; // These comments will have been removed from the queue.
}
} while ( $result_counts['processed'] > 0 );
WP_CLI::line( sprintf( _n( "Processed %d comment.", "Processed %d comments.", $total_counts['processed'], 'akismet' ), number_format( $total_counts['processed'] ) ) );
WP_CLI::line( sprintf( _n( "%d comment moved to Spam.", "%d comments moved to Spam.", $total_counts['spam'], 'akismet' ), number_format( $total_counts['spam'] ) ) );
if ( $total_counts['error'] ) {
WP_CLI::line( sprintf( _n( "%d comment could not be checked.", "%d comments could not be checked.", $total_counts['error'], 'akismet' ), number_format( $total_counts['error'] ) ) );
}
}
/**
* Fetches stats from the Akismet API.
*
* ## OPTIONS
*
* [<interval>]
* : The time period for which to retrieve stats.
* ---
* default: all
* options:
* - days
* - months
* - all
* ---
*
* [--format=<format>]
* : Allows overriding the output of the command when listing connections.
* ---
* default: table
* options:
* - table
* - json
* - csv
* - yaml
* - count
* ---
*
* [--summary]
* : When set, will display a summary of the stats.
*
* ## EXAMPLES
*
* wp akismet stats
* wp akismet stats all
* wp akismet stats days
* wp akismet stats months
* wp akismet stats all --summary
*/
public function stats( $args, $assoc_args ) {
$api_key = Akismet::get_api_key();
if ( empty( $api_key ) ) {
WP_CLI::error( __( 'API key must be set to fetch stats.', 'akismet' ) );
}
switch ( $args[0] ) {
case 'days':
$interval = '60-days';
break;
case 'months':
$interval = '6-months';
break;
default:
$interval = 'all';
break;
}
$response = Akismet::http_post(
Akismet::build_query( array(
'blog' => get_option( 'home' ),
'key' => $api_key,
'from' => $interval,
) ),
'get-stats'
);
if ( empty( $response[1] ) ) {
WP_CLI::error( __( 'Currently unable to fetch stats. Please try again.', 'akismet' ) );
}
$response_body = json_decode( $response[1], true );
if ( is_null( $response_body ) ) {
WP_CLI::error( __( 'Stats response could not be decoded.', 'akismet' ) );
}
if ( isset( $assoc_args['summary'] ) ) {
$keys = array(
'spam',
'ham',
'missed_spam',
'false_positives',
'accuracy',
'time_saved',
);
WP_CLI\Utils\format_items( $assoc_args['format'], array( $response_body ), $keys );
}
else {
$stats = $response_body['breakdown'];
WP_CLI\Utils\format_items( $assoc_args['format'], $stats, array_keys( end( $stats ) ) );
}
}
}

View File

@@ -0,0 +1,366 @@
<?php
class Akismet_REST_API {
/**
* Register the REST API routes.
*/
public static function init() {
if ( ! function_exists( 'register_rest_route' ) ) {
// The REST API wasn't integrated into core until 4.4, and we support 4.0+ (for now).
return false;
}
register_rest_route( 'akismet/v1', '/key', array(
array(
'methods' => WP_REST_Server::READABLE,
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'get_key' ),
), array(
'methods' => WP_REST_Server::EDITABLE,
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'set_key' ),
'args' => array(
'key' => array(
'required' => true,
'type' => 'string',
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ),
),
),
), array(
'methods' => WP_REST_Server::DELETABLE,
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'delete_key' ),
)
) );
register_rest_route( 'akismet/v1', '/settings/', array(
array(
'methods' => WP_REST_Server::READABLE,
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'get_settings' ),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'set_boolean_settings' ),
'args' => array(
'akismet_strictness' => array(
'required' => false,
'type' => 'boolean',
'description' => __( 'If true, Akismet will automatically discard the worst spam automatically rather than putting it in the spam folder.', 'akismet' ),
),
'akismet_show_user_comments_approved' => array(
'required' => false,
'type' => 'boolean',
'description' => __( 'If true, show the number of approved comments beside each comment author in the comments list page.', 'akismet' ),
),
),
)
) );
register_rest_route( 'akismet/v1', '/stats', array(
'methods' => WP_REST_Server::READABLE,
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'get_stats' ),
'args' => array(
'interval' => array(
'required' => false,
'type' => 'string',
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_interval' ),
'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ),
'default' => 'all',
),
),
) );
register_rest_route( 'akismet/v1', '/stats/(?P<interval>[\w+])', array(
'args' => array(
'interval' => array(
'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ),
'type' => 'string',
),
),
array(
'methods' => WP_REST_Server::READABLE,
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'get_stats' ),
)
) );
register_rest_route( 'akismet/v1', '/alert', array(
array(
'methods' => WP_REST_Server::READABLE,
'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'get_alert' ),
'args' => array(
'key' => array(
'required' => false,
'type' => 'string',
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ),
),
),
),
array(
'methods' => WP_REST_Server::EDITABLE,
'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'set_alert' ),
'args' => array(
'key' => array(
'required' => false,
'type' => 'string',
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ),
),
),
),
array(
'methods' => WP_REST_Server::DELETABLE,
'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
'callback' => array( 'Akismet_REST_API', 'delete_alert' ),
'args' => array(
'key' => array(
'required' => false,
'type' => 'string',
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ),
),
),
)
) );
}
/**
* Get the current Akismet API key.
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public static function get_key( $request = null ) {
return rest_ensure_response( Akismet::get_api_key() );
}
/**
* Set the API key, if possible.
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public static function set_key( $request ) {
if ( defined( 'WPCOM_API_KEY' ) ) {
return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be changed via the API.', 'akismet' ), array( 'status'=> 409 ) ) );
}
$new_api_key = $request->get_param( 'key' );
if ( ! self::key_is_valid( $new_api_key ) ) {
return rest_ensure_response( new WP_Error( 'invalid_key', __( 'The value provided is not a valid and registered API key.', 'akismet' ), array( 'status' => 400 ) ) );
}
update_option( 'wordpress_api_key', $new_api_key );
return self::get_key();
}
/**
* Unset the API key, if possible.
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public static function delete_key( $request ) {
if ( defined( 'WPCOM_API_KEY' ) ) {
return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be deleted.', 'akismet' ), array( 'status'=> 409 ) ) );
}
delete_option( 'wordpress_api_key' );
return rest_ensure_response( true );
}
/**
* Get the Akismet settings.
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public static function get_settings( $request = null ) {
return rest_ensure_response( array(
'akismet_strictness' => ( get_option( 'akismet_strictness', '1' ) === '1' ),
'akismet_show_user_comments_approved' => ( get_option( 'akismet_show_user_comments_approved', '1' ) === '1' ),
) );
}
/**
* Update the Akismet settings.
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public static function set_boolean_settings( $request ) {
foreach ( array(
'akismet_strictness',
'akismet_show_user_comments_approved',
) as $setting_key ) {
$setting_value = $request->get_param( $setting_key );
if ( is_null( $setting_value ) ) {
// This setting was not specified.
continue;
}
// From 4.7+, WP core will ensure that these are always boolean
// values because they are registered with 'type' => 'boolean',
// but we need to do this ourselves for prior versions.
$setting_value = Akismet_REST_API::parse_boolean( $setting_value );
update_option( $setting_key, $setting_value ? '1' : '0' );
}
return self::get_settings();
}
/**
* Parse a numeric or string boolean value into a boolean.
*
* @param mixed $value The value to convert into a boolean.
* @return bool The converted value.
*/
public static function parse_boolean( $value ) {
switch ( $value ) {
case true:
case 'true':
case '1':
case 1:
return true;
case false:
case 'false':
case '0':
case 0:
return false;
default:
return (bool) $value;
}
}
/**
* Get the Akismet stats for a given time period.
*
* Possible `interval` values:
* - all
* - 60-days
* - 6-months
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public static function get_stats( $request ) {
$api_key = Akismet::get_api_key();
$interval = $request->get_param( 'interval' );
$stat_totals = array();
$response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' );
if ( ! empty( $response[1] ) ) {
$stat_totals[$interval] = json_decode( $response[1] );
}
return rest_ensure_response( $stat_totals );
}
/**
* Get the current alert code and message. Alert codes are used to notify the site owner
* if there's a problem, like a connection issue between their site and the Akismet API,
* invalid requests being sent, etc.
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public static function get_alert( $request ) {
return rest_ensure_response( array(
'code' => get_option( 'akismet_alert_code' ),
'message' => get_option( 'akismet_alert_msg' ),
) );
}
/**
* Update the current alert code and message by triggering a call to the Akismet server.
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public static function set_alert( $request ) {
delete_option( 'akismet_alert_code' );
delete_option( 'akismet_alert_msg' );
// Make a request so the most recent alert code and message are retrieved.
Akismet::verify_key( Akismet::get_api_key() );
return self::get_alert( $request );
}
/**
* Clear the current alert code and message.
*
* @param WP_REST_Request $request
* @return WP_Error|WP_REST_Response
*/
public static function delete_alert( $request ) {
delete_option( 'akismet_alert_code' );
delete_option( 'akismet_alert_msg' );
return self::get_alert( $request );
}
private static function key_is_valid( $key ) {
$response = Akismet::http_post(
Akismet::build_query(
array(
'key' => $key,
'blog' => get_option( 'home' )
)
),
'verify-key'
);
if ( $response[1] == 'valid' ) {
return true;
}
return false;
}
public static function privileged_permission_callback() {
return current_user_can( 'manage_options' );
}
/**
* For calls that Akismet.com makes to the site to clear outdated alert codes, use the API key for authorization.
*/
public static function remote_call_permission_callback( $request ) {
$local_key = Akismet::get_api_key();
return $local_key && ( strtolower( $request->get_param( 'key' ) ) === strtolower( $local_key ) );
}
public static function sanitize_interval( $interval, $request, $param ) {
$interval = trim( $interval );
$valid_intervals = array( '60-days', '6-months', 'all', );
if ( ! in_array( $interval, $valid_intervals ) ) {
$interval = 'all';
}
return $interval;
}
public static function sanitize_key( $key, $request, $param ) {
return trim( $key );
}
}

View File

@@ -0,0 +1,114 @@
<?php
/**
* @package Akismet
*/
class Akismet_Widget extends WP_Widget {
function __construct() {
load_plugin_textdomain( 'akismet' );
parent::__construct(
'akismet_widget',
__( 'Akismet Widget' , 'akismet'),
array( 'description' => __( 'Display the number of spam comments Akismet has caught' , 'akismet') )
);
if ( is_active_widget( false, false, $this->id_base ) ) {
add_action( 'wp_head', array( $this, 'css' ) );
}
}
function css() {
?>
<style type="text/css">
.a-stats {
width: auto;
}
.a-stats a {
background: #7CA821;
background-image:-moz-linear-gradient(0% 100% 90deg,#5F8E14,#7CA821);
background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#7CA821),to(#5F8E14));
border: 1px solid #5F8E14;
border-radius:3px;
color: #CFEA93;
cursor: pointer;
display: block;
font-weight: normal;
height: 100%;
-moz-border-radius:3px;
padding: 7px 0 8px;
text-align: center;
text-decoration: none;
-webkit-border-radius:3px;
width: 100%;
}
.a-stats a:hover {
text-decoration: none;
background-image:-moz-linear-gradient(0% 100% 90deg,#6F9C1B,#659417);
background-image:-webkit-gradient(linear,0% 0,0% 100%,from(#659417),to(#6F9C1B));
}
.a-stats .count {
color: #FFF;
display: block;
font-size: 15px;
line-height: 16px;
padding: 0 13px;
white-space: nowrap;
}
</style>
<?php
}
function form( $instance ) {
if ( $instance && isset( $instance['title'] ) ) {
$title = $instance['title'];
}
else {
$title = __( 'Spam Blocked' , 'akismet' );
}
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:' , 'akismet'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<?php
}
function update( $new_instance, $old_instance ) {
$instance['title'] = strip_tags( $new_instance['title'] );
return $instance;
}
function widget( $args, $instance ) {
$count = get_option( 'akismet_spam_count' );
if ( ! isset( $instance['title'] ) ) {
$instance['title'] = __( 'Spam Blocked' , 'akismet' );
}
echo $args['before_widget'];
if ( ! empty( $instance['title'] ) ) {
echo $args['before_title'];
echo esc_html( $instance['title'] );
echo $args['after_title'];
}
?>
<div class="a-stats">
<a href="https://akismet.com" target="_blank" title=""><?php printf( _n( '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', '<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>', $count , 'akismet'), number_format_i18n( $count ) ); ?></a>
</div>
<?php
echo $args['after_widget'];
}
}
function akismet_register_widgets() {
register_widget( 'Akismet_Widget' );
}
add_action( 'widgets_init', 'akismet_register_widgets' );

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
<?php
# Silence is golden.

View File

@@ -0,0 +1,86 @@
=== Akismet Anti-Spam ===
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau
Tags: akismet, comments, spam, antispam, anti-spam, anti spam, comment moderation, comment spam, contact form spam, spam comments
Requires at least: 4.6
Tested up to: 5.5
Stable tag: 4.1.6
License: GPLv2 or later
Akismet checks your comments and contact form submissions against our global database of spam to protect you and your site from malicious content.
== Description ==
Akismet checks your comments and contact form submissions against our global database of spam to prevent your site from publishing malicious content. You can review the comment spam it catches on your blog's "Comments" admin screen.
Major features in Akismet include:
* Automatically checks all comments and filters out the ones that look like spam.
* Each comment has a status history, so you can easily see which comments were caught or cleared by Akismet and which were spammed or unspammed by a moderator.
* URLs are shown in the comment body to reveal hidden or misleading links.
* Moderators can see the number of approved comments for each user.
* A discard feature that outright blocks the worst spam, saving you disk space and speeding up your site.
PS: You'll be prompted to get an Akismet.com API key to use it, once activated. Keys are free for personal blogs; paid subscriptions are available for businesses and commercial sites.
== Installation ==
Upload the Akismet plugin to your blog, activate it, and then enter your Akismet.com API key.
1, 2, 3: You're done!
== Changelog ==
= 4.1.6 =
*Release Date - 4 June 2020*
* Disable "Check for Spam" button until the page is loaded to avoid errors with clicking through to queue recheck endpoint directly.
* Add filter "akismet_enable_mshots" to allow disabling screenshot popups on the edit comments admin page.
= 4.1.5 =
*Release Date - 29 April 2020*
* Based on user feedback, we have dropped the in-admin notice explaining the availability of the "privacy notice" option in the AKismet settings screen. The option itself is available, but after displaying the notice for the last 2 years, it is now considered a known fact.
* Updated the "Requires at least" to WP 4.6, based on recommendations from https://wp-info.org/tools/checkplugini18n.php?slug=akismet
* Moved older changelog entries to a separate file to keep the size of this readme reasonable, also based on recommendations from https://wp-info.org/tools/checkplugini18n.php?slug=akismet
= 4.1.4 =
*Release Date - 17 March 2020*
* Only redirect to the Akismet setup screen upon plugin activation if the plugin was activated manually from within the plugin-related screens, to help users with non-standard install workflows, like WP-CLI.
* Update the layout of the initial setup screen to be more readable on small screens.
* If no API key has been entered, don't run code that expects an API key.
* Improve the readability of the comment history entries.
* Don't modify the comment form HTML if no API key has been set.
= 4.1.3 =
*Release Date - 31 October 2019*
* Prevented an attacker from being able to cause a user to unknowingly recheck their Pending comments for spam.
* Improved compatibility with Jetpack 7.7+.
* Updated the plugin activation page to use consistent language and markup.
* Redirecting users to the Akismet connnection/settings screen upon plugin activation, in an effort to make it easier for people to get setup.
= 4.1.2 =
*Release Date - 14 May 2019*
* Fixed a conflict between the Akismet setup banner and other plugin notices.
* Reduced the number of API requests made by the plugin when attempting to verify the API key.
* Include additional data in the pingback pre-check API request to help make the stats more accurate.
* Fixed a bug that was enabling the "Check for Spam" button when no comments were eligible to be checked.
* Improved Akismet's AMP compatibility.
= 4.1.1 =
*Release Date - 31 January 2019*
* Fixed the "Setup Akismet" notice so it resizes responsively.
* Only highlight the "Save Changes" button in the Akismet config when changes have been made.
* The count of comments in your spam queue shown on the dashboard show now always be up-to-date.
= 4.1 =
*Release Date - 12 November 2018*
* Added a WP-CLI method for retrieving stats.
* Hooked into the new "Personal Data Eraser" functionality from WordPress 4.9.6.
* Added functionality to clear outdated alerts from Akismet.com.
For older changelog entries, please see the [additional changelog.txt file](https://plugins.svn.wordpress.org/akismet/trunk/changelog.txt) delivered with the plugin.

View File

@@ -0,0 +1,8 @@
<div class="akismet-box">
<?php Akismet::view( 'title' ); ?>
<?php Akismet::view( 'setup' );?>
</div>
<br/>
<div class="akismet-box">
<?php Akismet::view( 'enter' );?>
</div>

View File

@@ -0,0 +1,242 @@
<div id="akismet-plugin-container">
<div class="akismet-masthead">
<div class="akismet-masthead__inside-container">
<div class="akismet-masthead__logo-container">
<img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/logo-full-2x.png', __FILE__ ) ); ?>" alt="Akismet" />
</div>
</div>
</div>
<div class="akismet-lower">
<?php if ( Akismet::get_api_key() ) { ?>
<?php Akismet_Admin::display_status(); ?>
<?php } ?>
<?php if ( ! empty( $notices ) ) { ?>
<?php foreach ( $notices as $notice ) { ?>
<?php Akismet::view( 'notice', $notice ); ?>
<?php } ?>
<?php } ?>
<?php if ( $stat_totals && isset( $stat_totals['all'] ) && (int) $stat_totals['all']->spam > 0 ) : ?>
<div class="akismet-card">
<div class="akismet-section-header">
<div class="akismet-section-header__label">
<span><?php esc_html_e( 'Statistics' , 'akismet'); ?></span>
</div>
<div class="akismet-section-header__actions">
<a href="<?php echo esc_url( Akismet_Admin::get_page_url( 'stats' ) ); ?>">
<?php esc_html_e( 'Detailed Stats' , 'akismet');?>
</a>
</div>
</div>
<div class="akismet-new-snapshot">
<iframe allowtransparency="true" scrolling="no" frameborder="0" style="width: 100%; height: 220px; overflow: hidden;" src="<?php printf( '//akismet.com/web/1.0/snapshot.php?blog=%s&api_key=%s&height=200&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() );?>"></iframe>
<ul>
<li>
<h3><?php esc_html_e( 'Past six months' , 'akismet');?></h3>
<span><?php echo number_format( $stat_totals['6-months']->spam );?></span>
<?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['6-months']->spam, 'akismet' ) ); ?>
</li>
<li>
<h3><?php esc_html_e( 'All time' , 'akismet');?></h3>
<span><?php echo number_format( $stat_totals['all']->spam );?></span>
<?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['all']->spam, 'akismet' ) ); ?>
</li>
<li>
<h3><?php esc_html_e( 'Accuracy' , 'akismet');?></h3>
<span><?php echo floatval( $stat_totals['all']->accuracy ); ?>%</span>
<?php printf( _n( '%s missed spam', '%s missed spam', $stat_totals['all']->missed_spam, 'akismet' ), number_format( $stat_totals['all']->missed_spam ) ); ?>
|
<?php printf( _n( '%s false positive', '%s false positives', $stat_totals['all']->false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ); ?>
</li>
</ul>
</div>
</div>
<?php endif;?>
<?php if ( $akismet_user ):?>
<div class="akismet-card">
<div class="akismet-section-header">
<div class="akismet-section-header__label">
<span><?php esc_html_e( 'Settings' , 'akismet'); ?></span>
</div>
</div>
<div class="inside">
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
<table cellspacing="0" class="akismet-settings">
<tbody>
<?php if ( ! Akismet::predefined_api_key() ) { ?>
<tr>
<th class="akismet-api-key" width="10%" align="left" scope="row"><?php esc_html_e('API Key', 'akismet');?></th>
<td width="5%"/>
<td align="left">
<span class="api-key"><input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( get_option('wordpress_api_key') ); ?>" class="<?php echo esc_attr( 'regular-text code ' . $akismet_user->status ); ?>"></span>
</td>
</tr>
<?php } ?>
<?php if ( isset( $_GET['ssl_status'] ) ) { ?>
<tr>
<th align="left" scope="row"><?php esc_html_e( 'SSL Status', 'akismet' ); ?></th>
<td></td>
<td align="left">
<p>
<?php
if ( ! wp_http_supports( array( 'ssl' ) ) ) {
?><b><?php esc_html_e( 'Disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Your Web server cannot make SSL requests; contact your Web host and ask them to add support for SSL requests.', 'akismet' ); ?><?php
}
else {
$ssl_disabled = get_option( 'akismet_ssl_disabled' );
if ( $ssl_disabled ) {
?><b><?php esc_html_e( 'Temporarily disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Akismet encountered a problem with a previous SSL request and disabled it temporarily. It will begin using SSL for requests again shortly.', 'akismet' ); ?><?php
}
else {
?><b><?php esc_html_e( 'Enabled.', 'akismet' ); ?></b> <?php esc_html_e( 'All systems functional.', 'akismet' ); ?><?php
}
}
?>
</p>
</td>
</tr>
<?php } ?>
<tr>
<th align="left" scope="row"><?php esc_html_e('Comments', 'akismet');?></th>
<td></td>
<td align="left">
<p>
<label for="akismet_show_user_comments_approved" title="<?php esc_attr_e( 'Show approved comments' , 'akismet'); ?>">
<input
name="akismet_show_user_comments_approved"
id="akismet_show_user_comments_approved"
value="1"
type="checkbox"
<?php
// If the option isn't set, or if it's enabled ('1'), or if it was enabled a long time ago ('true'), check the checkbox.
checked( true, ( in_array( get_option( 'akismet_show_user_comments_approved' ), array( false, '1', 'true' ), true ) ) );
?>
/>
<?php esc_html_e( 'Show the number of approved comments beside each comment author', 'akismet' ); ?>
</label>
</p>
</td>
</tr>
<tr>
<th class="strictness" align="left" scope="row"><?php esc_html_e('Strictness', 'akismet'); ?></th>
<td></td>
<td align="left">
<fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet anti-spam strictness', 'akismet'); ?></span></legend>
<p><label for="akismet_strictness_1"><input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked('1', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Silently discard the worst and most pervasive spam so I never see it.', 'akismet'); ?></label></p>
<p><label for="akismet_strictness_0"><input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked('0', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Always put spam in the Spam folder for review.', 'akismet'); ?></label></p>
</fieldset>
<span class="akismet-note"><strong><?php esc_html_e('Note:', 'akismet');?></strong>
<?php
$delete_interval = max( 1, intval( apply_filters( 'akismet_delete_comment_interval', 15 ) ) );
printf(
_n(
'Spam in the <a href="%1$s">spam folder</a> older than 1 day is deleted automatically.',
'Spam in the <a href="%1$s">spam folder</a> older than %2$d days is deleted automatically.',
$delete_interval,
'akismet'
),
admin_url( 'edit-comments.php?comment_status=spam' ),
$delete_interval
);
?>
</td>
</tr>
<tr>
<th class="comment-form-privacy-notice" align="left" scope="row"><?php esc_html_e('Privacy', 'akismet'); ?></th>
<td></td>
<td align="left">
<fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet privacy notice', 'akismet'); ?></span></legend>
<p><label for="akismet_comment_form_privacy_notice_display"><input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_display" value="display" <?php checked('display', get_option('akismet_comment_form_privacy_notice')); ?> /> <?php esc_html_e('Display a privacy notice under your comment forms.', 'akismet'); ?></label></p>
<p><label for="akismet_comment_form_privacy_notice_hide"><input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_hide" value="hide" <?php echo in_array( get_option('akismet_comment_form_privacy_notice'), array('display', 'hide') ) ? checked('hide', get_option('akismet_comment_form_privacy_notice'), false) : 'checked="checked"'; ?> /> <?php esc_html_e('Do not display privacy notice.', 'akismet'); ?></label></p>
</fieldset>
<span class="akismet-note"><?php esc_html_e( 'To help your site with transparency under privacy laws like the GDPR, Akismet can display a notice to your users under your comment forms. This feature is disabled by default, however, you can turn it on above.', 'akismet' );?></span>
</td>
</tr>
</tbody>
</table>
<div class="akismet-card-actions">
<?php if ( ! Akismet::predefined_api_key() ) { ?>
<div id="delete-action">
<a class="submitdelete deletion" href="<?php echo esc_url( Akismet_Admin::get_page_url( 'delete_key' ) ); ?>"><?php esc_html_e('Disconnect this account', 'akismet'); ?></a>
</div>
<?php } ?>
<?php wp_nonce_field(Akismet_Admin::NONCE) ?>
<div id="publishing-action">
<input type="hidden" name="action" value="enter-key">
<input type="submit" name="submit" id="submit" class="akismet-button akismet-could-be-primary" value="<?php esc_attr_e('Save Changes', 'akismet');?>">
</div>
<div class="clear"></div>
</div>
</form>
</div>
</div>
<?php if ( ! Akismet::predefined_api_key() ) { ?>
<div class="akismet-card">
<div class="akismet-section-header">
<div class="akismet-section-header__label">
<span><?php esc_html_e( 'Account' , 'akismet'); ?></span>
</div>
</div>
<div class="inside">
<table cellspacing="0" border="0" class="akismet-settings">
<tbody>
<tr>
<th scope="row" align="left"><?php esc_html_e( 'Subscription Type' , 'akismet');?></th>
<td width="5%"/>
<td align="left">
<p><?php echo esc_html( $akismet_user->account_name ); ?></p>
</td>
</tr>
<tr>
<th scope="row" align="left"><?php esc_html_e( 'Status' , 'akismet');?></th>
<td width="5%"/>
<td align="left">
<p><?php
if ( 'cancelled' == $akismet_user->status ) :
esc_html_e( 'Cancelled', 'akismet' );
elseif ( 'suspended' == $akismet_user->status ) :
esc_html_e( 'Suspended', 'akismet' );
elseif ( 'missing' == $akismet_user->status ) :
esc_html_e( 'Missing', 'akismet' );
elseif ( 'no-sub' == $akismet_user->status ) :
esc_html_e( 'No Subscription Found', 'akismet' );
else :
esc_html_e( 'Active', 'akismet' );
endif; ?></p>
</td>
</tr>
<?php if ( $akismet_user->next_billing_date ) : ?>
<tr>
<th scope="row" align="left"><?php esc_html_e( 'Next Billing Date' , 'akismet');?></th>
<td width="5%"/>
<td align="left">
<p><?php echo date( 'F j, Y', $akismet_user->next_billing_date ); ?></p>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<div class="akismet-card-actions">
<div id="publishing-action">
<?php Akismet::view( 'get', array( 'text' => ( $akismet_user->account_type == 'free-api-key' && $akismet_user->status == 'active' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<?php } ?>
<?php endif;?>
</div>
</div>

View File

@@ -0,0 +1,72 @@
<?php
//phpcs:disable VariableAnalysis
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
?>
<div class="akismet-box">
<?php Akismet::view( 'title' ); ?>
<div class="akismet-jp-connect">
<h3><?php esc_html_e( 'Connect with Jetpack', 'akismet' ); ?></h3><?php
if ( in_array( $akismet_user->status, array( 'no-sub', 'missing' ) ) ) {?>
<p><?php esc_html_e( 'Use your Jetpack connection to set up Akismet.', 'akismet' ); ?></p>
<form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
<input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
<input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
<input type="hidden" name="auto-connect" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
<input type="hidden" name="redirect" value="plugin-signup"/>
<input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
</form>
<?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
<p><?php
/* translators: %s is the WordPress.com username */
echo sprintf( esc_html( __( 'You are connected as %s.', 'akismet' ) ), '<b>' . esc_html( $akismet_user->user_login ) . '</b>' ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
<?php } elseif ( $akismet_user->status == 'cancelled' ) { ?>
<p><?php esc_html_e( 'Use your Jetpack connection to set up Akismet.', 'akismet' ); ?></p>
<form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
<input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
<input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
<input type="hidden" name="user_id" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
<input type="hidden" name="redirect" value="upgrade"/>
<input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
</form>
<?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
<p><?php
/* translators: %s is the WordPress.com email address */
echo esc_html( sprintf( __( 'Your subscription for %s is cancelled.' , 'akismet' ), $akismet_user->user_email ) ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
<?php } elseif ( $akismet_user->status == 'suspended' ) { ?>
<div class="akismet-right">
<p><a href="https://akismet.com/contact" class="akismet-button akismet-is-primary"><?php esc_html_e( 'Contact Akismet support' , 'akismet' ); ?></a></p>
</div>
<p>
<span class="akismet-alert-text"><?php
/* translators: %s is the WordPress.com email address */
echo esc_html( sprintf( __( 'Your subscription for %s is suspended.' , 'akismet' ), $akismet_user->user_email ) ); ?></span>
<?php esc_html_e( 'No worries! Get in touch and we&#8217;ll sort this out.', 'akismet' ); ?>
</p>
<?php } else { // ask do they want to use akismet account found using jetpack wpcom connection ?>
<p><?php esc_html_e( 'Use your Jetpack connection to set up Akismet.', 'akismet' ); ?></p>
<form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate" class="akismet-right">
<input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key );?>"/>
<input type="hidden" name="action" value="enter-key">
<?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
<input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
</form>
<?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
<p><?php
/* translators: %s is the WordPress.com username */
echo sprintf( esc_html( __( 'You are connected as %s.', 'akismet' ) ), '<b>' . esc_html( $akismet_user->user_login ) . '</b>' ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
<?php } ?>
</div>
<div class="akismet-ak-connect">
<?php Akismet::view( 'setup' );?>
</div>
<div class="centered akismet-toggles">
<a href="#" class="toggle-jp-connect"><?php esc_html_e( 'Connect with Jetpack' ); ?></a>
<a href="#" class="toggle-ak-connect"><?php esc_html_e( 'Set up a different account' ); ?></a>
</div>
</div>
<br/>
<div class="akismet-box">
<?php Akismet::view( 'enter' );?>
</div>

View File

@@ -0,0 +1,13 @@
<div class="akismet-enter-api-key-box centered">
<a href="#"><?php esc_html_e( 'Manually enter an API key' ); ?></a>
<div class="enter-api-key">
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
<?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
<input type="hidden" name="action" value="enter-key">
<p style="width: 100%; display: flex; flex-wrap: nowrap; box-sizing: border-box;">
<input id="key" name="key" type="text" size="15" value="" placeholder="<?php esc_attr_e( 'Enter your API key' , 'akismet' ); ?>" class="regular-text code" style="flex-grow: 1; margin-right: 1rem;">
<input type="submit" name="submit" id="submit" class="akismet-button" value="<?php esc_attr_e( 'Connect with API key', 'akismet' );?>">
</p>
</form>
</div>
</div>

View File

@@ -0,0 +1,12 @@
<?php
//phpcs:disable VariableAnalysis
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
?>
<form name="akismet_activate" action="https://akismet.com/get/" method="POST" target="_blank">
<input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
<input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
<input type="hidden" name="redirect" value="<?php echo isset( $redirect ) ? $redirect : 'plugin-signup'; ?>"/>
<input type="submit" class="<?php echo isset( $classes ) && count( $classes ) > 0 ? implode( ' ', $classes ) : 'akismet-button';?>" value="<?php echo esc_attr( $text ); ?>"/>
</form>

View File

@@ -0,0 +1,141 @@
<?php
//phpcs:disable VariableAnalysis
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
?>
<?php if ( $type == 'plugin' ) :?>
<div class="updated" id="akismet_setup_prompt">
<form name="akismet_activate" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
<div class="akismet_activate">
<div class="aa_a">A</div>
<div class="aa_button_container">
<div class="aa_button_border">
<input type="submit" class="aa_button" value="<?php esc_attr_e( 'Set up your Akismet account', 'akismet' ); ?>" />
</div>
</div>
<div class="aa_description"><?php _e('<strong>Almost done</strong> - configure Akismet and say goodbye to spam', 'akismet');?></div>
</div>
</form>
</div>
<?php elseif ( $type == 'spam-check' ) :?>
<div class="notice notice-warning">
<p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' );?></strong></p>
<p><?php esc_html_e( 'Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation and will automatically be rechecked later.', 'akismet' ); ?></p>
<?php if ( $link_text ) { ?>
<p><?php echo $link_text; ?></p>
<?php } ?>
</div>
<?php elseif ( $type == 'alert' ) :?>
<div class='error'>
<p><strong><?php printf( esc_html__( 'Akismet Error Code: %s', 'akismet' ), $code ); ?></strong></p>
<p><?php echo esc_html( $msg ); ?></p>
<p><?php
/* translators: the placeholder is a clickable URL that leads to more information regarding an error code. */
printf( esc_html__( 'For more information: %s' , 'akismet'), '<a href="https://akismet.com/errors/' . $code . '">https://akismet.com/errors/' . $code . '</a>' );
?>
</p>
</div>
<?php elseif ( $type == 'notice' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status failed"><?php echo $notice_header; ?></h3>
<p class="akismet-description">
<?php echo $notice_text; ?>
</p>
</div>
<?php elseif ( $type == 'missing-functions' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status failed"><?php esc_html_e('Network functions are disabled.', 'akismet'); ?></h3>
<p class="akismet-description"><?php printf( __('Your web host or server administrator has disabled PHP&#8217;s <code>gethostbynamel</code> function. <strong>Akismet cannot work correctly until this is fixed.</strong> Please contact your web host or firewall administrator and give them <a href="%s" target="_blank">this information about Akismet&#8217;s system requirements</a>.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?></p>
</div>
<?php elseif ( $type == 'servers-be-down' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status failed"><?php esc_html_e("Your site can&#8217;t connect to the Akismet servers.", 'akismet'); ?></h3>
<p class="akismet-description"><?php printf( __('Your firewall may be blocking Akismet from connecting to its API. Please contact your host and refer to <a href="%s" target="_blank">our guide about firewalls</a>.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?></p>
</div>
<?php elseif ( $type == 'active-dunning' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status"><?php esc_html_e("Please update your payment information.", 'akismet'); ?></h3>
<p class="akismet-description"><?php printf( __('We cannot process your payment. Please <a href="%s" target="_blank">update your payment details</a>.', 'akismet'), 'https://akismet.com/account/'); ?></p>
</div>
<?php elseif ( $type == 'cancelled' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status"><?php esc_html_e("Your Akismet plan has been cancelled.", 'akismet'); ?></h3>
<p class="akismet-description"><?php printf( __('Please visit your <a href="%s" target="_blank">Akismet account page</a> to reactivate your subscription.', 'akismet'), 'https://akismet.com/account/'); ?></p>
</div>
<?php elseif ( $type == 'suspended' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status failed"><?php esc_html_e("Your Akismet subscription is suspended.", 'akismet'); ?></h3>
<p class="akismet-description"><?php printf( __('Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?></p>
</div>
<?php elseif ( $type == 'active-notice' && $time_saved ) :?>
<div class="akismet-alert akismet-active">
<h3 class="akismet-key-status"><?php echo esc_html( $time_saved ); ?></h3>
<p class="akismet-description"><?php printf( __('You can help us fight spam and upgrade your account by <a href="%s" target="_blank">contributing a token amount</a>.', 'akismet'), 'https://akismet.com/account/upgrade/'); ?></p>
</div>
<?php elseif ( $type == 'missing' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status failed"><?php esc_html_e( 'There is a problem with your API key.', 'akismet'); ?></h3>
<p class="akismet-description"><?php printf( __('Please contact <a href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet'), 'https://akismet.com/contact/'); ?></p>
</div>
<?php elseif ( $type == 'no-sub' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status failed"><?php esc_html_e( 'You don&#8217;t have an Akismet plan.', 'akismet'); ?></h3>
<p class="akismet-description">
<?php printf( __( 'In 2012, Akismet began using subscription plans for all accounts (even free ones). A plan has not been assigned to your account, and we&#8217;d appreciate it if you&#8217;d <a href="%s" target="_blank">sign into your account</a> and choose one.', 'akismet'), 'https://akismet.com/account/upgrade/' ); ?>
<br /><br />
<?php printf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), 'https://akismet.com/contact/' ); ?>
</p>
</div>
<?php elseif ( $type == 'new-key-valid' ) :
global $wpdb;
$check_pending_link = false;
$at_least_one_comment_in_moderation = !! $wpdb->get_var( "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_approved = '0' LIMIT 1" );
if ( $at_least_one_comment_in_moderation) {
$check_pending_link = 'edit-comments.php?akismet_recheck=' . wp_create_nonce( 'akismet_recheck' );
}
?>
<div class="akismet-alert akismet-active">
<h3 class="akismet-key-status"><?php esc_html_e( 'Akismet is now protecting your site from spam. Happy blogging!', 'akismet' ); ?></h3>
<?php if ( $check_pending_link ) { ?>
<p class="akismet-description"><?php printf( __( 'Would you like to <a href="%s">check pending comments</a>?', 'akismet' ), esc_url( $check_pending_link ) ); ?></p>
<?php } ?>
</div>
<?php elseif ( $type == 'new-key-invalid' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status"><?php esc_html_e( 'The key you entered is invalid. Please double-check it.' , 'akismet'); ?></h3>
</div>
<?php elseif ( $type == 'existing-key-invalid' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status"><?php esc_html_e( 'Your API key is no longer valid. Please enter a new key or contact support@akismet.com.' , 'akismet'); ?></h3>
</div>
<?php elseif ( $type == 'new-key-failed' ) :?>
<div class="akismet-alert akismet-critical">
<h3 class="akismet-key-status"><?php esc_html_e( 'The API key you entered could not be verified.' , 'akismet'); ?></h3>
<p class="akismet-description"><?php printf( __('The connection to akismet.com could not be established. Please refer to <a href="%s" target="_blank">our guide about firewalls</a> and check your server configuration.', 'akismet'), 'https://blog.akismet.com/akismet-hosting-faq/'); ?></p>
</div>
<?php elseif ( $type == 'limit-reached' && in_array( $level, array( 'yellow', 'red' ) ) ) :?>
<div class="akismet-alert akismet-critical">
<?php if ( $level == 'yellow' ): ?>
<h3 class="akismet-key-status failed"><?php esc_html_e( 'You&#8217;re using your Akismet key on more sites than your Pro subscription allows.', 'akismet' ); ?></h3>
<p class="akismet-description">
<?php printf( __( 'Your Pro subscription allows the use of Akismet on only one site. Please <a href="%s" target="_blank">purchase additional Pro subscriptions</a> or upgrade to an Enterprise subscription that allows the use of Akismet on unlimited sites.', 'akismet' ), 'https://docs.akismet.com/billing/add-more-sites/' ); ?>
<br /><br />
<?php printf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), 'https://akismet.com/contact/'); ?>
</p>
<?php elseif ( $level == 'red' ): ?>
<h3 class="akismet-key-status failed"><?php esc_html_e( 'You&#8217;re using Akismet on far too many sites for your Pro subscription.', 'akismet' ); ?></h3>
<p class="akismet-description">
<?php printf( __( 'To continue your service, <a href="%s" target="_blank">upgrade to an Enterprise subscription</a>, which covers an unlimited number of sites.', 'akismet'), 'https://akismet.com/account/upgrade/' ); ?>
<br /><br />
<?php printf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), 'https://akismet.com/contact/'); ?>
</p>
<?php endif; ?>
</div>
<?php endif;?>

View File

@@ -0,0 +1,11 @@
<div class="akismet-box">
<h2><?php esc_html_e( 'Manual Configuration', 'akismet' ); ?></h2>
<p>
<?php
/* translators: %s is the wp-config.php file */
echo sprintf( esc_html__( 'An Akismet API key has been defined in the %s file for this site.', 'akismet' ), '<code>wp-config.php</code>' );
?>
</p>
</div>

View File

@@ -0,0 +1,4 @@
<div class="akismet-setup-instructions">
<p><?php esc_html_e( 'Set up your Akismet account to enable spam filtering on this site.', 'akismet' ); ?></p>
<?php Akismet::view( 'get', array( 'text' => __( 'Set up your Akismet account' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?>
</div>

View File

@@ -0,0 +1,31 @@
<?php
//phpcs:disable VariableAnalysis
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
?>
<div id="akismet-plugin-container">
<div class="akismet-masthead">
<div class="akismet-masthead__inside-container">
<div class="akismet-masthead__logo-container">
<img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/logo-full-2x.png', __FILE__ ) ); ?>" alt="Akismet" />
</div>
</div>
</div>
<div class="akismet-lower">
<?php Akismet_Admin::display_status();?>
<div class="akismet-boxes">
<?php
if ( Akismet::predefined_api_key() ) {
Akismet::view( 'predefined' );
} elseif ( $akismet_user && in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) {
Akismet::view( 'connect-jp', compact( 'akismet_user' ) );
} else {
Akismet::view( 'activate' );
}
?>
</div>
</div>
</div>

View File

@@ -0,0 +1,11 @@
<div id="akismet-plugin-container">
<div class="akismet-masthead">
<div class="akismet-masthead__inside-container">
<a href="<?php echo esc_url( Akismet_Admin::get_page_url() );?>" class="akismet-right"><?php esc_html_e( 'Akismet Settings' , 'akismet' ); ?></a>
<div class="akismet-masthead__logo-container">
<img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/logo-full-2x.png', __FILE__ ) ); ?>" alt="Akismet" />
</div>
</div>
</div>
<iframe src="<?php echo esc_url( sprintf( '//akismet.com/web/1.0/user-stats.php?blog=%s&api_key=%s&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() ) ); ?>" width="100%" height="2500px" frameborder="0"></iframe>
</div>

View File

@@ -0,0 +1,3 @@
<div class="centered akismet-box-header">
<h2><?php esc_html_e( 'Eliminate spam from your site', 'akismet' ); ?></h2>
</div>

View File

@@ -0,0 +1,214 @@
<?php
global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
$wpcom_api_key = defined( 'WPCOM_API_KEY' ) ? constant( 'WPCOM_API_KEY' ) : '';
$akismet_api_host = Akismet::get_api_key() . '.rest.akismet.com';
$akismet_api_port = 80;
function akismet_test_mode() {
return Akismet::is_test_mode();
}
function akismet_http_post( $request, $host, $path, $port = 80, $ip = null ) {
$path = str_replace( '/1.1/', '', $path );
return Akismet::http_post( $request, $path, $ip );
}
function akismet_microtime() {
return Akismet::_get_microtime();
}
function akismet_delete_old() {
return Akismet::delete_old_comments();
}
function akismet_delete_old_metadata() {
return Akismet::delete_old_comments_meta();
}
function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
return Akismet::check_db_comment( $id, $recheck_reason );
}
function akismet_rightnow() {
if ( !class_exists( 'Akismet_Admin' ) )
return false;
return Akismet_Admin::rightnow_stats();
}
function akismet_admin_init() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_version_warning() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_load_js_and_css() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_nonce_field( $action = -1 ) {
return wp_nonce_field( $action );
}
function akismet_plugin_action_links( $links, $file ) {
return Akismet_Admin::plugin_action_links( $links, $file );
}
function akismet_conf() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_stats_display() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_stats() {
return Akismet_Admin::dashboard_stats();
}
function akismet_admin_warnings() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_comment_row_action( $a, $comment ) {
return Akismet_Admin::comment_row_actions( $a, $comment );
}
function akismet_comment_status_meta_box( $comment ) {
return Akismet_Admin::comment_status_meta_box( $comment );
}
function akismet_comments_columns( $columns ) {
_deprecated_function( __FUNCTION__, '3.0' );
return $columns;
}
function akismet_comment_column_row( $column, $comment_id ) {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_text_add_link_callback( $m ) {
return Akismet_Admin::text_add_link_callback( $m );
}
function akismet_text_add_link_class( $comment_text ) {
return Akismet_Admin::text_add_link_class( $comment_text );
}
function akismet_check_for_spam_button( $comment_status ) {
return Akismet_Admin::check_for_spam_button( $comment_status );
}
function akismet_submit_nonspam_comment( $comment_id ) {
return Akismet::submit_nonspam_comment( $comment_id );
}
function akismet_submit_spam_comment( $comment_id ) {
return Akismet::submit_spam_comment( $comment_id );
}
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
return Akismet::transition_comment_status( $new_status, $old_status, $comment );
}
function akismet_spam_count( $type = false ) {
return Akismet_Admin::get_spam_count( $type );
}
function akismet_recheck_queue() {
return Akismet_Admin::recheck_queue();
}
function akismet_remove_comment_author_url() {
return Akismet_Admin::remove_comment_author_url();
}
function akismet_add_comment_author_url() {
return Akismet_Admin::add_comment_author_url();
}
function akismet_check_server_connectivity() {
return Akismet_Admin::check_server_connectivity();
}
function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
return Akismet_Admin::get_server_connectivity( $cache_timeout );
}
function akismet_server_connectivity_ok() {
_deprecated_function( __FUNCTION__, '3.0' );
return true;
}
function akismet_admin_menu() {
return Akismet_Admin::admin_menu();
}
function akismet_load_menu() {
return Akismet_Admin::load_menu();
}
function akismet_init() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_get_key() {
return Akismet::get_api_key();
}
function akismet_check_key_status( $key, $ip = null ) {
return Akismet::check_key_status( $key, $ip );
}
function akismet_update_alert( $response ) {
return Akismet::update_alert( $response );
}
function akismet_verify_key( $key, $ip = null ) {
return Akismet::verify_key( $key, $ip );
}
function akismet_get_user_roles( $user_id ) {
return Akismet::get_user_roles( $user_id );
}
function akismet_result_spam( $approved ) {
return Akismet::comment_is_spam( $approved );
}
function akismet_result_hold( $approved ) {
return Akismet::comment_needs_moderation( $approved );
}
function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
return Akismet::get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url );
}
function akismet_update_comment_history( $comment_id, $message, $event = null ) {
return Akismet::update_comment_history( $comment_id, $message, $event );
}
function akismet_get_comment_history( $comment_id ) {
return Akismet::get_comment_history( $comment_id );
}
function akismet_cmp_time( $a, $b ) {
return Akismet::_cmp_time( $a, $b );
}
function akismet_auto_check_update_meta( $id, $comment ) {
return Akismet::auto_check_update_meta( $id, $comment );
}
function akismet_auto_check_comment( $commentdata ) {
return Akismet::auto_check_comment( $commentdata );
}
function akismet_get_ip_address() {
return Akismet::get_ip_address();
}
function akismet_cron_recheck() {
return Akismet::cron_recheck();
}
function akismet_add_comment_nonce( $post_id ) {
return Akismet::add_comment_nonce( $post_id );
}
function akismet_fix_scheduled_recheck() {
return Akismet::fix_scheduled_recheck();
}
function akismet_spam_comments() {
_deprecated_function( __FUNCTION__, '3.0' );
return array();
}
function akismet_spam_totals() {
_deprecated_function( __FUNCTION__, '3.0' );
return array();
}
function akismet_manage_page() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_caught() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function redirect_old_akismet_urls() {
_deprecated_function( __FUNCTION__, '3.0' );
}
function akismet_kill_proxy_check( $option ) {
_deprecated_function( __FUNCTION__, '3.0' );
return 0;
}
function akismet_pingback_forwarded_for( $r, $url ) {
// This functionality is now in core.
return false;
}
function akismet_pre_check_pingback( $method ) {
return Akismet::pre_check_pingback( $method );
}

View File

@@ -0,0 +1,21 @@
#dbcl_panel form p{
padding:5px;
clear:both;
}
#dbcl_panel form p label{
width:50px;
display:block;
float:left;
}
#dbcl_panel form p input{
float:left;
width:150px;
}
#dbcl_panel form p.center input{
width:200px;
}
#dbcl_results {
margin-top:20px;
}

View File

@@ -0,0 +1,20 @@
/*global dbcl:false, ajaxurl:false */
( function ( $ ) {
$( document ).on( 'submit', '#dbcl_form', function ( e ) {
e.preventDefault();
$( '#dbcl_results' ).empty();
var dbcl_data = {
action: 'dbcl',
dbcl_key: $( '#dbcl_key' ).val(),
dbcl_group: $( '#dbcl_group' ).val(),
security: dbcl.security
};
$.post( ajaxurl, dbcl_data, function ( res ) {
if ( true === res.success ) {
$( '#dbcl_results' ).html( res.data.cache );
} else {
$( '#dbcl_results' ).html( 'No cache data found.' );
}
} );
} );
} )( jQuery );

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<ruleset name="WPized Project">
<description>A custom set of rules to check for a WPized WordPress project</description>
<exclude-pattern>/docroot/wp-admin/*</exclude-pattern>
<exclude-pattern>/docroot/wp-includes/*</exclude-pattern>
<exclude-pattern>/docroot/wp-*.php</exclude-pattern>
<exclude-pattern>/docroot/index.php</exclude-pattern>
<exclude-pattern>/docroot/xmlrpc.php</exclude-pattern>
<exclude-pattern>/docroot/wp-content/plugins/*</exclude-pattern>
<rule ref="Squiz.PHP.CommentedOutCode"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<!--<rule ref="Generic.Commenting.Todo"/>-->
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<!--
We may also want to to include all the rules in a standard
-->
<rule ref="WordPress">
<!--
We may want a middle ground though. The best way to do this is add the
entire ruleset, then rule by rule, remove ones that don't suit a project. We
can do this by running `phpc ` with the '-s' flag, to see the names of the
different Sniffs, as their rules are broken. From here, we can opt to
exclude problematic sniffs like so.
<exclude name="WordPress.XSS.EscapeOutput" />
-->
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found" />
<exclude name="Generic.Commenting.Todo.TaskFound" />
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" />
<exclude name="Squiz.PHP.CommentedOutCode.Found" />
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" />
<exclude name="WordPress.Classes.ValidClassName" />
<exclude name="PEAR.Functions.FunctionCallSignature" />
<exclude name="WordPress.Files.FileName" />
<exclude name="WordPress.Arrays.ArrayDeclaration" />
<exclude name="WordPress.Arrays.ArrayKeySpacingRestrictions" />
<exclude name="WordPress.Functions.FunctionDeclarationArgumentSpacing" />
<exclude name="Squiz.Strings.DoubleQuoteUsage" />
<exclude name="WordPress.WhiteSpace.OperatorSpacing" />
<exclude name="WordPress.WhiteSpace.PhpIndent.Incorrect" />
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine" />
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile" />
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile" />
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing" />
<exclude name="Generic.WhiteSpace.ScopeIndent" />
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent" />
<exclude name="WordPress.NamingConventions.ValidFunctionName" />
<exclude name="WordPress.PHP.YodaConditions" />
<!--<exclude name="WordPress.VIP" />
<exclude name="WordPress.PHP" />
<exclude name="WordPress.XSS" />-->
</rule>
</ruleset>

View File

@@ -0,0 +1,87 @@
<?php
/**
* Plugin Name: Debug Bar Cache Lookup
* Plugin URI: https://wordpress.org/plugins/debug-bar-cache-lookup/
* Description: Look up items in object cache. Requires Debug Bar Plugin.
* Version: 0.1.1
* Author: Allan Collins
* Author URI: http://www.allancollins.net/
* License: GPLv2+
* Text Domain: dbcl
* Domain Path: /languages
*/
/**
* Copyright (c) 2015 Allan Collins (email : allan.collins@10up.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 or, at
* your discretion, any later version, as published by the Free
* Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Built using grunt-wp-plugin
* Copyright (c) 2013 10up, LLC
* https://github.com/10up/grunt-wp-plugin
*/
// Useful global constants
define( 'DBCL_VERSION', '0.1.0' );
define( 'DBCL_URL', plugin_dir_url( __FILE__ ) );
define( 'DBCL_PATH', dirname( __FILE__ ) . '/' );
/**
* Add the panel to the Debug Bar.
*
* @param array $panels Array of panel objects.
*
* @return array Array of panel objects.
*/
function dbcl_add_panel( $panels ) {
require DBCL_PATH . 'includes/class-debug-bar-cache-lookup.php';
array_push( $panels, new Debug_Bar_Cache_Lookup() );
return $panels;
}
add_filter( 'debug_bar_panels', 'dbcl_add_panel' );
/**
* Enqueue JavaScript, localization and stylesheet.
*/
function dbcl_enqueue() {
wp_enqueue_style( 'dbcl-css', DBCL_URL . 'assets/css/dbcl.css', array(), '20150113' );
wp_enqueue_script( 'dbcl-js', DBCL_URL . 'assets/js/dbcl.js', array( 'jquery' ), '20150113' );
wp_localize_script( 'dbcl-js', 'dbcl', array( 'security' => wp_create_nonce( "dbcl_security" ) ) );
}
add_action( 'debug_bar_enqueue_scripts', 'dbcl_enqueue' );
/**
* Ajax callback that retrieves the cache object information.
*/
function dbcl_ajax() {
check_ajax_referer( 'dbcl_security', 'security' );
$dbcl_key = filter_input( INPUT_POST, 'dbcl_key', FILTER_SANITIZE_STRING );
$dbcl_group = filter_input( INPUT_POST, 'dbcl_group', FILTER_SANITIZE_STRING );
$cache = wp_cache_get( $dbcl_key, $dbcl_group );
if ( ! $cache ) {
return wp_send_json_error();
}
ob_start();
print_r( $cache );
$cache = esc_html( ob_get_clean() );
return wp_send_json_success( array( 'cache' => $cache ) );
}
add_action( 'wp_ajax_dbcl', 'dbcl_ajax' );

View File

@@ -0,0 +1,19 @@
<?php
class Debug_Bar_Cache_Lookup extends Debug_Bar_Panel {
function init() {
$this->title( esc_html__( 'Cache Lookup', 'dbcl' ) );
}
function prerender() {
global $wp_object_cache;
$this->set_visible( is_object( $wp_object_cache ) && method_exists( $wp_object_cache, 'stats' ) );
}
function render() {
include DBCL_PATH . 'views/searchform.php';
}
}

View File

@@ -0,0 +1,47 @@
=== Debug Bar Cache Lookup ===
Contributors: collinsinternet
Donate link:
Tags: debug bar, object cache, memcached, memcache
Requires at least: 3.9
Tested up to: 4.5
Stable tag: 0.1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Look up items in object cache.
== Description ==
Are you running an object cache like memcached? Want to see if cache is working?
== Installation ==
= Manual Installation =
1. Upload the entire `/debug-bar-cache-lookup` directory to the `/wp-content/plugins/` directory.
2. Activate Debug Bar Cache Lookup through the 'Plugins' menu in WordPress.
3. When you activate the Debug Bar plugin, 'Cache Lookup' will be added to debug menu.
== Frequently Asked Questions ==
= Why would I need this? =
Sometimes there are times when you need to verify that an object is being properly cached.
Instead of using WP CLI or other tools, you can look it up from within the Debug Bar.
== Screenshots ==
1. The 'Cache Lookup'.
== Changelog ==
= 0.1.1 =
* Minor security update.
= 0.1.0 =
* First release
== Upgrade Notice ==
= 0.1.1 =
Security fixes.

View File

@@ -0,0 +1,16 @@
<?php /** View for the search form. **/ ?>
<div id="dbcl_panel">
<form id="dbcl_form">
<p>Enter the cache key and cache group:</p>
<p>
<label for="dbcl_key">Key:</label>
<input type="text" id="dbcl_key" name="dbcl_key"> <small>(Example: alloptions)</small>
</p>
<p>
<label for="dbcl_group">Group:</label>
<input type="text" id="dbcl_group" name="dbcl_group"> <small>(Example: options)</small>
</p>
<p class="center"><input type="submit" value="Lookup" class="button button-primary"></p>
</form><br/>
<pre id="dbcl_results"></pre>
</div>

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,71 @@
<?php
/**
* Debug Bar Constants Panel - Base class for a Debug Bar Constants Debug Bar Panels.
*
* @package WordPress\Plugins\Debug Bar Constants
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/Debug-Bar-Constants
*
* @copyright 2013-2018 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! class_exists( 'Debug_Bar_Constants_Panel' ) && class_exists( 'Debug_Bar_Panel' ) ) {
/**
* Base class.
*/
abstract class Debug_Bar_Constants_Panel extends Debug_Bar_Panel {
/**
* Should the tab be visible ?
* You can set conditions here so something will for instance only show on the front- or the
* back-end.
*/
public function prerender() {
$this->set_visible( true );
}
/**
* Helper method to render the output in a table.
*
* @param array $array Array to be shown in the table.
* @param string|null $col1 Label for the first table column.
* @param string|null $col2 Label for the second table column.
* @param string|array|null $class One or more CSS classes to add to the table.
*/
public function dbc_render_table( $array, $col1 = null, $col2 = null, $class = null ) {
$classes = Debug_Bar_Constants_Init::DBC_NAME;
if ( isset( $class ) ) {
if ( is_string( $class ) && '' !== $class ) {
$classes .= ' ' . $class;
} elseif ( ! empty( $class ) && is_array( $class ) ) {
$classes = $classes . ' ' . implode( ' ', $class );
}
}
$col1 = ( isset( $col1 ) ? $col1 : __( 'Name', 'debug-bar-constants' ) );
$col2 = ( isset( $col2 ) ? $col2 : __( 'Value', 'debug-bar-constants' ) );
uksort( $array, 'strnatcasecmp' );
if ( defined( 'Debug_Bar_Pretty_Output::VERSION' ) ) {
echo Debug_Bar_Pretty_Output::get_table( $array, $col1, $col2, $classes ); // WPCS: xss ok.
} else {
// An old version of the pretty output class was loaded.
Debug_Bar_Pretty_Output::render_table( $array, $col1, $col2, $classes );
}
}
} // End of class Debug_Bar_Constants_Panel.
} // End of if class_exists wrapper.

View File

@@ -0,0 +1,124 @@
<?php
/**
* Debug Bar Constants.
*
* @package WordPress\Plugins\Debug Bar Constants
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/Debug-Bar-Constants
*
* @copyright 2013-2018 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! class_exists( 'Debug_Bar_Constants' ) ) {
/**
* Plugin controller.
*/
class Debug_Bar_Constants {
/**
* Plugin version nr for use with enqueuing styles.
*
* @var string
*/
const DBC_STYLES_VERSION = '2.0.0';
/**
* Plugin version nr for use with enqueuing scripts.
*
* @var string
*/
const DBC_SCRIPT_VERSION = '2.0.0';
/**
* Constructor.
*/
public function __construct() {
spl_autoload_register( array( $this, 'auto_load' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
// Low priority, no need for it to be high up in the list.
add_filter( 'debug_bar_panels', array( $this, 'add_panels' ), 12 );
}
/**
* Auto load our class files.
*
* @param string $class Class name.
*
* @return void
*/
public function auto_load( $class ) {
static $classes = null;
if ( null === $classes ) {
$classes = array(
'debug_bar_constants_panel' => 'class-debug-bar-constants-panel.php',
'debug_bar_wp_constants' => 'class-debug-bar-wp-constants.php',
'debug_bar_wp_class_constants' => 'class-debug-bar-wp-class-constants.php',
'debug_bar_php_constants' => 'class-debug-bar-php-constants.php',
'debug_bar_pretty_output' => 'inc/debug-bar-pretty-output/class-debug-bar-pretty-output.php',
'debug_bar_list_php_classes' => 'inc/debug-bar-pretty-output/class-debug-bar-list-php-classes.php',
);
}
$cn = strtolower( $class );
if ( isset( $classes[ $cn ] ) ) {
include_once plugin_dir_path( __FILE__ ) . $classes[ $cn ];
}
}
/**
* Enqueue js and css files.
*/
public function enqueue_scripts() {
$suffix = ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' );
wp_enqueue_style(
Debug_Bar_Constants_Init::DBC_NAME,
plugins_url( 'css/' . Debug_Bar_Constants_Init::DBC_NAME . $suffix . '.css', __FILE__ ),
array( 'debug-bar' ),
self::DBC_STYLES_VERSION
);
wp_enqueue_script(
Debug_Bar_Constants_Init::DBC_NAME,
plugins_url( 'js/jquery.ui.totop' . $suffix . '.js', __FILE__ ),
array( 'jquery' ),
self::DBC_SCRIPT_VERSION,
true
);
}
/**
* Add the Debug Bar Constant panels to the Debug Bar.
*
* @param array $panels Existing debug bar panels.
*
* @return array
*/
public function add_panels( $panels ) {
$panels[] = new Debug_Bar_WP_Constants();
$panels[] = new Debug_Bar_WP_Class_Constants();
$panels[] = new Debug_Bar_PHP_Constants();
return $panels;
}
} // End of class Debug_Bar_Constants.
} // End of if class_exists wrapper.

View File

@@ -0,0 +1,135 @@
<?php
/**
* Debug Bar PHP Constants - Debug Bar Panel.
*
* @package WordPress\Plugins\Debug Bar Constants
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/Debug-Bar-Constants
*
* @copyright 2013-2017 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! class_exists( 'Debug_Bar_PHP_Constants' ) && class_exists( 'Debug_Bar_Constants_Panel' ) ) {
/**
* Debug Bar PHP Constants.
*/
class Debug_Bar_PHP_Constants extends Debug_Bar_Constants_Panel {
/**
* Constructor.
*/
public function init() {
$this->title( __( 'PHP Constants', 'debug-bar-constants' ) );
}
/**
* Render the output.
*/
public function render() {
$constants = get_defined_constants( true );
unset( $constants['user'] );
if ( ! empty( $constants ) && is_array( $constants ) ) {
uksort( $constants, 'strnatcasecmp' );
foreach ( $constants as $category => $set ) {
echo '
<h2><a href="#dbcphp-', esc_attr( $category ), '"><span>', esc_html( $category ), ':</span>', (int) count( $set ), '</a></h2>';
}
unset( $category, $set );
foreach ( $constants as $category => $set ) {
if ( ! empty( $set ) && is_array( $set ) ) {
// Set url to correct page in the PHP manual for more info.
$url = $this->get_php_manual_url( $category );
/* TRANSLATORS: %s = the name of a PHP extension. */
$title_attr = sprintf( __( 'Visit the PHP manual page about the %s constants.', 'debug-bar-constants' ), $category );
echo '
<h3 id="dbcphp-', esc_attr( $category ), '"><em>';
if ( ! empty( $url ) ) {
echo '<a href="', esc_url( $url ), '" target="_blank" title="', esc_attr( $title_attr ), '">', esc_html( ucfirst( $category ) ), '</a>';
} else {
echo esc_html( ucfirst( $category ) );
}
echo '</em> ', esc_html__( 'Constants:', 'debug-bar-constants' ), '</h3>';
$this->dbc_render_table( $set );
}
}
unset( $category, $set, $title_attr );
} else {
// Should never happen.
echo '<p>', esc_html__( 'No PHP constants found... this is really weird...', 'debug-bar-constants' ), '</p>';
}
}
/**
* Retrieve the PHP manual URL for the constants page of a specific PHP extension.
*
* Works round some of the peculiarities of the PHP.net URL scheme.
*
* @param string $category The PHP Extension for which to retrieve the URL.
*
* @return string URL
*/
protected function get_php_manual_url( $category ) {
$category = strtolower( $category );
switch ( $category ) {
case 'core':
$url = 'http://php.net/reserved.constants';
break;
case 'date':
$url = 'http://php.net/datetime.constants';
break;
case 'gd':
$url = 'http://php.net/image.constants';
break;
case 'odbc':
$url = 'http://php.net/uodbc.constants';
break;
case 'standard':
$url = ''; // Definitions are all over, part of core.
break;
case 'tokenizer':
$url = 'http://php.net/tokens';
break;
case 'xdebug':
$url = 'http://xdebug.com/docs/';
break;
default:
$url = 'http://php.net/' . rawurlencode( $category ) . '.constants';
break;
}
return $url;
}
} // End of class Debug_Bar_PHP_Constants.
} // End of if class_exists wrapper.

View File

@@ -0,0 +1,109 @@
<?php
/**
* Debug Bar WP Class Constants - Debug Bar Panel.
*
* @package WordPress\Plugins\Debug Bar Constants
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/Debug-Bar-Constants
*
* @copyright 2013-2018 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! class_exists( 'Debug_Bar_WP_Class_Constants' ) && class_exists( 'Debug_Bar_Constants_Panel' ) ) {
/**
* Debug Bar WP Class Constants.
*/
class Debug_Bar_WP_Class_Constants extends Debug_Bar_Constants_Panel {
/**
* Constructor.
*/
public function init() {
$this->title( __( 'WP Class Constants', 'debug-bar-constants' ) );
}
/**
* Render the output.
*/
public function render() {
$classes = get_declared_classes();
if ( class_exists( 'Debug_Bar_List_PHP_Classes' ) && property_exists( 'Debug_Bar_List_PHP_Classes', 'PHP_classes' ) ) {
$classes = array_udiff( $classes, Debug_Bar_List_PHP_Classes::$PHP_classes, 'strcasecmp' );
}
$constants = array();
if ( ! empty( $classes ) && is_array( $classes ) ) {
// Get the constants info first.
foreach ( $classes as $class ) {
$reflector = new ReflectionClass( $class );
$class_constants = $reflector->getConstants();
if ( ! empty( $class_constants ) && is_array( $class_constants ) ) {
$constants[ $class ] = $class_constants;
}
unset( $class_constants, $reflector );
}
unset( $class );
// Generate the output.
if ( ! empty( $constants ) && is_array( $constants ) ) {
uksort( $constants, 'strnatcasecmp' );
foreach ( $constants as $class => $set ) {
$count = count( $set );
echo '
<h2><a href="#dbcwpc-', esc_attr( $class ), '"><span>', esc_html( $class ), ':</span>', (int) $count, '</a></h2>';
unset( $count );
}
unset( $class, $set );
echo '<p class="dbcwpc-info">';
printf(
/* TRANSLATORS: 1: <strong> open tag; 2: close tag. */
esc_html__( '%1$sPlease note%2$s: these may be both native WordPress classes as well as classes which may be declared by plugins or themes.', 'debug-bar-constants' ),
'<strong>',
'</strong>'
);
echo '<br/>';
printf(
/* TRANSLATORS: 1: interpolates to "<code>class_name::constant_name</code>". */
esc_html__( 'You can use these constants in your code using %1$s.', 'debug-bar-constants' ),
'<code>class_name::constant_name</code>'
);
echo ' ';
printf(
/* TRANSLATORS: 1: link open tag; 2: link close tag. */
esc_html__( 'See the %1$sFAQ%2$s for more information.', 'debug-bar-constants' ),
'<a href="https://wordpress.org/plugins/debug-bar-constants/faq/" target="_blank">',
'</a>'
);
echo '</p>';
foreach ( $constants as $class => $set ) {
echo '
<h3 id="dbcwpc-', esc_attr( $class ), '"><em>', esc_html( ucfirst( $class ) ), '</em> ', esc_html__( 'Constants:', 'debug-bar-constants' ), '</h3>';
$this->dbc_render_table( $set );
}
unset( $class, $set );
}
} else {
// Should never happen.
echo '<p>', esc_html__( 'No classes nor class constants found... this is kinda strange...', 'debug-bar-constants' ), '</p>';
}
}
} // End of class Debug_Bar_WP_Class_Constants.
} // End of if class_exists wrapper.

View File

@@ -0,0 +1,63 @@
<?php
/**
* Debug Bar WP Constants - Debug Bar Panel.
*
* @package WordPress\Plugins\Debug Bar Constants
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/Debug-Bar-Constants
*
* @copyright 2013-2018 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! class_exists( 'Debug_Bar_WP_Constants' ) && class_exists( 'Debug_Bar_Constants_Panel' ) ) {
/**
* Debug Bar WP Constants.
*/
class Debug_Bar_WP_Constants extends Debug_Bar_Constants_Panel {
/**
* Constructor.
*/
public function init() {
$this->title( __( 'WP Constants', 'debug-bar-constants' ) );
}
/**
* Limit visibility of the output to super admins on multi-site and
* admins on non multi-site installations.
*/
public function prerender() {
$this->set_visible( is_super_admin() );
}
/**
* Render the output.
*/
public function render() {
$constants = get_defined_constants( true );
if ( isset( $constants['user'] ) && ( ! empty( $constants['user'] ) && is_array( $constants['user'] ) ) ) {
echo '
<h2><span>', esc_html__( 'Constants within WP:', 'debug-bar-constants' ), '</span>', (int) count( $constants['user'] ), '</h2>';
$this->dbc_render_table( $constants['user'] );
} else {
// Should never happen.
echo '<p>', esc_html__( 'No constants found... this is really weird...', 'debug-bar-constants' ), '</p>';
}
}
} // End of class Debug_Bar_WP_Constants.
} // End of if class_exists wrapper.

View File

@@ -0,0 +1,131 @@
/* CSS for plugin: Debug Bar Constants */
#debug-menu-target-Debug_Bar_PHP_Constants h2 a,
#debug-menu-target-Debug_Bar_WP_Class_Constants h2 a {
text-decoration: none !important;
color: inherit !important;
}
#debug-menu-target-Debug_Bar_PHP_Constants h2:hover,
#debug-menu-target-Debug_Bar_WP_Class_Constants h2:hover {
text-shadow: 0 1px 1px rgba( 0, 0, 0, 0.9 );
background: #333;
-webkit-box-shadow: inset -3px 0 6px rgba( 0, 0, 0, 0.4 );
-moz-box-shadow: inset -3px 0 6px rgba( 0, 0, 0, 0.4 );
box-shadow: inset -3px 0 6px rgba( 0, 0, 0, 0.4 );
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
border: 1px solid #333;
}
#debug-menu-target-Debug_Bar_PHP_Constants h2:hover a,
#debug-menu-target-Debug_Bar_WP_Class_Constants h2:hover a {
color: #FFFFFF !important;
text-shadow: 0 1px 1px rgba( 0, 0, 0, 0.9 );
}
#debug-menu-target-Debug_Bar_PHP_Constants h3,
#debug-menu-target-Debug_Bar_WP_Class_Constants h3 {
font-family: georgia, times, serif;
font-size: 22px;
margin-top: 1.2em;
clear: both;
}
p.dbcwpc-info {
margin: 1em 0;
padding: 0.7em;
background-color: #D8D8D8;
-webkit-box-shadow: inset -3px 0 6px rgba( 0, 0, 0, 0.4 );
-moz-box-shadow: inset -3px 0 6px rgba( 0, 0, 0, 0.4 );
box-shadow: inset -3px 0 6px rgba( 0, 0, 0, 0.4 );
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
border: 1px solid #333333;
clear: both;
}
table.debug-bar-constants,
table.debug-bar-constants th,
table.debug-bar-constants td {
border: 0px none;
}
table.debug-bar-constants {
width: 100%;
border-collapse: collapse;
cell-padding: 1em;
clear: both;
line-height: 1.5;
font-size: 12px;
table-layout: auto;
}
table.debug-bar-constants thead th,
table.debug-bar-constants tfoot th {
padding: 0.7em 5px;
width: auto;
text-align: center;
}
table.debug-bar-constants thead th {
border-bottom: 1px solid #ccc;
}
table.debug-bar-constants tfoot th {
border-top: 1px solid #ccc;
}
table.debug-bar-constants th {
width: 35%;
font-weight: bold;
padding: 2px 2em 2px 5px;
vertical-align: top;
text-align: left;
}
table.debug-bar-constants td {
padding: 2px 5px;
width: 63%;
vertical-align: top;
}
table.debug-bar-constants tr:nth-child(2n+1) {
background-color: #E8E8E8;
}
/*
|--------------------------------------------------------------------------
| UItoTop jQuery Plugin 1.2
| http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
|--------------------------------------------------------------------------
*/
#toTop {
display: none;
text-decoration: none;
position: fixed;
bottom: 10px;
right: 10px;
overflow: hidden;
width: 51px;
height: 51px;
border: none;
text-indent: 100%;
background: url(../images/ui.totop.png) no-repeat left top;
z-index: 99001;
}
#toTopHover {
background: url(../images/ui.totop.png) no-repeat left -51px;
width: 51px;
height: 51px;
display: block;
overflow: hidden;
float: left;
opacity: 0;
-moz-opacity: 0;
filter: alpha(opacity = 0);
z-index: 99001;
}
#toTop:active, #toTop:focus {
outline: none;
}

View File

@@ -0,0 +1,2 @@
/* CSS for plugin: Debug Bar Constants */
#debug-menu-target-Debug_Bar_PHP_Constants h2 a,#debug-menu-target-Debug_Bar_WP_Class_Constants h2 a{text-decoration:none !important;color:inherit !important}#debug-menu-target-Debug_Bar_PHP_Constants h2:hover,#debug-menu-target-Debug_Bar_WP_Class_Constants h2:hover{text-shadow:0 1px 1px rgba(0,0,0,0.9);background:#333;-webkit-box-shadow:inset -3px 0 6px rgba(0,0,0,0.4);-moz-box-shadow:inset -3px 0 6px rgba(0,0,0,0.4);box-shadow:inset -3px 0 6px rgba(0,0,0,0.4);-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px;border:1px solid #333}#debug-menu-target-Debug_Bar_PHP_Constants h2:hover a,#debug-menu-target-Debug_Bar_WP_Class_Constants h2:hover a{color:#fff !important;text-shadow:0 1px 1px rgba(0,0,0,0.9)}#debug-menu-target-Debug_Bar_PHP_Constants h3,#debug-menu-target-Debug_Bar_WP_Class_Constants h3{font-family:georgia,times,serif;font-size:22px;margin-top:1.2em;clear:both}p.dbcwpc-info{margin:1em 0;padding:.7em;background-color:#d8d8d8;-webkit-box-shadow:inset -3px 0 6px rgba(0,0,0,0.4);-moz-box-shadow:inset -3px 0 6px rgba(0,0,0,0.4);box-shadow:inset -3px 0 6px rgba(0,0,0,0.4);-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border:1px solid #333;clear:both}table.debug-bar-constants,table.debug-bar-constants th,table.debug-bar-constants td{border:0 none}table.debug-bar-constants{width:100%;border-collapse:collapse;cell-padding:1em;clear:both;line-height:1.5;font-size:12px;table-layout:auto}table.debug-bar-constants thead th,table.debug-bar-constants tfoot th{padding:.7em 5px;width:auto;text-align:center}table.debug-bar-constants thead th{border-bottom:1px solid #ccc}table.debug-bar-constants tfoot th{border-top:1px solid #ccc}table.debug-bar-constants th{width:35%;font-weight:bold;padding:2px 2em 2px 5px;vertical-align:top;text-align:left}table.debug-bar-constants td{padding:2px 5px;width:63%;vertical-align:top}table.debug-bar-constants tr:nth-child(2n+1){background-color:#e8e8e8}#toTop{display:none;text-decoration:none;position:fixed;bottom:10px;right:10px;overflow:hidden;width:51px;height:51px;border:0;text-indent:100%;background:url(../images/ui.totop.png) no-repeat left top;z-index:99001}#toTopHover{background:url(../images/ui.totop.png) no-repeat left -51px;width:51px;height:51px;display:block;overflow:hidden;float:left;opacity:0;-moz-opacity:0;filter:alpha(opacity = 0);z-index:99001}#toTop:active,#toTop:focus{outline:0}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,165 @@
<?php
/**
* Debug Bar Constants, a WordPress plugin.
*
* @package WordPress\Plugins\Debug Bar Constants
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/Debug-Bar-Constants
* @version 2.0.0
*
* @copyright 2013-2018 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*
* @wordpress-plugin
* Plugin Name: Debug Bar Constants
* Plugin URI: https://wordpress.org/plugins/debug-bar-constants/
* Description: Debug Bar Constants adds new panels to Debug Bar that display all the defined constants for the current request. Requires "Debug Bar" plugin.
* Version: 2.0.0
* Author: Juliette Reinders Folmer
* Author URI: http://www.adviesenzo.nl/
* Depends: Debug Bar
* Text Domain: debug-bar-constants
* Domain Path: /languages
* Copyright: 2013-2018 Juliette Reinders Folmer
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! class_exists( 'Debug_Bar_Constants_Init' ) ) {
/**
* Initialize plugin.
*/
class Debug_Bar_Constants_Init {
/**
* Plugin name for use with text-domains and CSS classes.
*
* @var string
*/
const DBC_NAME = 'debug-bar-constants';
/**
* Initialize the plugin.
*
* @return void
*/
public static function init() {
/*
* Initialize the main class.
*
* @internal The wp_installing() function was introduced in WP 4.4.
*/
if ( ( function_exists( 'wp_installing' ) && wp_installing() === false )
|| ( ! function_exists( 'wp_installing' )
&& ( ! defined( 'WP_INSTALLING' ) || WP_INSTALLING === false ) )
) {
include_once plugin_dir_path( __FILE__ ) . 'class-debug-bar-constants.php';
$GLOBALS['debug_bar_constants'] = new Debug_Bar_Constants();
}
// Show admin notice & de-activate itself if debug-bar plugin not active.
add_action( 'admin_init', array( __CLASS__, 'has_debug_bar' ) );
add_action( 'init', array( __CLASS__, 'load_textdomain' ) );
}
/**
* Load the plugin text strings.
*
* Compatible with use of the plugin in the must-use plugins directory.
*
* {@internal No longer needed since WP 4.6, though the language loading in
* WP 4.6 only looks at the `wp-content/languages/` directory and disregards
* any translations which may be included with the plugin.
* This is acceptable for plugins hosted on org, especially if the plugin
* is new and never shipped with it's own translations, but not when the plugin
* is hosted elsewhere.
* Can be removed if/when the minimum required version for this plugin is ever
* upped to 4.6. The `languages` directory can be removed in that case too.
* See: {@link https://core.trac.wordpress.org/ticket/34213} and
* {@link https://core.trac.wordpress.org/ticket/34114} }}
*/
public static function load_textdomain() {
$domain = self::DBC_NAME;
if ( function_exists( '_load_textdomain_just_in_time' ) ) {
return;
}
if ( is_textdomain_loaded( $domain ) ) {
return;
}
$lang_path = dirname( plugin_basename( __FILE__ ) ) . '/languages';
if ( false === strpos( __FILE__, basename( WPMU_PLUGIN_DIR ) ) ) {
load_plugin_textdomain( $domain, false, $lang_path );
} else {
load_muplugin_textdomain( $domain, $lang_path );
}
}
/**
* Check for the Debug Bar plugin being installed & active.
*
* @return void
*/
public static function has_debug_bar() {
$file = plugin_basename( __FILE__ );
if ( is_admin()
&& ( ! class_exists( 'Debug_Bar' ) && current_user_can( 'activate_plugins' ) )
&& is_plugin_active( $file )
) {
add_action( 'admin_notices', array( __CLASS__, 'display_admin_notice' ) );
deactivate_plugins( $file, false, is_network_admin() );
// Add to recently active plugins list.
$insert = array(
$file => time(),
);
if ( ! is_network_admin() ) {
update_option( 'recently_activated', ( $insert + (array) get_option( 'recently_activated' ) ) );
} else {
update_site_option( 'recently_activated', ( $insert + (array) get_site_option( 'recently_activated' ) ) );
}
// Prevent trying to activate again on page reload.
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
}
/**
* Display admin notice about activation failure when dependency not found.
*
* @return void
*/
public static function display_admin_notice() {
echo '<div class="error"><p>';
printf(
/* translators: 1: strong open tag; 2: strong close tag; 3: link to plugin installation page; 4: link close tag. */
esc_html__( 'Activation failed: Debug Bar must be activated to use the %1$sDebug Bar Constants%2$s Plugin. %3$sVisit your plugins page to install & activate%4$s.', 'debug-bar-constants' ),
'<strong>',
'</strong>',
'<a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=debug+bar' ) ) . '">',
'</a>'
);
echo '</p></div>';
}
}
}
add_action( 'plugins_loaded', array( 'Debug_Bar_Constants_Init', 'init' ) );

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,7 @@
debug-bar-pretty-output
=======================
Helper classes for WordPress Debug Bar plugins.
* `Debug_Bar_Pretty_Output` - pretty prints variables.
* `Debug_Bar_List_PHP_Classes` - lists all PHP Core and Extension classes.

View File

@@ -0,0 +1,690 @@
<?php
/**
* Debug Bar Pretty Output - Helper class for Debug Bar plugins.
*
* Used by the following plugins:
* - Debug Bar Constants
* - Debug Bar Cron (1.0+)
* - Debug Bar Post Types
* - Debug Bar Taxonomies
* - Debug Bar WP Objects (unreleased)
* - Debug Bar Screen Info
*
* @package Debug Bar Pretty Output
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/debug-bar-pretty-output
* @version 1.8.0
*
* @copyright 2013-2018 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher.
*/
if ( ! class_exists( 'Debug_Bar_Pretty_Output' ) && class_exists( 'Debug_Bar_Panel' ) ) {
/**
* Class Debug_Bar_Pretty_Output.
*/
class Debug_Bar_Pretty_Output {
const VERSION = '1.8.0';
const NAME = 'db-pretty-output';
const TBODY_MAX = 10;
/**
* Whether to limit how deep the variable printing will recurse into an array/object.
*
* @var bool|int Set to a positive integer to limit the recursion depth to that depth.
* Defaults to false.
*
* @since 1.4
*/
protected static $limit_recursion = false;
/**
* Set the recursion limit.
*
* Always make sure you also unset the limit after you're done with this class so as not to impact
* other plugins which may be using this printing class.
*
* @since 1.4
*
* @param int $depth Maximum recursion depth.
*/
public static function limit_recursion( $depth ) {
if ( is_int( $depth ) && $depth > 0 ) {
self::$limit_recursion = $depth;
}
}
/**
* Reset the recusion limit to it's default (unlimited).
*
* @since 1.4
*/
public static function unset_recursion_limit() {
self::$limit_recursion = false;
}
/**
* A not-so-pretty method to show pretty output ;-).
*
* @since 1.3
*
* @param mixed $var Variable to show.
* @param string $title Optional. Variable title.
* @param bool $escape Optional. Whether to character escape the textual output.
* @param string $space Internal. Indentation spacing.
* @param bool $short Internal. Short or normal annotation.
* @param int $depth Internal. The depth of the current recursion.
*
* @return string
*/
public static function get_output( $var, $title = '', $escape = true, $space = '', $short = false, $depth = 0 ) {
$output = '';
if ( '' === $space ) {
$output .= '<div class="db-pretty-var">';
}
if ( is_string( $title ) && '' !== $title ) {
$output .= '<h4 style="clear: both;">' . ( ( true === $escape ) ? esc_html( $title ) : $title ) . "</h4>\n";
}
if ( is_array( $var ) ) {
if ( ! empty( $var ) ) {
$output .= 'Array: <br />' . $space . '(<br />';
if ( is_int( self::$limit_recursion ) && $depth > self::$limit_recursion ) {
/* translators: %d = number used as a limit. */
$output .= '... ( ' . sprintf( __( 'output limited at recursion depth %d', 'db-pretty-output' ), self::$limit_recursion ) . ')<br />';
} else {
if ( true !== $short ) {
$spacing = $space . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
} else {
$spacing = $space . '&nbsp;&nbsp;';
}
foreach ( $var as $key => $value ) {
$output .= $spacing . '[' . ( ( true === $escape ) ? esc_html( $key ) : $key );
if ( true !== $short ) {
$output .= ' ';
switch ( true ) {
case ( is_string( $key ) ):
$output .= '<span style="color: #336600;;"><b><i>(string)</i></b></span>';
break;
case ( is_int( $key ) ):
$output .= '<span style="color: #FF0000;"><b><i>(int)</i></b></span>';
break;
case ( is_float( $key ) ):
$output .= '<span style="color: #990033;"><b><i>(float)</i></b></span>';
break;
default:
$output .= '(' . __( 'unknown', 'db-pretty-output' ) . ')';
break;
}
}
$output .= '] => ';
$output .= self::get_output( $value, '', $escape, $spacing, $short, ++$depth );
}
unset( $key, $value );
}
$output .= $space . ')<br />';
} else {
$output .= 'array()<br />';
}
} elseif ( is_string( $var ) ) {
$output .= self::get_pretty_string( $var, $short, $escape );
} elseif ( is_bool( $var ) ) {
$output .= self::get_pretty_bool( $var, $short );
} elseif ( is_int( $var ) ) {
$output .= self::get_pretty_int( $var, $short );
} elseif ( is_float( $var ) ) {
$output .= self::get_pretty_float( $var, $short );
} elseif ( is_null( $var ) ) {
$output .= self::get_pretty_null( $var, $short );
} elseif ( is_resource( $var ) ) {
$output .= self::get_pretty_resource( $var, $short );
} elseif ( is_object( $var ) ) {
$output .= 'Object: <br />' . $space . '(<br />';
if ( is_int( self::$limit_recursion ) && $depth > self::$limit_recursion ) {
/* translators: %d = number used as a limit. */
$output .= '... ( ' . sprintf( __( 'output limited at recursion depth %d', 'db-pretty-output' ), self::$limit_recursion ) . ')<br />';
} else {
if ( true !== $short ) {
$spacing = $space . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
} else {
$spacing = $space . '&nbsp;&nbsp;';
}
$output .= self::get_object_info( $var, $escape, $spacing, $short, ++$depth );
}
$output .= $space . ')<br /><br />';
} else {
$output .= esc_html__( 'I haven\'t got a clue what this is: ', 'db-pretty-output' ) . gettype( $var ) . '<br />';
}
if ( '' === $space ) {
$output .= '</div>';
}
return $output;
}
/**
* Convert a string to pretty output.
*
* @since 1.6.0
*
* @param string $string The string to make pretty.
* @param bool $short Short or normal annotation.
* @param bool $escape Whether to character escape the textual output.
*
* @return string
*/
private static function get_pretty_string( $string, $short = false, $escape = true ) {
$output = '<span style="color: #336600;">';
if ( true !== $short ) {
$output .= '<b><i>string[' . strlen( $string ) . ']</i></b> : ';
}
$output .= '&lsquo;';
if ( true === $escape ) {
$output .= str_replace( ' ', ' &nbsp;', esc_html( $string ) );
} else {
$output .= str_replace( ' ', ' &nbsp;', $string );
}
$output .= '&rsquo;</span><br />';
return $output;
}
/**
* Convert a boolean to pretty output.
*
* @since 1.6.0
*
* @param bool $bool The boolean variable to make pretty.
* @param bool $short Short or normal annotation.
*
* @return string
*/
private static function get_pretty_bool( $bool, $short = false ) {
$output = '<span style="color: #000099;">';
if ( true !== $short ) {
$output .= '<b><i>bool</i></b> : ' . $bool . ' ( = ';
} else {
$output .= '<b><i>b</i></b> ';
}
$output .= '<i>';
if ( false === $bool ) {
$output .= '<span style="color: #FF0000;">false</span>';
} elseif ( true === $bool ) {
$output .= '<span style="color: #336600;">true</span>';
} else {
$output .= __( 'undetermined', 'db-pretty-output' );
}
$output .= ' </i>';
if ( true !== $short ) {
$output .= ')';
}
$output .= '</span><br />';
return $output;
}
/**
* Convert an integer to pretty output.
*
* @since 1.6.0
*
* @param int $int The integer to make pretty.
* @param bool $short Short or normal annotation.
*
* @return string
*/
private static function get_pretty_int( $int, $short = false ) {
$output = '<span style="color: #FF0000;">';
if ( true !== $short ) {
$output .= '<b><i>int</i></b> : ';
}
if ( 0 === $int ) {
$output .= '<b>' . $int . '</b>';
} else {
$output .= $int;
}
$output .= "</span><br />\n";
return $output;
}
/**
* Convert a float to pretty output.
*
* @since 1.6.0
*
* @param float $float The float to make pretty.
* @param bool $short Short or normal annotation.
*
* @return string
*/
private static function get_pretty_float( $float, $short = false ) {
$output = '<span style="color: #990033;">';
if ( true !== $short ) {
$output .= '<b><i>float</i></b> : ';
}
$output .= $float . '</span><br />';
return $output;
}
/**
* Convert a null value to pretty output.
*
* @since 1.6.0
*
* @param null $null The null value to make pretty.
* @param bool $short Short or normal annotation.
*
* @return string
*/
private static function get_pretty_null( $null, $short = false ) {
$output = '<span style="color: #666666;">';
if ( true !== $short ) {
$output .= '<b><i>';
}
$output .= 'null';
if ( true !== $short ) {
$output .= '</i></b> : ' . $null . ' ( = <i>NULL</i> )';
}
$output .= '</span><br />';
return $output;
}
/**
* Convert a resource to pretty output.
*
* @since 1.6.0
*
* @param resource $resource The resource to make pretty.
* @param bool $short Short or normal annotation.
*
* @return string
*/
private static function get_pretty_resource( $resource, $short = false ) {
$output = '<span style="color: #666666;">';
if ( true !== $short ) {
$output .= '<b><i>resource</i></b> : ';
}
$output .= $resource;
if ( true !== $short ) {
$output .= ' ( = <i>RESOURCE</i> )';
}
$output .= '</span><br />';
return $output;
}
/**
* Retrieve pretty output about objects.
*
* @todo: get object properties to show the variable type on one line with the 'property'.
* @todo: get scope of methods and properties.
*
* @since 1.3
*
* @param object $obj Object to show.
* @param bool $escape Internal. Whether to character escape the textual output.
* @param string $space Internal. Indentation spacing.
* @param bool $short Internal. Short or normal annotation.
* @param int $depth Internal. The depth of the current recursion.
*
* @return string
*/
private static function get_object_info( $obj, $escape, $space, $short, $depth = 0 ) {
$output = '';
$output .= $space . '<b><i>Class</i></b>: ' . esc_html( get_class( $obj ) ) . ' (<br />';
if ( true !== $short ) {
$spacing = $space . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
} else {
$spacing = $space . '&nbsp;&nbsp;';
}
$properties = get_object_vars( $obj );
if ( ! empty( $properties ) && is_array( $properties ) ) {
foreach ( $properties as $var => $val ) {
if ( is_array( $val ) ) {
$output .= $spacing . '<b><i>property</i></b>: ' . esc_html( $var ) . "<b><i> (array)</i></b>\n";
$output .= self::get_output( $val, '', $escape, $spacing, $short, $depth );
} else {
$output .= $spacing . '<b><i>property</i></b>: ' . esc_html( $var ) . ' = ';
$output .= self::get_output( $val, '', $escape, $spacing, $short, $depth );
}
}
}
unset( $properties, $var, $val );
$methods = get_class_methods( $obj );
if ( ! empty( $methods ) && is_array( $methods ) ) {
foreach ( $methods as $method ) {
$output .= $spacing . '<b><i>method</i></b>: ' . esc_html( $method ) . "<br />\n";
}
}
unset( $methods, $method );
$output .= $space . ')<br /><br />';
return $output;
}
/**
* Helper Function specific to the Debug bar plugin.
* Retrieves html string of properties in a table and methods in an unordered list.
*
* @since 1.3
*
* @param object $obj Object for which to show the properties and methods.
* @param bool $is_sub Internal. Top level or nested object.
*
* @reurn string
*/
public static function get_ooutput( $obj, $is_sub = false ) {
$properties = get_object_vars( $obj );
$methods = get_class_methods( $obj );
$output = '';
if ( false === $is_sub ) {
$output .= '
<h2><span>' . esc_html__( 'Properties:', 'db-pretty-output' ) . '</span>' . count( $properties ) . '</h2>';
$output .= '
<h2><span>' . esc_html__( 'Methods:', 'db-pretty-output' ) . '</span>' . count( $methods ) . '</h2>';
}
// Properties.
if ( ! empty( $properties ) && is_array( $properties ) ) {
$h = 'h4';
if ( false === $is_sub ) {
$h = 'h3';
}
$output .= '
<' . $h . '>' . esc_html__( 'Object Properties:', 'db-pretty-output' ) . '</' . $h . '>';
uksort( $properties, 'strnatcasecmp' );
$output .= self::get_table( $properties, __( 'Property', 'db-pretty-output' ), __( 'Value', 'db-pretty-output' ) );
}
// Methods.
if ( ! empty( $methods ) && is_array( $methods ) ) {
$output .= '
<h3>' . esc_html__( 'Object Methods:', 'db-pretty-output' ) . '</h3>
<ul class="' . sanitize_html_class( self::NAME ) . '">';
uksort( $methods, 'strnatcasecmp' );
foreach ( $methods as $method ) {
$output .= '<li>' . esc_html( $method ) . '()</li>';
}
unset( $method );
$output .= '</ul>';
}
return $output;
}
/**
* Retrieve the table output.
*
* @since 1.3
*
* @param array $array Array to be shown in the table.
* @param string $col1 Label for the first table column.
* @param string $col2 Label for the second table column.
* @param string|array $class One or more CSS classes to add to the table.
*
* @return string
*/
public static function get_table( $array, $col1, $col2, $class = null ) {
$classes = 'debug-bar-table ' . sanitize_html_class( self::NAME );
if ( isset( $class ) ) {
if ( is_string( $class ) && '' !== $class ) {
$classes .= ' ' . sanitize_html_class( $class );
} elseif ( ! empty( $class ) && is_array( $class ) ) {
$class = array_map( $class, 'sanitize_html_class' );
$classes = $classes . ' ' . implode( ' ', $class );
}
}
$col1 = ( is_string( $col1 ) ) ? $col1 : __( 'Key', 'db-pretty-output' );
$col2 = ( is_string( $col2 ) ) ? $col2 : __( 'Value', 'db-pretty-output' );
$double_it = false;
if ( count( $array ) > self::TBODY_MAX ) {
$double_it = true;
}
$return = self::get_table_start( $col1, $col2, $classes, $double_it );
$return .= self::get_table_rows( $array );
$return .= self::get_table_end();
return $return;
}
/**
* Generate the table header.
*
* @param string $col1 Label for the first table column.
* @param string $col2 Label for the second table column.
* @param string|array $class One or more CSS classes to add to the table.
* @param bool $double_it Whether to repeat the table headers as table footer.
*/
private static function get_table_start( $col1, $col2, $class = null, $double_it = false ) {
$class_string = '';
if ( is_string( $class ) && '' !== $class ) {
$class_string = ' class="' . esc_attr( $class ) . '"';
}
$output = '
<table' . $class_string . '>
<thead>
<tr>
<th>' . esc_html( $col1 ) . '</th>
<th>' . esc_html( $col2 ) . '</th>
</tr>
</thead>';
if ( true === $double_it ) {
$output .= '
<tfoot>
<tr>
<th>' . esc_html( $col1 ) . '</th>
<th>' . esc_html( $col2 ) . '</th>
</tr>
</tfoot>';
}
$output .= '
<tbody>';
return apply_filters( 'db_pretty_output_table_header', $output );
}
/**
* Generate table rows.
*
* @param array $array Array to be shown in the table.
*
* @return string
*/
private static function get_table_rows( $array ) {
$output = '';
foreach ( $array as $key => $value ) {
$output .= self::get_table_row( $key, $value );
}
return $output;
}
/**
* Generate individual table row.
*
* @param mixed $key Item key to use a row label.
* @param mixed $value Value to show.
*
* @return string
*/
private static function get_table_row( $key, $value ) {
$output = '
<tr>
<th>' . esc_html( $key ) . '</th>
<td>';
if ( is_object( $value ) ) {
$output .= self::get_ooutput( $value, true );
} else {
$output .= self::get_output( $value, '', true, '', false );
}
$output .= '</td>
</tr>';
return apply_filters( 'db_pretty_output_table_body_row', $output, $key );
}
/**
* Generate table closing.
*
* @return string
*/
private static function get_table_end() {
return '
</tbody>
</table>
';
}
/**
* Print pretty output.
*
* @deprecated since v1.3 in favour of get_output().
*
* @param mixed $var Variable to show.
* @param string $title Optional. Variable title.
* @param bool $escape Optional. Whether to character escape the textual output.
* @param string $space Internal. Indentation spacing.
* @param bool $short Internal. Short or normal annotation.
* @param string $deprecated Deprecated argument. Do not use.
*/
public static function output( $var, $title = '', $escape = false, $space = '', $short = false, $deprecated = null ) {
_deprecated_function( __CLASS__ . '::' . __METHOD__, __CLASS__ . ' 1.3', __CLASS__ . '::get_output() ' . esc_html__( 'or even better: upgrade your Debug Bar plugins to their current version', 'db-pretty-output' ) );
echo self::get_output( $var, $title, $escape, $space, $short ); // WPCS: xss ok.
}
/**
* Print pretty output about objects.
*
* @deprecated since v1.3 in favour of get_object_info().
*
* @param object $obj Object to show.
* @param bool $escape Internal. Whether to character escape the textual output.
* @param string $space Internal. Indentation spacing.
* @param bool $short Internal. Short or normal annotation.
* @param string $deprecated Deprecated argument. Do not use.
*
* @return void
*/
private static function object_info( $obj, $escape, $space, $short, $deprecated = null ) {
_deprecated_function( __CLASS__ . '::' . __METHOD__, __CLASS__ . ' 1.3', __CLASS__ . '::get_object_info() ' . esc_html__( 'or even better: upgrade your Debug Bar plugins to their current version', 'db-pretty-output' ) );
echo self::get_object_info( $obj, $escape, $space, $short ); // WPCS: xss ok.
}
/**
* Helper Function specific to the Debug bar plugin.
* Outputs properties in a table and methods in an unordered list.
*
* @deprecated since v1.3 in favour of get_ooutput().
*
* @param object $obj Object for which to show the properties and methods.
* @param string $deprecated Deprecated argument. Do not use.
* @param bool $is_sub Internal. Top level or nested object.
*
* @return void
*/
public static function ooutput( $obj, $deprecated = null, $is_sub = false ) {
_deprecated_function( __CLASS__ . '::' . __METHOD__, __CLASS__ . ' 1.3', __CLASS__ . '::get_ooutput() ' . esc_html__( 'or even better: upgrade your Debug Bar plugins to their current version', 'db-pretty-output' ) );
echo self::get_ooutput( $obj, $is_sub ); // WPCS: xss ok.
}
/**
* Render the table output.
*
* @deprecated since v1.3 in favour of get_table().
*
* @param array $array Array to be shown in the table.
* @param string $col1 Label for the first table column.
* @param string $col2 Label for the second table column.
* @param string|array $class One or more CSS classes to add to the table.
* @param string $deprecated Deprecated argument. Do not use.
*
* @return void
*/
public static function render_table( $array, $col1, $col2, $class = null, $deprecated = null ) {
_deprecated_function( __CLASS__ . '::' . __METHOD__, __CLASS__ . ' 1.3', __CLASS__ . '::get_table() ' . esc_html__( 'or even better: upgrade your Debug Bar plugins to their current version', 'db-pretty-output' ) );
echo self::get_table( $array, $col1, $col2, $class ); // WPCS: xss ok.
}
} // End of class Debug_Bar_Pretty_Output.
/* Load text strings for this class. */
if ( function_exists( 'is_textdomain_loaded' ) && function_exists( 'load_plugin_textdomain' ) ) {
if ( ! is_textdomain_loaded( 'db-pretty-output' ) ) {
load_plugin_textdomain( 'db-pretty-output', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
}
} // End of if class_exists wrapper.

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,128 @@
msgid ""
msgstr ""
"Project-Id-Version: Debug Bar Pretty Output\n"
"POT-Creation-Date: 2016-04-11 20:36+0200\n"
"PO-Revision-Date: 2016-04-11 20:36+0200\n"
"Last-Translator: Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>\n"
"Language-Team: Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>\n"
"Language: nl_NL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.7\n"
"X-Poedit-KeywordsList: __;esc_html__;esc_html_e;esc_attr__;esc_attr_e;_e\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPath-1: ..\n"
#: class-debug-bar-pretty-output.php:101 class-debug-bar-pretty-output.php:208
#, php-format
msgid "output limited at recursion depth %d"
msgstr "output beperkt tot recursiediepte %d"
#: class-debug-bar-pretty-output.php:128
msgid "unknown"
msgstr "onbekend"
#: class-debug-bar-pretty-output.php:162
msgid "undetermined"
msgstr "niet bepaald"
#: class-debug-bar-pretty-output.php:222
msgid "I haven't got a clue what this is: "
msgstr "Geen idee wat dit is:"
#: class-debug-bar-pretty-output.php:307
msgid "Properties:"
msgstr "Eigenschappen:"
#: class-debug-bar-pretty-output.php:310
msgid "Methods:"
msgstr "Methoden:"
#: class-debug-bar-pretty-output.php:321
msgid "Object Properties:"
msgstr "Object eigenschappen:"
#: class-debug-bar-pretty-output.php:324
msgid "Property"
msgstr "Eigenschap"
#: class-debug-bar-pretty-output.php:324 class-debug-bar-pretty-output.php:371
msgid "Value"
msgstr "Waarde"
#: class-debug-bar-pretty-output.php:330
msgid "Object Methods:"
msgstr "Object Methoden:"
#: class-debug-bar-pretty-output.php:370
msgid "Key"
msgstr "Sleutel"
#: class-debug-bar-pretty-output.php:493 class-debug-bar-pretty-output.php:512
#: class-debug-bar-pretty-output.php:530 class-debug-bar-pretty-output.php:549
msgid "or even better: upgrade your Debug Bar plugins to their current version"
msgstr ""
"of better nog: upgrade de geïnstalleerde Debug Bar plugins naar hun huidige "
"versie"
#~ msgid "Empty array()"
#~ msgstr "Leeg array()"
#~ msgid "Name"
#~ msgstr "Naam"
#~ msgid "WP Constants"
#~ msgstr "WP Constants"
#~ msgid "Constants within WP:"
#~ msgstr "Constants binnen WP:"
#~ msgid "No constants found... this is really weird..."
#~ msgstr "Geen constants gevonden... dit is vreemd..."
#~ msgid "WP Class Constants"
#~ msgstr "WP Class Constants"
#~ msgid ""
#~ "<strong>Please note</strong>: these may be both native WordPress classes "
#~ "as well as classes which may be declared by plugins or Themes.<br />You "
#~ "can use these constants in your code using <code>class_name::"
#~ "constant_name</code>."
#~ msgstr ""
#~ "<strong>Toelichting:</strong>: dit kunnen zowel de WordPress eigen "
#~ "classes zijn als ook de classes welke door plugins of themes gedeclareerd "
#~ "zijn.<br />Je kan deze constants in je eigen code gebruiken door middel "
#~ "van <code>class_name::constant_name</code>."
#~ msgid "See the <a %s>FAQ</a> for more information."
#~ msgstr "Lees de <a %s>FAQ</a> voor meer informatie."
#~ msgid "Constants:"
#~ msgstr "Constants:"
#~ msgid "No classes nor class constants found... this is kinda strange..."
#~ msgstr "Geen classes of class constants gevonden... dit is vreemd..."
#~ msgid "PHP Constants"
#~ msgstr "PHP Constants"
#~ msgid "Visit the PHP manual page about the %s constants."
#~ msgstr "Bezoek de PHP handleiding pagina over de %s constants."
#~ msgid "No PHP constants found... this is really weird..."
#~ msgstr "Geen PHP constants gevonden... dit is vreemd..."
#~ msgid ""
#~ "Debug Bar must be activated to use the Debug Bar Constants Plugin. <a "
#~ "href=\"%s\">Visit your plugins page to activate</a>."
#~ msgstr ""
#~ "Debug Bar moet geactiveerd zijn om de Debug Bar Constants Plugin te "
#~ "kunnen gebruiken. <a href=\"%s\">Ga naar de plugins pagina om deze te "
#~ "activeren</a>."
#~ msgid "Nothing to display"
#~ msgstr "Niets om weer te geven"

View File

@@ -0,0 +1,71 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Debug Bar Pretty Output\n"
"POT-Creation-Date: 2016-04-11 20:36+0200\n"
"PO-Revision-Date: 2015-04-18 14:37+0100\n"
"Last-Translator: Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>\n"
"Language-Team: Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.7\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPathExcluded-0: *.js\n"
#: class-debug-bar-pretty-output.php:101 class-debug-bar-pretty-output.php:208
#, php-format
msgid "output limited at recursion depth %d"
msgstr ""
#: class-debug-bar-pretty-output.php:128
msgid "unknown"
msgstr ""
#: class-debug-bar-pretty-output.php:162
msgid "undetermined"
msgstr ""
#: class-debug-bar-pretty-output.php:222
msgid "I haven't got a clue what this is: "
msgstr ""
#: class-debug-bar-pretty-output.php:307
msgid "Properties:"
msgstr ""
#: class-debug-bar-pretty-output.php:310
msgid "Methods:"
msgstr ""
#: class-debug-bar-pretty-output.php:321
msgid "Object Properties:"
msgstr ""
#: class-debug-bar-pretty-output.php:324
msgid "Property"
msgstr ""
#: class-debug-bar-pretty-output.php:324 class-debug-bar-pretty-output.php:371
msgid "Value"
msgstr ""
#: class-debug-bar-pretty-output.php:330
msgid "Object Methods:"
msgstr ""
#: class-debug-bar-pretty-output.php:370
msgid "Key"
msgstr ""
#: class-debug-bar-pretty-output.php:493 class-debug-bar-pretty-output.php:512
#: class-debug-bar-pretty-output.php:530 class-debug-bar-pretty-output.php:549
msgid "or even better: upgrade your Debug Bar plugins to their current version"
msgstr ""

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,70 @@
/*
|--------------------------------------------------------------------------
| UItoTop jQuery Plugin 1.2 by Matt Varone
| http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
|--------------------------------------------------------------------------
*/
(function($){
$.fn.UItoTop = function(options) {
var defaults = {
text: 'To Top',
min: 200,
inDelay:600,
outDelay:400,
containerID: 'toTop',
containerHoverID: 'toTopHover',
scrollSpeed: 1200,
easingType: 'linear'
},
settings = $.extend(defaults, options),
containerIDhash = '#' + settings.containerID,
containerHoverIDHash = '#'+settings.containerHoverID;
$('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');
$(containerIDhash).hide().on('click.UItoTop',function(){
$('#debug-menu-targets').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType);
$('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType);
return false;
})
.prepend('<span id="'+settings.containerHoverID+'"></span>')
.hover(function() {
$(containerHoverIDHash, this).stop().animate({
'opacity': 1
}, 600, 'linear');
}, function() {
$(containerHoverIDHash, this).stop().animate({
'opacity': 0
}, 700, 'linear');
});
$('#debug-menu-targets').scroll(function() {
var sd = $('#debug-menu-targets').scrollTop();
if(typeof document.body.style.maxHeight === "undefined") {
$(containerIDhash).css({
'position': 'absolute',
'top': sd + $(window).height() - 50
});
}
if ( sd > settings.min ) {
$(containerIDhash).fadeIn(settings.inDelay);
}
else {
$(containerIDhash).fadeOut(settings.Outdelay);
}
});
};
})(jQuery);
jQuery(document).ready(function() {
/*
var defaults = {
containerID: 'toTop', // fading element id
containerHoverID: 'toTopHover', // fading element hover id
scrollSpeed: 1200,
easingType: 'linear'
};
*/
jQuery('#debug-menu-target-Debug_Bar_PHP_Constants').UItoTop({ easingType: 'swing', scrollSpeed: 300 });
});

View File

@@ -0,0 +1,2 @@
/* UItoTop jQuery Plugin 1.2 | Matt Varone | http://www.mattvarone.com/web-design/uitotop-jquery-plugin */
(function($){$.fn.UItoTop=function(options){var defaults={text:'To Top',min:200,inDelay:600,outDelay:400,containerID:'toTop',containerHoverID:'toTopHover',scrollSpeed:1200,easingType:'linear'},settings=$.extend(defaults,options),containerIDhash='#'+settings.containerID,containerHoverIDHash='#'+settings.containerHoverID;$('body').append('<a href="#" id="'+settings.containerID+'">'+settings.text+'</a>');$(containerIDhash).hide().on('click.UItoTop',function(){$('#debug-menu-targets').animate({scrollTop:0},settings.scrollSpeed,settings.easingType);$('#'+settings.containerHoverID,this).stop().animate({'opacity':0},settings.inDelay,settings.easingType);return false}).prepend('<span id="'+settings.containerHoverID+'"></span>').hover(function(){$(containerHoverIDHash,this).stop().animate({'opacity':1},600,'linear')},function(){$(containerHoverIDHash,this).stop().animate({'opacity':0},700,'linear')});$('#debug-menu-targets').scroll(function(){var sd=$('#debug-menu-targets').scrollTop();if(typeof document.body.style.maxHeight==="undefined"){$(containerIDhash).css({'position':'absolute','top':sd+$(window).height()-50})}if(sd>settings.min){$(containerIDhash).fadeIn(settings.inDelay)}else{$(containerIDhash).fadeOut(settings.Outdelay)}})}})(jQuery);jQuery(document).ready(function(){jQuery('#debug-menu-target-Debug_Bar_PHP_Constants').UItoTop({easingType:'swing',scrollSpeed:300})});

View File

@@ -0,0 +1,22 @@
# UItoTop jQuery Plugin
http://www.mattvarone.com/web-design/uitotop-jquery-plugin/
Ver 1.2
## License
Copyright (C) 2010 Matt Varone
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 <http://www.gnu.org/licenses/>.

View File

@@ -0,0 +1,122 @@
msgid ""
msgstr ""
"Project-Id-Version: Debug Bar Constants - a WordPress Plugin\n"
"POT-Creation-Date: 2018-01-16 01:23+0100\n"
"PO-Revision-Date: 2018-01-16 01:24+0100\n"
"Last-Translator: Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>\n"
"Language-Team: Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>\n"
"Language: nl_NL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.5\n"
"X-Poedit-KeywordsList: __;esc_html__;esc_html_e;esc_attr__;esc_attr_e;_e\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPath-1: ..\n"
#: class-debug-bar-constants-panel.php:56
msgid "Name"
msgstr "Naam"
#: class-debug-bar-constants-panel.php:57
msgid "Value"
msgstr "Waarde"
#: class-debug-bar-php-constants.php:33
msgid "PHP Constants"
msgstr "PHP Constants"
#: class-debug-bar-php-constants.php:60
#, php-format
msgid "Visit the PHP manual page about the %s constants."
msgstr "Bezoek de PHP handleiding pagina over de %s constants."
#: class-debug-bar-php-constants.php:71
#: class-debug-bar-wp-class-constants.php:97
msgid "Constants:"
msgstr "Constants:"
#: class-debug-bar-php-constants.php:80
msgid "No PHP constants found... this is really weird..."
msgstr "Geen PHP constants gevonden... dit is vreemd..."
#: class-debug-bar-wp-class-constants.php:33
msgid "WP Class Constants"
msgstr "WP Class Constants"
#: class-debug-bar-wp-class-constants.php:76
#, php-format
msgid ""
"%1$sPlease note%2$s: these may be both native WordPress classes as well as "
"classes which may be declared by plugins or themes."
msgstr ""
"%1$sToelichting%2$s: dit kunnen zowel de WordPress eigen classes zijn als "
"ook de classes welke door plugins of themes gedeclareerd zijn."
#: class-debug-bar-wp-class-constants.php:83
#, php-format
msgid "You can use these constants in your code using %1$s."
msgstr "Je kan deze constants in je eigen code gebruiken door middel van %1$s."
#: class-debug-bar-wp-class-constants.php:89
#, php-format
msgid "See the %1$sFAQ%2$s for more information."
msgstr "Lees de %1$sFAQ%2$s voor meer informatie."
#: class-debug-bar-wp-class-constants.php:104
msgid "No classes nor class constants found... this is kinda strange..."
msgstr "Geen classes of class constants gevonden... dit is vreemd..."
#: class-debug-bar-wp-constants.php:33
msgid "WP Constants"
msgstr "WP Constants"
#: class-debug-bar-wp-constants.php:53
msgid "Constants within WP:"
msgstr "Constants binnen WP:"
#: class-debug-bar-wp-constants.php:58
msgid "No constants found... this is really weird..."
msgstr "Geen constants gevonden... dit is vreemd..."
#. translators: 1: strong open tag; 2: strong close tag; 3: link to plugin installation page; 4: link close tag.
#: debug-bar-constants.php:154
#, php-format
msgid ""
"Activation failed: Debug Bar must be activated to use the %1$sDebug Bar "
"Constants%2$s Plugin. %3$sVisit your plugins page to install & activate%4$s."
msgstr ""
"De Debug Bar plugin moet geactiveerd zijn om de %1$sDebug Bar Constants "
"Plugin%2$s te kunnen gebruiken. %3$sGa naar de plugins pagina om deze te "
"activeren%4$s."
#. Plugin Name of the plugin/theme
msgid "Debug Bar Constants"
msgstr "Debug Bar Constants"
#. Plugin URI of the plugin/theme
msgid "https://wordpress.org/plugins/debug-bar-constants/"
msgstr "https://wordpress.org/plugins/debug-bar-constants/"
#. Description of the plugin/theme
msgid ""
"Debug Bar Constants adds new panels to Debug Bar that display all the "
"defined constants for the current request. Requires \"Debug Bar\" plugin."
msgstr ""
"Debug Bar Constants voegt nieuwe panelen toe aan de Debug Bar welke inzicht "
"geven in all gedefinieerde constants voor de huidige pagina. Vereist gebruik "
"van de \"Debug Bar\" plugin."
#. Author of the plugin/theme
msgid "Juliette Reinders Folmer"
msgstr "Juliette Reinders Folmer"
#. Author URI of the plugin/theme
msgid "http://www.adviesenzo.nl/"
msgstr "http://www.adviesenzo.nl/"
#~ msgid "Nothing to display"
#~ msgstr "Niets om weer te geven"

View File

@@ -0,0 +1,116 @@
#, fuzzy
msgid ""
msgstr ""
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
"Project-Id-Version: Debug Bar Constants\n"
"POT-Creation-Date: 2018-01-16 01:23+0100\n"
"PO-Revision-Date: 2017-06-26 16:11+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.5\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
"X-Poedit-WPHeader: debug-bar-constants.php\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPathExcluded-0: *.js\n"
"X-Poedit-SearchPathExcluded-1: inc\n"
#: class-debug-bar-constants-panel.php:56
msgid "Name"
msgstr ""
#: class-debug-bar-constants-panel.php:57
msgid "Value"
msgstr ""
#: class-debug-bar-php-constants.php:33
msgid "PHP Constants"
msgstr ""
#: class-debug-bar-php-constants.php:60
#, php-format
msgid "Visit the PHP manual page about the %s constants."
msgstr ""
#: class-debug-bar-php-constants.php:71
#: class-debug-bar-wp-class-constants.php:97
msgid "Constants:"
msgstr ""
#: class-debug-bar-php-constants.php:80
msgid "No PHP constants found... this is really weird..."
msgstr ""
#: class-debug-bar-wp-class-constants.php:33
msgid "WP Class Constants"
msgstr ""
#: class-debug-bar-wp-class-constants.php:76
#, php-format
msgid ""
"%1$sPlease note%2$s: these may be both native WordPress classes as well as "
"classes which may be declared by plugins or themes."
msgstr ""
#: class-debug-bar-wp-class-constants.php:83
#, php-format
msgid "You can use these constants in your code using %1$s."
msgstr ""
#: class-debug-bar-wp-class-constants.php:89
#, php-format
msgid "See the %1$sFAQ%2$s for more information."
msgstr ""
#: class-debug-bar-wp-class-constants.php:104
msgid "No classes nor class constants found... this is kinda strange..."
msgstr ""
#: class-debug-bar-wp-constants.php:33
msgid "WP Constants"
msgstr ""
#: class-debug-bar-wp-constants.php:53
msgid "Constants within WP:"
msgstr ""
#: class-debug-bar-wp-constants.php:58
msgid "No constants found... this is really weird..."
msgstr ""
#. translators: 1: strong open tag; 2: strong close tag; 3: link to plugin installation page; 4: link close tag.
#: debug-bar-constants.php:154
#, php-format
msgid ""
"Activation failed: Debug Bar must be activated to use the %1$sDebug Bar "
"Constants%2$s Plugin. %3$sVisit your plugins page to install & activate%4$s."
msgstr ""
#. Plugin Name of the plugin/theme
msgid "Debug Bar Constants"
msgstr ""
#. Plugin URI of the plugin/theme
msgid "https://wordpress.org/plugins/debug-bar-constants/"
msgstr ""
#. Description of the plugin/theme
msgid ""
"Debug Bar Constants adds new panels to Debug Bar that display all the "
"defined constants for the current request. Requires \"Debug Bar\" plugin."
msgstr ""
#. Author of the plugin/theme
msgid "Juliette Reinders Folmer"
msgstr ""
#. Author URI of the plugin/theme
msgid "http://www.adviesenzo.nl/"
msgstr ""

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,259 @@
=== Debug Bar Constants ===
Contributors: jrf
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=995SSNDTCVBJG
Tags: debugbar, debug-bar, Debug Bar, Constants, Debug Bar Constants
Requires at least: 3.4
Tested up to: 4.9
Stable tag: 2.0.0
Requires PHP: 5.2.4
Depends: Debug Bar
License: GPLv2
Debug Bar Constants adds three new panels to the Debug Bar that display the defined WP and PHP constants for the current request.
== Description ==
Debug Bar Constants adds three new panels to the Debug Bar that display the defined constants available to you as a developer for the current request:
* WP Constants
* WP Class Constants
* PHP Constants
= Important =
This plugin requires the [Debug Bar](https://wordpress.org/plugins/debug-bar/) plugin to be installed and activated.
Also note that this plugin should be used solely for debugging and/or in a development environment and is not intended for use on a production site.
***********************************
If you like this plugin, please [rate and/or review](https://wordpress.org/support/view/plugin-reviews/debug-bar-constants) it. If you have ideas on how to make the plugin even better or if you have found any bugs, please report these in the [Support Forum](https://wordpress.org/support/plugin/debug-bar-constants) or in the [GitHub repository](https://github.com/jrfnl/Debug-Bar-Constants/issues).
== Frequently Asked Questions ==
= Can it be used on live site ? =
**PLEASE DON'T!** Amongst the defined constants are your database credentials, so you really do not want to do this.
This plugin is only meant to be used for development purposes.
= What are constants ? =
[From PHP.net:](http://php.net/language.constants)
> A constant is an identifier (name) for a simple value. As the name suggests, that value cannot change during the execution of the script. A constant is case-sensitive by default. By convention, constant identifiers are always uppercase.
> Like super globals, the scope of a constant is global. You can access constants anywhere in your script without regard to scope. For more information on scope, read the manual section on [variable scope](http://php.net/language.variables.scope).
= I don't see my constants in the WP Constants list. What gives ? =
Congratulations! Sounds like you're practicing lean programming (or something is going wrong... ;-) ).
The constants you see are the ones available in the current request. If you define constants in a conditionally included file - for instance you only include the file when on a certain page -, these constants will not be available if the conditions have not been met.
= The number of constants is different on each page/most pages. How come ? =
See the previous question.
= What are class constants ? =
[From PHP.net:](http://php.net/language.oop5.constants)
> It is possible to define constant values on a per-class basis remaining the same and unchangeable. Constants differ from normal variables in that you don't use the $ symbol to declare or use them.
> The value must be a constant expression, not (for example) a variable, a property, a result of a mathematical operation, or a function call.
= Why do plugins and themes use class constants instead of normal constants ? =
It's good coding practice to avoid littering the global namespace with your own variables and constants. This is a good way to avoid this.
= Why is it useful to have insight into the defined class constants ? =
If your plugin/theme interacts with other plugins and/or themes, you may want to use their constants.
Example: A plugin might have their version number saved as a class constant (good practice!). On your part, your plugin may have been set up to only work if the related plugin has been upgraded to version x. In that case, you may want to check other plugins version number before your plugin interacts with it.
Don't forget to always check whether the class constant exists before you use it! It may not be available on all pages and surely not on all WP installs.
`
if( defined( 'class_name::constant_name' ) ) {
// Your code here
}
`
= I don't see my class in the WP Class Constants list. What gives ? =
* Depending on how lean you've programmed your plugin/theme, your class may not be included (and therefore not be declared) for the page you are viewing.
* The name of your class may be the same as the name of one of the native/extension PHP classes. PHP is normally configured with a limited number of Extensions. A large number of the available extensions declare classes when they are loaded and the WP Class Constants list is filtered for these classes. It's good practice not to use the names of those PHP native/extension classes for your own classes. Try renaming your class. If that doesn't work, please [let me know](https://github.com/jrfnl/Debug-Bar-Constants/issues) and I'll have a look at it.
= Why are *all* native/extension PHP Classes filtered out - and not just the ones for the extensions loaded on my server -, you ask ? =
Easy: It's bad practise to name your class the same as one of the PHP native/extension classes.
In general, when you're developing a plugin/theme, you are developing for an unknown group of other people with unknown server configurations - including which extensions are(n't) installed -, so you should always make sure that your class will not interfere with any of the PHP native/extension classes.
= I see some PHP classes and their constants in the WP Class Constants list. What gives ? =
I've tried to exclude all PHP classes from this list, however, I might have missed some. Also some new extensions and/or classes may have been introduced in PHP since the last version of this plugin was released.
Please [let me know](https://github.com/jrfnl/Debug-Bar-Constants/issues) which one(s) you found and I'll add it/them to the exclusion list.
= Why won't the plugin activate ? =
Have you read what it says in the beautifully red bar at the top of your plugins page ? As it says there, the Debug Bar plugin needs to be active for this plugin to work. If the Debug Bar plugin is not active, this plugin will automatically de-activate itself.
== Changelog ==
= 2.0.0 =
_Release date: 2018-01-22_
* Improved compatibility with PHP 7.2.
* Improved compatibility with the upcoming v 0.10.0 of the Debug Bar plugin.
* I18n/I10n: Improved text strings for localization.
* Updated the pretty print dependency to v1.8.0.
* Refactoring of part of the code base. No functional changes.
* General housekeeping.
* Added minimum PHP requirement header. (PHP 5.2.4, in line with WP itself.)
* Tested & found compatible WP 4.9.
= 1.7.0 =
_Release date: 2017-07-10_
* Improved usability of the admin notice in case the Debug Bar plugin is not active.
* The plugin will now add itself to the list of "recently active" plugins if it self-deactivates bcause the Debug Bar plugin is not active.
* Defer to just in time loading of translations for WP > 4.5.
* Updated the pretty print dependency to v1.7.0.
* Minor housekeeping.
* The minimum supported WP version is now 3.4, in line with the 0.9 version of the Debug Bar.
* Tested & found compatible WP 4.8.
= 1.6.1 =
_Release date: 2016-04-15_
* Get the leaner loading of text domains right (at last).
= 1.6.0 =
_Release date: 2016-04-12_
* Hard-coded the text domains for compatibility with [GlotPress](https://translate.wordpress.org/projects/wp-plugins/debug-bar-constants).
* Make loading of text-domain compatible with use of the plugin in the `must-use` plugins directory.
* Updated the pretty print class to v1.6.0.
* Minor housekeeping.
* Tested & found compatible WP 4.5.
= 1.5.0.3 =
_Release date: 2016-01-13_
* Fix very minor layout inconsistency in combination with Twenty-Sixteen theme.
* Updated the pretty print class to v1.5.2.
= 1.5.0.2 =
_Release date: 2016-01-10_
* Fix weird table layout on front-end in combination with Twenty-Sixteen theme.
* Leaner loading of text domains.
= 1.5.0.1 =
_Release date: 2015-12-07_
* Fix typo.
= 1.5 =
_Release date: 2015-12-05_
* Updated PHP Classes list for PHP7.
* Fixed (some) links to PHP manual resulting in 404s.
* Tested & found compatible with WP 4.4.
= 1.4 =
_Release date: 2015-04-18_
* Updated the pretty print class to v1.5.0 which now allows for limiting of the recursion depth.
* Tested & found compatible with WP 4.2.
* Minor tidying up.
* Updated language files.
= 1.3.1 =
_Release date: 2014-09-05_
* Fix compatibility with the [Plugin Dependencies](https://wordpress.org/plugins/plugin-dependencies/) plugin.
* Tested & found compatible with WP 4.0.
= 1.3 =
_Release date: 2013-12-02_
* Moved pretty print class to separate repository as several plugins are using it now.
= 1.2.1.2 =
_Release date: 2013-11-30_
* Fixed minor HTML validation issue.
* Fixed auto-disable message display in case the Debug Bar Plugin is not activated.
* Changed style and script file names to comply with current guidelines (.min).
* Tested with WP 3.8-beta1.
= 1.2.1.1 =
_Release date: 2013-10-01_
* Compliance with the [WordPress coding standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards).
* Some minor code cleanup inspired by some suggestions by [Maik Penz](https://github.com/goatherd).
= 1.2.1 =
_Release date: 2013-05-27_
* Minor fix to comply with strict standards. Thanks [Azizur Rahman for reporting](https://wordpress.org/support/topic/declaration-of-debug_bar_constantsinit-should-be-compatible-with-debug_bar_p).
= 1.2 =
_Release date: 2013-05-05_
* [New!] Added a panel for Class Constants.
* [Fix] Some left over references to functions not in this plugin.
* Headers for the PHP Constants now link to their PHP manual page.
* Moved more output rendering to the pretty-output class and applied a higher level of abstraction.
= 1.1 =
_Release date: 2013-04-30 / not released_
* [New!] Added auto-deactivation if the Debug Bar plugin is not active.
* [Fix] Removed js debug alert (oops..).
* [Fix] Adjusted the sorting to be case-insensitive.
* [Fix] Some small-HTML/CSS tweaks.
* Added object output helper method.
= 1.0 =
_Release date: 2013-04-28_
* Initial release.
== Upgrade Notice ==
= 1.5 =
* Updated PHP Classes list for PHP7.
= 1.4 =
* Upgrade highly recommended - multi-plugin compatibility issue.
= 1.3 =
* Upgrade highly recommended - multi-plugin compatibility issue.
= 1.2.1.2 =
* Small fixes, nothing exciting.
= 1.2 =
* New! panel for Class Constants. This release also fixes a number of bugs.
= 1.0 =
* Initial release.
== Installation ==
1. Install Debug Bar if not already installed (https://wordpress.org/plugins/debug-bar/).
1. Extract the .zip file for this plugin and upload its contents to the `/wp-content/plugins/` directory. Alternatively, you can install directly from the Plugin directory within your WordPress Install.
1. Activate the plugin through the "Plugins" menu in WordPress.
Don't use this plugin on a live site. This plugin is **only** intended to be used for development purposes.
== Screenshots ==
1. Debug Bar displaying WP Constants
1. Debug Bar displaying WP Class Constants
1. Debug Bar displaying PHP Constants

View File

@@ -0,0 +1,303 @@
<?php
/**
* Add a new Debug Bar Panel.
*/
class ZT_Debug_Bar_Cron extends Debug_Bar_Panel {
/**
* Holds all of the cron events.
*
* @var array
*/
private $_crons;
/**
* Holds only the cron events initiated by WP core.
*
* @var array
*/
private $_core_crons;
/**
* Holds the cron events created by plugins or themes.
*
* @var array
*/
private $_user_crons;
/**
* Total number of cron events
*
* @var int
*/
private $_total_crons = 0;
/**
* Whether cron is being executed or not.
*
* @var string
*/
private $_doing_cron = 'No';
/**
* Give the panel a title and set the enqueues.
*
* @return void
*/
public function init() {
$this->title( __( 'Cron', 'debug-bar' ) );
add_action( 'wp_print_styles', array( $this, 'print_styles' ) );
add_action( 'admin_print_styles', array( $this, 'print_styles' ) );
}
/**
* Enqueue styles.
*
* @return void
*/
public function print_styles() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
wp_enqueue_style( 'zt-debug-bar-cron', plugins_url( "css/debug-bar-cron$suffix.css", __FILE__ ), array(), '20131228' );
}
/**
* Show the menu item in Debug Bar.
*
* @return void
*/
public function prerender() {
$this->set_visible( true );
}
/**
* Show the contents of the page.
* @return void
*/
public function render() {
$this->get_crons();
$this->_doing_cron = get_transient( 'doing_cron' ) ? __( 'Yes', 'zt-debug-bar-cron' ) : __( 'No', 'zt-debug-bar-cron' );
// Get the time of the next event
$cron_times = array_keys( $this->_crons );
$unix_time_next_cron = $cron_times[0];
$time_next_cron = date( 'Y-m-d H:i:s', $unix_time_next_cron );
$human_time_next_cron = human_time_diff( $unix_time_next_cron );
// Add a class if past current time and doing cron is not running
$times_class = time() > $unix_time_next_cron && 'No' == $this->_doing_cron ? ' past' : '';
echo '<div class="debug-bar-cron">';
echo '<h2><span>' . __( 'Total Events', 'zt-debug-bar-cron' ) . ':</span>' . (int) $this->_total_crons . '</h2>';
echo '<h2><span>' . __( 'Doing Cron', 'zt-debug-bar-cron' ) . ':</span>' . $this->_doing_cron . '</h2>';
echo '<h2 class="times' . esc_attr( $times_class ) . '"><span>' . __( 'Next Event', 'zt-debug-bar-cron' ) . ':</span>' . $time_next_cron . '<br />' . $unix_time_next_cron . '<br />' . $human_time_next_cron . $this->display_past_time( $unix_time_next_cron ) . '</h2>';
echo '<h2><span>' . __( 'Current Time', 'zt-debug-bar-cron' ) . ':</span>' . date( 'H:i:s' ) . '</h2>';
echo '<div class="clear"></div>';
echo '<h3>' . __( 'Custom Events', 'zt-debug-bar-cron' ) . '</h3>';
if ( ! is_null( $this->_user_crons ) )
$this->display_events( $this->_user_crons );
else
echo '<p>' . __( 'No Custom Events scheduled.', 'zt-debug-bar-cron' ) . '</p>';
echo '<h3>' . __( 'Schedules', 'zt-debug-bar-cron' ) . '</h3>';
$this->display_schedules();
echo '<h3>' . __( 'Core Events', 'zt-debug-bar-cron' ) . '</h3>';
if ( ! is_null( $this->_core_crons ) )
$this->display_events( $this->_core_crons );
else
echo '<p>' . __( 'No Core Events scheduled.', 'zt-debug-bar-cron' ) . '</p>';
echo '</div>';
}
/**
* Gets all of the cron jobs.
*
* This function sorts the cron jobs into core crons, and custom crons. It also tallies
* a total count for the crons as this number is otherwise tough to get.
*
* @return array Array of crons.
*/
private function get_crons() {
if ( ! is_null( $this->_crons ) )
return $this->_crons;
if ( ! $crons = _get_cron_array() )
return $this->_crons;
$this->_crons = $crons;
// Lists all crons that are defined in WP Core
$core_cron_hooks = array(
'wp_scheduled_delete',
'upgrader_scheduled_cleanup',
'importer_scheduled_cleanup',
'publish_future_post',
'akismet_schedule_cron_recheck',
'akismet_scheduled_delete',
'do_pings',
'wp_version_check',
'wp_update_plugins',
'wp_update_themes'
);
// Sort and count crons
foreach ( $this->_crons as $time => $time_cron_array ) {
foreach ( $time_cron_array as $hook => $data ) {
$this->_total_crons++;
if ( in_array( $hook, $core_cron_hooks ) )
$this->_core_crons[ $time ][ $hook ] = $data;
else
$this->_user_crons[ $time ][ $hook ] = $data;
}
}
return $this->_crons;
}
/**
* Displays the events in an easy to read table.
*
* @param array $events Array of events.
* @return void|string Void on failure; table display of events on success.
*/
private function display_events( $events ) {
if ( is_null( $events ) || empty( $events ) )
return;
echo '<table class="zt-debug-bar-cron-event-table" cellspacing="0">';
echo '<thead><tr>';
echo '<th class="col1">' . __( 'Next Execution', 'zt-debug-bar-cron' ) . '</th>';
echo '<th class="col2">' . __( 'Hook', 'zt-debug-bar-cron' ) . '</th>';
echo '<th class="col3">' . __( 'Interval Hook', 'zt-debug-bar-cron' ) . '</th>';
echo '<th class="col4">' . __( 'Interval Value', 'zt-debug-bar-cron' ) . '</th>';
echo '<th class="col5">' . __( 'Args', 'zt-debug-bar-cron' ) . '</th>';
echo '</tr></thead>';
echo '<tbody>';
foreach ( $events as $time => $time_cron_array ) {
foreach ( $time_cron_array as $hook => $data ) {
// Add a class if past current time
$times_class = time() > $time && 'No' == $this->_doing_cron ? ' class="past"' : '';
echo '<tr>';
echo '<td' . $times_class . '>' . date( 'Y-m-d H:i:s', $time ) . '<br />' . $time . '<br />' . human_time_diff( $time ) . $this->display_past_time( $time ) . '</td>';
echo '<td>' . wp_strip_all_tags( $hook ) . '</td>';
foreach ( $data as $hash => $info ) {
// Report the schedule
echo '<td>';
if ( $info['schedule'] )
echo wp_strip_all_tags( $info['schedule'] );
else
echo 'Single Event';
echo '</td>';
// Report the interval
echo '<td>';
if ( isset( $info['interval'] ) ) {
echo wp_strip_all_tags( $info['interval'] ) . 's<br />';
echo $info['interval'] / 60 . 'm<br />';
echo $info['interval'] / ( 60 * 60 ). 'h';
} else {
echo 'Single Event';
}
echo '</td>';
// Report the args
echo '<td>';
if ( is_array( $info['args'] ) && ! empty( $info['args'] ) ) {
foreach ( $info['args'] as $key => $value ) {
$this->display_cron_arguments( $key, $value );
}
} else if ( is_string( $info['args'] ) && $info['args'] !== '' ) {
echo esc_html( $info['args'] );
} else {
echo 'No Args';
}
echo '</td>';
}
echo '</tr>';
}
}
echo '</tbody>';
echo '</table>';
}
/**
* Displays the cron arguments in a readable format.
*
* @param int|string $key Key of the array element.
* @param mixed $value Cron argument(s).
* @param int $depth Current recursion depth.
* @return void
*/
function display_cron_arguments( $key, $value, $depth = 0 ) {
if ( is_string( $value ) ) {
echo str_repeat( '&nbsp;', ( $depth * 2 ) ) . wp_strip_all_tags( $key ) . ' => ' . esc_html( $value ) . '<br />';
} else if ( is_array( $value ) ) {
if ( count( $value ) > 0 ) {
echo str_repeat( '&nbsp;', ( $depth * 2 ) ) . wp_strip_all_tags( $key ) . ' => array(<br />';
$depth++;
foreach ( $value as $k => $v ) {
$this->display_cron_arguments( $k, $v, $depth );
}
echo str_repeat( '&nbsp;', ( ( $depth - 1 ) * 2 ) ) . ')';
} else {
echo 'Empty Array';
}
}
}
/**
* Displays all of the schedules defined.
*
* @return void
*/
private function display_schedules() {
echo '<table class="zt-debug-bar-cron-event-table" cellspacing="0">';
echo '<thead><tr>';
echo '<th class="col1">' . __( 'Interval Hook', 'zt-debug-bar-cron' ) . '</th>';
echo '<th class="col2">' . __( 'Interval (S)', 'zt-debug-bar-cron' ) . '</th>';
echo '<th class="col3">' . __( 'Interval (M)', 'zt-debug-bar-cron' ) . '</th>';
echo '<th class="col4">' . __( 'Interval (H)', 'zt-debug-bar-cron' ) . '</th>';
echo '<th class="col5">' . __( 'Display Name', 'zt-debug-bar-cron' ) . '</th>';
echo '</tr></thead>';
echo '<tbody>';
foreach ( wp_get_schedules() as $interval_hook => $data ) {
echo '<tr>';
echo '<td>' . esc_html( $interval_hook ) . '</td>';
echo '<td>' . wp_strip_all_tags( $data['interval'] ) . '</td>';
echo '<td>' . wp_strip_all_tags( $data['interval'] ) / 60 . '</td>';
echo '<td>' . wp_strip_all_tags( $data['interval'] ) / ( 60 * 60 ). '</td>';
echo '<td>' . esc_html( $data['display'] ) . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
}
/**
* Compares time with current time and outputs 'ago' if current time is greater that even time.
*
* @param int $time Unix time of event.
* @return string
*/
private function display_past_time( $time ) {
return time() > $time ? ' ' . __( 'ago', 'zt-debug-bar-cron' ) : '';
}
}

View File

@@ -0,0 +1 @@
.debug-bar-cron h2.times{font-size:1.7em;line-height:1.1}.debug-bar-cron h2.times span{line-height:150%}.debug-bar-cron .past{color:red}.debug-bar-cron h2.times.past span{color:#888}.debug-bar-cron h3{font-family:georgia,times,serif;font-size:22px}.zt-debug-bar-cron-event-table{width:100%;border-top:1px solid #dfdfdf;border-bottom:1px solid #fcfcfc}.zt-debug-bar-cron-event-table th,.zt-debug-bar-cron-event-table td{padding:.3em 2.5em .3em .3em;border-top:1px solid #fcfcfc;border-bottom:1px solid #dfdfdf}.zt-debug-bar-cron-event-table tbody td{vertical-align:top}.zt-debug-bar-cron-event-table thead,.zt-debug-bar-cron-event-table tr:nth-child(2n+1){background:#fcfcfc}.zt-debug-bar-cron-event-table td.past{font-weight:bold}.zt-debug-bar-cron-event-table thead th.col1{width:180px}.zt-debug-bar-cron-event-table thead th.col2,.zt-debug-bar-cron-event-table thead th.col5{width:25%}.zt-debug-bar-cron-event-table thead th.col3{width:20%}.zt-debug-bar-cron-event-table thead th.col4{width:120px}

View File

@@ -0,0 +1,52 @@
.debug-bar-cron h2.times {
font-size: 1.7em;
line-height: 1.1;
}
.debug-bar-cron h2.times span {
line-height: 150%;
}
.debug-bar-cron .past {
color: red;
}
.debug-bar-cron h2.times.past span {
color: #888;
}
.debug-bar-cron h3 {
font-family: georgia, times, serif;
font-size: 22px;
}
.zt-debug-bar-cron-event-table {
width: 100%;
border-top: 1px solid #dfdfdf;
border-bottom: 1px solid #fcfcfc;
}
.zt-debug-bar-cron-event-table th,
.zt-debug-bar-cron-event-table td {
padding: .3em 2.5em .3em .3em;
border-top: 1px solid #fcfcfc;
border-bottom: 1px solid #dfdfdf;
}
.zt-debug-bar-cron-event-table tbody td {
vertical-align: top;
}
.zt-debug-bar-cron-event-table thead,
.zt-debug-bar-cron-event-table tr:nth-child(2n) {
background: #fcfcfc;
}
.zt-debug-bar-cron-event-table td.past {
font-weight: bold;
}
.zt-debug-bar-cron-event-table thead th.col1 {
width: 180px;
}
.zt-debug-bar-cron-event-table thead th.col2,
.zt-debug-bar-cron-event-table thead th.col5 {
width: 25%;
}
.zt-debug-bar-cron-event-table thead th.col3 {
width: 20%;
}
.zt-debug-bar-cron-event-table thead th.col4 {
width: 120px;
}

View File

@@ -0,0 +1,24 @@
<?php
/*
Plugin Name: Debug Bar Cron
Plugin URI: http://github.com/tollmanz/
Description: Adds information about WP scheduled events to Debug Bar.
Author: Zack Tollman, Helen Hou-Sandi
Version: 0.1.2
Author URI: http://github.com/tollmanz
*/
/**
* Adds panel, as defined in the included class, to Debug Bar.
*
* @param $panels array
* @return array
*/
function zt_add_debug_bar_cron_panel( $panels ) {
if ( ! class_exists( 'ZT_Debug_Bar_Cron' ) ) {
include ( 'class-debug-bar-cron.php' );
$panels[] = new ZT_Debug_Bar_Cron();
}
return $panels;
}
add_filter( 'debug_bar_panels', 'zt_add_debug_bar_cron_panel' );

View File

@@ -0,0 +1,66 @@
=== Debug Bar Cron ===
Contributors: tollmanz, helen, 10up
Donate Link: http://wordpress.org
Tags: debug bar, cron
Requires at least: 3.3
Tested up to: trunk
Stable tag: 0.1.3
Debug Bar Cron adds a new panel to Debug Bar that displays information about WP scheduled events.
== Description ==
Debug Bar Cron adds information about WP scheduled events to a new panel in the Debug Bar. This plugin is an extension for
Debug Bar and thus is dependent upon Debug Bar being installed for it to work properly.
Once installed, you will have access to the following information:
* Number of scheduled events
* If cron is currently running
* Time of next event
* Current time
* List of custom scheduled events
* List of core scheduled events
* List of schedules
== Installation ==
1. Install Debug Bar if not already installed (http://wordpress.org/extend/plugins/debug-bar/)
2. Upload the `debug-bar-cron` folder to the `/wp-content/plugins/` directory
3. Activate the plugin through the 'Plugins' menu in WordPress
4. View the WP schedule events information in the "Cron" panel in Debug Bar
== Frequently Asked Questions ==
= Is debugging cron easier with this plugin? =
Yes
== Screenshots ==
1. The Debug Bar Cron panel
== Changelog ==
= 0.1.3 =
* Fixed 'Array to string conversion' error when Cron job arguments are in a multi-dimensional array - props [Jrf](http://profiles.wordpress.org/jrf), [ethitter](http://profiles.wordpress.org/ethitter), and [mintindeed](http://profiles.wordpress.org/mintindeed).
* Fixed a number of HTML validation errors - props [Jrf](http://profiles.wordpress.org/jrf).
= 0.1.2 =
* Added indicators for missed events
= 0.1.1 =
* Readme updates
= 0.1 =
* Initial release
== Upgrade Notice ==
= 0.1.2 =
Adds indicators for missed events
= 0.1 =
Initial Release

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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:
{project} Copyright (C) {year} {fullname}
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
<http://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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -0,0 +1,326 @@
<?php
/**
* Option Management.
*
* @package WordPress\Plugins\Debug Bar Plugin Activation
* @subpackage Option
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! class_exists( 'Debug_Bar_Plugin_Activation_Option' ) ) {
/**
* Debug Bar Plugin Activation Option Management.
*/
class Debug_Bar_Plugin_Activation_Option {
/* *** DEFINE CLASS CONSTANTS *** */
/**
* Name of options variable containing the plugin proprietary settings.
*
* @const string
*/
const NAME = 'debug_bar_plugin_activation';
/* *** DEFINE CLASS PROPERTIES *** */
/**
* Default option values.
*
* @var array
*/
protected $defaults = array(
'version' => null,
'activate' => array(),
'deactivate' => array(),
'uninstall' => array(),
);
/* *** CLASS METHODS *** */
/**
* Initialize our option and add all relevant actions and filters
*/
public function __construct() {
/*
* Make sure the option will always get validated, independently of register_setting()
* which is only available in the back-end.
*/
add_filter( 'sanitize_option_' . self::NAME, array( $this, 'validate_option' ) );
/* Add filters which get applied to get_options() results. */
$this->add_default_filter();
add_filter( 'option_' . self::NAME, array( $this, 'filter_option' ) );
/*
* The option validation routines remove the default filters to prevent failing to insert
* an options if it's new. Let's add them back afterwards.
*
* {@internal This was needed due to bug #31047 and fixed with commit #31473 in WP 4.2.
* Should at some point in the future when the minimum WP version for the plugin gets
* upped, be removed.}}
*/
add_action( 'add_option', array( $this, 'add_default_filter' ) );
add_action( 'update_option', array( $this, 'add_default_filter' ) );
// Start buffering the output for those actions in which WP does not do so natively.
add_action( 'deactivate_plugin', array( $this, 'start_output_buffer' ) );
add_action( 'pre_uninstall_plugin', array( $this, 'start_output_buffer' ) );
add_action( 'delete_plugin', array( $this, 'start_output_buffer' ) );
// Save (de-)activation output to our option.
add_action( 'activated_plugin', array( $this, 'save_activation_output' ) );
add_action( 'deactivated_plugin', array( $this, 'save_deactivation_output' ) );
add_action( 'deleted_plugin', array( $this, 'save_deletion_output' ) );
// Remove plugin from our option on delete.
add_action( 'deleted_plugin', array( $this, 'remove_plugin_data' ) );
}
/**
* Start the output buffer for deleting plugins.
*
* The plugin may or may not have an uninstall routine. If it does, the output
* buffering is started there (`pre_uninstall_plugin`). Otherwise it is started at
* the next earliest opportunity (`delete_plugin`).
*
* @param string $plugin The plugin being deleted.
*/
public function start_output_buffer( $plugin ) {
static $plugins;
if ( ! isset( $plugins[ $plugin ] ) ) {
ob_start();
$plugins[ $plugin ] = true;
}
}
/**
* Save any output generated during plugin activation.
*
* @param string $plugin The plugin being activated.
*/
public function save_activation_output( $plugin ) {
$this->update_option_with_output( $plugin, 'activate' );
}
/**
* Save any output generated during plugin deactivation and stop the output buffering.
*
* @param string $plugin The plugin being deactivated.
*/
public function save_deactivation_output( $plugin ) {
$this->update_option_with_output( $plugin, 'deactivate' );
ob_end_clean();
}
/**
* Save any output generated during plugin deletion and stop the output buffering.
*
* @param string $plugin The plugin being deleted.
*/
public function save_deletion_output( $plugin ) {
$this->update_option_with_output( $plugin, 'uninstall' );
ob_end_clean();
}
/**
* Save the output from the output buffer to our option.
*
* @param string $plugin The plugin currently being handled.
* @param string $action Which action was executed - either 'activate', 'deactivate'
* or 'uninstall'.
*/
protected function update_option_with_output( $plugin, $action ) {
$option = get_option( self::NAME );
$output = ob_get_contents();
$output = trim( $output );
if ( '' !== $output ) {
$option[ $action ][ $plugin ] = $output;
update_option( self::NAME, $option );
}
}
/**
* Delete activation and deactivation output related to a plugin on deletion of
* that plugin - will be done automagically by the validation routine.
*
* @param string $plugin The plugin being deleted.
*/
public function remove_plugin_data( $plugin ) {
update_option( self::NAME, get_option( self::NAME ) );
}
/**
* Add filtering of the option default values.
*
* @return void
*/
public function add_default_filter() {
if ( false === has_filter( 'default_option_' . self::NAME, array( $this, 'filter_option_defaults' ) ) ) {
add_filter( 'default_option_' . self::NAME, array( $this, 'filter_option_defaults' ) );
};
}
/**
* Remove filtering of the option default values.
*
* This is needed to allow for inserting of the option if it doesn't exist.
* Should be called from our validation routine.
*
* @return void
*/
public function remove_default_filter() {
remove_filter( 'default_option_' . self::NAME, array( $this, 'filter_option_defaults' ) );
}
/**
* Filter option defaults.
*
* This in effect means that get_option() will not return false if the option is not found,
* but will instead return our defaults. This way we always have all of our option values available.
*
* @return array
*/
public function filter_option_defaults() {
return $this->defaults;
}
/**
* Filter option.
*
* This in effect means that get_option() will not just return our option from the database,
* but will instead return that option merged with our defaults.
* This way we always have all of our option values available. Even when we add new option
* values (to the defaults array) when the plugin is upgraded.
*
* @param array $options Current options.
*
* @return array
*/
public function filter_option( $options ) {
return $this->array_filter_merge( $this->defaults, $options );
}
/* *** HELPER METHODS *** */
/**
* Helper method - Combines a fixed array of default values with an options array
* while filtering out any keys which are not in the defaults array.
*
* @static
*
* @param array $defaults Entire list of supported defaults.
* @param array $options Current options.
*
* @return array Combined and filtered options array.
*/
protected function array_filter_merge( $defaults, $options ) {
$options = (array) $options;
$return = array();
foreach ( $defaults as $name => $default ) {
if ( array_key_exists( $name, $options ) ) {
$return[ $name ] = $options[ $name ];
} else {
$return[ $name ] = $default;
}
}
return $return;
}
/* *** OPTION VALIDATION *** */
/**
* Validated the settings received from our options page.
*
* @param array $received The new option values.
*
* @return array Cleaned option to be saved to the db.
*/
public function validate_option( $received ) {
/**
* {@internal This was needed due to bug #31047 and fixed with commit #31473 in WP 4.2.
* Should at some point in the future when the minimum WP version for the plugin gets
* upped, be removed.}}
*/
$this->remove_default_filter();
/* Start off with the defaults. */
$clean = $this->defaults;
/*
Validate received values and add them to the $clean array if valid:
- plugin file should be a valid filename and exist (except for the 'uninstall' section).
- output should be a non-empty string.
*/
foreach ( $received as $type => $plugins ) {
if ( 'version' === $type ) {
continue;
}
if ( 'uninstall' !== $type ) {
foreach ( $plugins as $plugin => $output ) {
if ( $this->is_valid_plugin_file( $plugin ) && ( ! empty( $output ) && is_string( $output ) ) ) {
$clean[ $type ][ $plugin ] = $output;
}
}
} else {
foreach ( $plugins as $plugin => $output ) {
if ( ! empty( $output ) && is_string( $output ) ) {
$clean[ $type ][ $plugin ] = $output;
}
}
}
}
$clean['version'] = Debug_Bar_Plugin_Activation::VERSION;
return $clean;
}
/**
* Validate whether a plugin filename in the form slug/filename.php or filename.php
* is a valid installed plugin.
*
* Based upon code from `wp_get_active_and_valid_plugins()` in `wp-includes/load.php`.
*
* @param string $plugin Plugin filename.
*
* @return bool
*/
protected function is_valid_plugin_file( $plugin ) {
return ( 0 === validate_file( $plugin ) // $plugin must validate as file
&& '.php' === substr( $plugin, -4 ) // $plugin must end with '.php'
&& file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
);
}
} /* End of class. */
} /* End of class exists wrapper. */

View File

@@ -0,0 +1,288 @@
<?php
/**
* Debug Bar Plugin Activation, a WordPress plugin.
*
* @package WordPress\Plugins\Debug Bar Plugin Activation
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/debug-bar-plugin-activation
* @since 1.0
* @version 1.0
*
* @copyright 2016 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! class_exists( 'Debug_Bar_Plugin_Activation' ) && class_exists( 'Debug_Bar_Panel' ) ) {
/**
* This class extends the functionality provided by the parent plugin "Debug Bar" by adding a
* panel showing plugin (de-)activation errors.
*/
class Debug_Bar_Plugin_Activation extends Debug_Bar_Panel {
/**
* Plugin version.
*
* @const string
*/
const VERSION = '1.0';
/**
* Version in which the scripts and styles were last updated.
* Used to break out of the cache.
*
* @const string
*/
const ASSETS_VERSION = '1.0';
/**
* Plugin slug.
*
* @const string
*/
const NAME = 'debug-bar-plugin-activation';
/**
* Whether or not an attempt has been made to load the textdomain.
* If so, no need to try again.
*
* @var bool
*/
private static $textdomain_loaded = false;
/**
* Constructor.
*/
public function init() {
$this->load_textdomain( self::NAME );
$this->title( __( 'Plugin (de-)activation output', 'debug-bar-plugin-activation' ) );
$this->set_visible( false );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
}
/**
* Load the plugin text strings.
*
* Compatible with use of the plugin in the must-use plugins directory.
*
* {@internal No longer needed since WP 4.6, though the language loading in
* WP 4.6 only looks at the `wp-content/languages/` directory and disregards
* any translations which may be included with the plugin.
* This is acceptable for plugins hosted on org, especially if the plugin
* is new and never shipped with it's own translations, but not when the plugin
* is hosted elsewhere.
* Can be removed if/when the minimum required version for this plugin is ever
* upped to 4.6. The `languages` directory can be removed in that case too.}}
*
* @param string $domain Text domain to load.
*/
protected function load_textdomain( $domain ) {
if ( function_exists( '_load_textdomain_just_in_time' ) ) {
return;
}
if ( is_textdomain_loaded( $domain ) || self::$textdomain_loaded ) {
return;
}
$lang_path = dirname( plugin_basename( __FILE__ ) ) . '/languages';
if ( false === strpos( __FILE__, basename( WPMU_PLUGIN_DIR ) ) ) {
load_plugin_textdomain( $domain, false, $lang_path );
} else {
load_muplugin_textdomain( $domain, $lang_path );
}
self::$textdomain_loaded = true;
}
/**
* Enqueue js and css files.
*/
public function enqueue_scripts() {
$suffix = ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' );
wp_enqueue_style( self::NAME, plugins_url( 'css/debug-bar-plugin-activation' . $suffix . '.css', __FILE__ ), array( 'debug-bar' ), self::ASSETS_VERSION );
wp_enqueue_script( self::NAME, plugins_url( 'js/debug-bar-plugin-activation' . $suffix . '.js', __FILE__ ), array( 'jquery' ), self::ASSETS_VERSION, true );
wp_localize_script(
self::NAME,
'debugBarPluginActivation',
array(
'dbpa_nonce' => wp_create_nonce( 'debug-bar-plugin-activation' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'spinner' => admin_url( 'images/wpspin_light.gif' ),
'errorMsg' => __( 'An error occurred', 'debug-bar-plugin-activation' ),
)
);
}
/**
* Get the total number of issues recorded.
*
* @return int
*/
protected function get_total() {
$option = get_option( Debug_Bar_Plugin_Activation_Option::NAME );
return ( count( $option['activate'] ) + count( $option['deactivate'] ) + count( $option['uninstall'] ) );
}
/**
* Determine whether or not the panel should show.
*/
public function prerender() {
$total = $this->get_total();
if ( $total > 0 ) {
$this->set_visible( true );
// DB 0.9+ - change over to use version nr (defined + nr) if PR is accepted.
if ( method_exists( 'Debug_Bar', 'enable_debug_bar' ) ) {
$this->title( $this->title() . '<span class="debug-bar-issue-count">' . absint( $total ) . '</span>' );
} else {
$this->title( $this->title() . '<span class="debug-bar-issue-count" style="float: right;">' . absint( $total ) . '</span>' );
}
}
}
/**
* Add classes to the Debug Bar button in the admin bar.
*
* @param array $classes Existing classes.
*
* @return array
*/
public function debug_bar_classes( $classes ) {
if ( $this->get_total() > 0 ) {
$classes[] = 'debug-bar-php-notice-summary';
$classes[] = 'debug-bar-notice-summary';
}
return $classes;
}
/**
* Renders the panel.
*/
public function render() {
$option = get_option( Debug_Bar_Plugin_Activation_Option::NAME );
echo '
<div id="debug-bar-plugin-activation">
<h2 id="', esc_attr( self::NAME . '-delete-all' ), '"><a href="#">Clear All</a> <span class="spinner"></span></h2>';
/* translators: 1: line break. */
$this->render_title( __( 'Total Plugins%1$s with %1$sActivation Issues:', 'debug-bar-plugin-activation' ), count( $option['activate'] ), 'activate' );
/* translators: 1: line break. */
$this->render_title( __( 'Total Plugins%1$s with %1$sDe-activation Issues:', 'debug-bar-plugin-activation' ), count( $option['deactivate'] ), 'deactivate' );
/* translators: 1: line break. */
$this->render_title( __( 'Total Plugins%1$s with %1$sUninstall Issues:', 'debug-bar-plugin-activation' ), count( $option['uninstall'] ), 'uninstall' );
$this->render_table( $option, 'activate', __( 'Activation Issues', 'debug-bar-plugin-activation' ) );
$this->render_table( $option, 'deactivate', __( 'De-activation Issues', 'debug-bar-plugin-activation' ) );
$this->render_table( $option, 'uninstall', __( 'Uninstall Issues', 'debug-bar-plugin-activation' ) );
echo '</div>';
}
/**
* Render a title block for the top of panel.
*
* @param string $title The title.
* @param int $count Count.
* @param string $type Counter for type.
*/
protected function render_title( $title, $count, $type ) {
echo '<h2><span>', sprintf( esc_html( $title ), '<br />' ), '</span><span class="count ', esc_attr( $type ), '">', absint( $count ), "</span></h2>\n";
}
/**
* Render a table of (de-)activation issues encountered.
*
* @param array $option The option value holding the currently logged (de-)activation issues.
* @param string $type Type of table to generate - either 'activate' or 'deactivate'.
* @param string $title Title for this table.
*/
protected function render_table( $option, $type, $title ) {
$count = count( $option[ $type ] );
if ( $count > 0 ) {
echo // WPCS: xss ok.
'
<h3 id="dbpa-', esc_attr( $type ), '">', esc_html( $title ), '</h3>
<table class="debug-bar-table ', self::NAME, '">', $this->get_table_header( $count > 5 ), '
<tbody>';
foreach ( $option[ $type ] as $plugin => $notices ) {
printf( '
<tr>
<td><a href="#" data-type="%1$s" data-plugin="%2$s" class="%3$s"><span class="dashicons dashicons-trash"></span></a> <span class="spinner"></span></td>
<td>%2$s</td>
<td>%4$s</td>
</tr>',
esc_attr( $type ),
esc_attr( $plugin ),
esc_attr( self::NAME . '-delete' ),
wp_kses_post( $notices )
);
}
echo '
</tbody>
</table>';
}
}
/**
* Create the table header.
*
* @param bool $double Whether or not to repeat the column labels at the end of the table.
*
* @return string
*/
protected function get_table_header( $double ) {
static $header_row;
/* Create header row. */
if ( ! isset( $header_row ) ) {
$header_row = '
<tr>
<th class="col-1">&nbsp;</th>
<th class="col-2">' . esc_html__( 'Plugin slug', 'debug-bar-plugin-activation' ) . '</th>
<th class="col-3">' . esc_html__( 'Unexpected output', 'debug-bar-plugin-activation' ) . '</th>
</tr>';
}
$table_header = '
<thead>
' . $header_row . '
</thead>';
if ( true === $double ) {
$table_header .= '
<tfoot>
' . $header_row . '
</tfoot>';
}
return $table_header;
}
} // End of class Debug_Bar_Plugin_Activation.
} // End of class_exists wrapper.

View File

@@ -0,0 +1,143 @@
/* CSS for plugin: Debug Bar Plugin Activation */
#debug-menu-target-Debug_Bar_Plugin_Activation h2 .count {
font-size: 28px;
color: #23282D;
}
#debug-menu-target-Debug_Bar_Plugin_Activation h3 {
font-family: georgia, times, serif;
font-size: 22px;
margin-top: 1.5em;
clear: both;
}
#debug-bar-plugin-activation-delete-all {
float: right !important;
}
#debug-bar-plugin-activation-delete-all a {
-moz-box-shadow: inset 0px 1px 0px 0px #bbdaf7;
-webkit-box-shadow: inset 0px 1px 0px 0px #bbdaf7;
box-shadow: inset 0px 1px 0px 0px #bbdaf7;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #79bbff), color-stop(1, #378de5));
background: -moz-linear-gradient(top, #79bbff 5%, #378de5 100%);
background: -webkit-linear-gradient(top, #79bbff 5%, #378de5 100%);
background: -o-linear-gradient(top, #79bbff 5%, #378de5 100%);
background: -ms-linear-gradient(top, #79bbff 5%, #378de5 100%);
background: linear-gradient(to bottom, #79bbff 5%, #378de5 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff', endColorstr='#378de5',GradientType=0);
background-color: #79bbff;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
border: 1px solid #84bbf3;
display: inline-block;
cursor: pointer;
color: #ffffff !important;
font-family: Arial;
font-size: 15px;
font-weight: bold;
padding: 6px 24px;
text-decoration: none !important;
text-shadow: 0 1px 0 #528ecc;
}
#debug-bar-plugin-activation-delete-all a:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff));
background: -moz-linear-gradient(top, #378de5 5%, #79bbff 100%);
background: -webkit-linear-gradient(top, #378de5 5%, #79bbff 100%);
background: -o-linear-gradient(top, #378de5 5%, #79bbff 100%);
background: -ms-linear-gradient(top, #378de5 5%, #79bbff 100%);
background: linear-gradient(to bottom, #378de5 5%, #79bbff 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff',GradientType=0);
background-color: #378de5;
}
#debug-bar-plugin-activation-delete-all a:active {
position: relative;
top: 1px;
}
table.debug-bar-plugin-activation,
table.debug-bar-plugin-activation th,
table.debug-bar-plugin-activation td {
border: 0px none;
}
table.debug-bar-plugin-activation {
width: 100%;
border-collapse: collapse;
cell-padding: 1em;
clear: both;
line-height: 1.5;
font-size: 12px;
table-layout: auto;
}
table.debug-bar-plugin-activation thead th,
table.debug-bar-plugin-activation tfoot th {
padding: 0.7em 5px;
width: auto;
}
table.debug-bar-plugin-activation thead th {
border-bottom: 1px solid #ccc;
}
table.debug-bar-plugin-activation tfoot th {
border-top: 1px solid #ccc;
}
table.debug-bar-plugin-activation th,
table.debug-bar-plugin-activation td {
padding-left: 5px;
padding-right: 10px;
}
table.debug-bar-plugin-activation .col-1 {
width: 5%;
min-width: 55px;
}
table.debug-bar-plugin-activation .col-2 {
width: 25%;
}
table.debug-bar-plugin-activation .col-3 {
width: 70%;
}
table.debug-bar-plugin-activation tr td:nth-child(2) {
font-weight: bold;
}
table.debug-bar-plugin-activation th {
font-weight: bold;
padding: 2px 2em 2px 5px;
vertical-align: top;
text-align: left;
}
table.debug-bar-plugin-activation td {
padding: 2px 5px;
vertical-align: top;
}
table.debug-bar-plugin-activation tr:nth-child(2n+1) {
background-color: #E8E8E8;
}
table.debug-bar-plugin-activation td a .dashicons {
color: #585858;
text-decoration: none;
}
table.debug-bar-plugin-activation td a:hover .dashicons {
color: #cc0000;
}
table.debug-bar-plugin-activation .spinner {
background: no-repeat scroll 0 0 / 16px 16px rgba(0, 0, 0, 0);
visibility: hidden;
float: right;
height: 16px;
margin: 2px 0 0 4px;
opacity: 0.7;
width: 16px;
padding-right: 15px;
}
table.debug-bar-plugin-activation .spinner.is-active {
visibility: visible;
}

View File

@@ -0,0 +1,2 @@
/* CSS for plugin: Debug Bar Plugin Activation */
#debug-menu-target-Debug_Bar_Plugin_Activation h2 .count{font-size:28px;color:#23282d}#debug-menu-target-Debug_Bar_Plugin_Activation h3{font-family:georgia,times,serif;font-size:22px;margin-top:1.5em;clear:both}#debug-bar-plugin-activation-delete-all{float:right !important}#debug-bar-plugin-activation-delete-all a{-moz-box-shadow:inset 0 1px 0 0 #bbdaf7;-webkit-box-shadow:inset 0 1px 0 0 #bbdaf7;box-shadow:inset 0 1px 0 0 #bbdaf7;background:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#79bbff),color-stop(1,#378de5));background:-moz-linear-gradient(top,#79bbff 5%,#378de5 100%);background:-webkit-linear-gradient(top,#79bbff 5%,#378de5 100%);background:-o-linear-gradient(top,#79bbff 5%,#378de5 100%);background:-ms-linear-gradient(top,#79bbff 5%,#378de5 100%);background:linear-gradient(to bottom,#79bbff 5%,#378de5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff',endColorstr='#378de5',GradientType=0);background-color:#79bbff;-moz-border-radius:6px;-webkit-border-radius:6px;border-radius:6px;border:1px solid #84bbf3;display:inline-block;cursor:pointer;color:#fff !important;font-family:Arial;font-size:15px;font-weight:bold;padding:6px 24px;text-decoration:none !important;text-shadow:0 1px 0 #528ecc}#debug-bar-plugin-activation-delete-all a:hover{background:-webkit-gradient(linear,left top,left bottom,color-stop(0.05,#378de5),color-stop(1,#79bbff));background:-moz-linear-gradient(top,#378de5 5%,#79bbff 100%);background:-webkit-linear-gradient(top,#378de5 5%,#79bbff 100%);background:-o-linear-gradient(top,#378de5 5%,#79bbff 100%);background:-ms-linear-gradient(top,#378de5 5%,#79bbff 100%);background:linear-gradient(to bottom,#378de5 5%,#79bbff 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5',endColorstr='#79bbff',GradientType=0);background-color:#378de5}#debug-bar-plugin-activation-delete-all a:active{position:relative;top:1px}table.debug-bar-plugin-activation,table.debug-bar-plugin-activation th,table.debug-bar-plugin-activation td{border:0 none}table.debug-bar-plugin-activation{width:100%;border-collapse:collapse;cell-padding:1em;clear:both;line-height:1.5;font-size:12px;table-layout:auto}table.debug-bar-plugin-activation thead th,table.debug-bar-plugin-activation tfoot th{padding:.7em 5px;width:auto}table.debug-bar-plugin-activation thead th{border-bottom:1px solid #ccc}table.debug-bar-plugin-activation tfoot th{border-top:1px solid #ccc}table.debug-bar-plugin-activation th,table.debug-bar-plugin-activation td{padding-left:5px;padding-right:10px}table.debug-bar-plugin-activation .col-1{width:5%;min-width:55px}table.debug-bar-plugin-activation .col-2{width:25%}table.debug-bar-plugin-activation .col-3{width:70%}table.debug-bar-plugin-activation tr td:nth-child(2){font-weight:bold}table.debug-bar-plugin-activation th{font-weight:bold;padding:2px 2em 2px 5px;vertical-align:top;text-align:left}table.debug-bar-plugin-activation td{padding:2px 5px;vertical-align:top}table.debug-bar-plugin-activation tr:nth-child(2n+1){background-color:#e8e8e8}table.debug-bar-plugin-activation td a .dashicons{color:#585858;text-decoration:none}table.debug-bar-plugin-activation td a:hover .dashicons{color:#c00}table.debug-bar-plugin-activation .spinner{background:no-repeat scroll 0 0 / 16px 16px rgba(0,0,0,0);visibility:hidden;float:right;height:16px;margin:2px 0 0 4px;opacity:.7;width:16px;padding-right:15px}table.debug-bar-plugin-activation .spinner.is-active{visibility:visible}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,145 @@
<?php
/**
* Debug Bar Plugin Activation, a WordPress plugin.
*
* @package WordPress\Plugins\Debug Bar Plugin Activation
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/debug-bar-plugin-activation
* @version 1.0
*
* @copyright 2016 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*
* @wordpress-plugin
* Plugin Name: Debug Bar Plugin Activation
* Plugin URI: https://wordpress.org/plugins/debug-bar-plugin-activation/
* Description: Debug Bar Plugin Activation adds a new panel to the Debug Bar which displays plugin (de-)activation errors.
* Version: 1.0
* Author: Juliette Reinders Folmer
* Author URI: http://www.adviesenzo.nl/
* Depends: Debug Bar
* Text Domain: debug-bar-plugin-activation
* Domain Path: /languages
* Copyright: 2016 Juliette Reinders Folmer
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
/**
* Make sure the plugin slug for this plugin is always available.
*/
if ( ! defined( 'DB_PA_BASENAME' ) ) {
define( 'DB_PA_BASENAME', plugin_basename( __FILE__ ) );
}
if ( ! function_exists( 'db_plugin_activation_has_parent_plugin' ) ) {
add_action( 'admin_init', 'db_plugin_activation_has_parent_plugin' );
/**
* Show admin notice & de-activate itself if the debug-bar parent plugin is not active.
*/
function db_plugin_activation_has_parent_plugin() {
if ( is_admin() && ( ! class_exists( 'Debug_Bar' ) && current_user_can( 'activate_plugins' ) ) && is_plugin_active( DB_PA_BASENAME ) ) {
add_action( 'admin_notices', create_function( null, 'echo \'<div class="error"><p>\', sprintf( __( \'Activation failed: Debug Bar must be activated to use the <strong>Debug Bar Plugin Activation</strong> Plugin. %sVisit your plugins page to activate.\', \'debug-bar-plugin-activation\' ), \'<a href="\' . admin_url( \'plugins.php#debug-bar\' ) . \'">\' ), \'</a></p></div>\';' ) );
deactivate_plugins( DB_PA_BASENAME, false, is_network_admin() );
// Add to recently active plugins list.
if ( ! is_network_admin() ) {
update_option( 'recently_activated', ( array( DB_PA_BASENAME => time() ) + (array) get_option( 'recently_activated' ) ) );
} else {
update_site_option( 'recently_activated', ( array( DB_PA_BASENAME => time() ) + (array) get_site_option( 'recently_activated' ) ) );
}
// Prevent trying again on page reload.
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
}
}
if ( ! function_exists( 'debug_bar_plugin_activation_panel' ) ) {
// Add it "high" so it's close to the other error related panels.
add_filter( 'debug_bar_panels', 'debug_bar_plugin_activation_panel', 5 );
/**
* Add the Debug Bar Plugin Activation panel to the Debug Bar.
*
* @param array $panels Existing debug bar panels.
*
* @return array
*/
function debug_bar_plugin_activation_panel( $panels ) {
if ( ! class_exists( 'Debug_Bar_Plugin_Activation' ) ) {
require_once 'class-debug-bar-plugin-activation.php';
}
$panels[] = new Debug_Bar_Plugin_Activation();
return $panels;
}
}
// Initialize the option which registers the (de-)activation errors.
if ( ! class_exists( 'Debug_Bar_Plugin_Activation_Option' ) ) {
require_once 'class-debug-bar-plugin-activation-option.php';
}
$debug_bar_plugin_activation_option = new Debug_Bar_Plugin_Activation_Option;
if ( ! function_exists( 'debug_bar_plugin_activation_do_ajax' ) ) {
/**
* Verify validity of ajax request and handle it if valid.
*/
function debug_bar_plugin_activation_do_ajax() {
// Verify this is a valid ajax request.
if ( ! isset( $_POST['dbpa_nonce'] ) || false === wp_verify_nonce( wp_unslash( $_POST['dbpa_nonce'] ), 'debug-bar-plugin-activation' ) ) { // WPCS: sanitization ok.
exit( '-1' );
}
// Sanitize the received values.
$vars = array_map( 'sanitize_text_field', array_map( 'wp_unslash', $_POST ) );
// Verify we have received the data needed to do anything.
if ( ! isset( $vars['type'] ) || ( 'all' !== $vars['type'] && '' === trim( $vars['plugin'] ) ) ) {
exit( '-1' );
}
// Validate & handle the received data.
$type = '';
if ( in_array( $vars['type'], array( 'activate', 'deactivate', 'uninstall', 'all' ), true ) ) {
$type = $vars['type'];
}
if ( 'all' === $type ) {
delete_option( Debug_Bar_Plugin_Activation_Option::NAME );
exit( '1' ); // Success response.
} else {
$option = get_option( Debug_Bar_Plugin_Activation_Option::NAME );
if ( isset( $option[ $type ][ $vars['plugin'] ] ) ) {
unset( $option[ $type ][ $vars['plugin'] ] );
update_option( Debug_Bar_Plugin_Activation_Option::NAME, $option );
exit( '1' ); // Success response.
}
}
/*
No valid action received (redundancy, can't really happen as WP wouldn't then call this
function, but would return 0 and exit already.
*/
exit( '-1' );
}
/* Add our ajax actions. */
add_action( 'wp_ajax_debug-bar-plugin-activation_delete', 'debug_bar_plugin_activation_do_ajax' );
}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,95 @@
/* globals debugBarPluginActivation */
jQuery( window ).ready( function() {
var dbMenuItem = jQuery( '#debug-menu-link-Debug_Bar_Plugin_Activation .debug-bar-issue-count' );
/* Make sure the spinner also works in the front-end */
jQuery( '#debug-bar-plugin-activation' ).find( 'span.spinner' ).css( { 'background-image': 'url("' + debugBarPluginActivation.spinner + '")' } );
/**
* Allow for deleting individual items.
*/
jQuery( 'table.debug-bar-plugin-activation' ).on( 'click', 'a.debug-bar-plugin-activation-delete', function( event ) {
var eventTarget = jQuery( this ),
rowType, spinner, eventData;
event.preventDefault();
rowType = eventTarget.attr( 'data-type' );
spinner = eventTarget.closest( 'td' ).find( 'span.spinner' );
spinner.addClass( 'is-active' );
// Event Data to be passed to ajax backend.
eventData = {
dbpa_nonce: debugBarPluginActivation.dbpa_nonce,
type: rowType,
plugin: eventTarget.attr( 'data-plugin' ),
action: 'debug-bar-plugin-activation_delete'
};
// Performing ajax request and proccesing response.
jQuery.post( debugBarPluginActivation.ajaxurl, eventData, function( response ) {
if ( 'number' === typeof response && 1 === response ) {
// Remove table and h3 header if it was the last row.
if ( 1 === eventTarget.closest( 'tbody' ).prop( 'rows' ).length ) {
eventTarget.closest( 'table' ).prev( 'h3' ).remove();
eventTarget.closest( 'table' ).remove();
jQuery( '#debug-bar-plugin-activation span.count.' + rowType ).text( 0 );
} else {
eventTarget.closest( 'tr' ).remove();
// Lower the counter by one.
jQuery( '#debug-bar-plugin-activation span.count.' + rowType ).text( function( index, text ) {
text = parseInt( text, 10 );
return ( text - 1 );
} );
}
// Lower the number in the menu on the left.
dbMenuItem.text( function( index, text ) {
text = parseInt( text, 10 );
return ( text - 1 );
} );
}
spinner.removeClass( 'is-active' );
}, 'json' );
} );
/**
* Allow for deleting all items in one go.
*/
jQuery( '#debug-bar-plugin-activation-delete-all' ).on( 'click', function( event ) {
var eventTarget = jQuery( this ),
spinner, eventData;
event.preventDefault();
spinner = eventTarget.closest( 'h2' ).find( 'span.spinner' );
spinner.addClass( 'is-active' );
// Event Data to be passed to ajax backend.
eventData = {
dbpa_nonce: debugBarPluginActivation.dbpa_nonce,
type: 'all',
action: 'debug-bar-plugin-activation_delete'
};
// Performing ajax request and proccesing response.
jQuery.post( debugBarPluginActivation.ajaxurl, eventData, function( response ) {
if ( 'number' === typeof response && 1 === response ) {
jQuery( '#debug-bar-plugin-activation h3, #debug-bar-plugin-activation table' ).remove();
jQuery( '#debug-bar-plugin-activation span.count' ).text( '0' ); // Set all counters to 0.
dbMenuItem.remove();
}
spinner.removeClass( 'is-active' );
}, 'json' );
} );
} );

View File

@@ -0,0 +1 @@
jQuery(window).ready(function(){var dbMenuItem=jQuery("#debug-menu-link-Debug_Bar_Plugin_Activation .debug-bar-issue-count");jQuery("#debug-bar-plugin-activation").find("span.spinner").css({"background-image":'url("'+debugBarPluginActivation.spinner+'")'});jQuery("table.debug-bar-plugin-activation").on("click","a.debug-bar-plugin-activation-delete",function(event){var eventTarget=jQuery(this),rowType,spinner,eventData;event.preventDefault();rowType=eventTarget.attr("data-type");spinner=eventTarget.closest("td").find("span.spinner");spinner.addClass("is-active");eventData={dbpa_nonce:debugBarPluginActivation.dbpa_nonce,type:rowType,plugin:eventTarget.attr("data-plugin"),action:"debug-bar-plugin-activation_delete"};jQuery.post(debugBarPluginActivation.ajaxurl,eventData,function(response){if("number"===typeof response&&1===response){if(1===eventTarget.closest("tbody").prop("rows").length){eventTarget.closest("table").prev("h3").remove();eventTarget.closest("table").remove();jQuery("#debug-bar-plugin-activation span.count."+rowType).text(0)}else{eventTarget.closest("tr").remove();jQuery("#debug-bar-plugin-activation span.count."+rowType).text(function(index,text){text=parseInt(text,10);return(text-1)})}dbMenuItem.text(function(index,text){text=parseInt(text,10);return(text-1)})}spinner.removeClass("is-active")},"json")});jQuery("#debug-bar-plugin-activation-delete-all").on("click",function(event){var eventTarget=jQuery(this),spinner,eventData;event.preventDefault();spinner=eventTarget.closest("h2").find("span.spinner");spinner.addClass("is-active");eventData={dbpa_nonce:debugBarPluginActivation.dbpa_nonce,type:"all",action:"debug-bar-plugin-activation_delete"};jQuery.post(debugBarPluginActivation.ajaxurl,eventData,function(response){if("number"===typeof response&&1===response){jQuery("#debug-bar-plugin-activation h3, #debug-bar-plugin-activation table").remove();jQuery("#debug-bar-plugin-activation span.count").text("0");dbMenuItem.remove()}spinner.removeClass("is-active")},"json")})});

View File

@@ -0,0 +1,90 @@
#, fuzzy
msgid ""
msgstr ""
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
"Project-Id-Version: Debug Bar Plugin Activation\n"
"POT-Creation-Date: 2016-07-01 15:57+0200\n"
"PO-Revision-Date: 2016-07-01 05:03+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.8\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-WPHeader: debug-bar-plugin-activation.php\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
"X-Poedit-SearchPath-0: .\n"
"X-Poedit-SearchPathExcluded-0: *.js\n"
"X-Poedit-SearchPathExcluded-1: testfiles\n"
#: class-debug-bar-plugin-activation.php:67
msgid "Plugin (de-)activation output"
msgstr ""
#: class-debug-bar-plugin-activation.php:125
msgid "An error occurred"
msgstr ""
#. translators: 1: line break.
#: class-debug-bar-plugin-activation.php:187
#, php-format
msgid "Total Plugins%1$s with %1$sActivation Issues:"
msgstr ""
#. translators: 1: line break.
#: class-debug-bar-plugin-activation.php:189
#, php-format
msgid "Total Plugins%1$s with %1$sDe-activation Issues:"
msgstr ""
#. translators: 1: line break.
#: class-debug-bar-plugin-activation.php:191
#, php-format
msgid "Total Plugins%1$s with %1$sUninstall Issues:"
msgstr ""
#: class-debug-bar-plugin-activation.php:193
msgid "Activation Issues"
msgstr ""
#: class-debug-bar-plugin-activation.php:194
msgid "De-activation Issues"
msgstr ""
#: class-debug-bar-plugin-activation.php:195
msgid "Uninstall Issues"
msgstr ""
#: class-debug-bar-plugin-activation.php:267
msgid "Plugin slug"
msgstr ""
#: class-debug-bar-plugin-activation.php:268
msgid "Unexpected output"
msgstr ""
#. Plugin Name of the plugin/theme
msgid "Debug Bar Plugin Activation"
msgstr ""
#. Plugin URI of the plugin/theme
msgid "https://wordpress.org/plugins/debug-bar-plugin-activation/"
msgstr ""
#. Description of the plugin/theme
msgid ""
"Debug Bar Plugin Activation adds a new panel to the Debug Bar which displays "
"plugin (de-)activation errors."
msgstr ""
#. Author of the plugin/theme
msgid "Juliette Reinders Folmer"
msgstr ""
#. Author URI of the plugin/theme
msgid "http://www.adviesenzo.nl/"
msgstr ""

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

View File

@@ -0,0 +1,96 @@
=== Debug Bar Plugin Activation ===
Contributors: jrf
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=995SSNDTCVBJG
Tags: debugbar, debug-bar, Debug Bar, plugin activation, plugin deactivation, uninstall, unexpected output
Requires at least: 3.8
Tested up to: 4.5
Stable tag: 1.0
License: GPLv2
Debug Bar Plugin Activation adds a new panel to the Debug Bar which displays plugin (de-)activation and uninstall errors.
== Description ==
Ever been "greeted" when you activated a plugin with the dreaded:
> This plugin generated # characters of **unexpected output** during activation....
And wondered what the unexpected output was ?
Or wondered whether a _de-activation_ or _uninstall_ routine was free of typical PHP errors ?
Well, no need to wonder anymore, as you can now see the output within your favorite debugging tool - the [Debug Bar](https://wordpress.org/plugins/debug-bar/).
Debug Bar Plugin Activation adds a new panel to the Debug Bar which displays the output generated during plugin activation, deactivation and uninstall.
Once you've fixed the issues, you can remove the logged output straight from the Debug Bar panel.
And when you uninstall a plugin, the associated logged activation and deactivation output entries will be removed automatically.
> This plugin was inspired by a conversation with [Mika Epstein](https://profiles.wordpress.org/ipstenu) during the [contributors day at WordCamp Europe 2016](https://2016.europe.wordcamp.org/introducing-the-wceu-2016-contributor-day-and-workshops/).
= Important =
This plugin requires the [Debug Bar](https://wordpress.org/plugins/debug-bar/) plugin to be installed and activated.
Also note that this plugin should be used solely for debugging and/or in a development environment and is not intended for use on a production site.
***********************************
If you like this plugin, please [rate and/or review](https://wordpress.org/support/view/plugin-reviews/debug-bar-plugin-activation) it. If you have ideas on how to make the plugin even better or if you have found any bugs, please report these in the [Support Forum](https://wordpress.org/support/plugin/debug-bar-plugin-activation) or in the [GitHub repository](https://github.com/jrfnl/debug-bar-plugin-activation/issues).
== Frequently Asked Questions ==
= Can it be used on live site ? =
This plugin is only meant to be used for development purposes, but shouldn't cause any issues if run on a production site.
= What is plugin (de-)activation ? =
> Activation and deactivation hooks provide ways to perform actions when plugins are activated or deactivated.
> Plugins can run an installation routine when they are activated in order to add rewrite rules, add custom database tables, or set default option values. ... The deactivation hook is best used to clear temporary data such as caches and temp directories.
Ref: [Plugin Handbook](https://developer.wordpress.org/plugins/the-basics/activation-deactivation-hooks/)
= What about uninstalling ? =
> Your plugin may need to do some clean-up when it is uninstalled from a site. A plugin is considered uninstalled if a user has deactivated the plugin, and then clicks the delete link.
>
> When your plugin is uninstalled, you'll want to clear out any rewrite rules added by the plugin, options and/or settings specific to to the plugin, or other database values that need to be removed.
Ref: [Plugin Handbook](https://developer.wordpress.org/plugins/the-basics/uninstall-methods/)
= How do I add activation, deactivation and uninstall routines to my plugin ? =
All the information you need is in the [Plugin Handbook on Plugin Basics](https://developer.wordpress.org/plugins/the-basics/).
= Why won't the plugin activate ? =
Have you read what it says in the beautifully red bar at the top of your plugins page ? As it says there, the Debug Bar plugin needs to be active for this plugin to work. If the Debug Bar plugin is not active, this plugin will automatically de-activate itself.
== Changelog ==
= 1.0 (2016-07-02) =
* Initial release.
== Upgrade Notice ==
= 1.0 =
* Initial release.
== Installation ==
1. Install Debug Bar if not already installed (https://wordpress.org/plugins/debug-bar/).
1. Extract the .zip file for this plugin and upload its contents to the `/wp-content/plugins/` directory. Alternatively, you can install directly from the Plugin directory within your WordPress Install.
1. Activate the plugin through the "Plugins" menu in WordPress.
Don't use this plugin on a live site. This plugin is **only** intended to be used for development purposes.
== Screenshots ==
1. Debug Bar Plugin Activation displaying error notices.

View File

@@ -0,0 +1,13 @@
<?php
/**
* Code used when the plugin is removed (not just deactivated but actively deleted by the WordPress Admin).
*
* @package WordPress\Plugins\Debug Bar Plugin Activation
* @subpackage Uninstall
*/
if ( ! current_user_can( 'activate_plugins' ) || ( ! defined( 'ABSPATH' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) ) {
exit();
}
delete_option( 'debug_bar_plugin_activation' );

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,832 @@
<?php
/**
* Debug Bar Shortcodes - Debug Bar Shortcodes Render.
*
* @package WordPress\Plugins\Debug Bar Shortcodes
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/Debug-Bar-Shortcodes
* @since 1.0
* @since 2.0 Class renamed - was: Debug_Bar_Shortcodes_Info
*
* @copyright 2013-2016 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
/**
* The classes in this file extend the functionality provided by the parent plugin "Debug Bar".
*/
if ( ! class_exists( 'Debug_Bar_Shortcodes_Render' ) ) :
/**
* Debug Bar Shortcodes - Debug Bar Panel Renderer.
*/
class Debug_Bar_Shortcodes_Render {
/**
* Plugin name for use in localization, class names etc.
*
* @var string $name
*/
public static $name = 'debug-bar-shortcodes';
/**
* The amount of shortcodes before the table header will be doubled at the bottom of the table.
*
* @var int
*/
public $double_min = 8;
/**
* Render the actual panel.
*/
public function display() {
$shortcodes = $GLOBALS['shortcode_tags'];
$count = count( $shortcodes );
$double = ( ( $count >= $this->double_min ) ? true : false ); // Whether to repeat the row labels at the bottom of the table.
echo '
<h2><span>', esc_html__( 'Total Registered Shortcodes:', 'debug-bar-shortcodes' ), '</span>', absint( $count ), '</h2>';
$output = '';
if ( is_array( $shortcodes ) && ! empty( $shortcodes ) ) {
uksort( $shortcodes, 'strnatcasecmp' );
$is_singular = ( is_main_query() && is_singular() );
$header_row = $this->render_table_header( $is_singular );
$output .= '
<table id="' . esc_attr( self::$name ) . '">
<thead>' . $header_row . '</thead>
' . ( ( true === $double ) ? '<tfoot>' . $header_row . '</tfoot>' : '' ) . '
<tbody>';
$i = 1;
foreach ( $shortcodes as $shortcode => $callback ) {
$sc_info = new Debug_Bar_Shortcode_Info( $shortcode );
$info = $sc_info->get_info_object();
$has_details = $sc_info->has_details();
$class = ( ( $i % 2 ) ? '' : ' class="even"' );
$output .= '
<tr' . $class . '>
<td>' . $i . '</td>
<td class="column-title">
<strong>[<code>' . esc_html( $shortcode ) . '</code>]</strong>
' . $this->render_action_links( $shortcode, $has_details, $info ) . '
</td>
<td>' . $this->determine_callback_type( $callback ) . '</td>';
if ( true === $is_singular ) {
$in_use = $this->has_shortcode( $shortcode );
$output .= '
<td>' . $this->render_image_based_on_bool( array( 'true' => esc_html__( 'Shortcode is used', 'debug-bar-shortcodes' ), 'false' => esc_html__( 'Shortcode not used', 'debug-bar-shortcodes' ) ), $in_use, true ) . '</td>
<td>' . ( ( true === $in_use ) ? $this->find_shortcode_usage( $shortcode ) : '&nbsp;' ) . '</td>';
unset( $in_use );
}
$output .= '
</tr>';
if ( true === $has_details ) {
$class = ( ( $i % 2 ) ? ' class="' . esc_attr( self::$name . '-details' ) . '"' : ' class="even ' . esc_attr( self::$name . '-details' ) . '"' );
$output .= '
<tr' . $class . '>
<td>&nbsp;</td>
<td colspan="' . ( ( true === $is_singular ) ? 4 : 2 ) . '">
' . $this->render_details_table( $shortcode, $info ) . '
</td>
</tr>
';
}
$i++;
}
unset( $shortcode, $callback, $sc_info, $info, $has_details, $class, $i );
$output .= '
</tbody>
</table>';
}
else {
$output = '<p>' . esc_html__( 'No shortcodes found.', 'debug-bar-shortcodes' ) . '</p>';
}
echo $output; // WPCS: xss ok.
}
/**
* Generate the table header/footer row html.
*
* @param bool $is_singular Whether we are viewing a singular page/post/post type.
*
* @return string
*/
private function render_table_header( $is_singular ) {
$output = '<tr>
<th>#</th>
<th>' . esc_html__( 'Shortcode', 'debug-bar-shortcodes' ) . '</th>
<th>' . esc_html__( 'Rendered by', 'debug-bar-shortcodes' ) . '</th>';
if ( true === $is_singular ) {
$output .= '
<th>' . esc_html__( 'In use?', 'debug-bar-shortcodes' ) . '</th>
<th>' . esc_html__( 'Usage', 'debug-bar-shortcodes' ) . '</th>';
}
$output .= '</tr>';
return $output;
}
/**
* Generate the action links for a shortcode.
*
* @param string $shortcode Current shortcode.
* @param bool $has_details Whether or not the $info is equal to the defaults.
* @param \Debug_Bar_Shortcode_Info_Defaults $info Shortcode info.
*
* @return string
*/
private function render_action_links( $shortcode, $has_details, $info ) {
$links = array();
if ( true === $has_details ) {
$links[] = '<a href="#" class="' . esc_attr( self::$name . '-view-details' ) . '" title="' . esc_html__( 'View more detailed information about the shortcode.', 'debug-bar-shortcodes' ) . '">' . esc_html__( 'View details', 'debug-bar-shortcodes' ) . '</a>';
}
else {
$links[] = '<a href="#' . esc_attr( $shortcode ) . '" class="' . esc_attr( self::$name . '-get-details' ) . '" title="' . esc_html__( 'Try and retrieve more detailed information about the shortcode.', 'debug-bar-shortcodes' ) . '">' . esc_html__( 'Retrieve details', 'debug-bar-shortcodes' ) . '</a>';
}
$links[] = '<a href="#' . esc_attr( $shortcode ) . '" class="' . esc_attr( self::$name . '-find' ) . '" title="' . esc_html__( 'Find out where this shortcode is used (if at all)', 'debug-bar-shortcodes' ) . '">' . esc_html__( 'Find uses', 'debug-bar-shortcodes' ) . '</a>';
if ( true === $has_details && '' !== $info->info_url ) {
$links[] = $this->render_view_online_link( $info->info_url );
}
return '<span class="spinner"></span><div class="row-actions">' . implode( ' | ', $links ) . '</div>';
}
/**
* Generate 'View online' link.
*
* @internal Separated from render_action_links() to also be able to use it as supplemental for ajax retrieve.
*
* @param string $url The URL to link to.
*
* @return string
*/
private function render_view_online_link( $url ) {
return '<a href="' . esc_url( $url ) . '" target="_blank" title="' . __( 'View extended info about the shortcode on the web', 'debug-bar-shortcodes' ) . '" class="' . esc_attr( self::$name . '-external-link' ) . '" >' . esc_html__( 'View online', 'debug-bar-shortcodes' ) . '</a>';
}
/**
* Function to retrieve a displayable string representing the callback.
*
* @internal Similar to callback determination in the Debug Bar Actions and Filters plugin,
* keep them in line with each other.
*
* @param mixed $callback A callback.
*
* @return string
*/
private function determine_callback_type( $callback ) {
if ( ( ! is_string( $callback ) && ! is_object( $callback ) ) && ( ! is_array( $callback ) || ( is_array( $callback ) && ( ! is_string( $callback[0] ) && ! is_object( $callback[0] ) ) ) ) ) {
// Type 1 - not a callback.
return '';
}
elseif ( self::is_closure( $callback ) ) {
// Type 2 - closure.
return '[<em>closure</em>]';
}
elseif ( ( is_array( $callback ) || is_object( $callback ) ) && self::is_closure( $callback[0] ) ) {
// Type 3 - closure within an array/object.
return '[<em>closure</em>]';
}
elseif ( is_string( $callback ) && false === strpos( $callback, '::' ) ) {
// Type 4 - simple string function (includes lambda's).
return sanitize_text_field( $callback ) . '()';
}
elseif ( is_string( $callback ) && false !== strpos( $callback, '::' ) ) {
// Type 5 - static class method calls - string.
return '[<em>class</em>] ' . str_replace( '::', ' :: ', sanitize_text_field( $callback ) ) . '()';
}
elseif ( is_array( $callback ) && ( is_string( $callback[0] ) && is_string( $callback[1] ) ) ) {
// Type 6 - static class method calls - array.
return '[<em>class</em>] ' . sanitize_text_field( $callback[0] ) . ' :: ' . sanitize_text_field( $callback[1] ) . '()';
}
elseif ( is_array( $callback ) && ( is_object( $callback[0] ) && is_string( $callback[1] ) ) ) {
// Type 7 - object method calls.
return '[<em>object</em>] ' . get_class( $callback[0] ) . ' -> ' . sanitize_text_field( $callback[1] ) . '()';
}
else {
// Type 8 - undetermined.
return '<pre>' . var_export( $callback, true ) . '</pre>';
}
}
/**
* Whether the current (singular) post contains the specified shortcode.
*
* Freely based on WP native implementation:
* Source http://core.trac.wordpress.org/browser/trunk/src/wp-includes/shortcodes.php#L144
* Last compared against source: 2015-12-14.
*
* @global object $post Current post object.
*
* @static array $matches Regex matches for the post in the form [id] -> [matches].
*
* @param string $shortcode The shortcode to check for.
*
* @return bool
*/
private function has_shortcode( $shortcode ) {
static $matches;
/* Have we got post content ? */
if ( ! is_object( $GLOBALS['post'] ) || ! isset( $GLOBALS['post']->post_content ) || '' === $GLOBALS['post']->post_content ) {
return false;
}
$content = $GLOBALS['post']->post_content; // Current post.
/* Use WP native function if available (WP 3.6+). */
if ( function_exists( 'has_shortcode' ) ) {
return has_shortcode( $content, $shortcode );
}
/* Otherwise use adjusted copy of the native function (WP < 3.6). */
$post_id = $GLOBALS['post']->ID;
// Cache retrieved shortcode matches in a static for efficiency.
if ( ! isset( $matches ) || ( is_array( $matches ) && ! isset( $matches[ $post_id ] ) ) ) {
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches[ $post_id ], PREG_SET_ORDER );
}
if ( empty( $matches[ $post_id ] ) ) {
return false;
}
foreach ( $matches[ $post_id ] as $found ) {
if ( $shortcode === $found[2] ) {
return true;
}
elseif ( ! empty( $shortcode[5] ) && has_shortcode( $shortcode[5], $shortcode ) ) {
return true;
}
}
return false;
}
/**
* Find the uses of a shortcode within the current post.
*
* @param string $shortcode The requested shortcode.
* @param string|null $content (optional) Content to search through for the shortcode.
* Defaults to the content of the current post/page/etc.
*
* @return string
*/
private function find_shortcode_usage( $shortcode, $content = null ) {
$result = __( 'Not found', 'debug-bar-shortcodes' );
if ( ! isset( $content ) && ( ! isset( $GLOBALS['post'] ) || ! is_object( $GLOBALS['post'] ) || ! isset( $GLOBALS['post']->post_content ) ) ) {
return $result;
}
if ( ! isset( $content ) ) {
$content = $GLOBALS['post']->post_content;
}
$shortcode = preg_quote( $shortcode );
$regex = '`(?:^|[^\[])(\[' . $shortcode . '[^\]]*\])(?:.*?(\[/' . $shortcode . '\])(?:[^\]]|$))?`s';
$count = preg_match_all( $regex, $content, $matches, PREG_SET_ORDER );
if ( is_int( $count ) && $count > 0 ) {
// Only one result, keep it simple.
if ( 1 === $count ) {
$result = '<code>' . esc_html( $matches[0][1] );
if ( isset( $matches[0][2] ) && '' !== $matches[0][2] ) {
$result .= '&hellip;' . esc_html( $matches[0][2] );
}
$result .= '</code>';
}
// More results, let's make it a neat list.
else {
$result = '<ol>';
foreach ( $matches as $match ) {
$result .= '<li><code>' . esc_html( $match[1] );
if ( isset( $match[2] ) && '' !== $match[2] ) {
$result .= '&hellip;' . esc_html( $match[2] );
}
$result .= '</code></li>';
}
unset( $match );
$result .= '</ol>';
}
}
return $result;
}
/**
* Retrieve a html image tag based on a value.
*
* @param array $alt Array with only three allowed keys:
* ['true'] => Alt value for true image.
* ['false'] => Alt value for false image.
* ['null'] => Alt value for null image (status unknown).
* @param bool|null $bool The value to base the output on, either boolean or null.
* @param bool $show_false Whether to show an image if false or to return an empty string.
* @param bool $show_null Whether to show an image if null or to return an empty string.
*
* @return string
*/
private function render_image_based_on_bool( $alt = array(), $bool = null, $show_false = false, $show_null = false ) {
static $images;
if ( ! isset( $images ) ) {
$images = array(
'true' => plugins_url( 'images/badge-circle-check-16.png', __FILE__ ),
'false' => plugins_url( 'images/badge-circle-cross-16.png', __FILE__ ),
'null' => plugins_url( 'images/help.png', __FILE__ ),
);
}
$img = ( ( isset( $bool ) ) ? ( ( true === $bool ) ? $images['true'] : $images['false'] ) : $images['null'] );
$alt_value = '';
if ( isset( $bool ) ) {
if ( true === $bool && isset( $alt['true'] ) ) {
$alt_value = $alt['true'];
}
elseif ( false === $bool && isset( $alt['false'] ) ) {
$alt_value = $alt['false'];
}
}
elseif ( isset( $alt['null'] ) ) {
$alt_value = $alt['null'];
}
$title_tag = '';
$alt_tag = '';
if ( '' !== $alt_value ) {
$title_tag = ' title="' . esc_attr( $alt_value ) . '"';
$alt_tag = ' alt="' . esc_attr( $alt_value ) . '"';
}
$return = '';
if ( ( null === $bool && true === $show_null ) || ( true === $bool || ( false === $bool && true === $show_false ) ) ) {
$return = '<img src="' . esc_url( $img ) . '" width="16" height="16"' . $alt_tag . $title_tag . '/>';
}
return $return;
}
/**
* Generate the html for a shortcode detailed info table.
*
* @param string $shortcode Current shortcode.
* @param \Debug_Bar_Shortcode_Info_Defaults $info Shortcode info.
*
* @return string
*/
private function render_details_table( $shortcode, $info ) {
$rows = array();
if ( '' !== $info->name ) {
$rows['name'] = '
<tr>
<th colspan="2">' . esc_html__( 'Name', 'debug-bar-shortcodes' ) . '</th>
<td>' . esc_html( $info->name ) . '</td>
</tr>';
}
if ( '' !== $info->description ) {
$rows['description'] = '
<tr>
<th colspan="2">' . esc_html__( 'Description', 'debug-bar-shortcodes' ) . '</th>
<td>' . $info->description . '</td>
</tr>';
}
$rows['syntax'] = $this->render_details_syntax_row( $shortcode, $info );
if ( '' !== $info->info_url ) {
$rows['info_url'] = '
<tr>
<th colspan="2">' . esc_html__( 'Info Url', 'debug-bar-shortcodes' ) . '</th>
<td><a href="' . esc_url( $info->info_url ) . '" target="_blank" class="' . esc_attr( self::$name . '-external-link' ) . '">' . esc_html( $info->info_url ) . '</a></td>
</tr>';
}
if ( ! empty( $info->parameters['required'] ) ) {
$rows['rp'] = $this->render_details_parameter_row(
$info,
'required',
__( 'Required parameters', 'debug-bar-shortcodes' )
);
}
if ( ! empty( $info->parameters['optional'] ) ) {
$rows['op'] = $this->render_details_parameter_row(
$info,
'optional',
__( 'Optional parameters', 'debug-bar-shortcodes' )
);
}
/* Ignore the result if syntax is the only info row (as it's always there). */
if ( 1 >= count( $rows ) && isset( $rows['syntax'] ) ) {
$output = '';
}
else {
$output = '
<h4>' . esc_html__( 'Shortcode details', 'debug-bar-shortcodes' ) . '</h4>
<table>' . implode( $rows ) . '
</table>';
}
return $output;
}
/**
* Generate the html for a shortcode detailed info table syntax row.
*
* @param string $shortcode Current shortcode.
* @param \Debug_Bar_Shortcode_Info_Defaults $info Shortcode info.
*
* @return string
*/
private function render_details_syntax_row( $shortcode, $info ) {
$row = '
<tr>
<th colspan="2">' . esc_html__( 'Syntax', 'debug-bar-shortcodes' ) . '</th>
<td>';
if ( isset( $info->self_closing ) ) {
$param = ( ( ! empty( $info->parameters['required'] ) || ! empty( $info->parameters['optional'] ) ) ? ' <em>[parameters]</em> ' : '' );
if ( true === $info->self_closing ) {
$row .= '<code>[' . esc_html( $shortcode ) . $param . ' /]</code>';
}
else {
$row .= '<code>[' . esc_html( $shortcode ) . $param . '] &hellip; [/' . esc_html( $shortcode ) . ']</code>';
}
}
else {
$row .= '<em>' . esc_html__( 'Unknown', 'debug-bar-shortcodes' ) . '</em>';
}
$row .= '</td>
</tr>';
return $row;
}
/**
* Generate the html for a shortcode detailed info table parameter row.
*
* @param \Debug_Bar_Shortcode_Info_Defaults $info Shortcode info.
* @param string $type Parameter type: 'required' or 'optional'.
* @param string $label Parameter label.
*
* @return string
*/
private function render_details_parameter_row( $info, $type, $label ) {
$row = '
<tr class="' . esc_attr( self::$name . '-sc-parameters' ) . '">
<th rowspan="' . count( $info->parameters[ $type ] ) . '">' . esc_html( $label ) . '</th>';
$first = true;
foreach ( $info->parameters[ $type ] as $pm => $explain ) {
if ( true !== $first ) {
$row .= '
<tr>';
}
else {
$first = false;
}
$row .= '
<td>' . esc_html( $pm ) . '</td>
<td>' . esc_html( $explain ) . '</td>
</tr>';
}
return $row;
}
/* ************** METHODS TO HANDLE AJAX REQUESTS ************** */
/**
* Try and retrieve more information about the shortcode from the actual php code.
*
* @param string $shortcode Validated shortcode.
* @param string $action The AJAX action which led to this function being called.
*
* @return void
*/
public function ajax_retrieve_details( $shortcode, $action ) {
$sc_info = new Debug_Bar_Shortcode_Info( $shortcode, true );
if ( false === $sc_info->has_details() ) {
$response = array(
'id' => 0,
'data' => '',
'action' => $action,
);
$this->send_ajax_response( $response );
exit;
}
$info = $sc_info->get_info_object();
$response = array(
'id' => 1,
'data' => $this->render_details_table( $shortcode, $info ),
'action' => $action,
'tr_class' => self::$name . '-details',
);
if ( isset( $info->info_url ) && '' !== $info->info_url ) {
$response['supplemental'] = $this->render_view_online_link( $info->info_url );
}
$this->send_ajax_response( $response );
exit;
}
/**
* Find out if a shortcode is used anywhere.
*
* Liberally nicked from TR All Shortcodes plugin & adjusted based on WP posts-list-table code.
* Source: https://wordpress.org/plugins/tr-all-shortcodes/
* Source: http://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-posts-list-table.php#L473
*
* @param string $shortcode Validated shortcode.
* @param string $action The AJAX action which led to this function being called.
*
* @return void
*/
public function ajax_find_shortcode_uses( $shortcode, $action ) {
// '_' is a wildcard in mysql, so escape it.
$query = $GLOBALS['wpdb']->prepare(
'select * from `' . $GLOBALS['wpdb']->posts . '`
where `post_status` <> "inherit"
and `post_type` <> "attachment"
and `post_content` like %s
order by `post_type` ASC, `post_date` DESC;',
'%[' . str_replace( '_', '\_', $shortcode ) . '%'
);
$posts = $GLOBALS['wpdb']->get_results( $query );
/* Do we have posts ? */
if ( 0 === $GLOBALS['wpdb']->num_rows ) {
$response = array(
'id' => 0,
'data' => '',
'action' => $action,
);
$this->send_ajax_response( $response );
exit;
}
/* Ok, we've found some posts using the shortcode. */
$output = '
<h4>' . __( 'Shortcode found in the following posts/pages/etc:', 'debug-bar-shortcodes' ) . '</h4>
<table>
<thead>
<tr>
<th>#</th>
<th>' . esc_html__( 'Title', 'debug-bar-shortcodes' ) . '</th>
<th>' . esc_html__( 'Post Type', 'debug-bar-shortcodes' ) . '</th>
<th>' . esc_html__( 'Status', 'debug-bar-shortcodes' ) . '</th>
<th>' . esc_html__( 'Author', 'debug-bar-shortcodes' ) . '</th>
<th>' . esc_html__( 'Shortcode usage(s)', 'debug-bar-shortcodes' ) . '</th>
</tr>
</thead>
<tbody>';
foreach ( $posts as $i => $post ) {
$edit_link = get_edit_post_link( $post->ID );
$title = _draft_or_post_title( $post->ID );
$post_type_object = get_post_type_object( $post->post_type );
$can_edit_post = current_user_can( 'edit_post', $post->ID );
$post_status_string = $this->get_post_status_string( $post->post_status );
$actions = array();
if ( $can_edit_post && 'trash' !== $post->post_status ) {
/* translators: no need to translate, WP standard translation will be used. */
$actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">';
/* translators: no need to translate, WP standard translation will be used. */
$actions['edit'] .= __( 'Edit' ) . '</a>';
}
if ( $post_type_object->public ) {
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ), true ) ) {
if ( $can_edit_post ) {
/* translators: no need to translate, WP standard translation will be used. */
$actions['view'] = '<a href="' . esc_url( apply_filters( 'preview_post_link', set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">';
/* translators: no need to translate, WP standard translation will be used. */
$actions['view'] .= __( 'Preview' ) . '</a>';
}
}
elseif ( 'trash' !== $post->post_status ) {
/* translators: no need to translate, WP standard translation will be used. */
$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">';
/* translators: no need to translate, WP standard translation will be used. */
$actions['view'] .= __( 'View' ) . '</a>';
}
}
$output .= '
<tr>
<td>' . ( $i + 1 ) . '</td>
<td class="column-title"><strong>' . $title . '</strong>';
if ( ! empty( $actions ) ) {
$output .= '<div class="row-actions">' . implode( ' | ', $actions ) . '</div>';
}
$output .= '
</td>
<td>' . esc_html( $post_type_object->labels->singular_name ) . '</td>
<td>' . esc_html( $post_status_string ) . '</td>
<td>' . esc_html( get_the_author_meta( 'display_name', $post->post_author ) ) . '</td>
<td>' . $this->find_shortcode_usage( $shortcode, $post->post_content ) . '</td>
</tr>';
}
unset( $i, $post );
$output .= '
</tbody>
</table>';
$response = array(
'id' => 1,
'data' => $output,
'action' => $action,
'tr_class' => self::$name . '-uses',
);
$this->send_ajax_response( $response );
exit;
}
/**
* Translate a post status keyword to a human readable localized string.
*
* @param string $post_status The post status to translate.
*
* @return string
*/
private function get_post_status_string( $post_status ) {
switch ( $post_status ) {
case 'publish':
/* translators: no need to translate, WP standard translation will be used. */
$post_status_string = __( 'Published' );
break;
case 'future':
/* translators: no need to translate, WP standard translation will be used. */
$post_status_string = __( 'Scheduled' );
break;
case 'private':
/* translators: no need to translate, WP standard translation will be used. */
$post_status_string = __( 'Private' );
break;
case 'pending':
/* translators: no need to translate, WP standard translation will be used. */
$post_status_string = __( 'Pending Review' );
break;
case 'draft':
case 'auto-draft':
/* translators: no need to translate, WP standard translation will be used. */
$post_status_string = __( 'Draft' );
break;
case 'trash':
/* translators: no need to translate, WP standard translation will be used. */
$post_status_string = __( 'Trash' );
break;
default:
$post_status_string = __( 'Unknown', 'debug-bar-shortcodes' );
break;
}
return $post_status_string;
}
/**
* Send ajax response.
*
* @param array $response Part response in the format:
* [id] => 0 = no result, 1 = result.
* [data] => html string (can be empty if no result).
* [supplemental] => (optional) supplemental info to pass.
* [tr_class] => (optional) class for the wrapping row.
*
* @return void
*/
public function send_ajax_response( $response ) {
$tr_class = '';
if ( isset( $response['tr_class'] ) && '' !== $response['tr_class'] ) {
$tr_class = ' class="' . esc_attr( $response['tr_class'] ) . '"';
}
$data = '';
if ( '' !== $response['data'] ) {
$data = '<tr' . $tr_class . '>
<td>&nbsp;</td>
<td colspan="{colspan}">
' . $response['data'] . '
</td>
</tr>';
}
$supplemental = array();
// Only accounts for the expected new view online link, everything else will be buggered.
if ( isset( $response['supplemental'] ) && '' !== $response['supplemental'] ) {
$supplemental['url_link'] = ' | ' . $response['supplemental'];
}
/* Send the response. */
$ajax_response = new WP_Ajax_Response();
$ajax_response->add(
array(
'what' => self::$name,
'action' => $response['action'],
'id' => $response['id'],
'data' => $data,
'supplemental' => $supplemental,
)
);
$ajax_response->send();
exit;
}
/* ************** HELPER METHODS ************** */
/**
* Check if a callback is a closure.
*
* @param mixed $arg Function name.
*
* @return bool
*/
public static function is_closure( $arg ) {
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
return false;
}
include_once plugin_dir_path( __FILE__ ) . 'php53/php5.3-closure-test.php';
return debug_bar_shortcodes_is_closure( $arg );
}
} // End of class Debug_Bar_Shortcodes_Render.
endif; // End of if class_exists wrapper.

View File

@@ -0,0 +1,145 @@
<?php
/**
* Debug Bar Shortcodes - Debug Bar Panel.
*
* @package WordPress\Plugins\Debug Bar Shortcodes
* @author Juliette Reinders Folmer <wpplugins_nospam@adviesenzo.nl>
* @link https://github.com/jrfnl/Debug-Bar-Shortcodes
* @since 1.0
* @version 2.0.3
*
* @copyright 2013-2016 Juliette Reinders Folmer
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU General Public License, version 2 or higher
*/
// Avoid direct calls to this file.
if ( ! function_exists( 'add_action' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
/**
* The classes in this file extend the functionality provided by the parent plugin "Debug Bar".
*/
if ( ! class_exists( 'Debug_Bar_Shortcodes' ) && class_exists( 'Debug_Bar_Panel' ) ) :
/**
* Debug Bar Shortcodes - Debug Bar Panel.
*/
class Debug_Bar_Shortcodes extends Debug_Bar_Panel {
const DBS_STYLES_VERSION = '2.0.2';
const DBS_SCRIPT_VERSION = '2.0.2';
const DBS_NAME = 'debug-bar-shortcodes';
/**
* Set up our panel.
*/
public function init() {
$this->load_textdomain( self::DBS_NAME );
$this->title( __( 'Shortcodes', 'debug-bar-shortcodes' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'dbs_enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'dbs_enqueue_scripts' ) );
}
/**
* Load the plugin text strings.
*
* Compatible with use of the plugin in the must-use plugins directory.
*
* @param string $domain Text domain to load.
*/
protected function load_textdomain( $domain ) {
if ( is_textdomain_loaded( $domain ) ) {
return;
}
$lang_path = dirname( plugin_basename( __FILE__ ) ) . '/languages';
if ( false === strpos( __FILE__, basename( WPMU_PLUGIN_DIR ) ) ) {
load_plugin_textdomain( $domain, false, $lang_path );
}
else {
load_muplugin_textdomain( $domain, $lang_path );
}
}
/**
* Enqueue our scripts and styles.
*/
public function dbs_enqueue_scripts() {
$suffix = ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' );
wp_enqueue_style(
self::DBS_NAME,
plugins_url( 'css/' . self::DBS_NAME . $suffix . '.css', __FILE__ ),
array( 'debug-bar' ),
self::DBS_STYLES_VERSION
);
wp_enqueue_script(
self::DBS_NAME,
plugins_url( 'js/' . self::DBS_NAME . $suffix . '.js', __FILE__ ),
array( 'jquery', 'wp-ajax-response' ),
self::DBS_SCRIPT_VERSION,
true
);
// Reminder for js @todo jquery-effects-highlight.
wp_localize_script(
self::DBS_NAME,
'i18nDbShortcodes',
$this->dbs_get_javascript_i18n()
);
}
/**
* Retrieve the strings for use in our javascript.
*
* @return array
*/
public function dbs_get_javascript_i18n() {
$strings = array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'hide_details' => __( 'Hide details', 'debug-bar-shortcodes' ),
'view_details' => __( 'View details', 'debug-bar-shortcodes' ),
'no_details' => __( 'No details found', 'debug-bar-shortcodes' ),
'hide_use' => __( 'Hide Uses', 'debug-bar-shortcodes' ),
'view_use' => __( 'View Uses', 'debug-bar-shortcodes' ),
'not_in_use' => __( 'Not Used', 'debug-bar-shortcodes' ),
'error' => __( 'Ajax request failed or no proper response received. If you have WP_DEBUG enabled, this might be caused by a php error. The js error console might contain more information.', 'debug-bar-shortcodes' ),
'illegal' => __( 'Illegal request received.', 'debug-bar-shortcodes' ),
'nonce' => wp_create_nonce( self::DBS_NAME ),
'spinner' => admin_url( 'images/wpspin_light.gif' ),
);
return $strings;
}
/**
* Show only if there are registered shortcodes.
*
* Unless someone de-registers the wp standard shortcodes, should always evaluate to true.
*/
public function prerender() {
$this->set_visible( is_array( $GLOBALS['shortcode_tags'] ) && ! empty( $GLOBALS['shortcode_tags'] ) );
}
/**
* Render the panel.
*/
public function render() {
$output_rendering = new Debug_Bar_Shortcodes_Render();
$output_rendering->display();
}
} // End of class Debug_Bar_Shortcodes.
endif; // End of if class_exists wrapper.

View File

@@ -0,0 +1,113 @@
/* CSS for plugin: Debug Bar Shortcodes */
#debug-menu-target-Debug_Bar_Shortcodes h3 {
font-family: georgia, times, serif;
font-size: 22px;
margin-top: 1.2em;
clear: both;
}
table#debug-bar-shortcodes {
width: 100%;
border-collapse: collapse;
cell-padding: 1em;
clear: both;
line-height: 1.5;
font-size: 12px;
table-layout: auto;
}
table#debug-bar-shortcodes thead tr,
table#debug-bar-shortcodes tfoot tr {
background-color: #E8E8E8;
}
table#debug-bar-shortcodes thead th,
table#debug-bar-shortcodes tfoot th {
padding: 0.7em 5px;
width: auto;
text-align: left;
}
table#debug-bar-shortcodes thead th {
border-bottom: 1px solid #ccc;
}
table#debug-bar-shortcodes tfoot th {
border-top: 1px solid #ccc;
}
table#debug-bar-shortcodes th {
font-weight: bold;
padding: 2px 2em 2px 5px;
vertical-align: top;
text-align: left;
}
table#debug-bar-shortcodes td {
padding: 2px 5px;
vertical-align: top;
border: 0 none;
}
/*table.debug-bar-shortcodes tr:nth-child(2n+1) {*/
table#debug-bar-shortcodes tr.even {
background-color: #E8E8E8;
}
table#debug-bar-shortcodes div.row-actions {
visibility: hidden;
}
table#debug-bar-shortcodes td.column-title .spinner {
background: no-repeat scroll 0 0 / 16px 16px rgba(0, 0, 0, 0);
visibility: hidden;
float: right;
height: 16px;
margin: 2px 5px 0;
opacity: 0.7;
width: 16px;
padding-right: 15px;
}
table#debug-bar-shortcodes td.column-title .spinner.is-active {
visibility: visible;
}
table#debug-bar-shortcodes tr.debug-bar-shortcodes-details {
display: none;
}
table#debug-bar-shortcodes td code em {
color: #999999;
}
table#debug-bar-shortcodes td ul,
table#debug-bar-shortcodes td ol {
margin: 0;
padding: 0 0 0 30px;
}
table#debug-bar-shortcodes td h4 {
font-size: 16px;
margin: 8px 0 0 0;
}
table#debug-bar-shortcodes tr.debug-bar-shortcodes-details table,
table#debug-bar-shortcodes tr.debug-bar-shortcodes-uses table {
font-size: 11px;
border-top: 1px solid #999999;
border-bottom: 1px solid #999999;
}
table#debug-bar-shortcodes tr.debug-bar-shortcodes-uses table thead th {
text-align: left;
}
table#debug-bar-shortcodes tr.debug-bar-shortcodes-details table th {
width: 110px;
}
table#debug-bar-shortcodes tr.debug-bar-shortcodes-details table th[colspan] {
width: 200px;
}
table#debug-bar-shortcodes tr.debug-bar-shortcodes-details table tr.debug-bar-shortcodes-sc-parameters {
border-top: 1px solid #999999 !important;
}

View File

@@ -0,0 +1,2 @@
/* CSS for plugin: Debug Bar Shortcodes */
#debug-menu-target-Debug_Bar_Shortcodes h3{font-family:georgia,times,serif;font-size:22px;margin-top:1.2em;clear:both}table#debug-bar-shortcodes{width:100%;border-collapse:collapse;cell-padding:1em;clear:both;line-height:1.5;font-size:12px;table-layout:auto}table#debug-bar-shortcodes thead tr,table#debug-bar-shortcodes tfoot tr{background-color:#e8e8e8}table#debug-bar-shortcodes thead th,table#debug-bar-shortcodes tfoot th{padding:.7em 5px;width:auto;text-align:left}table#debug-bar-shortcodes thead th{border-bottom:1px solid #ccc}table#debug-bar-shortcodes tfoot th{border-top:1px solid #ccc}table#debug-bar-shortcodes th{font-weight:bold;padding:2px 2em 2px 5px;vertical-align:top;text-align:left}table#debug-bar-shortcodes td{padding:2px 5px;vertical-align:top;border:0 none}table#debug-bar-shortcodes tr.even{background-color:#e8e8e8}table#debug-bar-shortcodes div.row-actions{visibility:hidden}table#debug-bar-shortcodes td.column-title .spinner{background:no-repeat scroll 0 0 / 16px 16px rgba(0,0,0,0);visibility:hidden;float:right;height:16px;margin:2px 5px 0;opacity:.7;width:16px;padding-right:15px}table#debug-bar-shortcodes td.column-title .spinner.is-active{visibility:visible}table#debug-bar-shortcodes tr.debug-bar-shortcodes-details{display:none}table#debug-bar-shortcodes td code em{color:#999}table#debug-bar-shortcodes td ul,table#debug-bar-shortcodes td ol{margin:0;padding:0 0 0 30px}table#debug-bar-shortcodes td h4{font-size:16px;margin:8px 0 0 0}table#debug-bar-shortcodes tr.debug-bar-shortcodes-details table,table#debug-bar-shortcodes tr.debug-bar-shortcodes-uses table{font-size:11px;border-top:1px solid #999;border-bottom:1px solid #999}table#debug-bar-shortcodes tr.debug-bar-shortcodes-uses table thead th{text-align:left}table#debug-bar-shortcodes tr.debug-bar-shortcodes-details table th{width:110px}table#debug-bar-shortcodes tr.debug-bar-shortcodes-details table th[colspan]{width:200px}table#debug-bar-shortcodes tr.debug-bar-shortcodes-details table tr.debug-bar-shortcodes-sc-parameters{border-top:1px solid #999 !important}

View File

@@ -0,0 +1,2 @@
<?php
// Nothing to see here.

Some files were not shown because too many files have changed in this diff Show More