rebase from live enviornment

This commit is contained in:
Rachit Bhargava
2024-01-09 22:14:20 -05:00
parent ff0b49a046
commit 3a22fcaa4a
15968 changed files with 2344674 additions and 45234 deletions

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,619 @@
.bsf-aiosrs-schema-row td .bsf-aiosrs-schema-custom-text-wrap {
vertical-align: top;
}
.bsf-aiosrs-schema-custom-text-wrap .time-duration-wrap input,
.aiosrs-pro-meta-fields-wrapper .time-duration-wrap input {
width: 55px;
font-size: 12px;
padding-right: 0;
margin-right: 0;
margin-left: 0;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-pro-custom-field-rating input.bsf-rating-field,
.aiosrs-pro-meta-fields-wrapper .aiosrs-pro-custom-field-rating input {
width: 50px;
}
.aiosrs-pro-repeater-table .aiosrs-pro-custom-field-rating input.bsf-rating-field {
width: 25% !important;
padding-right: 0;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-star-rating-wrap,
.aiosrs-pro-meta-fields-wrapper .aiosrs-star-rating-wrap {
display: inline-block;
vertical-align: top;
padding: 3px;
}
.bsf-aiosrs-schema-custom-text-wrap .image-field-wrap,
.aiosrs-pro-meta-fields-wrapper .image-field-wrap {
position: relative;
display: inline-block;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-image-select .dashicons {
font-size: 1.2em;
width: 1em;
height: 1em;
line-height: 1;
margin-right: 5px;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-image-remove,
.aiosrs-pro-meta-fields-wrapper .aiosrs-image-remove {
display: none;
position: absolute;
background: rgba(255, 255, 255, 0.7);
right: 0;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-image-remove {
font-size: 15px;
width: 1em;
height: 1em;
}
.bsf-aiosrs-schema-custom-text-wrap .bsf-custom-image-selected .aiosrs-image-select,
.aiosrs-pro-meta-fields-wrapper .bsf-custom-image-selected .aiosrs-image-select {
display: none;
}
.bsf-aiosrs-schema-custom-text-wrap .bsf-custom-image-selected .aiosrs-image-remove,
.aiosrs-pro-meta-fields-wrapper .bsf-custom-image-selected .aiosrs-image-remove {
display: inline-block;
}
.bsf-aiosrs-schema-custom-text-wrap .bsf-custom-image-selected .aiosrs-image-select.img,
.aiosrs-pro-meta-fields-wrapper .bsf-custom-image-selected .aiosrs-image-select.img {
max-width: 100%;
display: inline-block;
}
.bsf-aiosrs-schema-custom-text-wrap .bsf-custom-image-selected .aiosrs-image-select.img img {
max-height: 50px;
}
.aiosrs-pro-meta-fields-wrapper .bsf-custom-image-selected .aiosrs-image-select.img img {
vertical-align: middle;
max-width: 50px;
}
.aiosrs-pro-meta-fields-wrapper .inside,
.aiosrs-pro-meta-fields-wrapper {
margin-top: 0;
padding: 0;
}
.aiosrs-pro-meta-fields-wrapper th,
.aiosrs-pro-meta-fields-wrapper td {
padding: 10px 12px;
border-bottom: 1px solid #eee;
width: 33%;
}
.aiosrs-pro-meta-fields-wrapper .aiosrs-pro-custom-fields-dropdown-content th,
.aiosrs-pro-meta-fields-wrapper .aiosrs-pro-custom-fields-dropdown-content td {
border-top: 0;
}
.aiosrs-pro-meta-fields-wrapper th {
border-right: 1px solid #eee;
vertical-align: middle;
}
.bsf-aiosrs-schema-fixed-text-wrap input:not([type="checkbox"]),
.bsf-aiosrs-schema-custom-text-wrap input:not([type="checkbox"]),
.aiosrs-pro-meta-fields-wrapper input:not([type="checkbox"]),
.bsf-aiosrs-schema-custom-text-wrap textarea,
.aiosrs-pro-meta-fields-wrapper textarea {
width: 100%;
}
/* Tooltips */
.bsf-aiosrs-schema-heading-help {
color: #0073aa;
font-size: 18px;
cursor: help;
float: right;
vertical-align: middle;
}
.ui-widget-content.bsf-aiosrs-schema-ui-tooltip {
background: #333;
border-width: 1px;
border-color: #333;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 1px 0 2px 0 rgba(214, 214, 214, 0.5);
box-shadow: 1px 0 2px 0 rgba(214, 214, 214, 0.5);
color: #dedede;
max-width: 250px;
text-align: center;
padding: 7px;
text-rendering: optimizeLegibility;
text-shadow: none;
z-index: 9999;
}
/* New Style Verticle Tabs */
.aiosrs-pro-meta-fields-tabs-wrapper {
display: inline-block;
width: 15%;
vertical-align: top;
}
.aiosrs-pro-meta-fields-tabs-wrapper .aiosrs-pro-meta-fields-tab {
padding: 8px 12px;
border-bottom: 1px solid #eee;
border-right: 1px solid #eee;
margin-right: -1px;
cursor: pointer;
font-weight: 700;
background: #fff;
color: #666;
}
.aiosrs-pro-meta-fields-tabs-wrapper .aiosrs-pro-meta-fields-tab.active {
background: #f1f1f1;
color: inherit;
}
.aiosrs-pro-meta-fields-wrapper {
width: 100%;
vertical-align: top;
}
.aiosrs-pro-meta-fields-tabs-wrapper ~ .aiosrs-pro-meta-fields-wrapper {
display: inline-block;
width: calc(85% - 1px);
border-left: 1px solid #eee;
}
#aiosrs-pro-custom-fields .inside {
padding: unset;
border: 1px solid #e2e4e7;
}
#aiosrs-pro-custom-fields h2.hndle.ui-sortable-handle {
border-bottom: unset;
}
.aiosrs-pro-meta-fields-wrapper .form-table {
margin: 0;
}
.aiosrs-pro-meta-fields-wrap {
display: none;
}
.aiosrs-pro-meta-fields-wrap.open {
display: block;
}
.bsf-aiosrs-schema-custom-text-wrap .multi-select-wrap select,
.aiosrs-pro-meta-fields-wrapper .multi-select-wrap select {
width: 100%;
}
.bsf-aiosrs-schema-custom-text-wrap .aiosrs-star-rating-wrap:not(.disabled) .aiosrs-star-rating,
.aiosrs-pro-meta-fields-wrapper .aiosrs-star-rating-wrap:not(.disabled) .aiosrs-star-rating {
cursor: pointer;
}
.aiosrs-pro-meta-fields-wrapper .aiosrs-star-rating-wrap.disabled {
padding: 0 0 5px;
}
.aiosrs-pro-meta-fields-wrapper .aiosrs-reset-rating {
margin-left: 5px;
line-height: 1.7;
}
.aiosrs-pro-custom-field-rating .spinner {
float: none;
margin: 0 5px;
}
.aiosrs-pro-custom-field-rating .aiosrs-reset-rating.reset-disabled {
display: none;
}
.ui-timepicker-div .ui-widget-header {
margin-bottom: 8px;
}
.ui-timepicker-div dl {
text-align: left;
}
.ui-timepicker-div dl dt {
float: left;
clear: left;
padding: 0 0 0 15px;
}
.ui-timepicker-div dl dd {
margin: 15px 15px 12px 35%;
}
.ui-timepicker-div td {
font-size: 90%;
}
.ui-tpicker-grid-label {
background: none;
border: none;
margin: 0;
padding: 0;
}
.ui-timepicker-div .ui_tpicker_unit_hide {
display: none;
}
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input {
background: none;
color: inherit;
border: none;
outline: none;
border-bottom: solid 1px #555;
width: 95%;
}
.ui-timepicker-div .ui_tpicker_time .ui_tpicker_time_input:focus {
border-bottom-color: #aaa;
}
.ui-timepicker-rtl {
direction: rtl;
}
.ui-timepicker-rtl dl {
text-align: right;
padding: 0 5px 0 0;
}
.ui-timepicker-rtl dl dt {
float: right;
clear: right;
}
.ui-timepicker-rtl dl dd {
margin: 0 40% 10px 10px;
}
.ui-timepicker-div.ui-timepicker-oneLine {
padding-right: 2px;
}
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time,
.ui-timepicker-div.ui-timepicker-oneLine dt {
display: none;
}
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time_label {
display: block;
padding-top: 2px;
}
.ui-timepicker-div.ui-timepicker-oneLine dl {
text-align: right;
}
.ui-timepicker-div.ui-timepicker-oneLine dl dd,
.ui-timepicker-div.ui-timepicker-oneLine dl dd > div {
display: inline-block;
margin: 0;
}
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_minute::before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_second::before {
content: ":";
display: inline-block;
}
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_millisec::before,
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_microsec::before {
content: ".";
display: inline-block;
}
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide,
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide::before {
display: none;
}
input.wpsp-time-duration-field,
input.wpsp-date-field,
input.wpsp-datetime-local-field {
background-color: #fff;
}
.wpsp-connected-icon {
display: flex;
justify-content: center;
padding: 0.375rem 0.75rem;
margin-bottom: 0;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
white-space: nowrap;
background-color: #e9ecef;
border: 1px solid #ced4da;
border-color: #7e8993;
border-bottom-left-radius: 2px;
border-top-left-radius: 2px;
box-sizing: unset;
}
.wpsp-connected-field {
display: flex;
}
.wpsp-connected-group {
display: flex;
}
.wpsp-connected-group > select {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left: none;
margin: 0;
border-color: #7e8993 !important;
}
.wpsp-field-close,
.wpsp-custom-field-connect,
.wpsp-specific-field-connect {
align-items: center;
color: #999;
cursor: pointer;
display: inline-flex;
font-size: 18px;
justify-content: center;
position: absolute;
right: 28px;
top: 7.5px;
width: 5px;
}
.wpsp-custom-field-connect {
top: 6.5px;
}
.wpsp-specific-field-connect {
top: 5.5px;
}
.wpsp-parent-field {
position: relative;
}
.wpsp-required-error-field {
color: #f00 !important;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-heading,
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-content {
display: table-cell;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td.bsf-aiosrs-schema-row-heading {
width: 16%;
padding: 10px 12px;
vertical-align: middle;
border-right: 1px solid #eee;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td {
width: 27%;
padding: 10px 12px;
margin-bottom: unset;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type:first-child td {
padding-top: 30px;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater table.aiosrs-pro-repeater-table {
border-collapse: collapse;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater table.aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type {
border: 1px solid #eee;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-heading,
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-content {
display: table-cell;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td.bsf-aiosrs-schema-row-heading {
width: 5%;
padding: 10px 12px;
vertical-align: middle;
border-right: 1px solid #eee;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td {
width: 25%;
padding: 10px 12px;
margin-bottom: unset;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target table.aiosrs-pro-repeater-table {
border-collapse: collapse;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target table.aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type {
border: 1px solid #eee;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table-wrap tr.bsf-aiosrs-schema-row td.bsf-aiosrs-schema-row-content .aiosrs-pro-custom-field input {
width: 96%;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table-wrap tr.bsf-aiosrs-schema-row td.bsf-aiosrs-schema-row-content .aiosrs-pro-custom-field textarea {
width: 96%;
}
.bsf-aiosrs-schema-heading-help.wpsp-show-repeater-field,
.bsf-aiosrs-schema-heading-help.wpsp-hide-repeater-field,
.bsf-aiosrs-schema-heading-help.wpsp-show-repeater-target-field,
.bsf-aiosrs-schema-heading-help.wpsp-hide-repeater-target-field {
cursor: pointer;
padding: 5px;
font-size: 20px;
}
select[disabled] {
background-image: none !important;
}
.aiosrs-pro-meta-fields-wrap .wpsp-field-label {
width: 17%;
font-size: 13px;
line-height: 1.4;
font-weight: 700;
color: #333;
border-right: 1px solid #eee;
}
/* Added close button disable for repeater fields */
#aiosrs-pro-custom-fields .bsf-repeater-close {
display: inline-block;
}
.wpsp-local-fields .aiosrs-pro-custom-field input {
min-height: 33px;
padding-right: 18%;
border-radius: 3px;
}
.wpsp-parent-field.wpsp-custom-field.wpsp-custom-field-image .wpsp-custom-field-connect {
top: 0.5px;
}
.wpsp-parent-field.wpsp-custom-field.wpsp-custom-field-textarea .wpsp-custom-field-connect {
top: 12px;
}
/*Toggle CSS for the Enable Schema Markup */
.wpsp-enable-schema-markup {
display: block;
font-size: 13px;
}
.wpsp-enable-schema-markup__field {
margin-top: 8px;
line-height: normal;
align-items: center;
}
.wpsp-enable-schema-toggle {
position: relative;
display: inline-block;
}
.wpsp-enable-schema-toggle input.wpsp-enable-schema-toggle__input[type="checkbox"] {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
margin: 0;
padding: 0;
z-index: 1;
border: none;
}
.wpsp-enable-schema-toggle .wpsp-enable-schema-toggle__track {
content: "";
display: inline-block;
box-sizing: border-box;
vertical-align: top;
background-color: #fff;
border: 2px solid #6c7781;
width: 36px;
height: 18px;
border-radius: 9px;
transition: background 0.2s ease;
}
.wpsp-enable-schema-toggle .wpsp-enable-schema-toggle__thumb {
display: block;
position: absolute;
box-sizing: border-box;
top: 4px;
left: 4px;
width: 10px;
height: 10px;
border-radius: 50%;
transition: transform 0.1s ease;
background-color: #6c7781;
border: 5px solid #6c7781;
}
.wpsp-enable-schema-toggle.is-checked .wpsp-enable-schema-toggle__track {
background-color: #11a0d2;
border: 9px solid transparent;
}
.wpsp-enable-schema-toggle.is-checked .wpsp-enable-schema-toggle__thumb {
background-color: #fff;
border-width: 0;
transform: translateX(18px);
}
.aiosrs-pro-meta-fields-wrap.is-enable-schema-markup {
opacity: 0.2;
pointer-events: none;
}
.rtl .wpsp-parent-field .wpsp-field-close {
position: relative;
right: -35px;
}
.rtl .wpsp-specific-field-connect,
.rtl .wpsp-parent-field .wpsp-custom-field-connect {
position: absolute;
right: 90%;
}
.rtl .wpsp-parent-field .bsf-aiosrs-schema-meta-field {
border-left: 1px solid #eee;
}
.rtl .wpsp-local-fields .aiosrs-pro-custom-field input {
padding-left: 18%;
padding-right: 5%;
}
@-moz-document url-prefix() {
.aiosrs-pro-meta-fields-wrapper th,
.aiosrs-pro-meta-fields-wrapper td {
width: 36%;
}
.aiosrs-pro-meta-fields-wrap .wpsp-field-label {
width: 14%;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td.bsf-aiosrs-schema-row-heading {
width: 14%;
}
.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table tr.bsf-aiosrs-schema-row.bsf-aiosrs-schema-row-text-type td {
width: 36%;
}
}

View File

@@ -0,0 +1,21 @@
.aiosrs-rating-wrap .aiosrs-star-rating-wrap {
display: inline-block;
vertical-align: middle;
}
.aiosrs-rating-wrap .aiosrs-star-rating-wrap ~ .aiosrs-star-rating-wrap {
float: right;
}
.aiosrs-rating-wrap .aiosrs-star-rating-wrap .aiosrs-star-rating {
color: #ffd700;
}
.aiosrs-rating-wrap .aiosrs-star-rating-wrap:not(.disabled) .aiosrs-star-rating {
cursor: pointer;
}
.aiosrs-rating-wrap .success-msg {
color: #0f0;
margin-left: 5px;
}

View File

@@ -0,0 +1,98 @@
body.aiosrs-pro-license-form-open {
overflow: hidden;
}
#aiosrs-pro-license-form p {
padding: 5px 0 5px 0;
}
#aiosrs-pro-license-form .aiosrs-pro-license-form-overlay {
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100050;
}
#aiosrs-pro-license-form .aiosrs-pro-license-form-inner {
background: #fcfcfc;
position: fixed;
background-color: #fff;
z-index: 999999999;
padding: 2px 20px 20px;
text-align: left;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}
#aiosrs-pro-license-form-close-btn {
position: absolute;
left: auto;
right: 0;
top: 0;
width: 29px;
height: 29px;
border: 0;
padding: 0;
background: none;
cursor: pointer;
outline: none;
-webkit-transition: color 0.1s ease-in-out, background 0.1s ease-in-out;
-webkit-transform: translateX(100%);
transform: translateX(100%);
transition: color 0.1s ease-in-out, background 0.1s ease-in-out;
color: #eee;
}
#aiosrs-pro-license-form-close-btn:hover {
color: #00a0d2;
}
#aiosrs-pro-license-form-close-btn .dashicons {
display: block;
text-align: center;
line-height: 29px;
width: 29px;
height: 29px;
font-size: 29px;
position: absolute;
top: 0;
right: 0;
}
#aiosrs-pro-license-form .license-form-field input.regular-text {
margin-right: 10px;
}
/** Validation Messages */
.bsf-current-license-error-wp-schema-pro,
.bsf-current-license-success-wp-schema-pro {
display: block;
margin-bottom: 0.5em;
}
.bsf-current-license-error-wp-schema-pro {
color: #f44336;
}
.bsf-current-license-success-wp-schema-pro {
color: #008000;
}
/** License link */
#aiosrs-pro-license-form-btn.active {
color: #3db634;
}
#aiosrs-pro-license-form-btn.inactive {
color: #f44336;
}

View File

@@ -0,0 +1,460 @@
.bsf-aiosrs-pro {
max-width: 1200px;
}
.bsf-aiosrs-pro .aiosrs-help-link {
font-size: 1.2em;
}
.bsf-aiosrs-pro .aiosrs-help-link:focus {
box-shadow: none;
}
.bsf-aiosrs-pro .form-table th {
width: 280px;
}
.bsf-aiosrs-pro .form-table td.schema-contact-type-option {
display: block;
}
.bsf-aiosrs-pro .form-table td.schema-contact-type-option-change {
margin-bottom: unset;
padding-bottom: 0;
}
.sp-required {
color: #dc3232;
font-size: 14px;
margin-left: 2px;
}
.bsf-aiosrs-pro .select2-selection__choice {
line-height: 1.7;
}
.bsf-aiosrs-pro .select2-container * {
vertical-align: middle;
}
.bsf-aiosrs-pro .select2-container .select2-selection__choice__remove {
vertical-align: initial;
}
.wp-schema-pro-global-schemas .form-table select,
.wp-schema-pro-general-settings .form-table input[type="text"],
.wp-schema-pro-general-settings .form-table select,
.wp-schema-pro-breadcrumb-setting .form-table select,
.wp-schema-pro-advanced-settings .form-table select,
.wp-schema-pro-social-profiles .form-table input[type="url"] {
min-width: 50%;
}
.wp-schema-pro-corporate-contact .form-table input[type="url"],
.wp-schema-pro-corporate-contact .form-table input[type="text"],
.wp-schema-pro-corporate-contact .form-table input[type="email"],
.wp-schema-pro-corporate-contact .form-table select {
min-width: 64%;
}
#wp-schema-pro-setting-links {
margin-top: 10px;
margin-left: 5px;
}
#wp-schema-pro-setting-links a {
text-decoration: none;
box-shadow: none;
}
#wp-schema-pro-setting-links a.active {
color: inherit;
pointer-events: none;
font-weight: 600;
}
.wp-schema-pro-general-settings .custom-field-wrapper {
display: inline-block;
width: 48%;
vertical-align: middle;
}
.wp-schema-pro-general-settings .site-logo-custom-wrap {
vertical-align: top;
}
/**
* Custom Image Select
*/
.wp-schema-pro-general-settings .image-field-wrap,
.wp-schema-pro-advanced-settings .image-field-wrap {
position: relative;
display: inline-block;
}
.wp-schema-pro-general-settings .aiosrs-image-select .dashicons,
.wp-schema-pro-advanced-settings .aiosrs-image-select .dashicons {
font-size: 1.2em;
width: 1em;
height: 1em;
line-height: 16px;
margin-right: 5px;
vertical-align: middle;
}
.wp-schema-pro-general-settings .aiosrs-image-remove,
.wp-schema-pro-advanced-settings .aiosrs-image-remove {
display: none;
position: absolute;
background: rgba(255, 255, 255, 0.7);
right: 0;
font-size: 15px;
width: 1em;
height: 1em;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select,
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-select {
display: none;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-remove,
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-remove {
display: inline-block;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select.img,
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-select.img {
max-width: 100%;
display: inline-block;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select.img img {
max-height: 75px;
}
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select.img img,
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-select.img img {
vertical-align: middle;
max-width: 300px;
}
/**
* Default Image
*/
.wp-schema-pro-advanced-settings .bsf-custom-image-selected .aiosrs-image-select.img img,
.wp-schema-pro-general-settings .bsf-custom-image-selected .aiosrs-image-select.default-image.img img {
max-height: 150px;
}
/**
* Repeater Style
*/
.aiosrs-pro-repeater-table-wrap {
position: relative;
margin-bottom: 1em;
border: 1px solid #f1f1f1;
padding: 10px;
}
.aiosrs-pro-repeater-table-wrap .bsf-repeater-close {
position: absolute;
top: 0;
right: 0;
padding: 2px;
border: 1px solid #f1f1f1;
}
.bsf-repeater-add-new-btn {
float: right;
width: 100px;
}
.aiosrs-pro-repeater-table-wrap .form-table th,
.aiosrs-pro-repeater-table-wrap .form-table td {
border: 0;
padding: 0;
width: 100%;
display: inline-block;
}
.aiosrs-pro-repeater-table-wrap .form-table td input,
.aiosrs-pro-repeater-table-wrap .form-table td select {
min-width: 70%;
}
.bsf-aiosrs-schema-type-wrap .aiosrs-pro-repeater-table-wrap:first-of-type:last-of-type .bsf-repeater-close {
opacity: 0.3;
filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
pointer-events: none;
}
/**
* Tooltip
*/
.wp-schema-pro-tooltip-wrapper {
position: relative;
display: inline-block;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-description {
opacity: 0;
visibility: hidden;
transition: 0.3s;
position: absolute;
background: #333;
color: #dedede;
left: calc(100% - 2.4em);
bottom: calc(100% - 0.75em);
border-radius: 3px;
box-shadow: 0 0 1px 0 #333;
font-weight: 400;
min-width: 300px;
z-index: 9999;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-icon {
cursor: pointer;
font-size: 18px;
}
.wp-schema-pro-tooltip-wrapper.activate .wp-schema-pro-tooltip-icon {
pointer-events: none;
}
.wp-schema-pro-tooltip-wrapper .dashicons.dashicons-arrow-down {
position: absolute;
font-size: 3em;
top: calc(100% - 0.5em);
left: 0;
color: #333;
line-height: initial;
z-index: -1;
}
.wp-schema-pro-tooltip-wrapper.activate .wp-schema-pro-tooltip-description {
opacity: 1;
visibility: visible;
bottom: calc(100% + 0.75em);
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-content {
padding: 8px 12px;
}
.wp-schema-pro-tooltip-wrapper h2.wp-schema-pro-tooltip-heading ~ .wp-schema-pro-tooltip-content {
min-height: 50px;
}
.wp-schema-pro-tooltip-wrapper h2.wp-schema-pro-tooltip-heading {
color: #dedede;
font-weight: 600;
border-bottom: 1px solid #eee;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-content a {
text-decoration: none;
box-shadow: none;
font-size: inherit;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-content img {
max-width: 100%;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-content .tooltip-image {
margin-top: 10px;
}
.tooltip-with-image-wrapper .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-description {
min-width: 400px;
}
.rtl .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-description {
right: calc(100% - 2.4em);
left: 0;
}
.rtl .wp-schema-pro-tooltip-wrapper .dashicons.dashicons-arrow-down {
right: 0;
}
.hndle .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-icon {
color: #f00;
}
.hndle .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-icon::before {
content: "\f534";
}
.wp-schema-pro-yoast-compatibilty-wrap th {
display: flex;
}
.wp-schema-pro-yoast-compatibilty-wrap td {
vertical-align: top;
padding-top: 20px;
}
.wp-schema-pro-tooltip-content ol {
margin-top: 0.5em;
}
.schema-branding input::placeholder,
.contact-form input::placeholder {
font-style: italic;
}
.aiosrs-menu-page-wrapper #aiosrs-menu-page .wrap .wpsp-pro-logo {
vertical-align: middle;
}
.aiosrs-menu-page-wrapper #aiosrs-menu-page .wrap .wpsp-pro-title {
display: inline-block;
font-size: 20px;
}
.aiosrs-menu-page-wrapper #aiosrs-menu-page .wrap .wpsp-pro-logo img {
max-width: 12%;
margin: 20px 3px 20px 0;
}
#aiosrs-menu-page .schema-version {
font-size: 13px;
background-color: #fff;
padding: 2px;
}
.form-table td.breadcrumb-title {
padding: 0;
}
.wpsp-required-error-field {
color: #f00 !important;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr {
width: 50%;
display: inline-block;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr td input {
width: 135%;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr th {
width: 34%;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr:last-child {
width: auto;
display: block;
}
.wpsp-text-strong {
font-weight: 700;
}
.bsf-aiosrs-pro .postbox.wp-schema-pro-general-settings .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-breadcrumb-setting .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-advanced-settings .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-branding-settings .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-social-profiles .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-corporate-contact .hndle,
.bsf-aiosrs-pro .postbox.wp-schema-pro-global-schemas .hndle,
.bsf-aiosrs-pro .postbox-container .postbox .hndle {
border-bottom: 1px solid #ccd0d4;
}
.wp-schema-pro-general-settings .select2-container--default .select2-selection--single {
box-shadow: 0 0 0 transparent;
border-radius: 4px;
padding: 0.5em;
font-size: 14px;
height: 33px;
border: 1px solid #7e8993;
background-color: #fff;
color: #32373c;
}
.wp-schema-pro-general-settings .select2.select2-container.select2-container--default {
width: 50% !important;
}
.wp-schema-pro-general-settings .select2-container--default .select2-selection--single .select2-selection__rendered {
color: unset;
line-height: unset;
}
.wp-schema-pro-general-settings .select2-container--default .select2-selection--single .select2-selection__arrow {
top: 4px;
}
.select2-container--default .select2-selection.select2-selection--single:focus {
border-color: #007cba;
box-shadow: 0 0 0 1px #007cba;
outline: 2px solid transparent;
}
/**
* dynamic social profile repeater.
*/
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr th.wpsp-other-th {
width: 33% !important;
}
a#add-row {
float: right;
margin-right: 30px;
}
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr td input.wpsp-other {
width: 132% !important;
}
span.wpsp-field-close.dashicons.dashicons-dismiss {
color: #999;
cursor: pointer;
display: inline-flex;
font-size: 18px;
justify-content: center;
position: relative;
top: -22px;
left: 140%;
width: 5px;
}
@media screen and ( min-width: 783px) {
.wp-schema-pro-tooltip-wrapper {
float: right;
}
.rtl .wp-schema-pro-tooltip-wrapper {
float: left;
}
.hndle .wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-description {
min-width: 400px;
}
.hndle .wp-schema-pro-tooltip-wrapper {
float: none;
}
}
@-moz-document url-prefix() {
.bsf-aiosrs-pro .wp-schema-pro-social-profiles table.form-table tr {
width: 50%;
float: left;
}
}

View File

@@ -0,0 +1,589 @@
body {
margin: 100px auto 100px auto;
box-shadow: none;
background: #f1f1f1;
padding: 0;
max-width: 800px;
border: unset;
}
a {
text-decoration: none;
}
#aiosrs-pro-logo {
border: 0;
margin: 0 0 24px;
padding: 0;
text-align: center;
}
#aiosrs-pro-logo a,
#aiosrs-pro-logo a:active,
#aiosrs-pro-logo a:focus {
box-shadow: none;
}
#aiosrs-pro-logo img {
max-width: 30%;
}
/* Wizard Steps */
.aiosrs-pro-setup-wizard-steps,
.aiosrs-pro-setup-steps {
padding: 5px 0 24px;
margin: 0;
list-style: none;
overflow: hidden;
color: #ccc;
width: 100%;
display: -webkit-inline-flex;
display: -ms-inline-flexbox;
display: inline-flex;
}
.aiosrs-pro-setup-wizard-steps li,
.aiosrs-pro-setup-steps li {
width: 33%;
float: left;
padding: 0 0 0.8em;
margin: 0;
text-align: center;
position: relative;
border-bottom: 4px solid #ccc;
line-height: 22px;
}
.aiosrs-pro-setup-wizard-steps li::before,
.aiosrs-pro-setup-steps li::before {
content: "";
border: 4px solid #ccc;
border-radius: 100%;
width: 4px;
height: 4px;
position: absolute;
bottom: 0;
left: 50%;
margin-left: -6px;
margin-bottom: -8px;
background: #fff;
}
.aiosrs-pro-setup-wizard-steps li.active,
.aiosrs-pro-setup-steps li.active {
border-color: #0085ba;
color: #0085ba;
}
.aiosrs-pro-setup-wizard-steps li.active::before,
.aiosrs-pro-setup-steps li.active::before {
border-color: #0085ba;
}
.aiosrs-pro-setup-wizard-steps li.done,
.aiosrs-pro-setup-steps li.done {
border-color: #0085ba;
color: #0085ba;
}
.aiosrs-pro-setup-wizard-steps li.done::before,
.aiosrs-pro-setup-steps li.done::before {
border-color: #0085ba;
background: #0085ba;
}
.aiosrs-pro-setup-wizard-content a,
.aiosrs-pro-setup-content a {
color: #0085ba;
}
.aiosrs-pro-setup-wizard-content a:focus,
.aiosrs-pro-setup-content a:focus,
.aiosrs-pro-setup-wizard-content a:hover,
.aiosrs-pro-setup-content a:hover {
color: #111;
}
/* Wizard Content */
.aiosrs-pro-setup-wizard-content,
.aiosrs-pro-setup-content {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
padding: 24px 24px 0;
background: #fff;
overflow: hidden;
zoom: 1;
}
.aiosrs-pro-setup-wizard-content h1,
.aiosrs-pro-setup-content h1,
.aiosrs-pro-setup-wizard-content h2,
.aiosrs-pro-setup-content h2,
.aiosrs-pro-setup-wizard-content h3,
.aiosrs-pro-setup-content h3,
.aiosrs-pro-setup-wizard-content table,
.aiosrs-pro-setup-content table {
margin: 0 0 24px;
border: 0;
padding: 0;
color: #666;
clear: none;
}
.aiosrs-pro-setup-wizard-content p,
.aiosrs-pro-setup-content p {
margin: 0 0 24px;
}
.aiosrs-pro-setup-wizard-content p,
.aiosrs-pro-setup-content p,
.aiosrs-pro-setup-wizard-content table,
.aiosrs-pro-setup-content table {
font-size: 1em;
line-height: 1.75;
color: #666;
}
.aiosrs-pro-setup-wizard-content .form-table th,
.aiosrs-pro-setup-content .form-table th {
width: 40%;
vertical-align: top;
font-weight: 400;
}
.aiosrs-pro-setup-wizard-content .form-table td,
.aiosrs-pro-setup-content .form-table td {
vertical-align: top;
}
.aiosrs-pro-setup-wizard-content .form-table td input,
.aiosrs-pro-setup-content .form-table td input,
.aiosrs-pro-setup-wizard-content .form-table td select,
.aiosrs-pro-setup-content .form-table td select {
box-sizing: border-box;
color: inherit;
}
.aiosrs-pro-setup-wizard-content .form-table td input:not([type="checkbox"]),
.aiosrs-pro-setup-wizard-content .form-table td select {
width: 50%;
}
.aiosrs-pro-setup-wizard-content .form-table td .description,
.aiosrs-pro-setup-content .form-table td .description {
line-height: 1.5;
display: block;
margin-top: 0.25em;
color: #999;
font-style: italic;
}
.aiosrs-pro-setup-wizard-content .form-table td .input-checkbox,
.aiosrs-pro-setup-content .form-table td .input-checkbox,
.aiosrs-pro-setup-wizard-content .form-table td .input-radio,
.aiosrs-pro-setup-content .form-table td .input-radio {
width: auto;
box-sizing: inherit;
padding: inherit;
margin: 0 0.5em 0 0;
box-shadow: none;
}
/* Content Bottom Buttons */
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-actions,
.aiosrs-pro-setup .aiosrs-pro-setup-actions {
overflow: hidden;
}
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-actions .button,
.aiosrs-pro-setup .aiosrs-pro-setup-actions .button {
float: right;
font-size: 1em;
padding: 0.5em 1em;
line-height: 16px;
margin-right: 0.5em;
margin-bottom: 2px;
height: auto;
border-radius: 4px;
}
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-actions .skip-button,
.aiosrs-pro-setup .aiosrs-pro-setup-actions .skip-button {
margin-left: 10px;
margin-right: 0;
}
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-actions .button-primary,
.aiosrs-pro-setup .aiosrs-pro-setup-actions .button-primary {
float: right;
margin: 0;
opacity: 1;
}
.aiosrs-pro-return-to-dashboard {
font-size: 0.85em;
color: #b5b5b5;
margin: 1.18em 0;
display: block;
text-align: center;
}
/* Theme Config Page */
.wp-core-ui .aiosrs-pro-basic-config input.ast-color-picker {
vertical-align: top;
margin-right: 7px;
}
.wp-core-ui .aiosrs-pro-basic-config input.wp-picker-clear {
width: 70px;
}
/* Ready Page */
.aiosrs-pro-setup-wizard-content .twitter-share-button,
.aiosrs-pro-setup-content .twitter-share-button {
float: right;
}
/**
* Site Identity
*/
.aiosrs-pro-setup-wizard-content select,
.aiosrs-pro-setup-content select,
.aiosrs-pro-setup-wizard-content input,
.aiosrs-pro-setup-content input {
border: 1px solid #f1f1f1;
padding: 0.5em;
border-radius: 3px;
font-size: 14px;
}
.aiosrs-pro-setup-wizard-content .select2-container--default .select2-selection--single {
border: 1px solid #f1f1f1;
padding: 0.5em;
border-radius: 3px;
font-size: 14px;
height: 33px;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.07);
}
.aiosrs-pro-setup-wizard-content .select2.select2-container.select2-container--default {
width: 50% !important;
}
.aiosrs-pro-setup-wizard-content .select2-container--default .select2-selection--single .select2-selection__rendered {
color: unset;
line-height: unset;
}
.aiosrs-pro-setup-wizard-content .select2-container--default .select2-selection--single .select2-selection__arrow {
top: 4px;
}
.select2-container--default .select2-selection.select2-selection--single:focus {
border-color: #007cba;
box-shadow: 0 0 0 1px #007cba;
outline: 2px solid transparent;
}
.wp-picker-active .wp-picker-holder {
position: absolute;
z-index: 9;
}
.aiosrs-pro-setup-wizard-next-steps .button-hero:last-child,
.aiosrs-pro-setup-next-steps .button-hero:last-child {
margin-bottom: 0;
}
.aiosrs-pro-setup-wizard-next-steps .button-hero,
.aiosrs-pro-setup-next-steps .button-hero {
width: 100%;
margin-bottom: 1em;
}
/**
* Step: Last
*/
.aiosrs-pro-setup-wizard-next-steps-last ul,
.aiosrs-pro-setup-next-steps-last ul {
padding: 0;
}
.aiosrs-pro-setup-wizard-next-steps-last li i,
.aiosrs-pro-setup-next-steps-last li i {
padding-right: 10px;
}
.aiosrs-pro-setup-wizard-next-steps-last li,
.aiosrs-pro-setup-next-steps-last li {
list-style-type: none;
padding: 0;
margin-bottom: 0.5em;
}
/**
* Schema template
*/
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap {
display: inline-block;
background: #f1f1f1;
border: 1px solid #d8d8d8;
padding: 10px 5px;
width: calc(33% - 8px);
text-align: center;
margin-right: 10px;
margin-bottom: 10px;
cursor: pointer;
box-sizing: border-box;
overflow: hidden;
vertical-align: middle;
font-size: 16px;
}
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap:nth-child(3n) {
margin-right: 0;
}
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap.selected,
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap:hover {
background: #d6d6d6;
border-color: #b9b9b9;
}
.aiosrs-pro-basic-config .aiosrs-pro-schema-temp-wrap i {
font-size: 18px;
height: 18px;
display: block;
margin: auto;
}
.aiosrs-pro-basic-config td {
padding: 0;
}
.aiosrs-pro-setup-wizard-content table.bsf-aiosrs-schema-table,
.aiosrs-pro-setup-content table.bsf-aiosrs-schema-table {
border: 1px solid #e1e1e1;
border-collapse: collapse;
width: 100%;
}
.aiosrs-pro-setup-wizard-content table.form-table th,
.aiosrs-pro-setup-content table.aiosrs-pro-schema-ready th,
.aiosrs-pro-setup-wizard-content table.form-table td,
.aiosrs-pro-setup-content table.aiosrs-pro-schema-ready td,
.aiosrs-pro-setup-wizard-content table.form-table .button-hero,
.aiosrs-pro-setup-content table.aiosrs-pro-schema-ready .button-hero {
font-size: 16px;
font-size: 1rem;
}
.aiosrs-pro-setup-wizard-content table.aiosrs-pro-schema-ready td,
.aiosrs-pro-setup-content table.aiosrs-pro-schema-ready td {
padding-right: 0;
}
.aiosrs-pro-setup-wizard .wizard-close-link,
.aiosrs-pro-setup .wizard-close-link {
color: #ccc;
box-shadow: none;
}
/**
* Hide tooltip text
*/
.aiosrs-pro-setup-wizard .ui-helper-hidden-accessible,
.aiosrs-pro-setup .ui-helper-hidden-accessible {
display: none;
}
.aiosrs-pro-setup-wizard .ui-widget-content.bsf-aiosrs-schema-ui-tooltip,
.aiosrs-pro-setup .ui-widget-content.bsf-aiosrs-schema-ui-tooltip {
font-size: 14px;
}
.aiosrs-pro-schema-ready .button-primary.button-hero {
text-align: center;
}
/**
* Schema Pro On-Boarding
*/
.aiosrs-pro-setup-wizard .aiosrs-pro-setup-wizard-content .button-next,
.aiosrs-pro-setup-wizard-content.welcome-content-wrap .button-close {
margin-left: 10px;
}
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap input[type="text"] {
width: 100%;
}
.aiosrs-pro-setup-wizard-content.success-content-wrap .form-table td {
width: 45%;
text-align: center;
padding-right: 0;
}
.aiosrs-pro-setup-wizard-content.success-content-wrap .form-table td.space {
width: 10%;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .form-table select {
min-width: 53%;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .custom-field-wrapper {
display: inline-block;
width: 48%;
vertical-align: middle;
}
/**
* Custom Image Select
*/
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .image-field-wrap {
position: relative;
display: inline-block;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .aiosrs-image-select .dashicons {
font-size: 1.2em;
width: 1em;
height: 1em;
line-height: 22px;
margin-right: 5px;
vertical-align: middle;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .aiosrs-image-remove {
display: none;
position: absolute;
background: rgba(255, 255, 255, 0.7);
right: 0;
font-size: 15px;
width: 1em;
height: 1em;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-select {
display: none;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-remove {
display: inline-block;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-select.img {
max-width: 100%;
display: inline-block;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-select.img img {
max-height: 75px;
vertical-align: middle;
max-width: 300px;
}
.aiosrs-pro-setup-wizard-content.general-setting-content-wrap .bsf-custom-image-selected .aiosrs-image-select.default-image.img img {
max-height: 150px;
}
.close-button-wrapper {
text-align: center;
margin: 1em 0;
}
.close-button-wrapper a.button-close .dashicons {
vertical-align: middle;
font-size: 1.3em;
line-height: 0.9;
width: 1em;
height: 1em;
}
.close-button-wrapper .button {
font-size: 1em;
padding: 5px 15px;
height: auto;
background: #fff;
}
.aiosrs-pro-setup-wizard-content.welcome-content-wrap ul {
margin-top: 0;
}
.aiosrs-pro-setup-wizard-content.welcome-content-wrap ul li {
font-size: inherit;
color: #666;
}
.aiosrs-pro-setup-wizard-content .no-margin {
margin: 0 auto;
}
.aiosrs-pro-setup-wizard-content.global-schemas-content-wrap {
overflow: initial;
}
.aiosrs-pro-setup-wizard-content.global-schemas-content-wrap .aiosrs-pro-setup-wizard-actions {
padding-bottom: 24px;
margin-bottom: 0;
}
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap .form-table tr {
display: inline-block;
width: 50%;
}
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap .form-table tr th {
vertical-align: middle;
font-weight: 600;
}
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap .form-table tr td input {
width: 120%;
}
.aiosrs-pro-field-description {
font-style: italic;
}
.aiosrs-pro-setup-wizard #aiosrs-pro-logo .wpsp-setup-pro-title,
.aiosrs-pro-setup #aiosrs-pro-logo .wpsp-setup-pro-title {
color: #000;
font-size: 26px;
padding: 0;
font-weight: 600;
display: inline-block;
vertical-align: top;
border: unset;
}
@-moz-document url-prefix() {
.aiosrs-pro-setup-wizard-content.social-profiles-content-wrap .form-table tr {
width: 50%;
float: left;
}
}

View File

@@ -0,0 +1,388 @@
/* Meta Box Heading
------------------------------------------------------*/
#aiosrs-schema-settings .inside {
margin: 0;
padding: 0;
}
#aiosrs-schema-settings .nav-tab-wrapper {
border-bottom: 0;
}
#aiosrs-schema-settings .nav-tab-wrapper ul {
margin: 0;
}
/* Tooltips */
.bsf-aiosrs-schema-heading-help {
color: #0073aa;
float: unset;
font-size: 18px;
cursor: help;
}
.ui-widget-content.bsf-aiosrs-schema-ui-tooltip {
background: #333;
border-width: 1px;
border-color: #333;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 1px 0 2px 0 rgba(214, 214, 214, 0.5);
box-shadow: 1px 0 2px 0 rgba(214, 214, 214, 0.5);
color: #dedede;
max-width: 250px;
text-align: center;
padding: 7px;
text-rendering: optimizeLegibility;
text-shadow: none;
z-index: 9999;
}
/* Table */
.bsf-aiosrs-schema-table {
border: none;
border-bottom: 5px solid #f0f0f0;
}
.bsf-aiosrs-schema-table:last-of-type {
border-bottom-width: 0;
}
.bsf-aiosrs-schema-table.widefat {
border-width: 0;
border-bottom-width: 2px;
}
.bsf-aiosrs-schema-table.widefat:last-child {
border-bottom-width: 1px;
}
/* Rows */
.bsf-aiosrs-schema-row td::before,
.bsf-aiosrs-schema-row td::after {
display: table;
content: " ";
}
.bsf-aiosrs-schema-row td::after {
clear: both;
}
.bsf-aiosrs-schema-row td {
zoom: 1;
vertical-align: middle;
}
.bsf-aiosrs-schema-row td * {
vertical-align: middle;
}
.bsf-aiosrs-schema-row:last-child td {
border-bottom: none;
}
/* Row Heading */
.bsf-aiosrs-schema-row-heading {
border-right: 1px solid #e1e1e1;
padding: 15px;
width: 25%;
vertical-align: middle;
}
.bsf-aiosrs-schema-row td.bsf-aiosrs-schema-row-heading.title {
padding-bottom: 0;
border-bottom: 0;
}
.bsf-aiosrs-schema-row-heading label {
display: inline-block;
font-size: 13px;
line-height: 22px;
font-weight: 700;
padding: 0;
margin: 0 0 3px;
color: #333;
}
/* Row Content */
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-row-content {
padding: 15px 10px;
position: relative;
width: 75%;
}
.bsf-aiosrs-schema-row-content p:last-child {
margin-bottom: 0;
}
.bsf-aiosrs-schema-padding {
width: 110px;
}
.bsf-aiosrs-schema-padding-bottom-wrap {
margin-top: 5px;
}
/* Row Inputs */
.bsf-aiosrs-schema-row-content select {
width: 100%;
}
.bsf-aiosrs-schema-row-content .bsf-aiosrs-schema-action-desc.ast-no-desc {
margin-top: 0;
}
.bsf-aiosrs-schema-row-content .bsf-aiosrs-schema-action-desc {
margin-top: 10px;
}
/*Title CSS for the Enable on*/
.bsf-aiosrs-schema-row-select-target h2.bsf-aiosrs-schema-row-heading-select-target {
border-bottom: 1px solid #ccd0d4;
font-weight: 600 !important;
padding: 10px 12px !important;
}
.bsf-aiosrs-schema-row-select-target h2.bsf-aiosrs-schema-row-heading-select-target label {
vertical-align: initial;
}
/* Settings Meta Box
------------------------------------------------------*/
#bsf-aiosrs-schema-settings .inside {
margin: 0;
padding: 0;
}
/* Builder Buttons Meta Box
------------------------------------------------------*/
#bsf-aiosrs-schema-buttons .inside {
margin: 0;
padding: 15px;
}
#bsf-aiosrs-schema-buttons .button {
margin-right: 5px;
}
/* Rule Settings
------------------------------------------------------*/
/* Rule Forms */
.bsf-aiosrs-schema-saved-rule {
-js-display: flex;
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
padding: 0 0 8px 0;
}
.bsf-aiosrs-schema-saved-rule-select {
width: 100%;
}
.bsf-aiosrs-schema-rule-objects {
display: none;
}
.bsf-aiosrs-schema-rule-objects-visible {
-js-display: flex;
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
}
.bsf-aiosrs-schema-row-content .bsf-aiosrs-schema-rule-objects-visible select {
width: 50%;
}
.bsf-aiosrs-schema-rule-objects-visible .bsf-aiosrs-schema-rule-objects {
display: inline;
margin-left: 7px;
}
.bsf-aiosrs-schema-remove-rule-button {
display: none;
margin-top: 5px;
text-align: right;
width: 33px;
}
.bsf-aiosrs-schema-remove-rule {
color: #000;
cursor: pointer;
opacity: 0.2;
}
.bsf-aiosrs-schema-remove-rule:hover {
color: #d54e21;
opacity: 1;
}
.bsf-aiosrs-schema-add-rule {
float: left;
margin-right: 8px;
min-width: 150px;
}
.bsf-aiosrs-schema-add-rule .button {
text-align: center;
width: 100%;
}
/* Location Rules */
.bsf-aiosrs-schema-locations-form {
display: none;
}
/* Exclusion Rules */
.bsf-aiosrs-schema-exclusion-rules {
display: none;
}
/* Color Picker */
.bsf-aiosrs-schema-row .wp-picker-holder {
position: absolute;
z-index: 1;
}
.bsf-aiosrs-schema-row .iris-border .iris-picker-inner {
right: 0;
}
.bsf-aiosrs-schema-row-content .bsf-aiosrs-schema-type {
width: auto;
}
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-fixed-text-wrap,
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-custom-text-wrap {
width: calc(55% - 5px);
display: inline-block;
}
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-meta-field {
width: calc(45% - 5px);
display: inline-block;
}
.bsf-aiosrs-schema-table .bsf-aiosrs-schema-custom-text-wrap input {
width: 100%;
}
.bsf-aiosrs-schema-table .bsf-custom-remove-image,
.bsf-aiosrs-schema-table .update-custom-image,
.bsf-aiosrs-schema-table .bsf-hidden-field,
.bsf-custom-image-selected button.bsf-custom-select-image {
display: none;
}
.bsf-custom-image-selected .bsf-custom-remove-image {
display: inline-block;
}
.select-custom-image,
.bsf-custom-image-selected .update-custom-image {
display: block;
}
.bsf-custom-remove-image .dashicons {
padding: 0;
}
.bsf-custom-image-label {
margin-left: 5px;
display: inline-block;
}
.bsf-aiosrs-schema-specific-field-wrap {
display: inline-block;
width: 50%;
}
.bsf-aiosrs-guideline-link i {
font-size: 1rem;
width: auto;
}
/**
* Repeater Style
*/
.aiosrs-pro-repeater-table {
width: 100%;
border: 1px solid #f1f1f1;
padding: 10px;
}
.aiosrs-pro-repeater-table-wrap {
position: relative;
margin-bottom: 1em;
}
.bsf-aiosrs-schema-row:first-child {
line-height: 0;
height: 0;
}
.bsf-repeater-close {
position: absolute;
top: 0;
right: 0;
padding: 2px;
border: 1px solid #f1f1f1;
}
.bsf-repeater-add-new-btn {
float: right;
width: 100px;
}
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-heading,
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-content {
border: 0;
padding: 0;
width: 100%;
display: inline-block;
}
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-heading label,
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row-content {
line-height: 1;
}
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row td::before,
.aiosrs-pro-repeater-table .bsf-aiosrs-schema-row td::after {
display: none;
}
.bsf-aiosrs-schema-type-wrap .aiosrs-pro-repeater-table-wrap:first-of-type:last-of-type .bsf-repeater-close {
opacity: 0.3;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
pointer-events: none;
}
.bsf-aiosrs-schema-row-repeater-type > .bsf-aiosrs-schema-row-heading {
vertical-align: top;
padding-top: 25px;
}
.wp-schema-pro-tooltip-wrapper {
font-size: 14px;
line-height: 18px;
}
.wp-schema-pro-tooltip-wrapper .wp-schema-pro-tooltip-icon {
line-height: 1.5;
vertical-align: middle;
}
.aiosrs-pro-setup-wizard-content.advanced-settings-content-wrap .label-wrapper {
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -0,0 +1,704 @@
/* eslint-env jquery */
(function ($) {
$(window).on('load', function () {
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .aiosrs-pro-repeater-table-wrap'
).hide();
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater .bsf-repeater-add-new-btn'
).hide();
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .aiosrs-pro-repeater-table-wrap'
).hide();
$(
'.aiosrs-pro-custom-field.aiosrs-pro-custom-field-repeater-target .bsf-repeater-add-new-btn'
).hide();
});
$(document).ready(function () {
const { __ } = wp.i18n;
$('#wpsp-reset-dialog-confirmation').dialog({
dialogClass: 'wp-dialog',
autoOpen: false,
modal: true,
});
// Added support to repeater validation.
$(
'.wpsp-custom-field-connect, .wpsp-field-close, .bsf-aiosrs-schema-meta-field, image-field-wrap, .aiosrs-pro-custom-field, .wpsp-custom-field-connect'
).on('click focus change', function () {
$('.wpsp-local-fields').each(function (index, repeater) {
let fieldValue = $(repeater)
.find('.wpsp-default-hidden-value')
.val();
const requiredPath = $(repeater)
.parents('.bsf-aiosrs-schema-row-content')
.prev();
fieldValue = fieldValue.trim();
if (fieldValue) {
if ($('body').hasClass('block-editor-page')) {
if (
!$(repeater).find('.wpsp-required-error-field')
.length
) {
let metaField;
switch (fieldValue) {
case 'post_title':
metaField = $(
'.editor-post-title__input'
).val();
break;
case 'post_content':
metaField =
$(
'p.block-editor-rich-text__editable'
).text().length > 1
? $(
'p.block-editor-rich-text__editable'
).text()
: '';
break;
case 'post_excerpt':
metaField = $(
'.components-textarea-control__input'
).val();
break;
case 'featured_img':
if (
'Set featured image' ===
$(
'.editor-post-featured-image__toggle'
).text()
) {
metaField = '';
} else {
metaField = $(
'.components-responsive-wrapper__content'
).attr('src');
}
break;
default:
requiredPath.removeClass(
'wpsp-required-error-field'
);
}
if (undefined !== metaField) {
if ('' !== metaField) {
requiredPath.removeClass(
'wpsp-required-error-field'
);
} else if (
requiredPath.find('.required').length
) {
requiredPath.addClass(
'wpsp-required-error-field'
);
}
}
}
} else {
requiredPath.removeClass('wpsp-required-error-field');
}
} else if (requiredPath.find('.required').length) {
requiredPath.addClass('wpsp-required-error-field');
}
});
});
$('.wpsp-show-repeater-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater'
);
parent.find('.aiosrs-pro-repeater-table-wrap').show();
parent.find('.bsf-repeater-add-new-btn').show();
parent.find('.wpsp-show-repeater-field').addClass('bsf-hidden');
parent
.find('.wpsp-hide-repeater-field')
.removeClass('bsf-hidden');
});
$('.wpsp-hide-repeater-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater'
);
parent.find('.aiosrs-pro-repeater-table-wrap').hide();
parent.find('.bsf-repeater-add-new-btn').hide();
parent.find('.wpsp-hide-repeater-field').addClass('bsf-hidden');
parent
.find('.wpsp-show-repeater-field')
.removeClass('bsf-hidden');
});
$('.wpsp-show-repeater-target-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater-target'
);
parent.find('.aiosrs-pro-repeater-table-wrap').show();
parent.find('.bsf-repeater-add-new-btn').show();
parent
.find('.wpsp-show-repeater-target-field')
.addClass('bsf-hidden');
parent
.find('.wpsp-hide-repeater-target-field')
.removeClass('bsf-hidden');
});
$('.wpsp-hide-repeater-target-field').click(function () {
const parent = $(this).parents(
'.aiosrs-pro-custom-field-repeater-target'
);
parent.find('.aiosrs-pro-repeater-table-wrap').hide();
parent.find('.bsf-repeater-add-new-btn').hide();
parent
.find('.wpsp-hide-repeater-target-field')
.addClass('bsf-hidden');
parent
.find('.wpsp-show-repeater-target-field')
.removeClass('bsf-hidden');
});
$('input[type="checkbox"].wpsp-enable-schema-toggle__input').on(
'click',
function () {
const parent = $(this).parents(
'.wpsp-enable-schema-markup'
);
const thisVal = $(this).val();
const togglebtn = parent.find('.wpsp-enable-schema-toggle');
const togglehid = parent.find(
'.wpsp-enable-schema-toggle__input-hidden'
);
const isChecked = togglebtn.hasClass('is-checked');
if (!isChecked && '1' === thisVal) {
togglehid.attr('value', '1');
togglebtn.addClass('is-checked');
} else {
togglehid.attr('value', 'disabled');
togglebtn.removeClass('is-checked');
}
}
);
$(document).on('change click', function () {
$('.wpsp-local-fields')
.find('select, textarea, input')
.on('change keyup', function (event) {
if (
event.isTrigger &&
!$(this).hasClass('wpsp-specific-field') &&
!$(this).hasClass('wpsp-date-field')
) {
return false;
}
const parent = $(this).parents('.wpsp-local-fields');
parent
.find('.wpsp-default-hidden-value')
.val($(this).val());
parent
.find('.wpsp-default-hidden-fieldtype')
.val(
$(this)
.parents('.wpsp-parent-field')
.attr('data-type')
);
if (
$(this).is('select') &&
$(this).parent().hasClass('wpsp-connect-field')
) {
const selectedOption = $(this).val();
if (
'create-field' === selectedOption ||
'specific-field' === selectedOption
) {
if ('create-field' === selectedOption) {
displayCustomField(parent);
parent
.find('.wpsp-default-hidden-fieldtype')
.val('custom-field');
}
if ('specific-field' === selectedOption) {
displaySpecificField(parent);
parent
.find('.wpsp-default-hidden-fieldtype')
.val('specific-field');
}
parent
.find('.wpsp-default-hidden-value')
.val('');
}
}
});
$('select.bsf-aiosrs-schema-meta-field').change(function () {
const parent = $(this).parents('.wpsp-local-fields');
const label = parent.find('select option:selected').html();
const selectedOption = $(this).val();
if (
'none' === selectedOption ||
'create-field' === selectedOption ||
'specific-field' === selectedOption
) {
parent
.find('.bsf-aiosrs-schema-heading-help')
.attr(
'title',
'Please connect any field to apply in the Schema Markup!'
);
} else {
parent
.find('.bsf-aiosrs-schema-heading-help')
.attr(
'title',
'The ' +
label +
' value in this field will be added to the schema markup of this particular post/page.'
);
}
});
function displaySpecificField(parent) {
parent.find('.wpsp-connect-field,.wpsp-custom-field').hide();
parent
.find('.wpsp-specific-field')
.removeClass('bsf-hidden')
.show()
.find('select, textarea, input')
.val('');
}
function displayCustomField(parent) {
parent
.find('.wpsp-connect-field,.wpsp-specific-field')
.hide();
parent
.find('.wpsp-custom-field')
.removeClass('bsf-hidden')
.show()
.find('select, textarea, input')
.val('');
}
$(document).on('click', '.wpsp-field-close', function () {
const parent = $(this).parents('.wpsp-local-fields');
const select = parent
.find('.wpsp-connect-field')
.removeClass('bsf-hidden')
.show()
.find('select')
.removeAttr('disabled');
const selectVal = select.val();
if ('specific-field' === selectVal) {
parent.find('.wpsp-default-hidden-value').val('');
parent
.find('.wpsp-default-hidden-fieldtype')
.val('specific-field');
displaySpecificField(parent);
return;
}
parent.find('.wpsp-default-hidden-value').val('');
parent
.find('.wpsp-default-hidden-fieldtype')
.val('custom-field');
displayCustomField(parent);
});
$(document).on(
'click',
'.wpsp-specific-field-connect, .wpsp-custom-field-connect',
function () {
const parent = $(this).parents('.wpsp-local-fields');
const select = parent
.find('.wpsp-connect-field')
.removeClass('bsf-hidden')
.show()
.find('select')
.removeAttr('disabled');
let selectVal = select.val();
if (
'create-field' === selectVal ||
'specific-field' === selectVal
) {
selectVal = 'none';
}
parent
.find('.wpsp-default-hidden-value')
.val(selectVal);
parent
.find('.wpsp-default-hidden-fieldtype')
.val('global-field');
parent
.find('.wpsp-custom-field, .wpsp-specific-field')
.hide();
}
);
});
$(document).on('change input', '.bsf-rating-field', function () {
const starWrap = $(this).next('.aiosrs-star-rating-wrap'),
value = $(this).val();
let filled = value > 5 ? 5 : parseInt(value);
if (value > 5) {
filled = 5;
} else if (value < 0) {
filled = 0;
} else {
filled = parseInt(value);
}
const half = value === filled || value > 5 || value < 0 ? 0 : 1;
starWrap.find('span').each(function (index) {
$(this).removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
);
if (index < filled) {
$(this).addClass('dashicons-star-filled');
} else if (index === filled && half === 1) {
$(this).addClass('dashicons-star-half');
} else {
$(this).addClass('dashicons-star-empty');
}
});
});
$(document).on(
'click',
'.aiosrs-star-rating-wrap:not(.disabled) > .aiosrs-star-rating',
function (e) {
e.preventDefault();
const index = $(this).data('index');
const starWrap = $(this).parent();
const parent = $(this).parents('.wpsp-local-fields');
starWrap.prev('.bsf-rating-field').val(index);
parent.find('.wpsp-default-hidden-value').val(index);
starWrap.find('.aiosrs-star-rating').each(function (i) {
$(this).removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
);
if (i < index) {
$(this).addClass('dashicons-star-filled');
} else {
$(this).addClass('dashicons-star-empty');
}
});
}
);
$(document).on(
'change',
'#aiosrs-pro-custom-fields .aiosrs-pro-custom-field-checkbox input[type="checkbox"]',
function (e) {
e.preventDefault();
const siblings = $(this)
.closest('tr.row')
.siblings('tr.row');
if ($(this).prop('checked')) {
siblings.show();
} else {
siblings.hide();
}
}
);
$(
'#aiosrs-pro-custom-fields .aiosrs-pro-custom-field-checkbox input[type="checkbox"]'
).trigger('change');
$(document.body).on(
'change',
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup input[type="checkbox"].wpsp-enable-schema-toggle__input',
function (e) {
e.preventDefault();
const parent = $(this).parents(
'.wpsp-enable-schema-markup'
);
if ($(this).prop('checked')) {
parent
.find('.wpsp-enable-schema-toggle')
.addClass('is-checked');
parent
.find('.wpsp-enable-schema-toggle__input-hidden')
.attr('value', '1');
} else {
parent
.find('.wpsp-enable-schema-toggle')
.removeClass('is-checked');
parent
.find('.wpsp-enable-schema-toggle__input-hidden')
.attr('value', 'disabled');
}
}
);
$(
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup input[type="checkbox"].wpsp-enable-schema-toggle__input'
).trigger('change');
$(document).on('click', '.aiosrs-reset-rating', function (e) {
e.preventDefault();
const thisObj = $(this);
const parent = thisObj.closest('.aiosrs-pro-custom-field-rating');
const ajaxData = {
action: 'aiosrs_reset_post_rating',
post_id: thisObj.data('post-id'),
schema_id: thisObj.data('schema-id'),
nonce: thisObj.data('nonce'),
};
$('#wpsp-reset-dialog-confirmation').dialog({
resizable: false,
title: __('Confirmation Required!', 'wp-schema-pro'),
height: 'auto',
width: 400,
modal: true,
open() {
$(this)
.closest('.ui-dialog')
.find('.ui-dialog-titlebar-close')
.hide();
const markup =
'<p><span class="dashicons dashicons-trash"></span> Do you really want to reset current post rating?</p>';
$(this).html(markup);
},
buttons: {
Yes() {
thisObj.addClass('reset-disabled');
parent.find('.spinner').addClass('is-active');
jQuery
.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: ajaxData,
})
.success(function (response) {
if (
'undefined' !== typeof response.success &&
response.success === true
) {
const avgRating = response['rating-avg'],
reviewCount =
response['review-count'];
parent
.find('.aiosrs-rating')
.text(avgRating);
parent
.find('.aiosrs-rating-count')
.text(reviewCount);
parent
.find(
'.aiosrs-star-rating-wrap > .aiosrs-star-rating'
)
.removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
)
.addClass('dashicons-star-empty');
} else {
thisObj.removeClass('reset-disabled');
}
parent
.find('.spinner')
.removeClass('is-active');
});
$(this).dialog('close');
},
Cancel() {
$(this).dialog('close');
},
},
});
$('#wpsp-reset-dialog-confirmation').dialog('open');
});
$(document).on('change', '.multi-select-wrap select', function () {
const multiselectWrap = $(this).closest('.multi-select-wrap'),
selectWrap = multiselectWrap.find('select'),
inputField = multiselectWrap.find('input[type="hidden"]'),
value = selectWrap.val();
if (
'undefined' !== typeof value &&
null !== value &&
value.length > 0
) {
inputField.val(value.join(','));
} else {
inputField.val('');
}
});
// Verticle Tabs
$(document).on(
'click',
'.aiosrs-pro-meta-fields-tab',
function (e) {
e.preventDefault();
const id = $(this).data('tab-id');
$(this)
.siblings('.aiosrs-pro-meta-fields-tab')
.removeClass('active');
$(this).addClass('active');
$('#aiosrs-pro-custom-fields')
.find('.aiosrs-pro-meta-fields-wrap')
.removeClass('open');
$('#aiosrs-pro-custom-fields')
.find('.' + id)
.addClass('open');
}
);
// Toggle Js for Enable Schema Markup.
$(document.body).on(
'change',
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup .wpsp-enable-schema-toggle',
function () {
const parent = $(this).parents(
'.aiosrs-pro-meta-fields-tab'
);
const parents = $(this).parents('.inside');
const id = parent.data('tab-id');
const hasClass = parents
.find('.aiosrs-pro-meta-fields-wrapper')
.find('.' + id)
.hasClass('is-enable-schema-markup');
const isChecked = parent
.find('.wpsp-enable-schema-toggle')
.hasClass('is-checked');
if (!hasClass && !isChecked) {
parents
.find('.aiosrs-pro-meta-fields-wrapper')
.find('.' + id)
.addClass('is-enable-schema-markup');
}
}
);
$(
'#aiosrs-pro-custom-fields .wpsp-enable-schema-markup .wpsp-enable-schema-toggle'
).trigger('change');
$('.wpsp-enable-schema-toggle').on('click', function () {
const parent = $(this).parents('.aiosrs-pro-meta-fields-tab');
const parents = $(this).parents('.inside');
const id = parent.data('tab-id');
parents
.find('.aiosrs-pro-meta-fields-wrapper')
.find('.' + id)
.toggleClass('is-enable-schema-markup');
});
// Call Tooltip
$('.bsf-aiosrs-schema-heading-help').tooltip({
content() {
return $(this).prop('title');
},
tooltipClass: 'bsf-aiosrs-schema-ui-tooltip',
position: {
my: 'center top',
at: 'center bottom+10',
},
hide: {
duration: 200,
},
show: {
duration: 200,
},
});
let fileFrame;
window.inputWrapper = '';
$(document.body).on(
'click',
'.image-field-wrap .aiosrs-image-select',
function (e) {
e.preventDefault();
window.inputWrapper = $(this).closest(
'.bsf-aiosrs-schema-custom-text-wrap, .aiosrs-pro-custom-field-image'
);
// Create the media frame.
fileFrame = wp.media({
button: {
text: 'Select Image',
close: false,
},
states: [
new wp.media.controller.Library({
title: __('Select Custom Image', 'wp-schema-pro'),
library: wp.media.query({ type: 'image' }),
multiple: false,
}),
],
});
// When an image is selected, run a callback.
fileFrame.on('select', function () {
const attachment = fileFrame
.state()
.get('selection')
.first()
.toJSON();
const image = window.inputWrapper.find(
'.image-field-wrap img'
);
if (image.length === 0) {
window.inputWrapper
.find('.image-field-wrap')
.append(
'<a href="#" class="aiosrs-image-select img"><img src="' +
attachment.url +
'" /></a>'
);
} else {
image.attr('src', attachment.url);
}
window.inputWrapper
.find('.image-field-wrap')
.addClass('bsf-custom-image-selected');
window.inputWrapper
.find('.single-image-field')
.val(attachment.id);
const parent = window.inputWrapper.parents(
'.wpsp-local-fields'
);
parent
.find('.wpsp-default-hidden-value')
.val(attachment.id);
parent
.find('.wpsp-default-hidden-fieldtype')
.val(
window.inputWrapper
.parents('.wpsp-parent-field')
.attr('data-type')
);
fileFrame.close();
});
fileFrame.open();
}
);
$(document).on('click', '.aiosrs-image-remove', function (e) {
e.preventDefault();
const parent = $(this).closest(
'.bsf-aiosrs-schema-custom-text-wrap, .aiosrs-pro-custom-field-image'
);
parent
.find('.image-field-wrap')
.removeClass('bsf-custom-image-selected');
parent.find('.single-image-field').val('');
parent.find('.image-field-wrap img').removeAttr('src');
});
window.inputWrapper = '';
});
})(jQuery);

View File

@@ -0,0 +1,147 @@
/* eslint-env jquery */
(function ($) {
/**
* AIOSRS Frontend
*
* @class WPSchemaProFrontend
* @since 1.0
*/
const WPSchemaProFrontend = {
/**
* Initializes a AIOSRS Frontend.
*
* @since 1.0
* @function init
*/
container: '',
init() {
const self = this;
jQuery(document).on(
'click',
'.aiosrs-rating-wrap .aiosrs-star-rating',
function (e) {
e.preventDefault();
self.star_rating(this);
}
);
jQuery(document).on(
'mouseover',
'.aiosrs-rating-wrap .aiosrs-star-rating',
function (e) {
e.preventDefault();
self.hover_star_rating(this);
}
);
jQuery(document).on(
'mouseout',
'.aiosrs-rating-wrap .aiosrs-star-rating-wrap',
function (e) {
e.preventDefault();
if (!$(this).hasClass('disabled')) {
const index = $(this)
.parent()
.find('.aiosrs-rating')
.text();
self.update_stars($(this), index);
}
}
);
},
hover_star_rating(field) {
const self = this,
parent = $(field).closest('.aiosrs-star-rating-wrap'),
index = $(field).data('index');
if (!parent.hasClass('disabled')) {
self.update_stars(parent, index);
}
},
update_stars(wrap, rating) {
let filled = rating > 5 ? 5 : parseInt(rating);
if (rating > 5) {
filled = 5;
} else if (rating < 0) {
filled = 0;
} else {
filled = parseInt(rating);
}
const half = rating === filled || rating > 5 || rating < 0 ? 0 : 1;
wrap.find('span').each(function (index) {
$(this).removeClass(
'dashicons-star-filled dashicons-star-half dashicons-star-empty'
);
if (index < filled) {
$(this).addClass('dashicons-star-filled');
} else if (index === filled && half === 1) {
$(this).addClass('dashicons-star-empty');
} else {
$(this).addClass('dashicons-star-empty');
}
});
},
star_rating(field) {
const self = this,
schemaId = $(field)
.closest('.aiosrs-rating-wrap')
.data('schema-id'),
parent = $(field).closest('.aiosrs-star-rating-wrap'),
index = $(field).data('index');
if (!parent.hasClass('disabled')) {
self.update_stars(parent, index);
parent.addClass('disabled');
$.ajax({
url: AIOSRS_Frontend.ajaxurl,
type: 'POST',
data: {
action: 'aiosrs_user_rating',
rating: index,
schemaId,
post_id: AIOSRS_Frontend.post_id,
nonce: AIOSRS_Frontend.user_rating_nonce,
},
}).success(function (response) {
if (response.success === true) {
const summaryWrap = parent.next(
'.aiosrs-rating-summary-wrap'
),
rating = response.rating,
avgRating = response['rating-avg'],
reviewCount = response['review-count'];
summaryWrap.find('.aiosrs-rating').text(avgRating);
summaryWrap
.find('.aiosrs-rating-count')
.text(reviewCount);
if (parent.next('.success-msg').length === 0) {
parent.after(
'<span class="success-msg">' +
AIOSRS_Frontend.success_msg +
'</span>'
);
}
setTimeout(function () {
parent.parent().find('.success-msg').remove();
parent.removeClass('disabled');
}, 5000);
self.update_stars(parent, rating);
}
});
}
},
};
/* Initializes the AIOSRS Frontend. */
$(function () {
WPSchemaProFrontend.init();
});
})(jQuery);

View File

@@ -0,0 +1,26 @@
/* eslint-env jquery */
jQuery( document ).ready( function () {
jQuery( '#aiosrs-pro-license-form-btn' ).on( 'click', function ( e ) {
e.preventDefault();
jQuery( '#aiosrs-pro-license-form' ).show();
jQuery( 'body' ).addClass( 'aiosrs-pro-license-form-open' );
} );
jQuery( '#aiosrs-pro-license-form-close-btn' ).on( 'click', function ( e ) {
e.preventDefault();
jQuery( '#aiosrs-pro-license-form' ).hide();
jQuery( 'body' ).removeClass( 'aiosrs-pro-license-form-open' );
} );
jQuery( '#aiosrs-pro-license-form .aiosrs-pro-license-form-overlay' ).on(
'click',
function ( e ) {
e.preventDefault();
jQuery( '#aiosrs-pro-license-form' ).hide();
jQuery( 'body' ).removeClass( 'aiosrs-pro-license-form-open' );
}
);
} );

View File

@@ -0,0 +1,783 @@
/* eslint-env jquery */
(function ($) {
/**
* AIOSRS Schema
*
* @class AIOSRSSchema
* @since 1.0
*/
const AIOSRSSchema = {
/**
* Initializes a AIOSRS Schema.
*
* @since 1.0
* @function init
*/
container: '',
init() {
const self = this;
self.container = $(
'#aiosrs-schema-settings, #aiosrs-pro-custom-fields'
);
// Init backgrounds.
$(document).ready(function () {
$('.select2-class').select2();
const selectOption = ['Site Meta', 'Post Meta (Basic Fields)'];
const customOptionGroup = $('#bsf-aiosrs-schema-type').val();
if ('custom-markup' === customOptionGroup) {
for (let i = 0; i < selectOption.length; i++) {
$(
'#bsf-aiosrs-custom-markup-custom-markup optgroup[label="' +
selectOption[i] +
'"]'
).remove();
}
}
const customMarkupSchemId = $(
'#custom-schema-schema-field'
).val();
if (customMarkupSchemId) {
for (let i = 0; i < selectOption.length; i++) {
$(
'#custom-markup-' +
customMarkupSchemId +
'-custom-markup-connected optgroup[label="' +
selectOption[i] +
'"]'
).remove();
}
}
});
self.container.on(
'change',
'select.bsf-aiosrs-schema-meta-field',
function () {
const selfFun = $(this),
parent = selfFun.parent(),
value = selfFun.val();
const textwrapperCustom = parent.find(
'.bsf-aiosrs-schema-custom-text-wrap'
);
if ('custom-text' === value) {
textwrapperCustom.removeClass('bsf-hidden-field');
} else if (
!textwrapperCustom.hasClass('bsf-hidden-field')
) {
textwrapperCustom.addClass('bsf-hidden-field');
}
const textWrapperFixed = parent.find(
'.bsf-aiosrs-schema-fixed-text-wrap'
);
if ('fixed-text' === value) {
textWrapperFixed.removeClass('bsf-hidden-field');
} else if (!textWrapperFixed.hasClass('bsf-hidden-field')) {
textWrapperFixed.addClass('bsf-hidden-field');
}
const specificMetaWrapper = parent.find(
'.bsf-aiosrs-schema-specific-field-wrap'
);
if ('specific-field' === value) {
specificMetaWrapper.removeClass('bsf-hidden-field');
} else if (
!specificMetaWrapper.hasClass('bsf-hidden-field')
) {
specificMetaWrapper.addClass('bsf-hidden-field');
}
}
);
self.container.on(
'change',
'.bsf-aiosrs-schema-row-rating-type select.bsf-aiosrs-schema-meta-field',
function (e) {
e.preventDefault();
$(this)
.closest('.bsf-aiosrs-schema-table')
.find('.bsf-aiosrs-schema-row')
.css('display', '');
if ('accept-user-rating' === $(this).val()) {
const reviewCountWrap = $(this)
.closest('.bsf-aiosrs-schema-row')
.next('.bsf-aiosrs-schema-row'),
name = reviewCountWrap
.find('.bsf-aiosrs-schema-meta-field')
.attr('name');
const selectedSchemaType = jQuery(
'.bsf-aiosrs-review-schema-type'
).val();
if (selectedSchemaType) {
const prepareName =
'bsf-aiosrs-review[' +
selectedSchemaType +
'-review-count]';
if (name.indexOf(prepareName) >= 0) {
reviewCountWrap.hide();
}
}
if (name.indexOf('[review-count]') >= 0) {
reviewCountWrap.hide();
}
}
}
);
self.container
.find('select.bsf-aiosrs-schema-meta-field')
.trigger('change');
$('select.bsf-aiosrs-schema-select2').each(function (index, el) {
self.init_target_rule_select2(el);
});
self.container.on(
'click',
'.bsf-repeater-add-new-btn',
function (event) {
event.preventDefault();
self.add_new_repeater($(this));
self.prepare_event_schmea_fields();
}
);
self.container.on('click', '.bsf-repeater-close', function (event) {
event.preventDefault();
self.add_remove_repeater($(this));
});
self.schemaTypeDependency();
self.bindTooltip();
if (!$('body').hasClass('post-type-aiosrs-schema')) {
self.field_validation();
}
},
field_validation() {
$(
'.wpsp-custom-field-connect, .wpsp-field-close, .bsf-aiosrs-schema-meta-field, image-field-wrap, .aiosrs-pro-custom-field, .wpsp-custom-field-connect'
).on('click focus change', function () {
$('.bsf-aiosrs-schema-type-wrap').each(function (
index,
repeater
) {
let fieldValue = $(repeater)
.find('.wpsp-default-hidden-value')
.val();
const requiredPath = $(repeater)
.parents('.bsf-aiosrs-schema-row-content')
.prev();
if (undefined !== fieldValue) {
fieldValue = fieldValue.trim();
if (fieldValue) {
if ($('body').hasClass('block-editor-page')) {
if (
!$(repeater).find(
'.wpsp-required-error-field'
).length
) {
let metaField;
switch (fieldValue) {
case 'post_title':
metaField = $(
'.editor-post-title__input'
).val();
break;
case 'post_content':
metaField =
$(
'p.block-editor-rich-text__editable'
).text().length > 1
? $(
'p.block-editor-rich-text__editable'
).text()
: '';
break;
case 'post_excerpt':
metaField = $(
'.components-textarea-control__input'
).val();
break;
case 'featured_img':
if (
'Set featured image' ===
$(
'.editor-post-featured-image__toggle'
).text()
) {
metaField = '';
} else {
metaField = $(
'.components-responsive-wrapper__content'
).attr('src');
}
break;
default:
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass(
'wpsp-required-error-field'
);
}
if (undefined !== metaField) {
if ('' !== metaField) {
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass(
'wpsp-required-error-field'
);
} else if (
requiredPath.find('.required')
.length
) {
requiredPath
.find('label')
.addClass(
'wpsp-required-error-field'
);
}
}
} else {
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass(
'wpsp-required-error-field'
);
}
} else {
requiredPath.removeClass(
'wpsp-required-error-field'
);
requiredPath
.find('label')
.removeClass('wpsp-required-error-field');
}
} else if (requiredPath.find('.required').length) {
requiredPath
.find('label')
.addClass('wpsp-required-error-field');
}
}
});
});
},
hide_review_count() {
$(this)
.closest('.bsf-aiosrs-schema-table')
.find('.bsf-aiosrs-schema-row')
.css('display', '');
if ('accept-user-rating' === $(this).val()) {
const reviewCountWrap = $(this)
.closest('.bsf-aiosrs-schema-row')
.next('.bsf-aiosrs-schema-row'),
name = reviewCountWrap
.find('.bsf-aiosrs-schema-meta-field')
.attr('name');
const selectedSchemaType = jQuery(
'.bsf-aiosrs-review-schema-type'
).val();
if (selectedSchemaType) {
const prepareName =
'bsf-aiosrs-review[' +
selectedSchemaType +
'-review-count]';
if (name.indexOf(prepareName) >= 0) {
reviewCountWrap.hide();
}
}
if (name.indexOf('[review-count]') >= 0) {
reviewCountWrap.hide();
}
}
},
add_new_repeater(selector) {
const self = this,
parentWrap = selector.closest('.bsf-aiosrs-schema-type-wrap'),
totalCount = parentWrap.find('.aiosrs-pro-repeater-table-wrap')
.length,
template = parentWrap
.find('.aiosrs-pro-repeater-table-wrap')
.first()
.clone();
template
.find(
'.bsf-aiosrs-schema-custom-text-wrap, .bsf-aiosrs-schema-specific-field-wrap'
)
.each(function () {
if (!$(this).hasClass('bsf-hidden-field')) {
$(this).addClass('bsf-hidden-field');
}
});
template
.find('select.bsf-aiosrs-schema-meta-field')
.each(function () {
$(this).val('none');
const fieldName =
'undefined' !== typeof $(this).attr('name')
? $(this)
.attr('name')
.replace('[0]', '[' + totalCount + ']')
: '',
fieldClass =
'undefined' !== typeof $(this).attr('class')
? $(this)
.attr('class')
.replace('-0-', '-' + totalCount + '-')
: '',
fieldId =
'undefined' !== typeof $(this).attr('id')
? $(this)
.attr('id')
.replace('-0-', '-' + totalCount + '-')
: '';
$(this).attr('name', fieldName);
$(this).attr('class', fieldClass);
$(this).attr('id', fieldId);
});
template
.find(
'input, textarea, select:not(.bsf-aiosrs-schema-meta-field)'
)
.each(function () {
$(this).val('');
const fieldName =
'undefined' !== typeof $(this).attr('name')
? $(this)
.attr('name')
.replace('[0]', '[' + totalCount + ']')
: '',
fieldClass =
'undefined' !== typeof $(this).attr('class')
? $(this)
.attr('class')
.replace('-0-', '-' + totalCount + '-')
: '',
fieldId =
'undefined' !== typeof $(this).attr('id')
? $(this)
.attr('id')
.replace('-0-', '-' + totalCount + '-')
: '';
$(this).attr('name', fieldName);
$(this).attr('class', fieldClass);
$(this).attr('id', fieldId);
});
template.find('span.select2-container').each(function () {
$(this).remove();
});
template.insertBefore(selector);
template
.find('select.bsf-aiosrs-schema-select2')
.each(function (index, el) {
self.init_target_rule_select2(el);
});
AIOSRSSchema.init_date_time_fields();
},
add_remove_repeater(selector) {
const parentWrap = selector.closest('.bsf-aiosrs-schema-type-wrap'),
repeaterCount = parentWrap.find(
'> .aiosrs-pro-repeater-table-wrap'
).length;
if (repeaterCount > 1) {
selector.closest('.aiosrs-pro-repeater-table-wrap').remove();
if ('aiosrs-pro-custom-fields' === this.container.attr('id')) {
// Reset index to avoid duplicate names.
parentWrap
.find('> .aiosrs-pro-repeater-table-wrap')
.each(function (wrapIndex, repeaterWap) {
$(repeaterWap).each(function (
elementIndex,
element
) {
$(element)
.find(
'input, textarea, select:not(.bsf-aiosrs-schema-meta-field)'
)
.each(function (elIndex, el) {
const fieldName =
'undefined' !==
typeof $(el).attr('name')
? $(el)
.attr('name')
.replace(
/\[\d+]/,
'[' +
wrapIndex +
']'
)
: '';
$(el).attr('name', fieldName);
});
});
});
}
}
},
bindTooltip() {
// Call Tooltip
$('.bsf-aiosrs-schema-heading-help').tooltip({
content() {
return $(this).prop('title');
},
tooltipClass: 'bsf-aiosrs-schema-ui-tooltip',
position: {
my: 'center top',
at: 'center bottom+10',
},
hide: {
duration: 200,
},
show: {
duration: 200,
},
});
},
schemaTypeDependency() {
const container = this.container;
this.container.on(
'change',
'select[name="bsf-aiosrs-schema-type"]',
function () {
container
.find('.bsf-aiosrs-schema-meta-wrap')
.css('display', 'none');
const schemaType = $(this).val();
if (
'undefined' !== typeof schemaType &&
'' !== schemaType
) {
container
.find('#bsf-' + schemaType + '-schema-meta-wrap')
.css('display', '');
}
}
);
},
init_target_rule_select2(selector) {
$(selector).select2({
placeholder: 'Search Fields...',
ajax: {
url: ajaxurl,
dataType: 'json',
method: 'post',
delay: 250,
data(params) {
return {
nonce_ajax: AIOSRS_Rating.specified_field,
q: params.term, // search term
page: params.page,
action: 'bsf_get_specific_meta_fields',
};
},
processResults(data) {
return {
results: data,
};
},
cache: true,
},
minimumInputLength: 2,
});
},
get_review_item_type_html(itemType) {
jQuery
.post({
url: ajaxurl,
data: {
action: 'fetch_item_type_html',
itemType,
nonce: AIOSRS_Rating.security,
post_id: jQuery('#post_ID').val(),
},
})
.done(function (response) {
$('.bsf-review-item-type-field').remove();
$(response).insertAfter(
jQuery('#bsf-aiosrs-review-schema-type')
.parent()
.parent()
.closest('tr')
);
$('select.bsf-aiosrs-schema-select2').each(function (
index,
el
) {
AIOSRSSchema.init_target_rule_select2(el);
});
const itemSpecificType =
'.bsf-aiosrs-review-' + itemType + '-rating';
$(itemSpecificType).each(function () {
$(this)
.closest('.bsf-aiosrs-schema-table')
.find('.bsf-aiosrs-schema-row')
.css('display', '');
if ('accept-user-rating' === $(this).val()) {
const reviewCountWrap = $(this)
.closest('.bsf-aiosrs-schema-row')
.next('.bsf-aiosrs-schema-row'),
name = reviewCountWrap
.find('.bsf-aiosrs-schema-meta-field')
.attr('name');
const selectedSchemaType = jQuery(
'.bsf-aiosrs-review-schema-type'
).val();
if (selectedSchemaType) {
const prepareName =
'bsf-aiosrs-review[' +
selectedSchemaType +
'-review-count]';
if (name.indexOf(prepareName) >= 0) {
reviewCountWrap.hide();
}
}
if (name.indexOf('[review-count]') >= 0) {
reviewCountWrap.hide();
}
}
});
AIOSRSSchema.init_date_time_fields();
AIOSRSSchema.prepare_event_schmea_fields();
})
.fail(function () { });
},
prepare_event_schmea_fields() {
$(
'.wpsp-dropdown-event-status, .wpsp-dropdown-bsf-aiosrs-event-event-status'
).change(function () {
const parent = $(this).parents(
'.bsf-aiosrs-schema-meta-wrap, .aiosrs-pro-meta-fields-wrap'
);
parent
.find(
'td.wpsp-event-status-rescheduled, td.bsf-aiosrs-review-bsf-aiosrs-event-previous-date'
)
.hide();
if (!this.value) {
this.value = 'EventScheduled';
}
if ('EventRescheduled' === this.value) {
parent
.find(
'td.wpsp-event-status-rescheduled, td.bsf-aiosrs-review-bsf-aiosrs-event-previous-date'
)
.show();
}
const eventStatus = $(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
).val();
if (
'EventMovedOnline' === this.value ||
'OfflineEventAttendanceMode' !== eventStatus
) {
parent.find('td.wpsp-event-status-offline').hide();
parent.find('td.wpsp-event-status-online').show();
parent.find('td.wpsp-online-event-timezone').show();
parent
.find(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
)
.val('OnlineEventAttendanceMode');
} else {
parent.find('td.wpsp-event-status-offline').show();
parent.find('td.wpsp-event-status-online').hide();
parent.find('td.wpsp-online-event-timezone').hide();
}
});
$(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
).change(function () {
const parent = $(this).parents(
'.bsf-aiosrs-schema-meta-wrap, .aiosrs-pro-meta-fields-wrap'
);
parent.find('td.wpsp-event-status-rescheduled').hide();
const eventStatus = $(
'.wpsp-dropdown-event-status, .wpsp-dropdown-bsf-aiosrs-event-event-status'
).val();
if ('EventMovedOnline' !== eventStatus) {
parent.find('td.wpsp-event-status-offline').show();
parent.find('td.wpsp-event-status-online').hide();
parent.find('td.wpsp-online-event-timezone').hide();
}
if ('OfflineEventAttendanceMode' !== this.value) {
parent.find('td.wpsp-event-status-offline').hide();
parent.find('td.wpsp-event-status-online').show();
parent.find('td.wpsp-online-event-timezone').show();
}
if ('MixedEventAttendanceMode' === this.value) {
parent.find('td.wpsp-event-status-offline').show();
parent.find('td.wpsp-event-status-online').show();
parent.find('td.wpsp-online-event-timezone').show();
}
});
$(
'.wpsp-dropdown-event-attendance-mode, .wpsp-dropdown-bsf-aiosrs-event-event-attendance-mode'
).trigger('change');
},
init_date_time_fields() {
$(
'.wpsp-datetime-local-field, .wpsp-date-field, .wpsp-time-duration-field'
).each(function () {
$(this).removeClass('hasDatepicker');
});
const startDateSelectors =
'.wpsp-date-published-date, .wpsp-datetime-local-event-start-date, .wpsp-date-start-date, .wpsp-datetime-local-start-date';
const endDateSelectors =
'.wpsp-date-modified-date, .wpsp-datetime-local-event-end-date, .wpsp-date-end-date, .wpsp-datetime-local-end-date';
$(document).on('focus', '.wpsp-time-duration-field', function () {
$(this).timepicker({
timeFormat: 'HH:mm:ss',
hourMin: 0,
hourMax: 99,
oneLine: true,
currentText: 'Clear',
onSelect() {
updateTimeFormat(this);
},
});
});
$(document).on(
'focus',
'.wpsp-datetime-local-field, .wpsp-date-field',
function () {
$(this).datetimepicker({
dateFormat: 'yy-mm-dd',
timeFormat: 'hh:mm TT',
changeMonth: true,
changeYear: true,
showOn: 'focus',
showButtonPanel: true,
closeText: 'Done',
currentText: 'Clear',
yearRange: '-100:+10', // last hundred year
onClose(dateText, inst) {
const thisEle = '#' + inst.id;
if (jQuery(thisEle).is(startDateSelectors)) {
$(endDateSelectors).datetimepicker(
'option',
'minDate',
new Date(dateText)
);
} else if (jQuery(thisEle).is(endDateSelectors)) {
$(startDateSelectors).datetimepicker(
'option',
'maxDate',
new Date(dateText)
);
}
jQuery(thisEle)
.parents('.wpsp-local-fields')
.find('.wpsp-default-hidden-value')
.val(dateText);
},
});
}
);
$.datepicker._gotoToday = function (id) {
$(id).datepicker('setDate', '').datepicker('hide').blur();
};
function updateTimeFormat(thisEle) {
const durationWrap = $(thisEle).closest(
'.aiosrs-pro-custom-field-time-duration'
);
const inputField = durationWrap.find('.time-duration-field');
let value = $(thisEle).val();
value = value.replace(/:/, 'H');
value = value.replace(/:/, 'M');
value = 'PT' + value + 'S';
inputField.val(value);
// Post/pages related support.
const parent = $(thisEle).parents('.wpsp-local-fields');
parent.find('.wpsp-default-hidden-value').val(value);
}
},
};
/* Initializes the AIOSRS Schema. */
$(function () {
AIOSRSSchema.init();
if (!$('body').hasClass('aiosrs-pro-setup')) {
AIOSRSSchema.init_date_time_fields();
}
});
$(document).ready(function () {
let parent = $('.aiosrs-pro-meta-fields-wrap');
parent.each(function (index, value) {
let labelMarkup = $(value).find('.wpsp-field-label');
let label = labelMarkup.text();
if ('Image License' === label.trim()) {
labelMarkup.attr('style', 'width:6%');
}
});
$('#bsf-aiosrs-review-schema-type').change(function () {
const itemVal = $(this).val().trim();
if (!itemVal) {
$('.bsf-review-item-type-field').remove();
return;
}
AIOSRSSchema.get_review_item_type_html(itemVal);
});
$('#bsf-aiosrs-review-schema-type').change();
AIOSRSSchema.prepare_event_schmea_fields();
});
})(jQuery);

View File

@@ -0,0 +1,415 @@
/* eslint-env jquery */
(function ($) {
const { __ } = wp.i18n;
const temp = {
person: __('Website Owner Name'),
organization: __('Organization Name', 'wp-schema-pro'),
Webshop: __('Webshop Name', 'wp-schema-pro'),
personblog: __('Website Owner Name', 'wp-schema-pro'),
Smallbusiness: __('Blog Website Name', 'wp-schema-pro'),
Otherbusiness: __('Business Name', 'wp-schema-pro'),
};
/**
* AIOSRS Frontend
*
* @class WPSchemaProSettings
* @since 1.0
*/
const WPSchemaProSettings = {
init() {
const self = this;
this.customFieldDependecy();
this.customImageSelect();
this.initRepeater();
this.toolTips();
this.regenerateSchema();
$('select.wp-select2').each(function (index, el) {
self.init_target_rule_select2(el);
});
},
regenerateSchema() {
$('#wpsp-regenerate-schema').click(function () {
$(this).next('span.spinner').addClass('is-active');
jQuery
.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'regenerate_schema',
nonce: $(this).data('nonce'),
},
})
.success(function () {
$('#wpsp-regenerate-schema')
.next('span.spinner')
.removeClass('is-active');
$('#wpsp-regenerate-notice')
.show()
.delay(2000)
.fadeOut();
});
});
},
toolTips() {
$(document).on(
'click',
'.wp-schema-pro-tooltip-icon',
function (e) {
e.preventDefault();
$('.wp-schema-pro-tooltip-wrapper').removeClass('activate');
$(this).parent().addClass('activate');
}
);
$(document).on('click', function (e) {
if (
!$(e.target).hasClass(
'wp-schema-pro-tooltip-description'
) &&
!$(e.target).hasClass('wp-schema-pro-tooltip-icon') &&
$(e.target).closest('.wp-schema-pro-tooltip-description')
.length === 0
) {
$('.wp-schema-pro-tooltip-wrapper').removeClass('activate');
}
});
},
customImageSelect() {
let fileFrame;
window.inputWrapper = '';
$(document.body).on(
'click',
'.image-field-wrap .aiosrs-image-select',
function (e) {
e.preventDefault();
window.inputWrapper = $(this).closest('td');
// Create the media frame.
fileFrame = wp.media({
button: {
text: 'Select Image',
close: false,
},
states: [
new wp.media.controller.Library({
title: 'Select Custom Image',
library: wp.media.query({ type: 'image' }),
multiple: false,
}),
],
});
// When an image is selected, run a callback.
fileFrame.on('select', function () {
const attachment = fileFrame
.state()
.get('selection')
.first()
.toJSON();
const image = window.inputWrapper.find(
'.image-field-wrap img'
);
if (image.length === 0) {
window.inputWrapper
.find('.image-field-wrap')
.append(
'<a href="#" class="aiosrs-image-select img"><img src="' +
attachment.url +
'" /></a>'
);
} else {
image.attr('src', attachment.url);
}
window.inputWrapper
.find('.image-field-wrap')
.addClass('bsf-custom-image-selected');
window.inputWrapper
.find('.single-image-field')
.val(attachment.id);
fileFrame.close();
});
fileFrame.open();
}
);
$(document).on('click', '.aiosrs-image-remove', function (e) {
e.preventDefault();
const parent = $(this).closest('td');
parent
.find('.image-field-wrap')
.removeClass('bsf-custom-image-selected');
parent.find('.single-image-field').val('');
parent.find('.image-field-wrap img').removeAttr('src');
});
window.inputWrapper = '';
},
customFieldDependecy() {
jQuery(document).on(
'change',
'#post-body-content .wp-schema-pro-custom-option-select, .aiosrs-pro-setup-wizard-content.general-setting-content-wrap .wp-schema-pro-custom-option-select',
function () {
const customWrap = jQuery(this).next(
'.custom-field-wrapper'
);
customWrap.css('display', 'none');
if ('custom' === jQuery(this).val()) {
customWrap.css('display', '');
}
}
);
jQuery(document).on(
'change',
'select[name="wp-schema-pro-general-settings[site-represent]"]',
function () {
const wrapper = jQuery(this).closest('table'),
logoWrap = wrapper.find(
'.wp-schema-pro-site-logo-wrap'
),
companyNameWrap = wrapper.find(
'.wp-schema-pro-site-name-wrap'
),
personNameWrap = wrapper.find(
'.wp-schema-pro-person-name-wrap'
);
companyNameWrap.css('display', 'none');
personNameWrap.css('display', 'none');
if ('' !== jQuery(this).val()) {
if (
'organization' === jQuery(this).val() ||
'Webshop' === jQuery(this).val() ||
'Smallbusiness' === jQuery(this).val() ||
'Otherbusiness' === jQuery(this).val()
) {
logoWrap.css('display', '');
companyNameWrap.css('display', '');
} else {
personNameWrap.css('display', '');
logoWrap.css('display', '');
}
}
}
);
jQuery(document).on(
'change',
'select[name="wp-schema-pro-general-settings[site-represent]"]',
function () {
const organizationType = jQuery(this).val();
if ('' !== jQuery(this).val()) {
if (organizationType in temp) {
$('.wpsp-organization-label').text(
temp[organizationType]
);
}
}
}
);
jQuery(document).on(
'change',
'select[name="wp-schema-pro-corporate-contact[contact-type]"]',
function () {
const wrapper = jQuery(this).closest('table'),
contactPointWrap = wrapper.find(
'.wp-schema-pro-other-wrap'
);
contactPointWrap.css('display', 'none');
if ('' !== jQuery(this).val()) {
if ('other' === jQuery(this).val()) {
contactPointWrap.css('display', '');
}
}
}
);
$('#add-row').on('click', function () {
const row = $('.empty-row.screen-reader-text').clone(true);
row.removeClass('empty-row screen-reader-text');
row.insertBefore('#repeatable-fieldset-one >tr:last');
return false;
});
$('.remove-row').on('click', function () {
$(this).parents('tr').remove();
return false;
});
},
initRepeater() {
$(document).on(
'click',
'.bsf-repeater-add-new-btn',
function (event) {
event.preventDefault();
const selector = $(this),
parentWrap = selector.closest(
'.bsf-aiosrs-schema-type-wrap'
),
totalCount = parentWrap.find(
'.aiosrs-pro-repeater-table-wrap'
).length,
template = parentWrap
.find('.aiosrs-pro-repeater-table-wrap')
.first()
.clone();
template.find('input, textarea, select').each(function () {
$(this).val('');
const fieldName =
'undefined' !== typeof $(this).attr('name')
? $(this)
.attr('name')
.replace(
'[0]',
'[' + totalCount + ']'
)
: '',
fieldClass =
'undefined' !== typeof $(this).attr('class')
? $(this)
.attr('class')
.replace(
'-0-',
'-' + totalCount + '-'
)
: '',
fieldId =
'undefined' !== typeof $(this).attr('id')
? $(this)
.attr('id')
.replace(
'-0-',
'-' + totalCount + '-'
)
: '';
$(this).attr('name', fieldName);
$(this).attr('class', fieldClass);
$(this).attr('id', fieldId);
});
template.insertBefore(selector);
}
);
$(document).on('click', '.bsf-repeater-close', function (event) {
event.preventDefault();
const selector = $(this),
parentWrap = selector.closest(
'.bsf-aiosrs-schema-type-wrap'
),
repeaterCount = parentWrap.find(
'> .aiosrs-pro-repeater-table-wrap'
).length;
if (repeaterCount > 1) {
selector
.closest('.aiosrs-pro-repeater-table-wrap')
.remove();
}
});
},
init_target_rule_select2(selector) {
$(selector).select2({
placeholder: 'Search Fields...',
ajax: {
url: ajaxurl,
dataType: 'json',
method: 'post',
delay: 250,
data(params) {
return {
nonce_ajax: AIOSRS_search.search_field,
q: params.term, // search term
page: params.page,
action: 'bsf_get_specific_pages',
};
},
processResults(data) {
return {
results: data,
};
},
cache: true,
},
minimumInputLength: 2,
});
},
};
const loadDefaultValues = function () {
const field = jQuery(
'select[name="wp-schema-pro-general-settings[site-represent]"]'
),
wrapper = field.closest('table'),
logoWrap = wrapper.find('.wp-schema-pro-site-logo-wrap'),
companyNameWrap = wrapper.find('.wp-schema-pro-site-name-wrap'),
personNameWrap = wrapper.find('.wp-schema-pro-person-name-wrap');
companyNameWrap.css('display', 'none');
personNameWrap.css('display', 'none');
if ('' !== field.val()) {
if (
'organization' === field.val() ||
'Webshop' === field.val() ||
'Smallbusiness' === field.val() ||
'Otherbusiness' === field.val()
) {
logoWrap.css('display', '');
companyNameWrap.css('display', '');
} else {
personNameWrap.css('display', '');
logoWrap.css('display', '');
}
}
};
const loadDefaultOrganizationLabel = function () {
const field = jQuery(
'select[name="wp-schema-pro-general-settings[site-represent]"]'
),
organizationType = field.val();
if ('' !== field) {
if (organizationType in temp) {
$('.wpsp-organization-label').text(temp[organizationType]);
}
}
};
$(document).ready(function () {
$('.wp-select2').select2();
$('.wpsp-setup-configuration-settings').select2();
loadDefaultValues();
loadDefaultOrganizationLabel();
$('#add-row').on('click', function () {
const row = $('.empty-row.screen-reader-text').clone(true);
row.removeClass('empty-row screen-reader-text');
row.insertBefore('#repeatable-fieldset-one tbody>tr:last');
return false;
});
$('.remove-row').on('click', function () {
$(this).parents('tr').remove();
return false;
});
});
/* Initializes the AIOSRS Frontend. */
$(function () {
WPSchemaProSettings.init();
});
})(jQuery);

View File

@@ -0,0 +1,32 @@
/* eslint-env jquery */
/**
* File setup-wizard.js
*
* Handles Color Picker
*
* @package
*/
( function ( $ ) {
jQuery( document ).ready( function () {
$( document ).on(
'click',
'.aiosrs-pro-schema-temp-wrap',
function ( e ) {
e.preventDefault();
$( '.aiosrs-pro-schema-temp-wrap' ).removeClass( 'selected' );
$( '.aiosrs-pro-setup-actions' )
.find( '.button-next' )
.removeAttr( 'disabled' );
$( this ).addClass( 'selected' );
const type = $( this ).data( 'schema-type' ),
title = $( this ).data( 'schema-title' );
$( document ).find( '.bsf-aiosrs-schema-type' ).val( type );
$( document ).find( '.bsf-aiosrs-schema-title' ).val( title );
}
);
} );
} )( jQuery );

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
.aiosrs-rating-wrap .aiosrs-star-rating-wrap{display:inline-block;vertical-align:middle}.aiosrs-rating-wrap .aiosrs-star-rating-wrap~.aiosrs-star-rating-wrap{float:right}.aiosrs-rating-wrap .aiosrs-star-rating-wrap .aiosrs-star-rating{color:gold}.aiosrs-rating-wrap .aiosrs-star-rating-wrap:not(.disabled) .aiosrs-star-rating{cursor:pointer}.aiosrs-rating-wrap .success-msg{color:#0f0;margin-left:5px}

View File

@@ -0,0 +1 @@
body.aiosrs-pro-license-form-open{overflow:hidden}#aiosrs-pro-license-form p{padding:5px 0}#aiosrs-pro-license-form .aiosrs-pro-license-form-overlay{background:#000;opacity:.7;filter:alpha(opacity=70);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";position:fixed;top:0;right:0;bottom:0;left:0;z-index:100050}#aiosrs-pro-license-form .aiosrs-pro-license-form-inner{background:#fff;position:fixed;z-index:999999999;padding:2px 20px 20px;text-align:left;top:50%;left:50%;-webkit-transform:translateX(-50%) translateY(-50%);transform:translateX(-50%) translateY(-50%);-webkit-box-shadow:0 3px 6px rgba(0,0,0,.3);box-shadow:0 3px 6px rgba(0,0,0,.3)}#aiosrs-pro-license-form-close-btn{position:absolute;left:auto;right:0;top:0;width:29px;height:29px;border:0;padding:0;background:0 0;cursor:pointer;outline:0;-webkit-transition:color .1s ease-in-out,background .1s ease-in-out;-webkit-transform:translateX(100%);transform:translateX(100%);transition:color .1s ease-in-out,background .1s ease-in-out;color:#eee}#aiosrs-pro-license-form-close-btn:hover{color:#00a0d2}#aiosrs-pro-license-form-close-btn .dashicons{display:block;text-align:center;line-height:29px;width:29px;height:29px;font-size:29px;position:absolute;top:0;right:0}#aiosrs-pro-license-form .license-form-field input.regular-text{margin-right:10px}.bsf-current-license-error-wp-schema-pro,.bsf-current-license-success-wp-schema-pro{display:block;margin-bottom:.5em}.bsf-current-license-error-wp-schema-pro{color:#f44336}.bsf-current-license-success-wp-schema-pro{color:green}#aiosrs-pro-license-form-btn.active{color:#3db634}#aiosrs-pro-license-form-btn.inactive{color:#f44336}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(e){const s={container:"",init(){const a=this;jQuery(document).on("click",".aiosrs-rating-wrap .aiosrs-star-rating",function(s){s.preventDefault(),a.star_rating(this)}),jQuery(document).on("mouseover",".aiosrs-rating-wrap .aiosrs-star-rating",function(s){s.preventDefault(),a.hover_star_rating(this)}),jQuery(document).on("mouseout",".aiosrs-rating-wrap .aiosrs-star-rating-wrap",function(s){s.preventDefault(),e(this).hasClass("disabled")||(s=e(this).parent().find(".aiosrs-rating").text(),a.update_stars(e(this),s))})},hover_star_rating(s){var a=e(s).closest(".aiosrs-star-rating-wrap"),s=e(s).data("index");a.hasClass("disabled")||this.update_stars(a,s)},update_stars(s,a){let t=5<a?5:parseInt(a);const r=a===(t=5<a?5:a<0?0:parseInt(a))||5<a||a<0?0:1;s.find("span").each(function(s){e(this).removeClass("dashicons-star-filled dashicons-star-half dashicons-star-empty"),s<t?e(this).addClass("dashicons-star-filled"):(s===t&&r,e(this).addClass("dashicons-star-empty"))})},star_rating(s){const n=this,a=e(s).closest(".aiosrs-rating-wrap").data("schema-id"),i=e(s).closest(".aiosrs-star-rating-wrap"),t=e(s).data("index");i.hasClass("disabled")||(n.update_stars(i,t),i.addClass("disabled"),e.ajax({url:AIOSRS_Frontend.ajaxurl,type:"POST",data:{action:"aiosrs_user_rating",rating:t,schemaId:a,post_id:AIOSRS_Frontend.post_id,nonce:AIOSRS_Frontend.user_rating_nonce}}).success(function(s){var a,t,r;!0===s.success&&(a=i.next(".aiosrs-rating-summary-wrap"),t=s.rating,r=s["rating-avg"],s=s["review-count"],a.find(".aiosrs-rating").text(r),a.find(".aiosrs-rating-count").text(s),0===i.next(".success-msg").length&&i.after('<span class="success-msg">'+AIOSRS_Frontend.success_msg+"</span>"),setTimeout(function(){i.parent().find(".success-msg").remove(),i.removeClass("disabled")},5e3),n.update_stars(i,t))}))}};e(function(){s.init()})}(jQuery);

View File

@@ -0,0 +1 @@
jQuery(document).ready(function(){jQuery("#aiosrs-pro-license-form-btn").on("click",function(e){e.preventDefault(),jQuery("#aiosrs-pro-license-form").show(),jQuery("body").addClass("aiosrs-pro-license-form-open")}),jQuery("#aiosrs-pro-license-form-close-btn").on("click",function(e){e.preventDefault(),jQuery("#aiosrs-pro-license-form").hide(),jQuery("body").removeClass("aiosrs-pro-license-form-open")}),jQuery("#aiosrs-pro-license-form .aiosrs-pro-license-form-overlay").on("click",function(e){e.preventDefault(),jQuery("#aiosrs-pro-license-form").hide(),jQuery("body").removeClass("aiosrs-pro-license-form-open")})});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(s){jQuery(document).ready(function(){s(document).on("click",".aiosrs-pro-schema-temp-wrap",function(e){e.preventDefault(),s(".aiosrs-pro-schema-temp-wrap").removeClass("selected"),s(".aiosrs-pro-setup-actions").find(".button-next").removeAttr("disabled"),s(this).addClass("selected");var e=s(this).data("schema-type"),t=s(this).data("schema-title");s(document).find(".bsf-aiosrs-schema-type").val(e),s(document).find(".bsf-aiosrs-schema-title").val(t)})})}(jQuery);

View File

@@ -0,0 +1 @@
[ID*="-optin-notice"]{padding:1px 12px;border-right-color:#007cba}[ID*="-optin-notice"] .notice-container{padding-top:10px;padding-bottom:12px}[ID*="-optin-notice"] .notice-content{margin:0}[ID*="-optin-notice"] .notice-heading{padding:0 0 12px 20px}[ID*="-optin-notice"] .button-primary{margin-left:5px}

View File

@@ -0,0 +1 @@
[ID*="-optin-notice"]{padding:1px 12px;border-left-color:#007cba}[ID*="-optin-notice"] .notice-container{padding-top:10px;padding-bottom:12px}[ID*="-optin-notice"] .notice-content{margin:0}[ID*="-optin-notice"] .notice-heading{padding:0 20px 12px 0}[ID*="-optin-notice"] .button-primary{margin-right:5px}

View File

@@ -0,0 +1,21 @@
[ID*="-optin-notice"] {
padding: 1px 12px;
border-right-color: #007cba;
}
[ID*="-optin-notice"] .notice-container {
padding-top: 10px;
padding-bottom: 12px;
}
[ID*="-optin-notice"] .notice-content {
margin: 0;
}
[ID*="-optin-notice"] .notice-heading {
padding: 0 0 12px 20px;
}
[ID*="-optin-notice"] .button-primary {
margin-left: 5px;
}

View File

@@ -0,0 +1,21 @@
[ID*="-optin-notice"] {
padding: 1px 12px;
border-left-color: #007cba;
}
[ID*="-optin-notice"] .notice-container {
padding-top: 10px;
padding-bottom: 12px;
}
[ID*="-optin-notice"] .notice-content {
margin: 0;
}
[ID*="-optin-notice"] .notice-heading {
padding: 0 20px 12px 0;
}
[ID*="-optin-notice"] .button-primary {
margin-right: 5px;
}

View File

@@ -0,0 +1,118 @@
<?php
/**
* BSF analytics loader file.
*
* @version 1.0.0
*
* @package bsf-analytics
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
/**
* Class BSF_Analytics_Loader.
*/
class BSF_Analytics_Loader {
/**
* Analytics Entities.
*
* @access private
* @var array Entities array.
*/
private $entities = array();
/**
* Analytics Version.
*
* @access private
* @var float analytics version.
*/
private $analytics_version = '';
/**
* Analytics path.
*
* @access private
* @var string path array.
*/
private $analytics_path = '';
/**
* Instance
*
* @access private
* @var object Class object.
*/
private static $instance = null;
/**
* Get instace of class.
*
* @return object
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
add_action( 'init', array( $this, 'load_analytics' ) );
}
/**
* Set entity for analytics.
*
* @param string $data Entity attributes data.
* @return void
*/
public function set_entity( $data ) {
array_push( $this->entities, $data );
}
/**
* Load Analytics library.
*
* @return void
*/
public function load_analytics() {
$unique_entities = array();
if ( ! empty( $this->entities ) ) {
foreach ( $this->entities as $entity ) {
foreach ( $entity as $key => $data ) {
if ( isset( $data['path'] ) ) {
if ( file_exists( $data['path'] . '/version.json' ) ) {
$file_contents = file_get_contents( $data['path'] . '/version.json' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$analytics_version = json_decode( $file_contents, 1 );
$analytics_version = $analytics_version['bsf-analytics-ver'];
if ( version_compare( $analytics_version, $this->analytics_version, '>' ) ) {
$this->analytics_version = $analytics_version;
$this->analytics_path = $data['path'];
}
}
}
if ( ! isset( $unique_entities[ $key ] ) ) {
$unique_entities[ $key ] = $data;
}
}
}
if ( file_exists( $this->analytics_path ) && ! class_exists( 'BSF_Analytics' ) ) {
require_once $this->analytics_path . '/class-bsf-analytics.php';
new BSF_Analytics( $unique_entities, $this->analytics_path, $this->analytics_version );
}
}
}
}

View File

@@ -0,0 +1,258 @@
<?php
/**
* BSF analytics stat class file.
*
* @package bsf-analytics
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_Analytics_Stats' ) ) {
/**
* BSF analytics stat class.
*/
class BSF_Analytics_Stats {
/**
* Active plugins.
*
* Holds the sites active plugins list.
*
* @var array
*/
private $plugins;
/**
* Instance of BSF_Analytics_Stats.
*
* Holds only the first object of class.
*
* @var object
*/
private static $instance = null;
/**
* Create only once instance of a class.
*
* @return object
* @since 1.0.0
*/
public static function instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Get stats.
*
* @return array stats data.
* @since 1.0.0
*/
public function get_stats() {
return apply_filters( 'bsf_core_stats', $this->get_default_stats() );
}
/**
* Retrieve stats for site.
*
* @return array stats data.
* @since 1.0.0
*/
private function get_default_stats() {
return array(
'graupi_version' => defined( 'BSF_UPDATER_VERSION' ) ? BSF_UPDATER_VERSION : false,
'domain_name' => get_site_url(),
'php_os' => PHP_OS,
'server_software' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? filter_var( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ), FILTER_SANITIZE_STRING ) : '',
'mysql_version' => $this->get_mysql_version(),
'php_version' => $this->get_php_version(),
'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
'php_post_max_size' => ini_get( 'post_max_size' ),
'php_max_execution_time' => ini_get( 'max_execution_time' ),
'php_memory_limit' => ini_get( 'memory_limit' ),
'zip_installed' => extension_loaded( 'zip' ),
'imagick_availabile' => extension_loaded( 'imagick' ),
'xmlreader_exists' => class_exists( 'XMLReader' ),
'gd_available' => extension_loaded( 'gd' ),
'curl_version' => $this->get_curl_version(),
'curl_ssl_version' => $this->get_curl_ssl_version(),
'is_writable' => $this->is_content_writable(),
'wp_version' => get_bloginfo( 'version' ),
'user_count' => $this->get_user_count(),
'posts_count' => wp_count_posts()->publish,
'page_count' => wp_count_posts( 'page' )->publish,
'site_language' => get_locale(),
'timezone' => wp_timezone_string(),
'is_ssl' => is_ssl(),
'is_multisite' => is_multisite(),
'network_url' => network_site_url(),
'external_object_cache' => (bool) wp_using_ext_object_cache(),
'wp_debug' => WP_DEBUG,
'wp_debug_display' => WP_DEBUG_DISPLAY,
'script_debug' => SCRIPT_DEBUG,
'active_plugins' => $this->get_active_plugins(),
'active_theme' => get_template(),
'active_stylesheet' => get_stylesheet(),
);
}
/**
* Get installed PHP version.
*
* @return float PHP version.
* @since 1.0.0
*/
private function get_php_version() {
if ( defined( 'PHP_MAJOR_VERSION' ) && defined( 'PHP_MINOR_VERSION' ) && defined( 'PHP_RELEASE_VERSION' ) ) { // phpcs:ignore
return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
}
return phpversion();
}
/**
* User count on site.
*
* @return int User count.
* @since 1.0.0
*/
private function get_user_count() {
if ( is_multisite() ) {
$user_count = get_user_count();
} else {
$count = count_users();
$user_count = $count['total_users'];
}
return $user_count;
}
/**
* Get active plugin's data.
*
* @return array active plugin's list.
* @since 1.0.0
*/
private function get_active_plugins() {
if ( ! $this->plugins ) {
// Ensure get_plugin_data function is loaded.
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = wp_get_active_and_valid_plugins();
$plugins = array_map( 'get_plugin_data', $plugins );
$this->plugins = array_map( array( $this, 'format_plugin' ), $plugins );
}
return $this->plugins;
}
/**
* Format plugin data.
*
* @param string $plugin plugin.
* @return array formatted plugin data.
* @since 1.0.0
*/
public function format_plugin( $plugin ) {
return array(
'name' => html_entity_decode( $plugin['Name'], ENT_COMPAT, 'UTF-8' ),
'url' => $plugin['PluginURI'],
'version' => $plugin['Version'],
'slug' => $plugin['TextDomain'],
'author_name' => html_entity_decode( wp_strip_all_tags( $plugin['Author'] ), ENT_COMPAT, 'UTF-8' ),
'author_url' => $plugin['AuthorURI'],
);
}
/**
* Curl SSL version.
*
* @return float SSL version.
* @since 1.0.0
*/
private function get_curl_ssl_version() {
$curl = array();
if ( function_exists( 'curl_version' ) ) {
$curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
}
return isset( $curl['ssl_version'] ) ? $curl['ssl_version'] : false;
}
/**
* Get cURL version.
*
* @return float cURL version.
* @since 1.0.0
*/
private function get_curl_version() {
if ( function_exists( 'curl_version' ) ) {
$curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
}
return isset( $curl['version'] ) ? $curl['version'] : false;
}
/**
* Get MySQL version.
*
* @return float MySQL version.
* @since 1.0.0
*/
private function get_mysql_version() {
global $wpdb;
return $wpdb->db_version();
}
/**
* Check if content directory is writable.
*
* @return bool
* @since 1.0.0
*/
private function is_content_writable() {
$upload_dir = wp_upload_dir();
return wp_is_writable( $upload_dir['basedir'] );
}
}
}
/**
* Polyfill for sites using WP version less than 5.3
*/
if ( ! function_exists( 'wp_timezone_string' ) ) {
/**
* Get timezone string.
*
* @return string timezone string.
* @since 1.0.0
*/
function wp_timezone_string() {
$timezone_string = get_option( 'timezone_string' );
if ( $timezone_string ) {
return $timezone_string;
}
$offset = (float) get_option( 'gmt_offset' );
$hours = (int) $offset;
$minutes = ( $offset - $hours );
$sign = ( $offset < 0 ) ? '-' : '+';
$abs_hour = abs( $hours );
$abs_mins = abs( $minutes * 60 );
$tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
return $tz_offset;
}
}

View File

@@ -0,0 +1,514 @@
<?php
/**
* BSF analytics class file.
*
* @version 1.0.0
*
* @package bsf-analytics
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'BSF_Analytics' ) ) {
/**
* BSF analytics
*/
class BSF_Analytics {
/**
* Member Variable
*
* @var array Entities data.
*/
private $entities;
/**
* Member Variable
*
* @var string Usage tracking document URL
*/
public $usage_doc_link = 'https://store.brainstormforce.com/usage-tracking/?utm_source=wp_dashboard&utm_medium=general_settings&utm_campaign=usage_tracking';
/**
* Setup actions, load files.
*
* @param array $args entity data for analytics.
* @param string $analytics_path directory path to analytics library.
* @param float $analytics_version analytics library version.
* @since 1.0.0
*/
public function __construct( $args, $analytics_path, $analytics_version ) {
// Bail when no analytics entities are registered.
if ( empty( $args ) ) {
return;
}
$this->entities = $args;
define( 'BSF_ANALYTICS_VERSION', $analytics_version );
define( 'BSF_ANALYTICS_URI', $this->get_analytics_url( $analytics_path ) );
add_action( 'admin_init', array( $this, 'handle_optin_optout' ) );
add_action( 'admin_init', array( $this, 'option_notice' ) );
add_action( 'init', array( $this, 'maybe_track_analytics' ), 99 );
$this->set_actions();
add_action( 'admin_init', array( $this, 'register_usage_tracking_setting' ) );
$this->includes();
}
/**
* Setup actions for admin notice style and analytics cron event.
*
* @since 1.0.4
*/
public function set_actions() {
foreach ( $this->entities as $key => $data ) {
add_action( 'astra_notice_before_markup_' . $key . '-optin-notice', array( $this, 'enqueue_assets' ) );
add_action( 'update_option_' . $key . '_analytics_optin', array( $this, 'update_analytics_option_callback' ), 10, 3 );
add_action( 'add_option_' . $key . '_analytics_optin', array( $this, 'add_analytics_option_callback' ), 10, 2 );
}
}
/**
* BSF Analytics URL
*
* @param string $analytics_path directory path to analytics library.
* @return String URL of bsf-analytics directory.
* @since 1.0.0
*/
public function get_analytics_url( $analytics_path ) {
$content_dir_path = wp_normalize_path( WP_CONTENT_DIR );
$analytics_path = wp_normalize_path( $analytics_path );
return str_replace( $content_dir_path, content_url(), $analytics_path );
}
/**
* Get API URL for sending analytics.
*
* @return string API URL.
* @since 1.0.0
*/
private function get_api_url() {
return defined( 'BSF_API_URL' ) ? BSF_API_URL : 'https://support.brainstormforce.com/';
}
/**
* Enqueue Scripts.
*
* @since 1.0.0
* @return void
*/
public function enqueue_assets() {
/**
* Load unminified if SCRIPT_DEBUG is true.
*
* Directory and Extensions.
*/
$dir_name = ( SCRIPT_DEBUG ) ? 'unminified' : 'minified';
$file_rtl = ( is_rtl() ) ? '-rtl' : '';
$css_ext = ( SCRIPT_DEBUG ) ? '.css' : '.min.css';
$css_uri = BSF_ANALYTICS_URI . '/assets/css/' . $dir_name . '/style' . $file_rtl . $css_ext;
wp_enqueue_style( 'bsf-analytics-admin-style', $css_uri, false, BSF_ANALYTICS_VERSION, 'all' );
}
/**
* Send analytics API call.
*
* @since 1.0.0
*/
public function send() {
wp_remote_post(
$this->get_api_url() . 'wp-json/bsf-core/v1/analytics/',
array(
'body' => BSF_Analytics_Stats::instance()->get_stats(),
'timeout' => 5,
'blocking' => false,
)
);
}
/**
* Check if usage tracking is enabled.
*
* @return bool
* @since 1.0.0
*/
public function is_tracking_enabled() {
foreach ( $this->entities as $key => $data ) {
$is_enabled = get_site_option( $key . '_analytics_optin' ) === 'yes' ? true : false;
$is_enabled = $this->is_white_label_enabled( $key ) ? false : $is_enabled;
if ( apply_filters( $key . '_tracking_enabled', $is_enabled ) ) {
return true;
}
}
return false;
}
/**
* Check if WHITE label is enabled for BSF products.
*
* @param string $source source of analytics.
* @return bool
* @since 1.0.0
*/
public function is_white_label_enabled( $source ) {
$options = apply_filters( $source . '_white_label_options', array() );
$is_enabled = false;
if ( is_array( $options ) ) {
foreach ( $options as $option ) {
if ( true === $option ) {
$is_enabled = true;
break;
}
}
}
return $is_enabled;
}
/**
* Display admin notice for usage tracking.
*
* @since 1.0.0
*/
public function option_notice() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
foreach ( $this->entities as $key => $data ) {
$time_to_display = isset( $data['time_to_display'] ) ? $data['time_to_display'] : '+24 hours';
$usage_doc_link = isset( $data['usage_doc_link'] ) ? $data['usage_doc_link'] : $this->usage_doc_link;
// Don't display the notice if tracking is disabled or White Label is enabled for any of our plugins.
if ( false !== get_site_option( $key . '_analytics_optin', false ) || $this->is_white_label_enabled( $key ) ) {
continue;
}
// Show tracker consent notice after 24 hours from installed time.
if ( strtotime( $time_to_display, $this->get_analytics_install_time( $key ) ) > time() ) {
continue;
}
/* translators: %s product name */
$notice_string = __( 'Want to help make <strong>%1s</strong> even more awesome? Allow us to collect non-sensitive diagnostic data and usage information. ', 'wp-schema-pro' );
if ( is_multisite() ) {
$notice_string .= __( 'This will be applicable for all sites from the network.', 'wp-schema-pro' );
}
$language_dir = is_rtl() ? 'rtl' : 'ltr';
Astra_Notices::add_notice(
array(
'id' => $key . '-optin-notice',
'type' => '',
'message' => sprintf(
'<div class="notice-content">
<div class="notice-heading">
%1$s
</div>
<div class="astra-notices-container">
<a href="%2$s" class="astra-notices button-primary">
%3$s
</a>
<a href="%4$s" data-repeat-notice-after="%5$s" class="astra-notices button-secondary">
%6$s
</a>
</div>
</div>',
/* translators: %s usage doc link */
sprintf( $notice_string . '<span dir="%2s"><a href="%3s" target="_blank" rel="noreferrer noopener">%4s</a><span>', esc_html( $data['product_name'] ), $language_dir, esc_url( $usage_doc_link ), __( ' Know More.', 'wp-schema-pro' ) ),
esc_url(
add_query_arg(
array(
$key . '_analytics_optin' => 'yes',
$key . '_analytics_nonce' => wp_create_nonce( $key . '_analytics_optin' ),
'bsf_analytics_source' => $key,
)
)
),
__( 'Yes! Allow it', 'wp-schema-pro' ),
esc_url(
add_query_arg(
array(
$key . '_analytics_optin' => 'no',
$key . '_analytics_nonce' => wp_create_nonce( $key . '_analytics_optin' ),
'bsf_analytics_source' => $key,
)
)
),
MONTH_IN_SECONDS,
__( 'No Thanks', 'wp-schema-pro' )
),
'show_if' => true,
'repeat-notice-after' => false,
'priority' => 18,
'display-with-other-notices' => true,
)
);
}
}
/**
* Process usage tracking opt out.
*
* @since 1.0.0
*/
public function handle_optin_optout() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$source = isset( $_GET['bsf_analytics_source'] ) ? sanitize_text_field( wp_unslash( $_GET['bsf_analytics_source'] ) ) : '';
if ( ! isset( $_GET[ $source . '_analytics_nonce' ] ) ) {
return;
}
if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET[ $source . '_analytics_nonce' ] ) ), $source . '_analytics_optin' ) ) {
return;
}
$optin_status = isset( $_GET[ $source . '_analytics_optin' ] ) ? sanitize_text_field( wp_unslash( $_GET[ $source . '_analytics_optin' ] ) ) : '';
if ( 'yes' === $optin_status ) {
$this->optin( $source );
} elseif ( 'no' === $optin_status ) {
$this->optout( $source );
}
wp_safe_redirect(
esc_url_raw(
remove_query_arg(
array(
$source . '_analytics_optin',
$source . '_analytics_nonce',
'bsf_analytics_source',
)
)
)
);
}
/**
* Opt in to usage tracking.
*
* @param string $source source of analytics.
* @since 1.0.0
*/
private function optin( $source ) {
update_site_option( $source . '_analytics_optin', 'yes' );
}
/**
* Opt out to usage tracking.
*
* @param string $source source of analytics.
* @since 1.0.0
*/
private function optout( $source ) {
update_site_option( $source . '_analytics_optin', 'no' );
}
/**
* Load analytics stat class.
*
* @since 1.0.0
*/
private function includes() {
require_once __DIR__ . '/class-bsf-analytics-stats.php';
}
/**
* Register usage tracking option in General settings page.
*
* @since 1.0.0
*/
public function register_usage_tracking_setting() {
foreach ( $this->entities as $key => $data ) {
if ( ! apply_filters( $key . '_tracking_enabled', true ) || $this->is_white_label_enabled( $key ) ) {
return;
}
$usage_doc_link = isset( $data['usage_doc_link'] ) ? $data['usage_doc_link'] : $this->usage_doc_link;
$author = isset( $data['author'] ) ? $data['author'] : 'Brainstorm Force';
register_setting(
'general', // Options group.
$key . '_analytics_optin', // Option name/database.
array( 'sanitize_callback' => array( $this, 'sanitize_option' ) ) // sanitize callback function.
);
add_settings_field(
$key . '-analytics-optin', // Field ID.
__( 'Usage Tracking', 'wp-schema-pro' ), // Field title.
array( $this, 'render_settings_field_html' ), // Field callback function.
'general',
'default', // Settings page slug.
array(
'type' => 'checkbox',
'title' => $author,
'name' => $key . '_analytics_optin',
'label_for' => $key . '-analytics-optin',
'id' => $key . '-analytics-optin',
'usage_doc_link' => $usage_doc_link,
)
);
}
}
/**
* Sanitize Callback Function
*
* @param bool $input Option value.
* @since 1.0.0
*/
public function sanitize_option( $input ) {
if ( ! $input || 'no' === $input ) {
return 'no';
}
return 'yes';
}
/**
* Print settings field HTML.
*
* @param array $args arguments to field.
* @since 1.0.0
*/
public function render_settings_field_html( $args ) {
?>
<fieldset>
<label for="<?php echo esc_attr( $args['label_for'] ); ?>">
<input id="<?php echo esc_attr( $args['id'] ); ?>" type="checkbox" value="1" name="<?php echo esc_attr( $args['name'] ); ?>" <?php checked( get_site_option( $args['name'], 'no' ), 'yes' ); ?>>
<?php
/* translators: %s Product title */
echo esc_html( sprintf( __( 'Allow %s products to track non-sensitive usage tracking data.', 'wp-schema-pro' ), $args['title'] ) );// phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
if ( is_multisite() ) {
esc_html_e( ' This will be applicable for all sites from the network.', 'wp-schema-pro' );
}
?>
</label>
<?php
echo wp_kses_post( sprintf( '<a href="%1s" target="_blank" rel="noreferrer noopener">%2s</a>', esc_url( $args['usage_doc_link'] ), __( 'Learn More.', 'wp-schema-pro' ) ) );
?>
</fieldset>
<?php
}
/**
* Set analytics installed time in option.
*
* @param string $source source of analytics.
* @return string $time analytics installed time.
* @since 1.0.0
*/
private function get_analytics_install_time( $source ) {
$time = get_site_option( $source . '_analytics_installed_time' );
if ( ! $time ) {
$time = time();
update_site_option( $source . '_analytics_installed_time', time() );
}
return $time;
}
/**
* Schedule/unschedule cron event on updation of option.
*
* @param string $old_value old value of option.
* @param string $value value of option.
* @param string $option Option name.
* @since 1.0.0
*/
public function update_analytics_option_callback( $old_value, $value, $option ) {
if ( is_multisite() ) {
$this->add_option_to_network( $option, $value );
}
}
/**
* Analytics option add callback.
*
* @param string $option Option name.
* @param string $value value of option.
* @since 1.0.0
*/
public function add_analytics_option_callback( $option, $value ) {
if ( is_multisite() ) {
$this->add_option_to_network( $option, $value );
}
}
/**
* Send analaytics track event if tracking is enabled.
*
* @since 1.0.0
*/
public function maybe_track_analytics() {
if ( ! $this->is_tracking_enabled() ) {
return;
}
$analytics_track = get_site_transient( 'bsf_analytics_track' );
// If the last data sent is 2 days old i.e. transient is expired.
if ( ! $analytics_track ) {
$this->send();
set_site_transient( 'bsf_analytics_track', true, 2 * DAY_IN_SECONDS );
}
}
/**
* Save analytics option to network.
*
* @param string $option name of option.
* @param string $value value of option.
* @since 1.0.0
*/
public function add_option_to_network( $option, $value ) {
// If action coming from general settings page.
if ( isset( $_POST['option_page'] ) && 'general' === $_POST['option_page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( get_site_option( $option ) ) {
update_site_option( $option, $value );
} else {
add_site_option( $option, $value );
}
}
}
}
}

View File

@@ -0,0 +1,4 @@
{
"bsf-analytics-ver": "1.1.3"
}

View File

@@ -0,0 +1,172 @@
/* ========================================================================
* Frosty.js
* https://owensbla.github.com/frosty
* by Blake Owens (http://blakeowens.com/)
* ======================================================================== */
.bsf-has-tip,
.has-tip {
cursor: help;
}
.tip {
background-color: black;
background-color: rgba(0, 0, 0, 0.8);
color: #eeeeee;
font-size: 11px;
line-height: 1.5em;
max-width: 200px;
padding: 4px 8px;
}
.tip.success {
background-color: #47fe42;
background-color: rgba(71, 254, 66, 0.8);
color: #025600;
}
.tip.error {
background-color: #ff7f86;
background-color: rgba(255, 127, 134, 0.8);
color: #7f0006;
}
.tip.light {
background-color: #ebebeb;
background-color: rgba(235, 235, 235, 0.8);
color: #222222;
}
.tip[class*="arrow"]:before {
content: ' ';
position: absolute;
border: solid transparent;
width: 0px;
height: 0px;
border-width: 5px;
border-color: black;
border-color: rgba(0, 0, 0, 0.8);
}
.success[class*="arrow"]:before {
border-color: #47fe42;
border-color: rgba(71, 254, 66, 0.8);
}
.error[class*="arrow"]:before {
border-color: #ff7f86;
border-color: rgba(255, 127, 134, 0.8);
}
.light[class*="arrow"]:before {
border-color: #ebebeb;
border-color: rgba(235, 235, 235, 0.8);
}
.tip.arrow-right:before {
border-right-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
left: 100%;
}
.tip.arrow-left:before {
border-left-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
right: 100%;
}
.tip.arrow-top:before {
border-top-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
bottom: 100%;
left: 50%;
}
.tip.arrow-bottom:before {
border-bottom-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
top: 100%;
left: 50%;
}
/* Customizer Tooltip */
.customize-support .tip {
background-color: rgba(0, 148, 221, 0.95);
color: #FFF;
font-size: 13px;
line-height: 1.5em;
max-width: 200px;
padding: 5px 11px;
border: 1px solid #0094DD;
border-radius: 1px;
}
.customize-support .tip[class*="arrow"]:before {
border-width: 5px;
border-color: #0094DD;
border-color: rgba(0, 148, 221, 0.95);
}
.customize-support .tip.arrow-right:before {
border-right-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
left: 100%;
}
.customize-support .tip.arrow-left:before {
border-left-color: transparent;
border-top-color: transparent;
border-bottom-color: transparent;
margin-top: -5px;
top: 50%;
right: 100%;
}
.customize-support .tip.arrow-top:before {
border-top-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
bottom: 100%;
left: 50%;
}
.customize-support .tip.arrow-bottom:before {
border-bottom-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
margin-left: -5px;
top: 100%;
left: 50%;
}
/*---close button tooltip--------*/
.tip[class*="close-tip-content"]{
border-radius:7px;
max-width:300px;
padding: 15px 30px;
}
.tip[class*="close-tip-content"]:before{
border-width: 8px!important;
margin-top: -8px!important;
}
.tip[class*="close-tip-content"][class*="arrow-bottom"]{
/* margin-top:-10px; */
}
.tip[class*="close-tip-content"][class*="arrow-bottom"]:before{
margin-top: -1px!important;
}
.tip[class*="close-tip-content"][class*="arrow-right"]:before {
left: 100%;
left: calc(100% - 1px);
}
.cp-innertip.tip[class*="close-tip-content"][class*="arrow"]{
margin-top: 30px!important;
}
@media (max-width:768px) {
.tip[class*="close-tip-content"]{
border-radius:7px;
max-width:200px;
padding: 5px 20px;
}
}
@media (max-width:610px) {
.tip[class*="close-tip-content"]{
max-width:170px;
}
}

View File

@@ -0,0 +1,138 @@
.bsf-core-license-form p {
padding: 5px 0px 5px 0px;
font-style: normal;
}
.license-form-allow-email .submit-button-wrap > input,
.license-form-allow-email .submit-button-wrap > p {
display: inline-block;
vertical-align: bottom;
}
.bsf-core-license-form .license-form-allow-email .purchase-license a {
text-decoration: none;
}
.license-form-allow-email {
margin-bottom: 15px;
}
.license-form-allow-email .license-form-external-links {
font-style: italic;
}
.license-form-field input {
width: 100%;
}
.bsf-core-license-form .license-form-allow-email h3 {
font-size: 2em;
margin-bottom: 0.5em;
}
.bsf-core-license-form .license-form-allow-email .purchase-license {
margin-left: 10px;
}
.bsf-core-license-form .license-form-allow-email .submit-button-wrap {
padding: 20px 0px 10px 0px;
}
.license-form-allow-email .bsf-core-license-form-inner, {
padding: 10px 30px 30px;
}
.bsf-core-license-form .bsf-core-license-form-overlay {
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100050;
}
.bsf-core-license-form .bsf-core-license-form-inner {
background: #fcfcfc;
position: fixed;
background-color: #fff;
z-index: 999999999;
padding: 2px 20px 20px;
text-align: left;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
}
.bsf-core-license-form-close-btn {
position: absolute;
left: auto;
right: 0;
top: 0;
width: 29px;
height: 29px;
border: 0;
padding: 0;
background: none;
cursor: pointer;
outline: none;
-webkit-transition: color .1s ease-in-out, background .1s ease-in-out;
-webkit-transform: translateX(100%) translateY(-100%);
transform: translateX(100%) translateY(-100%);
transition: color .1s ease-in-out, background .1s ease-in-out;
color: #eee;
}
.bsf-core-license-form-close-btn:hover {
color: #00a0d2;
}
.bsf-core-license-form-close-btn .dashicons {
display: block;
text-align: center;
line-height: 29px;
width: 29px;
height: 29px;
font-size: 29px;
position: absolute;
top: 0;
right: 0;
}
.bsf-core-license-form .license-form-field input.regular-text {
margin-right: 10px;
}
/** License link */
.bsf-core-license-form-btn.inactive {
color: #3db634;
font-weight: 500;
}
.bsf-core-license-form-btn {
cursor: pointer;
}
.bsf-license-message.license-success {
display: none;
}
.bsf-system-info-wrapper {
overflow: scroll;
max-height: 60vh;
}
.bsf-license-heading {
margin: 1em 0;
}
.bsf-license-not-active-astra-portfolio.bsf-license-heading {
margin: 1em 0 0 0;
}
.envato-license-registration form {
margin-bottom: 1em;
}

View File

@@ -0,0 +1,84 @@
.bsf-core-rollback-overlay {
background: #000;
opacity: 0.7;
filter: alpha(opacity=70);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100050;
}
.bsf-confirm-rollback-popup-content {
background: #fcfcfc;
position: fixed;
/* background-color: #fff; */
z-index: 999999999;
padding: 2px 20px 0px;
text-align: left;
top: 50%;
left: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
-webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 );
border-radius: 2px;
}
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-cancel{
padding: 0px 16px;
margin-right: 149px;
}
.bsf-confirm-text{
margin-bottom: 25px;
}
.bsf-confirm-rollback-popup-buttons-wrapper .bsf-confirm-ok{
margin-right: 0px;
padding: 0px 16px;
float: right;
}
.bsf-rollback-heading{
text-align: center;
}
.bsf-confirm-rollback-popup-header {
font-size: 15px;
color: #495157;
padding: 30px 0 10px;
font-weight: 500;
text-align: center;
}
.bsf-confirm-rollback-popup-message {
-webkit-box-sizing: border-box;
box-sizing: border-box;
min-height: 50px;
text-align: center;
}
.bsf-confirm-rollback-popup-buttons-wrapper {
border-top: 1px solid #e4e4e4;
width: 100%;
padding: 9px 0px 9px 0px
}
.bsf-confirm-rollback-popup-button {
font-family: Roboto, Arial, Helvetica, Verdana, sans-serif;
width: 50%;
border: none;
background: none;
color: #6d7882;
font-size: 15px;
cursor: pointer;
padding: 13px 0;
outline: 0;
}
.bsf-confirm-rollback-popup-button:hover {
background:#e6e9ec6b
}
.bsf-confirm-rollback-popup-button.confirm-cancel {
border-right: 1px solid #e6e9ec;
}
.bsf-confirm-rollback-popup-button.confirm-ok {
color: rgb(74, 0, 224);
}
.bsf-confirm-rollback-popup.show {
display: block;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,146 @@
input.form-control.smile-switch.switch + label.bsf-switch-btn:before {
display: none;
}
input.form-control.smile-input.bsf-switch-input {
display: none;
}
.switch-wrapper {
width: 95px;
}
.shadow_type .onoffswitch-switch {
width: 45px;
}
.shadow_type .onoffswitch-inactive .onoffswitch-switch:before {
right: 45px;
}
.shadow_type .onoffswitch-active .onoffswitch-switch:before {
left: 45px;
}
.ios-toggle, .ios-toggle:active {
position:absolute;
top:-5000px;
height:0;
width:0;
opacity:0;
border:none;
outline:none;
}
.checkbox-label {
display:block;
position:relative;
padding:0px;
margin: 0px;
margin-bottom:20px;
font-size:12px;
line-height:16px;
width:40px;
height:20px;
-webkit-border-radius:18px;
-moz-border-radius:18px;
border-radius:18px;
background:#f8f8f8;
cursor:pointer;
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.checkbox-label:before {
content:'';
display:block;
position:absolute;
z-index:1;
line-height:34px;
text-indent:40px;
height:20px;
width:20px;
-webkit-border-radius:100%;
-moz-border-radius:100%;
border-radius:100%;
top:0px;
left:0px;
right:auto;
background:white;
-webkit-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
-moz-box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
box-shadow:0 3px 3px rgba(0, 0, 0, .2), 0 0 0 2px #dddddd;
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.checkbox-label:after {
content: attr(data-off);
font-size: 13px;
display: block;
position: absolute;
z-index: 0;
top: 0;
left: 50px;
padding: 0;
height: 20px;
line-height: 20px;
width: 36px;
text-align: left;
color: #BFBFBF;
white-space: nowrap;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
/* Switch CHECKBOX */
.switch-checkbox + .checkbox-label {
-webkit-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
-moz-box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
box-shadow:inset 0 0 0 18px #dddddd, 0 0 0 2px #dddddd;
background: #dddddd;
}
.switch-checkbox:checked + .checkbox-label {
-webkit-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
-moz-box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
box-shadow:inset 0 0 0 18px #0094DD, 0 0 0 2px #0094DD;
background: #0094DD;
}
.switch-checkbox:checked + .checkbox-label:after {
color:#0094DD;
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
/* Toggle Checkbox */
.ios-toggle:checked + .checkbox-label {
-webkit-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
-moz-box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
box-shadow:inset 0 0 0 20px #0094DD, 0 0 0 2px #0094DD;
}
.ios-toggle:checked + .checkbox-label:before {
left:calc(100% - 21px);
-webkit-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
-moz-box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
box-shadow:0 0 0 1px transparent, 0 2px 2px rgba(0, 0, 0, .3);
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.ios-toggle:checked + .checkbox-label:after {
content:attr(data-on);
-webkit-transition:.25s ease-in-out;
-moz-transition:.25s ease-in-out;
-o-transition:.25s ease-in-out;
transition:.25s ease-in-out;
}
.ios-toggle[type=checkbox] {
display: none;
}
.brainstorm-updater-switch {
display: inline-block;
position: absolute;
right: 0;
top: 0;
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="icomoon" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" d="" horiz-adv-x="512" />
<glyph unicode="&#xe603;" d="M467.577-21.5c-2.284 7.369-0.104 15.762 7.18 20.556 10.155 6.679 25.5 20.586 84.534 27.952 35.525 4.396-8.694-54.877-3.142-34.181 1.955 7.287-25.91 1.952-25.91 1.952s-46.553-8.773-58.643-24.894c0 0-1.733 2.227-4.019 8.615zM138.271 557.027c0 0 15.887 237.492 368.384 222.11 0 0 146.319-12.099 215.165-56.96 0 0-293.96 10.546-583.551-165.149zM181.807 507.887c0 0 203.521 128.399 558.772 144.239 0 0 48.21-0.329 72.158-35.208 0 0 14.367-31.64 14.086-88.5 0 0-48.229-1.442-85.408-2.723 0 0-355.977-11.586-537.674-199.511 12.648 44.529-121.089 119.532-21.934 181.703zM255.72 238.57c0 0-14.079 43.451 43.498 69.493 54.329 24.572 127.831 96.191 426.625 133.305 0 0 124.558 25.427 48.884-54.439-84.28-88.948-100.337-111.947-100.337-111.947s-22.41-25.55-14.155 5.204c8.255 30.756-120.967 22.15-120.967 22.15s-201.788-45.676-252.733-113.604c0 0-21.178 22.924-30.816 49.839zM369.409 146.887c0 0 106.32 73.825 227.492 55.88 0 0 29.174-1.921-1.115-22.419-30.29-20.503-226.376-33.461-226.376-33.461zM418.719 53.659c0 0-11.482 30.506 7.413 36.941s36.903 30.834 136.907 41.988c40.619-4.038 1.169-110.607-7.296-79.135 2.763 10.295-10.126 9.762-10.126 9.762s-93.985-18.303-111.035-41.039c0 0-12.635 22.476-15.862 31.483zM899.013 687.749c92.851-208.867-26.868-487.037-271.661-536.994 233.968 65.7 273.711 363.944 218.284 497.451-81.853 197.157-343.286 268.698-505.34 206.428-162.056-62.269-203.018-122.175-238.522-224.811 32.087 89.126 91.171 209.056 273.127 278.972 181.958 69.917 431.262-12.179 524.112-221.047z" />
</font></defs></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -0,0 +1,32 @@
jQuery( document ).on('click', '.bsf-envato-form-activation', function(event) {
submitButton = jQuery( this ).parent('.submit-button-wrap');
console.log(submitButton);
product_id = submitButton.siblings( 'form input[name="product_id"]' ).val();
url = submitButton.siblings( 'form input[name="url"]' ).val();
redirect = submitButton.siblings( 'form input[name="redirect"]' ).val();
privacyConsent = submitButton.siblings( 'input#bsf-license-privacy-consent').val();
termsConditionConsent = submitButton.siblings( 'input#bsf-license-terms-conditions-consent').val();
envato_activation_nonce = bsf_core.envato_activation_nonce;
jQuery.ajax({
url: ajaxurl,
dataType: 'json',
data: {
action: 'bsf_envato_redirect_url',
product_id: product_id,
url: url,
redirect: redirect,
privacy_consent: privacyConsent,
terms_conditions_consent: termsConditionConsent,
envato_activation_nonce: envato_activation_nonce,
}
})
.done(function( response ) {
window.location = response.data.url;
return true;
})
.fail(function(e) {
return false;
});
return false;
});

View File

@@ -0,0 +1,105 @@
(function ($) {
var BSFExtensionInstaller = {
init: function () {
$(document).on('click', '.bsf-install-button', BSFExtensionInstaller._installNow);
$( document ).on('wp-plugin-installing' , BSFExtensionInstaller._pluginInstalling);
$( document ).on('wp-plugin-install-error' , BSFExtensionInstaller._installError);
$( document ).on('wp-plugin-install-success' , BSFExtensionInstaller._installSuccess);
},
/**
* Install Now
*/
_installNow: function (event) {
event.preventDefault();
var $button = jQuery(event.target),
$document = jQuery(document);
if ( $button.hasClass('updating-message') || $button.hasClass('button-disabled') ) {
return;
}
if (wp.updates.shouldRequestFilesystemCredentials && !wp.updates.ajaxLocked) {
wp.updates.requestFilesystemCredentials(event);
$document.on('credential-modal-cancel', function () {
var $message = $('.install-now.updating-message');
$message
.removeClass('updating-message')
.text(wp.updates.l10n.installNow);
wp.a11y.speak(wp.updates.l10n.updateCancel, 'polite');
});
}
wp.updates.installPlugin({
slug: $button.data('slug')
});
},
/**
* Install Success
*/
_installSuccess: function( event, response ) {
event.preventDefault();
// Transform the 'Install' button into an 'Activate' button.
var $init = $( '.bsf-extension-' + response.slug ).data('init');
var nonce = $( '#bsf_activate_extension_nonce' ).val();
// WordPress adds "Activate" button after waiting for 1000ms. So we will run our activation after that.
setTimeout( function() {
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
'action' : 'bsf-extention-activate',
'init' : $init,
'security' : nonce
},
})
.done(function (result) {
if( result.success ) {
$ext = $('.bsf-extension-' + response.slug );
$ext.addClass('bsf-plugin-installed');
$ext.find('.bsf-install-button').addClass('bsf-plugin-installed-button').html('Installed <i class="dashicons dashicons-yes"></i>');
$ext.find('.bsf-extension-start-install').removeClass('show-install');
}
});
}, 1200 );
},
/**
* Plugin Installation Error.
*/
_installError: function( event, response ) {
var $card = $( '.bsf-extension-' + response.slug + ' .bsf-extension-start-install-content')
$card.html( '<h2>' + response.errorMessage + '</h2>' );
},
/**
* Installing Plugin
*/
_pluginInstalling: function(event, args) {
event.preventDefault();
$('.bsf-extension-' + args.slug + ' .bsf-extension-start-install').addClass('show-install');
},
}
/**
* Initialize BSFExtensionInstaller
*/
$(function () {
BSFExtensionInstaller.init();
});
})(jQuery);

View File

@@ -0,0 +1,263 @@
/* ========================================================================
* Frosty.js v1.0
* https://github.com/owensbla/frosty
* http://labs.blakeowens.com/frosty
*
* Plugin boilerplate provied by: http://jqueryboilerplate.com/
* ========================================================================
* Copyright 2013 Blake Owens
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* ======================================================================== */
;(function ($, window, document, undefined) {
var pluginName = "frosty";
var defaults = {
attribute: 'title',
className: 'tip',
content: '',
delay: 0,
hasArrow: true,
html: false,
offset: 30,
position: 'left',
removeTitle: true,
selector: false,
trigger: 'hover,focus',
onHidden: function() {},
onShown: function() {},
};
function Frosty(anchor, options) {
this.anchor = anchor;
this.$anchor = $(anchor);
this.options = $.extend({}, defaults, options, this.$anchor.data());
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Frosty.prototype = {
init: function () {
this._createTip();
this._bindEvents();
},
show: function() {
var _this = this,
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.show) : parseInt(this.options.delay);
clearTimeout(this.timeout);
this.timeout = delay === 0 ?
this._setState('visible') :
setTimeout(function() { _this._setState('visible'); }, delay);
},
hide: function() {
var _this = this
delay = typeof this.options.delay === 'object' ? parseInt(this.options.delay.hide) : parseInt(this.options.delay);
clearTimeout(this.timeout);
this.timeout = delay === 0 ?
this._setState('hidden') :
setTimeout(function() { _this._setState('hidden'); }, delay);
},
toggle: function() {
this.state === 'visible' ? this.hide() : this.show();
},
addClass: function(klass) {
console.log("in");
if (typeof klass === 'string') { this.$el.addClass(klass); }
},
removeClass: function(klass) {
if (typeof klass === 'string') { this.$el.removeClass(klass); }
},
_setState: function(state) {
this.state = state;
switch (state) {
case 'visible':
this.$el.appendTo('body');
this._checkContent();
this._setPosition();
this.options.onShown.call(this);
this.$anchor.trigger('shown');
break;
case 'hidden':
this.$el.detach();
this.options.onHidden.call(this);
this.$anchor.trigger('hidden');
break;
}
},
_checkContent: function() {
if (this.options.selector) {
this.tipContent = $(this.options.selector).html();
this.$el.html(this.tipContent);
}
},
_createTip: function() {
if (this.options.html) {
this.tipContent = this.options.content;
} else if (this.options.selector) {
this.tipContent = $(this.options.selector).html();
} else {
this.tipContent = this.$anchor.attr(this.options.attribute);
if (this.options.attribute === 'title' && this.options.removeTitle) {
this.$anchor.attr('data-original-title', this.tipContent);
this.$anchor.removeAttr('title');
}
}
this.$el = $('<div />', {
'class': this.options.className,
html: '<span class="cp_tooltip_text">'+this.tipContent+'</span>'
}).css({
'z-index': '9999999999',
'left': '-9999px',
'position': 'absolute',
});
this.$el.appendTo('body');
var coords = this.getPosition();
this.$el.detach().css(coords);
if (this.options.hasArrow) { this._addArrowClass(); }
},
_addArrowClass: function() {
switch (this.options.position) {
case 'left':
this.$el.addClass('arrow-right');
break;
case 'right':
this.$el.addClass('arrow-left');
break;
case 'bottom':
this.$el.addClass('arrow-top');
break;
default:
this.$el.addClass('arrow-bottom');
}
},
_bindEvents: function() {
switch (this.options.trigger) {
case 'click':
this.$anchor.click($.proxy(this.toggle, this));
break
case 'manual':
break;
case 'focus':
this.$anchor.focus($.proxy(this.show, this));
this.$anchor.blur($.proxy(this.hide, this));
break;
default:
this.$anchor.hover($.proxy(this.show, this), $.proxy(this.hide, this));
}
//$(window).resize($.proxy(this._setPosition, this));
},
getPosition: function () {
var coords = this.$anchor.offset();
switch (this.options.position) {
case 'left':
coords.left = coords.left - this.$el.outerWidth() - this.options.offset;
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
break;
case 'right':
coords.left = coords.left + this.$anchor.outerWidth() + this.options.offset;
coords.top = coords.top + (this.$anchor.outerHeight() / 2) - (this.$el.outerHeight() / 2);
break;
case 'bottom':
coords.top = coords.top + this.$anchor.outerHeight() + this.options.offset;
coords.left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
break;
default:
coords.top = coords.top - this.$el.outerHeight() - this.options.offset;
var left = coords.left + (this.$anchor.outerWidth() / 2) - (this.$el.outerWidth() / 2);
if( left < 0 )
left = 0;
coords.left = left;
}
//console.log(coords);
return coords;
},
_setPosition: function() {
this.$el.css(this.getPosition());
}
};
$.fn[pluginName] = function (options, args) {
//console.log($.data(this, "plugin_" + pluginName));
if (typeof options === 'string') {
//console.log(options);
switch (options) {
case 'show':
this.each(function() { $.data(this, "plugin_" + pluginName)['show'](); });
break;
case 'hide':
this.each(function() { $.data(this, "plugin_" + pluginName)['hide'](); });
break;
case 'toggle':
this.each(function() { $.data(this, "plugin_" + pluginName)['toggle'](); });
break;
case 'addClass':
this.each(function() { $.data(this, "plugin_" + pluginName)['addClass'](args); });
break;
case 'removeClass':
this.each(function() { $.data(this, "plugin_" + pluginName)['removeClass'](args); });
break;
}
}
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName, new Frosty(this, options));
}
});
};
})(jQuery, window, document);
(function($){
$(document).ready(function(){
$('.bsf-has-tip, .has-tip').each(function(i,tip){
$tip = $(tip);
var attribute = (typeof $tip.attr('data-attribute') != 'undefined') ? $tip.attr('data-attribute') : 'title';
var offset = (typeof $tip.attr('data-offset') != 'undefined') ? $tip.attr('data-offset') : 10;
var position = (typeof $tip.attr('data-position') != 'undefined') ? $tip.attr('data-position') : 'top';
var trigger = (typeof $tip.attr('data-trigger')) ? $tip.attr('data-trigger') : 'hover,focus';
var className = (typeof $tip.attr('data-classes') != 'undefined') ? 'tip '+$tip.attr('data-classes') : 'tip';
$tip.frosty({
className : className,
attribute: attribute,
offset: offset,
position: position,
trigger: trigger
});
});
});
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,151 @@
(function($){
BSFCoreLicenseForm = {
/**
* Init
*/
init: function()
{
this._showFormOnLoad();
this._bind();
},
/**
* Binds events
*/
_bind: function()
{
$( document ).on('click', '.bsf-core-license-form-btn', BSFCoreLicenseForm._showFormOnClick);
$( document ).on('click', '.bsf-core-license-form-close-btn', BSFCoreLicenseForm._closeForm);
$( document ).on('click', '.bsf-core-license-form .bsf-core-license-form-overlay', BSFCoreLicenseForm._closeForm);
},
_changeURL: function( url )
{
History.pushState(null, null, url);
},
/**
* Show form on Load
*/
_showFormOnLoad: function( e )
{
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
var slug = BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form');
BSFCoreLicenseForm._showForm( slug );
}
},
/**
* Show form on Click
*/
_showFormOnClick: function( e )
{
// don't override click action if the link is not from the popup form.
var licenseFormURl = $( this ).attr('href') || '';
if ( null !== BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form', licenseFormURl) ||
true === $( this ).hasClass('bsf-core-plugin-link') ) {
e.preventDefault();
var slug = $( this ).attr('plugin-slug') || '';
var url_params = {'bsf-inline-license-form':slug};
BSFCoreLicenseForm._showForm( slug );
// Change URL.
if( ! BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
var current_url = window.location.href;
var current_url_separator = ( window.location.href.indexOf( "?" ) === -1 ) ? "?" : "&";
var new_url = current_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
BSFCoreLicenseForm._changeURL( new_url );
}
}
},
/**
* Show form by slug
*/
_showForm: function( slug )
{
if( $(".bsf-core-license-form[plugin-slug='"+slug+"']").length ) {
$(".bsf-core-license-form[plugin-slug='"+slug+"']").show();
$('body').addClass('bsf-core-license-form-open');
}
},
/**
* Close form.
*/
_closeForm: function( e )
{
e.preventDefault();
$('.bsf-core-license-form').hide();
$('body').removeClass('bsf-core-license-form-open');
if( BSFCoreLicenseForm._getParamFromURL('bsf-inline-license-form') ) {
var url_params = BSFCoreLicenseForm._getQueryStrings();
delete url_params['bsf-inline-license-form'];
delete url_params['bsf-inline-license-form'];
delete url_params['license_action'];
delete url_params['token'];
delete url_params['product_id'];
delete url_params['purchase_key'];
delete url_params['success'];
delete url_params['status'];
delete url_params['message'];
delete url_params['debug'];
delete url_params['activation_method'];
var current_url = window.location.href;
var root_url = current_url.substr(0, current_url.indexOf('?'));
if( jQuery.isEmptyObject( url_params ) ) {
var new_url = root_url + decodeURIComponent( $.param( url_params ) );
} else {
var current_url_separator = ( root_url.indexOf( "?" ) === -1 ) ? "?" : "&";
var new_url = root_url + current_url_separator + decodeURIComponent( $.param( url_params ) );
}
// Change URL.
BSFCoreLicenseForm._changeURL( new_url );
}
},
/**
* Get URL param.
*/
_getParamFromURL: function(name, url)
{
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
},
/**
* Get query strings.
*/
_getQueryStrings( str )
{
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
}
};
/**
* Initialization
*/
$(function(){
BSFCoreLicenseForm.init();
});
})(jQuery);

View File

@@ -0,0 +1,16 @@
jQuery(document).ready(function(){
var switch_btn = jQuery(".bsf-switch-btn");
jQuery(document).on('click', '.bsf-switch-btn', function(e){
var id = jQuery(this).data('id');
var value = jQuery(this).parents(".switch-wrapper").find("#"+id).val();
if( value == 1 || value == '1' ) {
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','0');
} else {
jQuery(this).parents(".switch-wrapper").find("#"+id).attr('value','1');
}
jQuery(this).parents(".switch-wrapper").find(".bsf-switch-input").trigger('change');
});
});

View File

@@ -0,0 +1,61 @@
(function($){
var currentRollbackButton;
rollbackVersion = {
init: function() {
$( document ).on('change', '.bsf-rollback-version-select' , rollbackVersion.onSelectVersion );
$( document ).on('click', '.bsf-rollback-button' , rollbackVersion.onRollbackClick );
$( document ).on('click', '.bsf-confirm-cancel' , rollbackVersion.closeRollbackPopup );
$( document ).on('click', '.bsf-confirm-ok' , rollbackVersion.onRollbackOk );
},
onSelectVersion:function() {
var selectRollback = jQuery( this );
rollbackButton = selectRollback.next( '.bsf-rollback-button' )
placeholderText = rollbackButton.data( 'placeholder-text' );
placeholderUrl = rollbackButton.data( 'placeholder-url' );
rollbackButton.attr( 'href', placeholderUrl.replace( 'VERSION', selectRollback.val() ) );
},
onRollbackClick: function ( e ) {
e.preventDefault();
var rollbackButton = jQuery( this );
// This will update the current rollback button object.
currentRollbackButton = rollbackButton;
rollbackHeading = $('.bsf-confirm-heading');
rollbackConfirmText = $('.bsf-rollback-text');
closestDiv = rollbackButton.closest('.bsf-rollback-version');
versionNumber = closestDiv.find('.bsf-rollback-version-select').val();
selectProductName = closestDiv.find('#bsf-product-name').val();
// Rollback Heading text.
rollbackHeadingdata = rollbackHeading.data('text').replace( '#PRODUCT_NAME#', selectProductName );
rollbackHeading.html( rollbackHeadingdata );
// Rollback Confirmation text.
rollbackConfirmdata = rollbackConfirmText.data('text').replace( '#PRODUCT_NAME#', selectProductName );
rollbackConfirmdata = rollbackConfirmdata.replace( '#VERSION#', versionNumber )
rollbackConfirmText.html( rollbackConfirmdata );
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'block';
},
closeRollbackPopup: function ( e ) {
document.querySelector('.bsf-confirm-rollback-popup').style.display = 'none';
},
onRollbackOk:function ( e ) {
e.preventDefault();
if( currentRollbackButton ){
var redirectUrl = currentRollbackButton.closest('.bsf-rollback-version').find('.bsf-rollback-button').attr('href');
location.href = redirectUrl;
}
rollbackVersion.closeRollbackPopup( e );
}
}
$( document ).ready(function() {
rollbackVersion.init();
});
})( jQuery );

View File

@@ -0,0 +1,413 @@
<?php
/**
* Admin functions.
*
* @package BSF core
*/
if ( ! function_exists( 'bsf_generate_rand_token' ) ) {
/**
* Generate 32 characters random token.
*
* @return string
*/
function bsf_generate_rand_token() {
$valid_characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
$token = '';
$length = 32;
for ( $n = 1; $n < $length; $n++ ) {
$which_character = wp_rand( 0, strlen( $valid_characters ) - 1 );
$token .= $valid_characters[ $which_character ];
}
return $token;
}
}
/**
* Update version numbers of all the brainstorm products in options `brainstorm_products` and `brainstrom_bundled_products`
*
* @todo Current version numbers can be fetched from WordPress at runtime whenever ruquired,
* Remote version can only be required when transient for update data is deleted (i hope)
*/
if ( ! function_exists( 'bsf_update_all_product_version' ) ) {
/**
* Updates all product versions.
*
* @return void
*/
function bsf_update_all_product_version() {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
$bsf_product_themes = array();
if ( ! empty( $brainstrom_products ) ) :
$bsf_product_plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
endif;
$bundled_product_updated = false;
if ( ! empty( $bsf_product_plugins ) ) {
foreach ( $bsf_product_plugins as $key => $plugin ) {
if ( ! isset( $plugin['id'] ) || empty( $plugin['id'] ) ) {
continue;
}
if ( ! isset( $plugin['template'] ) || empty( $plugin['template'] ) ) {
continue;
}
if ( ! isset( $plugin['type'] ) || empty( $plugin['type'] ) ) {
continue;
}
$version = ( isset( $plugin['version'] ) ) ? $plugin['version'] : '';
$current_version = bsf_get_current_version( $plugin['template'], $plugin['type'] );
$name = bsf_get_current_name( $plugin['template'], $plugin['type'] );
if ( '' !== $name ) {
$brainstrom_products['plugins'][ $key ]['product_name'] = $name;
}
if ( '' !== $current_version ) {
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
$brainstrom_products['plugins'][ $key ]['version'] = $current_version;
}
}
}
}
if ( ! empty( $bsf_product_themes ) ) {
foreach ( $bsf_product_themes as $key => $theme ) {
if ( ! isset( $theme['id'] ) || empty( $theme['id'] ) ) {
continue;
}
if ( ! isset( $theme['template'] ) || empty( $theme['template'] ) ) {
continue;
}
if ( ! isset( $theme['type'] ) || empty( $theme['type'] ) ) {
continue;
}
$version = ( isset( $theme['version'] ) ) ? $theme['version'] : '';
$current_version = bsf_get_current_version( $theme['template'], $theme['type'] );
$name = bsf_get_current_name( $theme['template'], $theme['type'] );
if ( '' !== $name ) {
$brainstrom_products['themes'][ $key ]['product_name'] = $name;
}
if ( '' !== $current_version || false !== $current_version ) {
if ( version_compare( $version, $current_version ) === - 1 || 1 === version_compare( $version, $current_version ) ) {
$brainstrom_products['themes'][ $key ]['version'] = $current_version;
}
}
}
}
if ( ! empty( $brainstrom_bundled_products ) ) {
foreach ( $brainstrom_bundled_products as $keys => $bps ) {
$version = '';
if ( strlen( $keys ) > 1 ) {
foreach ( $bps as $key => $bp ) {
if ( ! isset( $bp->id ) || '' === $bp->id ) {
continue;
}
$version = $bp->version;
$current_version = bsf_get_current_version( $bp->init, $bp->type );
if ( '' !== $current_version && false !== $current_version ) {
if ( 1 === - version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
if ( is_object( $brainstrom_bundled_products ) ) {
$brainstrom_bundled_products = array( $brainstrom_bundled_products );
}
$single_bp = $brainstrom_bundled_products[ $keys ];
$single_bp[ $key ]->version = $current_version;
$bundled_product_updated = true;
$brainstrom_bundled_products[ $keys ] = $single_bp;
}
}
}
} else {
if ( ! isset( $bps->id ) || '' === $bps->id ) {
continue;
}
$version = $bps->version;
$current_version = bsf_get_current_version( $bps->init, $bps->type );
if ( '' !== $current_version || false !== $current_version ) {
if ( - 1 === version_compare( $version, $current_version ) || 1 === version_compare( $version, $current_version ) ) {
$brainstrom_bundled_products[ $keys ]->version = $current_version;
$bundled_product_updated = true;
}
}
}
}
}
update_option( 'brainstrom_products', $brainstrom_products );
if ( $bundled_product_updated ) {
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
}
}
}
add_action( 'admin_init', 'bsf_update_all_product_version', 1000 );
if ( ! function_exists( 'bsf_get_current_version' ) ) {
/**
* Get current version of plugin / theme.
*
* @param string $template plugin template/slug.
* @param string $type type of product.
*
* @return float
*/
function bsf_get_current_version( $template, $type ) {
if ( '' === $template ) {
return false;
}
if ( 'theme' === $type || 'themes' === $type ) {
$theme = wp_get_theme( $template );
$version = $theme->get( 'Version' );
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
if ( ! is_file( $plugin_file ) ) {
return false;
}
$plugin = get_plugin_data( $plugin_file );
$version = $plugin['Version'];
}
return $version;
}
}
if ( ! function_exists( 'bsf_get_current_name' ) ) {
/**
* Get name of plugin / theme.
*
* @param string $template plugin template/slug.
* @param string $type type of product.
* @return string
*/
function bsf_get_current_name( $template, $type ) {
if ( '' === $template ) {
return false;
}
if ( 'theme' === $type || 'themes' === $type ) {
$theme = wp_get_theme( $template );
$name = $theme->get( 'Name' );
} elseif ( 'plugin' === $type || 'plugins' === $type ) {
$plugin_file = rtrim( WP_PLUGIN_DIR, '/' ) . '/' . $template;
if ( ! is_file( $plugin_file ) ) {
return false;
}
$plugin = get_plugin_data( $plugin_file );
$name = $plugin['Name'];
}
return $name;
}
}
add_action( 'admin_notices', 'bsf_notices', 1000 );
add_action( 'network_admin_notices', 'bsf_notices', 1000 );
if ( ! function_exists( 'bsf_notices' ) ) {
/**
* Display admin notices.
*
* @return bool
*/
function bsf_notices() {
global $pagenow;
if ( 'update-core.php' === $pagenow || 'plugins.php' === $pagenow || 'post-new.php' === $pagenow || 'edit.php' === $pagenow || 'post.php' === $pagenow ) {
$brainstrom_products = get_option( 'brainstrom_products' );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
if ( empty( $brainstrom_products ) ) {
return false;
}
$brainstrom_bundled_products_keys = array();
if ( ! empty( $brainstrom_bundled_products ) ) :
foreach ( $brainstrom_bundled_products as $bps ) {
foreach ( $bps as $key => $bp ) {
array_push( $brainstrom_bundled_products_keys, $bp->id );
}
}
endif;
$mix = array();
$plugins = ( isset( $brainstrom_products['plugins'] ) ) ? $brainstrom_products['plugins'] : array();
$themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
$mix = array_merge( $plugins, $themes );
if ( empty( $mix ) ) {
return false;
}
if ( ( defined( 'BSF_PRODUCTS_NOTICES' ) && ( 'false' === BSF_PRODUCTS_NOTICES || false === BSF_PRODUCTS_NOTICES ) ) ) {
return false;
}
$is_multisite = is_multisite();
$is_network_admin = is_network_admin();
foreach ( $mix as $product ) :
if ( ! isset( $product['id'] ) ) {
continue;
}
if ( false === apply_filters( "bsf_display_product_activation_notice_{$product['id']}", true ) ) {
continue;
}
if ( isset( $product['is_product_free'] ) && ( 'true' === $product['is_product_free'] || true === $product['is_product_free'] ) ) {
continue;
}
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
$constant_nag = 'BSF_' . $constant . '_NAG';
$constant_notice = 'BSF_' . $constant . '_NOTICES';
if ( defined( $constant_nag ) && ( 'false' === constant( $constant_nag ) || false === constant( $constant_nag ) ) ) {
continue;
}
if ( defined( $constant_notice ) && ( 'false' === constant( $constant_notice ) || false === constant( $constant_notice ) ) ) {
continue;
}
$status = ( isset( $product['status'] ) ) ? $product['status'] : false;
$type = ( isset( $product['type'] ) ) ? $product['type'] : false;
if ( ! $type ) {
continue;
}
if ( 'plugin' === $type ) {
if ( ! is_plugin_active( $product['template'] ) ) {
continue;
}
} elseif ( 'theme' === $type ) {
$theme = wp_get_theme();
if ( $product['template'] !== $theme->template ) {
continue;
}
} else {
continue;
}
if ( BSF_Update_Manager::bsf_is_product_bundled( $product['id'] ) ) {
continue;
}
if ( 'registered' !== $status ) :
$url = bsf_registration_page_url( '', $product['id'] );
$message = __( 'Please', 'bsf' ) . ' <a href="' . esc_url( $url ) . '" class="bsf-core-license-form-btn" plugin-slug="' . esc_html( $product['id'] ) . '">' . __( 'activate', 'bsf' ) . '</a> ' . __( 'your copy of the', 'bsf' ) . ' <i>' . esc_html( $product['product_name'] ) . '</i> ' . __( 'to get update notifications, access to support features & other resources!', 'bsf' );
$message = apply_filters( "bsf_product_activation_notice_{$product['id']}", $message, $url, $product['product_name'] );
$allowed_html = array(
'a' => array(
'href' => array(),
'class' => array(),
'title' => array(),
'plugin-slug' => array(),
),
'br' => array(),
'em' => array(),
'strong' => array(),
'i' => array(),
);
if ( ( $is_multisite && $is_network_admin ) || ! $is_multisite ) {
echo '<div class="notice notice-warning"><p>' . wp_kses( $message, $allowed_html ) . '</p></div>';
}
endif;
endforeach;
}
}
}
// delete bundled products after switch theme.
if ( ! function_exists( 'bsf_theme_deactivation' ) ) {
/**
* Delete transients while switching theme.
*
* @return void
*/
function bsf_theme_deactivation() {
update_option( 'bsf_force_check_extensions', false );
}
}
add_action( 'switch_theme', 'bsf_theme_deactivation' );
add_action( 'deactivated_plugin', 'bsf_theme_deactivation' );
if ( ! function_exists( 'bsf_get_free_menu_position' ) ) {
/**
* Get free theme position.
*
* @param int $start menu position priority index.
* @param float $increment increment number for menu position.
* @return int
*/
function bsf_get_free_menu_position( $start, $increment = 0.3 ) {
foreach ( $GLOBALS['menu'] as $key => $menu ) {
$menus_positions[] = $key;
}
if ( ! in_array( $start, $menus_positions, true ) ) {
return $start;
}
/* the position is already reserved find the closet one */
while ( in_array( $start, $menus_positions, true ) ) {
$start += $increment;
}
return $start;
}
}
if ( ! function_exists( 'bsf_get_option' ) ) {
/**
* Get free theme position.
*
* @param bool $request return complete option data OR a single variable.
* @return array
*/
function bsf_get_option( $request = false ) {
$bsf_options = get_option( 'bsf_options' );
if ( ! $request ) {
return $bsf_options;
} else {
return ( isset( $bsf_options[ $request ] ) ) ? $bsf_options[ $request ] : false;
}
}
}
if ( ! function_exists( 'bsf_update_option' ) ) {
/**
* Update bsf option with key and value.
*
* @param string $request variable key.
* @param string $value variable value.
* @return bool
*/
function bsf_update_option( $request, $value ) {
$bsf_options = get_option( 'bsf_options' );
$bsf_options[ $request ] = $value;
return update_option( 'bsf_options', $bsf_options );
}
}
if ( ! function_exists( 'bsf_sort' ) ) {
/**
* Sort array of objects.
*
* @param string $a The first string.
* @param string $b The second string.
* @return int
*/
function bsf_sort( $a, $b ) {
return strcmp( strtolower( $a->short_name ), strtolower( $b->short_name ) );
}
}

View File

@@ -0,0 +1,239 @@
<?php
/**
* Product update functions.
*
* @package BSF core
*/
// Alternative function for wp_remote_get.
if ( ! function_exists( 'bsf_get_remote_version' ) ) {
/**
* Get remote version for product
*
* @param array $product_list products data.
* @param array $products products data (deprecated).
* @return array
*/
function bsf_get_remote_version( $product_list, $products ) {
global $ultimate_referer;
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
$data = array(
'action' => 'bsf_get_product_versions',
'ids' => $products,
'products' => $product_list,
'site_url' => get_site_url(),
'php_version' => bsf_get_php_version(),
'wp_version' => get_bloginfo( 'version' ),
'locale' => get_locale(),
'bsf_core_version' => BSF_UPDATER_VERSION,
'active_theme' => get_template(),
'active_stylesheet' => get_stylesheet(),
'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
'php_post_max_size' => ini_get( 'post_max_size' ),
'php_max_execution_time' => ini_get( 'max_execution_time' ),
'php_memory_limit' => ini_get( 'memory_limit' ),
);
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '10',
)
);
// Request http URL if the https version fails.
if ( is_wp_error( $request ) && 200 !== wp_remote_retrieve_response_code( $request ) ) {
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '8',
)
);
}
if ( ! is_wp_error( $request ) || 200 === wp_remote_retrieve_response_code( $request ) ) {
$result = json_decode( wp_remote_retrieve_body( $request ) );
if ( ! empty( $result ) ) {
if ( empty( $result->error ) ) {
return $result->updated_versions;
} else {
return $result->error;
}
}
}
}
}
if ( ! function_exists( 'bsf_check_product_update' ) ) {
/**
* Check product updates.
*
* @return void
*/
function bsf_check_product_update() {
$is_update = true;
$registered = array(); // This list will be deprecated in favor of $product_list.
$product_list = array();
$all_products = brainstorm_get_all_products( false, false, true );
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
foreach ( $all_products as $key => $product ) {
if ( ! isset( $product['id'] ) ) {
continue;
}
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
if ( defined( $constant ) && ( 'false' === constant( $constant ) || false === constant( $constant ) ) ) {
continue;
}
$registered[] = $product['id'];
$product_list[ $product['id'] ] = array(
'id' => $product['id'],
'installed_version' => $product['version'],
);
// Add bundled products to the list.
if ( isset( $brainstrom_bundled_products[ $product['id'] ] ) ) {
$bundled_products = $brainstrom_bundled_products[ $product['id'] ];
$bundled_product_data = array();
foreach ( $bundled_products as $bundled_product ) {
$bundled_product_data[ $bundled_product->id ] = array(
'id' => $bundled_product->id,
'installed_version' => $bundled_product->version,
);
}
$product_list[ $product['id'] ]['bundled_products'] = $bundled_product_data;
}
}
$remote_versions = bsf_get_remote_version( $product_list, $registered );
$bsf_product_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$bsf_product_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
if ( false !== $remote_versions ) {
if ( ! empty( $remote_versions ) ) {
$is_bundled_update = false;
foreach ( $remote_versions as $rkey => $remote_data ) {
$rid = ( isset( $remote_data->id ) ) ? (string) $remote_data->id : '';
$remote_version = ( isset( $remote_data->remote_version ) ) ? $remote_data->remote_version : '';
$in_house = ( isset( $remote_data->in_house ) ) ? $remote_data->in_house : '';
$on_market = ( isset( $remote_data->on_market ) ) ? $remote_data->on_market : '';
$is_product_free = ( isset( $remote_data->is_product_free ) ) ? $remote_data->is_product_free : '';
$short_name = ( isset( $remote_data->short_name ) ) ? $remote_data->short_name : '';
$changelog_url = ( isset( $remote_data->changelog_url ) ) ? $remote_data->changelog_url : '';
$purchase_url = ( isset( $remote_data->purchase_url ) ) ? $remote_data->purchase_url : '';
$version_beta = ( isset( $remote_data->version_beta ) ) ? $remote_data->version_beta : '';
$download_url = ( isset( $remote_data->download_url ) ) ? $remote_data->download_url : '';
$download_url_beta = ( isset( $remote_data->download_url_beta ) ) ? $remote_data->download_url_beta : '';
$tested_upto = ( isset( $remote_data->tested ) ) ? $remote_data->tested : '';
foreach ( $bsf_product_plugins as $key => $plugin ) {
if ( ! isset( $plugin['id'] ) ) {
continue;
}
$pid = (string) $plugin['id'];
if ( $pid === $rid ) {
$brainstrom_products['plugins'][ $key ]['remote'] = $remote_version;
$brainstrom_products['plugins'][ $key ]['in_house'] = $in_house;
$brainstrom_products['plugins'][ $key ]['on_market'] = $on_market;
$brainstrom_products['plugins'][ $key ]['is_product_free'] = $is_product_free;
$brainstrom_products['plugins'][ $key ]['short_name'] = $short_name;
$brainstrom_products['plugins'][ $key ]['changelog_url'] = $changelog_url;
$brainstrom_products['plugins'][ $key ]['purchase_url'] = $purchase_url;
$brainstrom_products['plugins'][ $key ]['version_beta'] = $version_beta;
$brainstrom_products['plugins'][ $key ]['download_url_beta'] = $download_url_beta;
$brainstrom_products['plugins'][ $key ]['download_url'] = $download_url;
$brainstrom_products['plugins'][ $key ]['tested'] = $tested_upto;
// Deregister status for plugin.
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
$brainstrom_products['plugins'][ $key ]['status'] = 'not-registered';
} else {
$brainstrom_products['plugins'][ $key ]['status'] = 'registered';
}
$is_update = true;
}
}
foreach ( $bsf_product_themes as $key => $theme ) {
if ( ! isset( $theme['id'] ) ) {
continue;
}
$pid = $theme['id'];
if ( $pid === $rid ) {
$brainstrom_products['themes'][ $key ]['remote'] = $remote_version;
$brainstrom_products['themes'][ $key ]['in_house'] = $in_house;
$brainstrom_products['themes'][ $key ]['on_market'] = $on_market;
$brainstrom_products['themes'][ $key ]['is_product_free'] = $is_product_free;
$brainstrom_products['themes'][ $key ]['short_name'] = $short_name;
$brainstrom_products['themes'][ $key ]['changelog_url'] = $changelog_url;
$brainstrom_products['themes'][ $key ]['purchase_url'] = $purchase_url;
$brainstrom_products['themes'][ $key ]['version_beta'] = $version_beta;
$brainstrom_products['themes'][ $key ]['download_url'] = $download_url;
$brainstrom_products['themes'][ $key ]['download_url_beta'] = $download_url_beta;
$is_update = true;
// Deregister status for theme.
if ( isset( $remote_data->status ) && 0 === $remote_data->status ) {
$brainstrom_products['themes'][ $key ]['status'] = 'not-registered';
} else {
$brainstrom_products['themes'][ $key ]['status'] = 'registered';
}
}
}
if ( isset( $remote_data->bundled_products ) && ! empty( $remote_data->bundled_products ) ) {
if ( ! empty( $brainstrom_bundled_products ) && is_array( $brainstrom_bundled_products ) ) {
foreach ( $brainstrom_bundled_products as $bkeys => $bps ) {
foreach ( $bps as $bkey => $bp ) {
if ( ! isset( $bp->id ) ) {
continue;
}
foreach ( $remote_data->bundled_products as $rbp ) {
if ( ! isset( $rbp->id ) ) {
continue;
}
if ( $rbp->id === $bp->id ) {
$bprd = $brainstrom_bundled_products[ $bkeys ];
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->remote = $rbp->remote_version;
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->parent = $rbp->parent;
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->short_name = $rbp->short_name;
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->changelog_url = $rbp->changelog_url;
if ( isset( $rbp->download_url ) ) {
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url = $rbp->download_url;
}
if ( isset( $rbp->download_url_beta ) ) {
$brainstrom_bundled_products[ $bkeys ][ $bkey ]->download_url_beta = $rbp->download_url_beta;
}
$is_bundled_update = true;
}
}
}
}
}
}
}
if ( $is_bundled_update ) {
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
}
}
}
if ( $is_update ) {
update_option( 'brainstrom_products', $brainstrom_products );
}
}
}

View File

@@ -0,0 +1,2 @@
/* Do not change otherwise you won't get updates */
ID:[bsf-core]

View File

@@ -0,0 +1,18 @@
### Version - 1.21
# Support for beta updates of the products.
### Version - 1.19
- License Manager v2.0 - Allow plugins to individually set the license form.
- Update themes and plugins with WordPress's transients. so support for WP-CLI and any other website management tools.
- New License manager API.
- Improvement: Force check product update now works when WordPress updates are force checked.
- Slight redesign of help and debug settings screens.
- Support for white label with filters.
- Option to move Brainstorm registration menu in settings.
- Hide purchase key when it is validated.
- Remove use of deprecated 'mysql_' functions.
- Allow users to skip brainstorm account registration.
- Allow plugins/themes to completely hide the screen for Brainstorm Registration.
- Allow using staging API server for development.
- Fix: Occasional PHP fatal errors when using the child theme.

View File

@@ -0,0 +1,449 @@
<?php
/**
* BSf Evato Activation Class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF_Envato_Activate setup
*
* @since 1.0
*/
class BSF_Envato_Activate {
/**
* Instance
*
* @var BSF_Envato_Activate
*/
private static $instance;
/**
* Reference to the License manager class.
*
* @var BSF_License_Manager
*/
private $license_manager;
/**
* Stores temporary response messsages from the API validations.
*
* @var array()
*/
private $message_box;
/**
* Initiator.
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new BSF_Envato_Activate();
}
return self::$instance;
}
/**
* Constructor function that initializes required actions and hooks
*
* @since 1.0
*/
public function __construct() {
$this->license_manager = new BSF_License_Manager();
$action = isset( $_GET['license_action'] ) ? esc_attr( $_GET['license_action'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( 'activate_license' === $action ) {
$this->process_envato_activation();
}
add_filter( 'update_footer', array( $this, 'alternate_method_link' ), 20 );
add_action( 'bsf_inlne_license_envato_after_form', array( $this, 'inline_alternate_method_link' ), 20, 2 );
}
/**
* Envato Register.
*
* @param array $args Arguments.
*/
public function envato_register( $args ) {
// Check if alternate method is to be used.
$method = ( isset( $_GET['activation_method'] ) && isset( $_GET['bsf_activation_nonce'] ) && wp_verify_nonce( $_GET['bsf_activation_nonce'], 'bsf_activation_nonce' ) ) ? esc_attr( $_GET['activation_method'] ) : 'oauth';
$html = '';
$product_id = isset( $args['product_id'] ) ? $args['product_id'] : '';
$is_active = $this->license_manager->bsf_is_active_license( $product_id );
$product_name = $this->license_manager->bsf_get_product_info( $product_id, 'name' );
$purchase_url = $this->license_manager->bsf_get_product_info( $product_id, 'purchase_url' );
$bundled = BSF_Update_Manager::bsf_is_product_bundled( $product_id );
if ( ! empty( $bundled ) ) {
$parent_id = $bundled[0];
$is_active = $this->license_manager->bsf_is_active_license( $parent_id );
$parent_name = brainstrom_product_name( $parent_id );
$registration_page = bsf_registration_page_url( '', $parent_id );
$html .= '<div class="bundled-product-license-registration">';
$html .= '<span>';
if ( $is_active ) {
$html .= '<h3>License Active!</h3>';
$html .= '<p>' . sprintf(
'Your license is activated, you will receive updates for <i>%s</i> when they are available.',
$product_name
) . '</p>';
} else {
$html .= '<h3>Updates Unavailable!</h3>';
$html .= '<p>' . sprintf(
'This plugin is came bundled with the <i>%1$s</i>. For receiving updates, you need to activate license of <i>%2$s</i> <a href="%3$s">here</a>.',
$parent_name,
$parent_name,
$registration_page
) . '</p>';
}
$html .= '</span>';
$html .= '</div>';
return $html;
}
if ( 'license-key' === $method ) {
$html .= bsf_license_activation_form( $args );
return $html;
}
// Licence activation button.
$form_action = ( isset( $args['form_action'] ) && ! is_null( $args['form_action'] ) ) ? $args['form_action'] : '';
$form_class = ( isset( $args['form_class'] ) && ! is_null( $args['form_class'] ) ) ? $args['form_class'] : "bsf-license-form-{$product_id}";
$submit_button_class = ( isset( $args['submit_button_class'] ) && ! is_null( $args['submit_button_class'] ) ) ? $args['submit_button_class'] : '';
$license_form_heading_class = ( isset( $args['bsf_license_form_heading_class'] ) && ! is_null( $args['bsf_license_form_heading_class'] ) ) ? $args['bsf_license_form_heading_class'] : '';
$license_active_class = ( isset( $args['bsf_license_active_class'] ) && ! is_null( $args['bsf_license_active_class'] ) ) ? $args['bsf_license_active_class'] : '';
$license_not_activate_message = ( isset( $args['bsf_license_not_activate_message'] ) && ! is_null( $args['bsf_license_not_activate_message'] ) ) ? $args['bsf_license_not_activate_message'] : '';
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
$button_text_activate = ( isset( $args['button_text_activate'] ) && ! is_null( $args['button_text_activate'] ) ) ? __( 'Sign Up & Activate', 'bsf' ) : __( 'Sign Up & Activate', 'bsf' );
$button_text_deactivate = ( isset( $args['button_text_deactivate'] ) && ! is_null( $args['button_text_deactivate'] ) ) ? $args['button_text_deactivate'] : __( 'Deactivate License', 'bsf' );
$placeholder = ( isset( $args['placeholder'] ) && ! is_null( $args['placeholder'] ) ) ? $args['placeholder'] : 'Enter your license key..';
$popup_license_form = ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false;
$bsf_license_allow_email = ( isset( $args['bsf_license_allow_email'] ) && ! is_null( $args['bsf_license_allow_email'] ) ) ? $args['bsf_license_allow_email'] : true;
if ( true === $bsf_license_allow_email ) {
$form_class .= ' license-form-allow-email ';
if ( ! $is_active ) {
$submit_button_class .= ' button-primary button-hero bsf-envato-form-activation ';
}
}
if ( true !== $is_active ) {
$form_action = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
} else {
$form_action = bsf_registration_page_url( '', $product_id );
}
$html .= '<div class="envato-license-registration">';
$html .= '<form method="post" class="' . $form_class . '" action="' . $form_action . '">';
$html .= wp_nonce_field( 'bsf_license_activation_deactivation_nonce', 'bsf_graupi_nonce', true, false );
if ( $this->get_message( 'message' ) !== '' ) {
$html .= '<span class="bsf-license-message license-' . $this->get_message( 'status' ) . '">';
$html .= $this->get_message( 'message' );
$html .= '</span>';
}
if ( $is_active ) {
$envato_active_oauth_title = apply_filters( "envato_active_oauth_title_{$product_id}", 'Updates & Support Registration - <span class="active">Active!</span>' );
$envato_active_oauth_subtitle = '<span class="active">' . sprintf(
'Your license is active.',
$product_name
) . '</span>';
$envato_active_oauth_subtitle = apply_filters( "envato_active_oauth_subtitle_{$product_id}", $envato_active_oauth_subtitle );
if ( $popup_license_form ) {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
$html .= '</div>';
} else {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $envato_active_oauth_title . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_active_oauth_subtitle . '</p>';
$html .= '</div>';
}
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="License Validated"/>';
$html .= '<input type="hidden" class="' . $size . '-text" id="bsf_license_manager[product_id]" name="bsf_license_manager[product_id]" value="' . esc_attr( stripslashes( $product_id ) ) . '"/>';
$html .= '<input type="submit" class="button ' . $submit_button_class . '" name="bsf_deactivate_license" value="' . esc_attr( $button_text_deactivate ) . '"/>';
} else {
$envato_not_active_oauth_title = apply_filters( "envato_not_active_oauth_title_{$product_id}", __( 'Updates & Support Registration - <span class="not-active">Not Active!</span>', 'bsf' ) );
$envato_not_active_oauth_subtitle = apply_filters( "envato_not_active_oauth_subtitle_{$product_id}", __( 'Click on the button below to activate your license and subscribe to our newsletter.', 'bsf' ) );
if ( $popup_license_form ) {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $product_name . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
$html .= '</div>';
} else {
$html .= '<div class="bsf-wrap-title">';
$html .= '<h3 class="envato-oauth-heading">' . $envato_not_active_oauth_title . '</h2>';
$html .= '<p class="envato-oauth-subheading">' . $envato_not_active_oauth_subtitle . '</p>';
$html .= '</div>';
}
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="url" value="' . get_site_url() . '"/>';
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="redirect" value="' . $this->get_redirect_url( $product_id ) . '"/>';
$html .= '<input type="hidden" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="product_id" value="' . $product_id . '"/>';
$html .= '<input id="bsf-license-privacy-consent" name="bsf_license_manager[privacy_consent]" type="hidden" value="true" />';
$html .= '<input id="bsf-license-terms-conditions-consent" name="bsf_license_manager[terms_conditions_consent]" type="hidden" value="true" />';
$html .= '<div class="submit-button-wrap">';
$html .= '<input type="button" class="button ' . $submit_button_class . '" name="bsf_activate_license" value="' . esc_attr( $button_text_activate ) . '"/>';
$html .= "<p class='purchase-license'><a target='_blank' href='$purchase_url'>Purchase License »</a></p>";
$html .= '</div>';
}
$html .= '</form>';
$html = apply_filters( 'bsf_inlne_license_envato_after_form', $html, $product_id );
$html .= '</div> <!-- envato-license-registration -->';
if ( isset( $_GET['debug'] ) ) {
$html .= get_bsf_systeminfo();
}
return $html;
}
/**
* Envato activation URL.
*
* @param array $form_data Form data.
* @return $envato_activation_url.
*/
public function envato_activation_url( $form_data ) {
$product_id = isset( $form_data['product_id'] ) ? esc_attr( $form_data['product_id'] ) : '';
$form_data['token'] = sha1( $this->create_token( $product_id ) );
$url = bsf_get_api_site() . 'envato-validation-callback/?wp-envato-validate';
$envato_activation_url = add_query_arg(
$form_data,
$url
);
return $envato_activation_url;
}
/**
* Get redirect URL.
*
* @param int $product_id Product ID.
* @return $current_url.
*/
protected function get_redirect_url( $product_id = '' ) {
if ( is_ssl() ) {
$current_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
} else {
$current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
$current_url = esc_url( remove_query_arg( array( 'license_action', 'token', 'product_id', 'purchase_key', 'success', 'status', 'message' ), $current_url ) );
if ( '' !== $product_id ) {
$current_url = add_query_arg(
array(
'bsf-inline-license-form' => $product_id,
),
$current_url
);
}
return $current_url;
}
/**
* Create Token.
*
* @param int $product_id Product ID.
* @return $token.
*/
protected function create_token( $product_id ) {
$token = $product_id . '|' . current_time( 'timestamp' ) . '|' . bsf_generate_rand_token();
update_site_option( "bsf_envato_token_$product_id", $token );
return $token;
}
/**
* Validate Token.
*
* @param string $token Token.
* @param int $product_id Product ID.
* @return bool.
*/
protected function validate_token( $token, $product_id ) {
$stored_token = get_site_option( "bsf_envato_token_$product_id", '' );
if ( sha1( $stored_token ) === $token ) {
$token_atts = explode( '|', $stored_token );
$stored_id = $token_atts[0];
if ( $stored_id !== $product_id ) {
// Token is invalid.
return false;
}
$timestamp = (int) $token_atts[1];
$valid_ultil = $timestamp + 900;
if ( current_time( 'timestamp' ) > $valid_ultil ) {
// Timestamp has expired.
return false;
}
// If above conditions did not meet, the token is valid.
return true;
}
return false;
}
/**
* Process envato activation.
*/
protected function process_envato_activation() {
$token = isset( $_GET['token'] ) ? esc_attr( $_GET['token'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$product_id = isset( $_GET['product_id'] ) ? esc_attr( $_GET['product_id'] ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( $this->validate_token( $token, $product_id ) ) {
$args = array();
$args['purchase_key'] = isset( $_GET['purchase_key'] ) ? esc_attr( $_GET['purchase_key'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$args['status'] = isset( $_GET['status'] ) ? esc_attr( $_GET['status'] ) : '';// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$this->license_manager->bsf_update_product_info( $product_id, $args );
$this->set_message(
array(
'status' => 'success',
'message' => 'License successfully activated!',
)
);
} else {
$this->set_message(
array(
'status' => 'error',
'message' => 'The token is invalid or is expired, please try again.',
)
);
}
}
/**
* Set message.
*
* @param array $message Message.
*/
protected function set_message( $message = array() ) {
$this->message_box = $message;
}
/**
* Get message.
*
* @param string $key key.
* @return $mesage
*/
protected function get_message( $key ) {
$message = $this->message_box;
return isset( $message[ $key ] ) ? $message[ $key ] : '';
}
/**
* Inline alternate method link.
*
* @param string $html HTML.
* @param int $bsf_product_id Product ID.
* @return $html.
*/
public function inline_alternate_method_link( $html, $bsf_product_id ) {
$privacy_policy_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'privacy_policy' );
$terms_conditions_link = $this->license_manager->bsf_get_product_info( $bsf_product_id, 'terms_conditions' );
if ( isset( $privacy_policy_link ) ) {
$html .= sprintf(
'<a class="license-form-external-links" target="_blank" href="%s">Privacy Policy</a> | ',
$privacy_policy_link
);
}
if ( isset( $terms_conditions_link ) ) {
$html .= sprintf(
'<a class="license-form-external-links" target="_blank" href="%s">Terms & Conditions</a>',
$terms_conditions_link
);
}
return $html;
}
/**
* ALternate method link.
*
* @param string $content Content.
* @return $content.
*/
public function alternate_method_link( $content ) {
$bsf_activation_nonce = wp_create_nonce( 'bsf_activation_nonce' );
$content = sprintf(
'<a href="%s">Activate license using purchase key</a>',
add_query_arg(
array(
'activation_method' => 'license-key',
'bsf_activation_nonce' => $bsf_activation_nonce,
)
)
);
return $content;
}
}
/**
* BSF envato register.
*
* @param string $args Arguments..
* @return envato_register().
*/
function bsf_envato_register( $args ) {
$bsf_envato_activate = BSF_Envato_Activate::instance();
return $bsf_envato_activate->envato_register( $args );
}

View File

@@ -0,0 +1,896 @@
<?php
/**
* BSF License manager class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'BSF_License_Manager' ) ) {
/**
* Class BSF_License_Manager
*/
class BSF_License_Manager {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance = null;
/**
* Inline form products.
*
* @access private
* @var $inline_form_products Inline form products.
*/
private static $inline_form_products = array();
/**
* Instance.
*/
public static function instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Initiator
*/
public function __construct() {
add_action( 'admin_head', array( $this, 'admin_css' ), 100 );
add_action( 'admin_init', array( $this, 'bsf_activate_license' ) );
add_action( 'admin_init', array( $this, 'bsf_deactivate_license' ) );
add_action( 'bsf_product_update_registered', array( $this, 'refresh_products_on_license_activae' ) );
add_action( 'admin_footer', array( $this, 'render_popup_form_markup' ) );
$this->includes();
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
}
/**
* Refresh products on License activation.
*/
public function refresh_products_on_license_activae() {
update_site_option( 'bsf_force_check_extensions', true );
}
/**
* Includes.
*/
public function includes() {
require_once BSF_UPDATER_PATH . '/class-bsf-envato-activate.php';
}
/**
* Admin CSS.
*/
public function admin_css() {
?>
<style type="text/css">
.bsf-pre {
white-space: normal;
}
/* license consent */
.bsf-license-consent-container {
display: flex;
}
.bsf-license-consent-container label {
padding-top: 0;
}
.wp-admin p.bsf-license-consent-container input {
margin-top: 2px;
margin-right: 10px;
}
</style>
<?php
}
/**
* BSF Deactivate license.
*/
public function bsf_deactivate_license() {
if ( ! isset( $_POST['bsf_deactivate_license'] ) ) {
return;
}
if ( ! isset( $_POST['bsf_graupi_nonce'] ) || ( isset( $_POST['bsf_graupi_nonce'] ) && ! wp_verify_nonce( $_POST['bsf_graupi_nonce'], 'bsf_license_activation_deactivation_nonce' ) ) ) {
return;
}
if ( ! isset( $_POST['bsf_license_manager']['license_key'] ) || empty( $_POST['bsf_license_manager']['license_key'] ) ) {
return;
}
if ( ! isset( $_POST['bsf_license_manager']['product_id'] ) || empty( $_POST['bsf_license_manager']['product_id'] ) ) {
return;
}
$product_id = esc_attr( $_POST['bsf_license_manager']['product_id'] );
$license_key = $this->bsf_get_product_info( $product_id, 'purchase_key' );
// Check if the key is from EDD.
$is_edd = $this->is_edd( $license_key );
$path = bsf_get_api_url() . '?referer=deactivate-' . $product_id;
// Using Brainstorm API v2.
$data = array(
'action' => 'bsf_deactivate_license',
'purchase_key' => $license_key,
'product_id' => $product_id,
'site_url' => get_site_url(),
'is_edd' => $is_edd,
'referer' => 'customer',
);
$data = apply_filters( 'bsf_deactivate_license_args', $data );
$response = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '15',
)
);
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
$result = json_decode( wp_remote_retrieve_body( $response ), true );
if ( isset( $result['success'] ) && ( true === $result['success'] || 'true' === $result['success'] ) ) {
// update license saus to the product.
$_POST['bsf_license_deactivation']['success'] = $result['success'];
$_POST['bsf_license_deactivation']['message'] = $result['message'];
unset( $result['success'] );
unset( $result['message'] );
$this->bsf_update_product_info( $product_id, $result );
do_action( 'bsf_deactivate_license_' . $product_id . '_after_success', $result, $response, $_POST );
} else {
$_POST['bsf_license_deactivation']['success'] = $result['success'];
$_POST['bsf_license_deactivation']['message'] = $result['message'];
}
} else {
// If there is an error, the status will not be changed. hence it's true.
$_POST['bsf_license_activation']['success'] = true;
$_POST['bsf_license_activation']['message'] = 'There was an error when connecting to our license API - <pre class="bsf-pre">' . $response->get_error_message() . '</pre>';
}
// Delete license key status transient.
delete_transient( $product_id . '_license_status' );
}
/**
* BSF Activate license.
*/
public function bsf_activate_license() {
if ( ! isset( $_POST['bsf_activate_license'] ) ) {
return;
}
if ( ! isset( $_POST['bsf_graupi_nonce'] ) || ( isset( $_POST['bsf_graupi_nonce'] ) && ! wp_verify_nonce( $_POST['bsf_graupi_nonce'], 'bsf_license_activation_deactivation_nonce' ) ) ) {
return;
}
if ( ! isset( $_POST['bsf_license_manager']['license_key'] ) || empty( $_POST['bsf_license_manager']['license_key'] ) ) {
return;
}
if ( ! isset( $_POST['bsf_license_manager']['product_id'] ) || empty( $_POST['bsf_license_manager']['product_id'] ) ) {
return;
}
$post_data = $_POST['bsf_license_manager'];
$_POST['bsf_license_activation'] = $this->bsf_process_license_activation( $post_data );
}
/**
* BSF Activate license processing.
*
* @param Array $post_data Post data.
*/
public function bsf_process_license_activation( $post_data ) {
$license_key = esc_attr( $post_data['license_key'] );
$product_id = esc_attr( $post_data['product_id'] );
$user_name = isset( $post_data['user_name'] ) ? esc_attr( $post_data['user_name'] ) : '';
$user_email = isset( $post_data['user_email'] ) ? esc_attr( $post_data['user_email'] ) : '';
$privacy_consent = ( isset( $post_data['privacy_consent'] ) && 'true' === $post_data['privacy_consent'] ) ? true : false;
$terms_conditions_consent = ( isset( $post_data['terms_conditions_consent'] ) && 'true' === $post_data['terms_conditions_consent'] ) ? true : false;
// Check if the key is from EDD.
$is_edd = $this->is_edd( $license_key );
// Server side check if the license key is valid.
$path = bsf_get_api_url() . '?referer=activate-' . $product_id;
// Using Brainstorm API v2.
$data = array(
'action' => 'bsf_activate_license',
'purchase_key' => $license_key,
'product_id' => $product_id,
'user_name' => $user_name,
'user_email' => $user_email,
'privacy_consent' => $privacy_consent,
'terms_conditions_consent' => $terms_conditions_consent,
'site_url' => get_site_url(),
'is_edd' => $is_edd,
'referer' => 'customer',
);
$data = apply_filters( 'bsf_activate_license_args', $data );
$response = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '15',
)
);
$res = array();
if ( ! is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 200 ) {
$result = json_decode( wp_remote_retrieve_body( $response ), true );
if ( isset( $result['success'] ) && ( true === $result['success'] || 'true' === $result['success'] ) ) {
// update license saus to the product.
$res['success'] = $result['success'];
$res['message'] = $result['message'];
unset( $result['success'] );
// Update product key.
$result['purchase_key'] = $license_key;
$this->bsf_update_product_info( $product_id, $result );
do_action( 'bsf_activate_license_' . $product_id . '_after_success', $result, $response, $post_data );
} else {
$res['success'] = $result['success'];
$res['message'] = $result['message'];
}
} else {
$res['success'] = false;
$res['message'] = 'There was an error when connecting to our license API - <pre class="bsf-pre">' . $response->get_error_message() . '</pre>';
}
// Delete license key status transient.
delete_transient( $product_id . '_license_status' );
return $res;
}
/**
* Is EDD.
*
* @param string $license_key License key.
*/
public function is_edd( $license_key ) {
// Purchase key length for EDD is 32 characters.
if ( strlen( $license_key ) === 32 ) {
return true;
}
return false;
}
/**
* BSF Update product Info.
*
* @param int $product_id Product ID.
* @param array $args Arguments.
*/
public function bsf_update_product_info( $product_id, $args ) {
$brainstrom_products = get_option( 'brainstrom_products', array() );
foreach ( $brainstrom_products as $type => $products ) {
foreach ( $products as $id => $product ) {
if ( $id == $product_id ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
foreach ( $args as $key => $value ) {
$brainstrom_products[ $type ][ $id ][ $key ] = $value;
do_action( "bsf_product_update_{$value}", $product_id, $value );
}
}
}
}
update_option( 'brainstrom_products', $brainstrom_products );
}
/**
* BSF is active license.
*
* @param int $product_id Product ID.
*/
public static function bsf_is_active_license( $product_id ) {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstorm_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstorm_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$all_products = $brainstorm_plugins + $brainstorm_themes;
// If a product is marked as free, it is considered as active.
$is_free = self::is_product_free( $product_id );
if ( 'true' === $is_free || true === $is_free ) {
return true;
}
$is_bundled = BSF_Update_Manager::bsf_is_product_bundled( $product_id );
// The product is not bundled.
if ( isset( $all_products[ $product_id ] ) ) {
if ( isset( $all_products[ $product_id ]['status'] ) && 'registered' === $all_products[ $product_id ]['status'] ) {
// If the purchase key is empty, Return false.
if ( ! isset( $all_products[ $product_id ]['purchase_key'] ) ) {
return false;
}
// Check if license is active on API.
if ( false === self::instance()->get_remote_license_status( $all_products[ $product_id ]['purchase_key'], $product_id ) ) {
return false;
}
return true;
}
}
// The product is bundled.
if ( ! empty( $is_bundled ) ) {
// If the bundled product does not require to activate the license then treat the license is active.
$product = get_brainstorm_product( $product_id );
if ( isset( $product['licence_require'] ) && 'false' === $product['licence_require'] ) {
return true;
}
foreach ( $is_bundled as $key => $value ) {
$product_id = $value;
if ( isset( $all_products[ $product_id ] ) ) {
if ( isset( $all_products[ $product_id ]['status'] ) && 'registered' === $all_products[ $product_id ]['status'] ) {
// If the purchase key is empty, Return false.
if ( ! isset( $all_products[ $product_id ]['purchase_key'] ) ) {
return false;
}
// Check if license is active on API.
if ( false === self::instance()->get_remote_license_status( $all_products[ $product_id ]['purchase_key'], $product_id ) ) {
return false;
}
return true;
}
}
}
}
// By default Return false.
return false;
}
/**
* Get remote license status.
*
* @param string $purchase_key Purchase Key.
* @param int $product_id Product ID.
*/
public function get_remote_license_status( $purchase_key, $product_id ) {
$transient_key = $product_id . '_license_status';
// Check if license status is cached.
if ( false !== get_transient( $transient_key ) ) {
return (bool) get_transient( $transient_key );
}
// Set default license to license status stored in the database.
$license_status = $this->bsf_get_product_info( $product_id, 'status' );
if ( 'registered' === $license_status ) {
$license_status = '1';
} else {
$license_status = '0';
}
$path = bsf_get_api_url() . '?referer=license-status-' . $product_id;
// Using Brainstorm API v2.
$data = array(
'action' => 'bsf_license_status',
'purchase_key' => $purchase_key,
'site_url' => get_site_url(),
);
$data = apply_filters( 'bsf_license_status_args', $data );
$response = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '10',
)
);
// Try to make a second request to unsecure URL.
if ( is_wp_error( $response ) && wp_remote_retrieve_response_code( $response ) !== 200 ) {
$path = bsf_get_api_url( true ) . '?referer=license-status-' . $product_id;
$response = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '8',
)
);
}
if ( ! is_wp_error( $response ) && wp_remote_retrieve_response_code( $response ) === 200 ) {
$response_body = json_decode( wp_remote_retrieve_body( $response ), true );
// Check if status received from API is true.
if ( isset( $response_body['status'] ) && true === $response_body['status'] ) {
$license_status = '1';
} else {
$license_status = '0';
}
}
// Save license status in transient which will expire in 6 hours.
set_transient( $transient_key, $license_status, 6 * HOUR_IN_SECONDS );
return (bool) $license_status;
}
/**
* Is product free.
*
* @param int $product_id Product ID.
*/
public static function is_product_free( $product_id ) {
$license_manager = self::instance();
$is_free = $license_manager->bsf_get_product_info( $product_id, 'is_product_free' );
return $is_free;
}
/**
* Get product info.
*
* @param int $product_id Product ID.
* @param string $key Key.
*/
public function bsf_get_product_info( $product_id, $key ) {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstorm_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstorm_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$all_products = $brainstorm_plugins + $brainstorm_themes;
if ( isset( $all_products[ $product_id ][ $key ] ) && ! empty( $all_products[ $product_id ][ $key ] ) ) {
return $all_products[ $product_id ][ $key ];
}
}
/**
* For Popup License form check `popup_license_form` is `true`.
*
* @param array $args Arguments.
*/
public function license_activation_form( $args ) {
$html = '';
$product_id = ( isset( $args['product_id'] ) && ! is_null( $args['product_id'] ) ) ? $args['product_id'] : '';
// bail out if product id is missing.
if ( empty( $product_id ) ) {
esc_html_e( 'Product id is missing.', 'bsf' );
return;
}
$popup_license_form = ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false;
$form_action = ( isset( $args['form_action'] ) && ! is_null( $args['form_action'] ) ) ? $args['form_action'] : '';
$form_class = ( isset( $args['form_class'] ) && ! is_null( $args['form_class'] ) ) ? $args['form_class'] : "bsf-license-form-{$product_id}";
$submit_button_class = ( isset( $args['submit_button_class'] ) && ! is_null( $args['submit_button_class'] ) ) ? $args['submit_button_class'] : '';
$license_form_heading_class = ( isset( $args['bsf_license_form_heading_class'] ) && ! is_null( $args['bsf_license_form_heading_class'] ) ) ? $args['bsf_license_form_heading_class'] : '';
$license_active_class = ( isset( $args['bsf_license_active_class'] ) && ! is_null( $args['bsf_license_active_class'] ) ) ? $args['bsf_license_active_class'] : '';
$license_not_activate_message = ( isset( $args['bsf_license_not_activate_message'] ) && ! is_null( $args['bsf_license_not_activate_message'] ) ) ? $args['bsf_license_not_activate_message'] : '';
$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
$button_text_activate = ( isset( $args['button_text_activate'] ) && ! is_null( $args['button_text_activate'] ) ) ? $args['button_text_activate'] : __( 'Activate License', 'bsf' );
$button_text_deactivate = ( isset( $args['button_text_deactivate'] ) && ! is_null( $args['button_text_deactivate'] ) ) ? $args['button_text_deactivate'] : __( 'Deactivate License', 'bsf' );
$placeholder = ( isset( $args['placeholder'] ) && ! is_null( $args['placeholder'] ) ) ? $args['placeholder'] : 'Enter your license key..';
$placeholder_name = ( isset( $args['placeholder_name'] ) && ! is_null( $args['placeholder_name'] ) ) ? $args['placeholder_name'] : 'Your Name..';
$placeholder_email = ( isset( $args['placeholder_email'] ) && ! is_null( $args['placeholder_email'] ) ) ? $args['placeholder_email'] : 'Your Email..';
$bsf_license_allow_email = ( isset( $args['bsf_license_allow_email'] ) && ! is_null( $args['bsf_license_allow_email'] ) ) ? $args['bsf_license_allow_email'] : true;
$license_form_title = ( isset( $args['license_form_title'] ) && ! is_null( $args['license_form_title'] ) ) ? $args['license_form_title'] : 'Updates & Support Registration - ';
$is_active = self::bsf_is_active_license( $product_id );
$license_key = $this->bsf_get_product_info( $product_id, 'purchase_key' );
if ( true === $bsf_license_allow_email || 'true' === $bsf_license_allow_email ) {
$form_class .= ' license-form-allow-email ';
if ( ! $is_active ) {
$button_text_activate = 'Sign Up & Activate';
$submit_button_class .= ' button-primary button-hero ';
}
}
// Forcefully disable the subscribe options for uabb.
// This should be disabled from uabb and removed from graupi.
if ( 'uabb' === $product_id ) {
$bsf_license_allow_email = false;
}
$purchase_url = $this->bsf_get_product_info( $product_id, 'purchase_url' );
$product_name = apply_filters( "agency_updater_productname_{$product_id}", $this->bsf_get_product_info( $product_id, 'name' ) );
if ( empty( $product_name ) ) {
$product_name = apply_filters( "agency_updater_productname_{$product_id}", $this->bsf_get_product_info( $product_id, 'product_name' ) );
}
// License activation messages.
$current_status = '';
$current_message = '';
if ( isset( $_POST['bsf_license_activation']['success'] ) && isset( $_POST['bsf_license_manager']['product_id'] ) && $product_id === $_POST['bsf_license_manager']['product_id'] ) { // phpcs:ignore:WordPress.Security.NonceVerification.Missing
$current_status = esc_attr( $_POST['bsf_license_activation']['success'] );// phpcs:ignore:WordPress.Security.NonceVerification.Missing
if ( true === $current_status || 'true' === $current_status || '1' === $current_status ) {
$current_status = 'bsf-current-license-success bsf-current-license-success-' . $product_id;
$is_active = true;
} else {
$current_status = 'bsf-current-license-error bsf-current-license-error-' . $product_id;
$is_active = false;
}
}
if ( isset( $_POST['bsf_license_activation']['message'] ) ) { // phpcs:ignore:WordPress.Security.NonceVerification.Missing
$current_message = wp_kses_post( $_POST['bsf_license_activation']['message'] );// phpcs:ignore:WordPress.Security.NonceVerification.Missing
}
$license_status = 'Active!';
$license_status_class = 'bsf-license-active-' . $product_id;
$html .= '<div class="bsf-license-key-registration">';
// License not active message.
$form_heading_status = '';
if ( false === $is_active || 'false' === $is_active ) {
$license_status = 'Not Active!';
$license_status_class = 'bsf-license-not-active-' . $product_id;
$not_activate = '';
$html .= apply_filters( "bsf_license_not_activate_message_{$product_id}", $not_activate, $license_status_class, $license_not_activate_message );
if ( true === $bsf_license_allow_email || 'true' === $bsf_license_allow_email ) {
$popup_license_subtitle = apply_filters( "bsf_license_key_form_inactive_subtitle_{$product_id}", sprintf( '<p>%s</p>', __( 'Click on the button below to activate your license and subscribe to our newsletter.', 'bsf' ) ) );
} else {
$popup_license_subtitle = apply_filters( "bsf_license_key_form_inactive_subtitle_{$product_id}", sprintf( '<p>%s</p>', __( 'Enter your purchase key and activate automatic updates.', 'bsf' ) ) );
}
} else {
$form_class .= " form-submited-{$product_id}";
$popup_license_subtitle = apply_filters( "bsf_license_key_form_active_subtitle_{$product_id}", '' );
}
do_action( "bsf_before_license_activation_form_{$product_id}" );
$html .= '<form method="post" class="' . $form_class . '" action="' . $form_action . '">';
$html .= wp_nonce_field( 'bsf_license_activation_deactivation_nonce', 'bsf_graupi_nonce', true, false );
if ( $popup_license_form ) {
$form_heading = '<h3 class="' . $license_status_class . ' ' . $license_form_heading_class . '">' . $product_name . '</h3>';
$form_heading .= $popup_license_subtitle;
} else {
$form_heading = '<h3 class="' . $license_status_class . ' ' . $license_form_heading_class . '">' . $license_form_title . '<span>' . $license_status . '</span></h3>';
}
$html .= apply_filters( "bsf_license_form_heading_{$product_id}", $form_heading, $license_status_class, $license_status );
if ( ! empty( $current_status ) && ! empty( $current_message ) ) {
$current_message = '<span class="' . $current_status . '">' . $current_message . '</span>';
$html .= apply_filters( "bsf_license_current_message_{$product_id}", $current_message );
}
if ( true === $is_active || 'true' === $is_active ) {
$licnse_active_message = __( 'Your license is active.', 'bsf' );
$licnse_active_message = apply_filters( 'bsf_license_active_message', $licnse_active_message );
$html .= '<span class="license-form-field">';
$html .= '<input type="text" readonly class="' . $license_active_class . ' ' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="' . esc_attr( $licnse_active_message ) . '"/>';
$html .= '</span>';
$html .= '<input type="hidden" class="' . $size . '-text" id="bsf_license_manager[product_id]" name="bsf_license_manager[product_id]" value="' . esc_attr( stripslashes( $product_id ) ) . '"/>';
do_action( "bsf_before_license_activation_submit_button_{$product_id}" );
$html .= '<input type="submit" class="button ' . $submit_button_class . '" name="bsf_deactivate_license" value="' . esc_attr( $button_text_deactivate ) . '"/>';
} else {
if ( true === $bsf_license_allow_email || 'true' === $bsf_license_allow_email ) {
$html .= '<span class="license-form-field">';
$html .= '<h4>Your Name</h4>';
$html .= '<input type="text" class="' . $size . '-text" id="bsf_license_manager[user_name]" name="bsf_license_manager[user_name]" value=""/>';
$html .= '</span>';
$html .= '<span class="license-form-field">';
$html .= '<h4>Your Email Address</h4>';
$html .= '<input type="email" class="' . $size . '-text" id="bsf_license_manager[user_email]" name="bsf_license_manager[user_email]" value=""/>';
$html .= '</span>';
$html .= '<span class="license-form-field">';
$html .= '<h4>Your License Key</h4>';
$html .= '<input type="text" class="' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="" autocomplete="off" required/>';
$html .= '</span>';
$html .= '<span class="license-form-field">';
$html .= '</span>';
} else {
$html .= '<span class="license-form-field">';
$html .= '<input type="text" placeholder="' . esc_attr( $placeholder ) . '" class="' . $size . '-text" id="bsf_license_manager[license_key]" name="bsf_license_manager[license_key]" value="" autocomplete="off"/>';
$html .= '</span>';
}
$html .= '<input type="hidden" class="' . $size . '-text" id="bsf_license_manager[product_id]" name="bsf_license_manager[product_id]" value="' . esc_attr( stripslashes( $product_id ) ) . '"/>';
do_action( "bsf_before_license_activation_submit_button_{$product_id}" );
$html .= '<input id="bsf-license-privacy-consent" name="bsf_license_manager[privacy_consent]" type="hidden" value="true" />';
$html .= '<input id="bsf-license-terms-conditions-consent" name="bsf_license_manager[terms_conditions_consent]" type="hidden" value="true" />';
$html .= '<div class="submit-button-wrap">';
$html .= '<input type="submit" class="button ' . $submit_button_class . '" name="bsf_activate_license" value="' . esc_attr( $button_text_activate ) . '"/>';
if ( true === $bsf_license_allow_email || 'true' === $bsf_license_allow_email ) {
$get_license_message = "<p class='purchase-license'><a target='_blank' href='$purchase_url'>Purchase License »</a></p>";
} else {
$get_license_message = "<p>If you don't have a license, you can <a target='_blank' href='$purchase_url'>get it here »</a></p>";
}
$html .= apply_filters( "bsf_get_license_message_{$product_id}", $get_license_message, $purchase_url );
$html .= '</div>';
}
$html .= '</form>';
do_action( "bsf_after_license_activation_form_{$product_id}" );
$html = apply_filters( 'bsf_inlne_license_envato_after_form', $html, $product_id );
$html .= '</div> <!-- envato-license-registration -->';
if ( isset( $_GET['debug'] ) ) { // phpcs:ignore:WordPress.Security.NonceVerification.Recommended
$html .= get_bsf_systeminfo();
}
// Output the license activation/deactivation form.
return apply_filters( "bsf_core_license_activation_form_{$product_id}", $html, $args );
}
/**
* Load Scripts
*
* @since 1.0.0
*
* @param string $hook Current Hook.
* @return void
*/
public function load_scripts( $hook = '' ) {
if ( 'plugins.php' === $hook ) {
wp_register_script( 'bsf-core-jquery-history', bsf_core_url( '/assets/js/jquery-history.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
wp_enqueue_style( 'bsf-core-license-form', bsf_core_url( '/assets/css/license-form-popup.css' ), array(), BSF_UPDATER_VERSION, 'all' );
wp_enqueue_script( 'bsf-core-license-form', bsf_core_url( '/assets/js/license-form-popup.js' ), array( 'jquery', 'bsf-core-jquery-history' ), BSF_UPDATER_VERSION, true );
}
}
/**
* Get BSF inline license form.
*
* @param array $links Links.
* @param array $args Arguments.
* @param string $license_from_type license form type.
*/
public function get_bsf_inline_license_form( $links, $args, $license_from_type ) {
$product_id = $args['product_id'];
if ( ! isset( $product_id ) ) {
return $links;
}
if ( is_multisite() && ! is_network_admin() && false === apply_filters( "bsf_core_popup_license_form_per_network_site_{$product_id}", false ) ) {
return $links;
}
$status = 'inactive';
$license_string = __( 'Activate License', 'bsf-core' );
if ( self::bsf_is_active_license( $product_id ) ) {
$status = 'active';
$license_string = __( 'License', 'bsf-core' );
}
$product_id = $args['product_id'];
// Render the license form only once on a page.
if ( array_key_exists( $product_id, self::$inline_form_products ) ) {
return $links;
}
$form_args = array(
'product_id' => $product_id,
'button_text_activate' => esc_html__( 'Activate License', 'bsf-core' ),
'button_text_deactivate' => esc_html__( 'Deactivate License', 'bsf-core' ),
'license_form_title' => '',
'license_deactivate_status' => esc_html__( 'Your license is not active!', 'bsf-core' ),
'license_activate_status' => esc_html__( 'Your license is activated!', 'bsf-core' ),
'submit_button_class' => 'bsf-product-license button-default',
'form_class' => 'form-wrap bsf-license-register-' . esc_attr( $product_id ),
'bsf_license_form_heading_class' => 'bsf-license-heading',
'bsf_license_active_class' => 'success-message',
'bsf_license_not_activate_message' => 'license-error',
'size' => 'regular',
'bsf_license_allow_email' => false,
'popup_license_form' => ( isset( $args['popup_license_form'] ) ) ? $args['popup_license_form'] : false,
'license_from_type' => $license_from_type,
);
$form_args = wp_parse_args( $args, $form_args );
self::$inline_form_products[ $product_id ] = $form_args;
$action_links = array(
'license' => '<a plugin-slug="' . esc_attr( $product_id ) . '" class="bsf-core-plugin-link bsf-core-license-form-btn ' . esc_attr( $status ) . '" aria-label="' . esc_attr( $license_string ) . '">' . esc_html( $license_string ) . '</a>',
);
return array_merge( $links, $action_links );
}
/**
* Render the markup for popup form.
*/
public function render_popup_form_markup() {
$current_screen = get_current_screen();
// Bail if not on plugins.php screen.
if ( ! is_object( $current_screen ) && null === $current_screen ) {
return;
}
if ( 'plugins' !== $current_screen->id && 'plugins-network' !== $current_screen->id ) {
return;
}
foreach ( self::$inline_form_products as $product_id => $product ) {
?>
<div plugin-slug="<?php echo esc_attr( $product_id ); ?>" class="bsf-core-license-form" style="display: none;">
<div class="bsf-core-license-form-overlay"></div>
<div class="bsf-core-license-form-inner">
<button type="button" class="bsf-core-license-form-close-btn">
<span class="screen-reader-text"><?php esc_html_e( 'Close', 'bsf-core' ); ?></span>
<span class="dashicons dashicons-no-alt"></span>
</button>
<?php
$licence_form_method = isset( $_GET['license-form-method'] ) ? sanitize_text_field( $_GET['license-form-method'] ) : ''; // phpcs:ignore:WordPress.Security.NonceVerification.Recommended
$allowed_html = array(
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
),
'br' => array(),
'em' => array(),
'strong' => array(),
'div' => array(
'class' => array(),
'id' => array(),
),
'span' => array(
'class' => array(),
'id' => array(),
),
'input' => array(
'class' => array(),
'id' => array(),
'type' => array(),
'name' => array(),
'value' => array(),
'autocomplete' => array(),
),
'p' => array(
'class' => array(),
),
'h1' => array(),
'h2' => array(),
'h3' => array(),
'h4' => array(),
'h5' => array(),
'h6' => array(),
'i' => array(),
'form' => array(
'method' => array(),
'action' => array(),
'class' => array(),
'id' => array(),
),
);
if ( 'edd' === $product['license_from_type'] || 'license-key' === $licence_form_method ) {
echo wp_kses( bsf_license_activation_form( $product ), $allowed_html );
} elseif ( 'envato' === $product['license_from_type'] || 'oauth' === $licence_form_method ) {
echo wp_kses( bsf_envato_register( $product ), $allowed_html );
}
do_action( "bsf_inlne_license_form_footer_{$product[ 'license_from_type' ]}", $product_id );
do_action( 'bsf_inlne_license_form_footer', $product_id );
// Avoid rendering the markup twice as admin_footer can be called multiple times.
unset( self::$inline_form_products[ $product_id ] );
?>
</div>
</div>
<?php
}
}
} // Class BSF_License_Manager
new BSF_License_Manager();
}
/**
* BSF License activation form.
*
* @param array $args Arguments.
*/
function bsf_license_activation_form( $args ) {
$license_manager = BSF_License_Manager::instance();
return $license_manager->license_activation_form( $args );
}
/**
* Get BSF inline license form.
*
* @param array $links Links.
* @param array $bsf_product_id BSF Product ID.
* @param string $license_from_type license form type.
*/
function get_bsf_inline_license_form( $links, $bsf_product_id, $license_from_type ) {
$license_manager = BSF_License_Manager::instance();
return $license_manager->get_bsf_inline_license_form( $links, $bsf_product_id, $license_from_type );
}

View File

@@ -0,0 +1,180 @@
<?php
/**
* BSF Rollback Version manager class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF Rollback Version manager.
*/
class BSF_Rollback_Version_Manager {
/**
* This is set for page reload cache.
*
* @var $reload_page_cache
*/
public static $reload_page_cache = 1;
/**
* Constructor function that initializes required sections.
*/
public function __construct() {
add_action( 'admin_notices', array( $this, 'bsf_download_rollback_version' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
}
/**
* Display Rollback to privious versions form.
*
* @param string $product_id Product ID.
* @since 1.0.0
*/
public function render_rollback_version_form( $product_id ) {
add_action( 'admin_footer', array( $this, 'rollback_version_popup' ) );
// Enqueue scripts only when this function is called.
wp_enqueue_script( 'bsf-core-version-rollback' );
wp_enqueue_style( 'bsf-core-version-rollback-css' );
$product_details = get_brainstorm_product( $product_id );
$installed_version = isset( $product_details['version'] ) ? $product_details['version'] : '';
$product_versions = BSF_Rollback_Version::bsf_get_product_versions( $product_id ); // Get Remote versions
// Show versions above than latest install version of the product.
$sorted_versions = BSF_Rollback_Version::sort_product_versions( $product_versions, $installed_version );
if ( empty( $sorted_versions ) ) {
echo esc_html__( 'No Versions Found! ', 'bsf-core' );
return;
}
$product_name = isset( $product_details['name'] ) ? $product_details['name'] : '';
$white_label_name = bsf_get_white_lable_product_name( $product_id, $product_name );
?>
<div class="bsf-rollback-version">
<input type="hidden" name="product-name" id="bsf-product-name" value="<?php echo esc_attr( $white_label_name ); ?>">
<select class="bsf-rollback-version-select">
<?php
foreach ( $sorted_versions as $version ) {
?>
<option value="<?php echo esc_attr( $version ); ?>"><?php echo esc_html( $version ); ?> </option>
<?php
}
?>
</select>
<a data-placeholder-text=" <?php echo esc_html__( 'Rollback', 'bsf-core' ); ?>" href="<?php echo esc_url( add_query_arg( 'version_no', $sorted_versions[0], wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&product_id=' . $product_id ), 'bsf_rollback' ) ) ); ?>"
data-placeholder-url="<?php echo esc_url( wp_nonce_url( admin_url( 'index.php?action=bsf_rollback&version_no=VERSION&product_id=' . $product_id ), 'bsf_rollback' ) ); ?>" class="button bsf-rollback-button"><?php echo esc_html__( 'Rollback', 'bsf-core' ); ?> </a>
</div>
<?php
}
/**
* Download Product Version.
*/
public function bsf_download_rollback_version() {
if ( ! current_user_can( 'update_plugins' ) ) {
return false;
}
if ( empty( $_GET['version_no'] ) || empty( $_GET['product_id'] ) || ! isset( $_GET['action'] ) ) {
return false;
}
check_admin_referer( 'bsf_rollback' );
$bsf_update_manager = new BSF_Update_Manager();
$version_no = sanitize_text_field( $_GET['version_no'] );
$product_id = sanitize_text_field( $_GET['product_id'] );
$product_details = get_brainstorm_product( $product_id );
$plugin_slug = ! empty( $product_details['slug'] ) ? $product_details['slug'] : '';
$plugin_name = ! empty( $product_details['template'] ) ? $product_details['template'] : '';
$bundled_plugin_name = ! empty( $product_details['init'] ) ? $product_details['init'] : '';
$purchase_key = $bsf_update_manager->get_purchse_key( $product_id );
$product_title = ! empty( $product_details['name'] ) ? $product_details['name'] : '';
$plugin_name = ! empty( $plugin_name ) ? $plugin_name : $bundled_plugin_name;
$download_params = array(
'version_no' => $version_no,
'purchase_key' => $purchase_key,
'site_url' => get_site_url(),
);
$download_url = bsf_get_api_site( false, true ) . 'download/' . $product_id . '?' . http_build_query( $download_params );
$rollback = new BSF_Rollback_Version(
array(
'version' => $version_no,
'plugin_name' => $plugin_name,
'plugin_slug' => $plugin_slug,
'package_url' => $download_url,
'product_title' => $product_title,
'product_id' => $product_id,
)
);
$rollback->run();
// Delete product versions transient data after update.
bsf_clear_versions_cache( $product_id );
wp_die();
}
/**
* Load Scripts
*
* @since 1.0.0
*
* @param string $hook Current Hook.
* @return void
*/
public function load_scripts( $hook = '' ) {
wp_register_script( 'bsf-core-version-rollback', bsf_core_url( '/assets/js/version-rollback.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
wp_register_style( 'bsf-core-version-rollback-css', bsf_core_url( '/assets/css/rollback-version.css' ), array(), BSF_UPDATER_VERSION );
}
/**
* Version rollback Confirmation popup.
*
* @since 1.0.0
*/
public function rollback_version_popup() {
// This is set to fix the duplicate markup on page load.
if ( 1 !== self::$reload_page_cache ) {
return;
}
self::$reload_page_cache = 0;
?>
<div class="bsf-confirm-rollback-popup" style="display:none;">
<div class="bsf-core-rollback-overlay"></div>
<div class="bsf-confirm-rollback-popup-content">
<h3 class="bsf-rollback-heading bsf-confirm-heading" data-text="<?php esc_html_e( 'Rollback #PRODUCT_NAME# Version', 'bsf-core' ); ?>"></h3>
<p class="bsf-confirm-text bsf-rollback-text" data-text="<?php esc_html_e( 'Are you sure you want to rollback #PRODUCT_NAME# to version #VERSION#?', 'bsf-core' ); ?>" ></p>
<div class="bsf-confirm-rollback-popup-buttons-wrapper">
<button class="button bsf-product-license button-default bsf-confirm-cancel"><?php esc_html_e( 'Cancel', 'bsf-core' ); ?></button>
<button class="button button-primary bsf-confirm-ok"><?php esc_html_e( 'Continue', 'bsf-core' ); ?></button>
</div>
</div>
</div>
<?php
}
}
new BSF_Rollback_Version_Manager();
/**
* Render Rollback versoin form.
*
* @param string $product_id Product ID.
*/
function bsf_get_version_rollback_form( $product_id ) {
if ( ! bsf_display_rollback_version_form( $product_id ) ) {
return false;
}
$instance = new BSF_Rollback_Version_Manager();
$instance->render_rollback_version_form( $product_id );
}

View File

@@ -0,0 +1,720 @@
<?php
/**
* BSF Analytics Stats
*
* @package BSF_Core
*/
/**
* Delete these transients/options for debugging
* set_site_transient( 'update_plugins', null );
* set_site_transient( 'update_themes', null );
* delete_option( 'brainstrom_products' );
*/
if ( ! class_exists( 'BSF_Update_Manager' ) ) {
/**
* Update Manager Class
*
* @class BSF_Update_Manager
*/
class BSF_Update_Manager {
/**
* Constructor function that initializes required sections
*/
public function __construct() {
// update data to WordPress's transient.
add_filter(
'pre_set_site_transient_update_plugins',
array(
$this,
'brainstorm_update_plugins_transient',
)
);
add_filter( 'pre_set_site_transient_update_themes', array( $this, 'brainstorm_update_themes_transient' ) );
// display changelog in update details.
add_filter( 'plugins_api', array( $this, 'bsf_get_plugin_information' ), 10, 3 );
// display correct error messages.
add_action( 'load-plugins.php', array( $this, 'bsf_update_display_license_link' ) );
add_filter( 'upgrader_pre_download', array( $this, 'modify_download_package_message' ), 20, 3 );
add_action( 'bsf_get_plugin_information', array( $this, 'plugin_information' ) );
}
/**
* Function to update plugin's transient.
*
* @param obj $_transient_data Transient Data.
* @return $_transient_data.
*/
public function brainstorm_update_plugins_transient( $_transient_data ) {
global $pagenow;
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new stdClass();
}
$update_data = $this->bsf_update_transient_data( 'plugins' );
foreach ( $update_data as $key => $product ) {
if ( isset( $product['template'] ) && '' !== $product['template'] ) {
$template = $product['template'];
} elseif ( isset( $product['init'] ) && '' !== $product['init'] ) {
$template = $product['init'];
}
if ( isset( $_transient_data->response[ $template ] ) ) {
continue;
}
if ( false === $this->enable_auto_updates( $product['id'] ) ) {
continue;
}
$plugin = new stdClass();
$plugin->id = isset( $product['id'] ) ? $product['id'] : '';
$plugin->slug = $this->bsf_get_plugin_slug( $template );
$plugin->plugin = isset( $template ) ? $template : '';
$plugin->upgrade_notice = '';
if ( $this->use_beta_version( $plugin->id ) ) {
$plugin->new_version = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
$plugin->upgrade_notice .= 'It is recommended to use the beta version on a staging enviornment only.';
} else {
$plugin->new_version = isset( $product['remote'] ) ? $product['remote'] : '';
}
$plugin->url = isset( $product['purchase_url'] ) ? $product['purchase_url'] : '';
if ( BSF_License_Manager::bsf_is_active_license( $product['id'] ) === true ) {
$plugin->package = $this->bsf_get_package_uri( $product['id'] );
} else {
$plugin->package = '';
$bundled = self::bsf_is_product_bundled( $plugin->id );
if ( ! empty( $bundled ) ) {
$parent_id = $bundled[0];
$parent_name = brainstrom_product_name( $parent_id );
$plugin->upgrade_notice = 'This plugin is came bundled with the ' . $parent_name . '. For receiving updates, you need to register license of ' . $parent_name . '.';
} else {
$plugin->upgrade_notice .= ' Please activate your license to receive automatic updates.';
}
}
$plugin->tested = isset( $product['tested'] ) ? $product['tested'] : '';
$plugin->requires_php = isset( $product['php_version'] ) ? $product['php_version'] : '';
$plugin->icons = apply_filters(
"bsf_product_icons_{$product['id']}",
array(
'1x' => ( isset( $product['product_image'] ) ) ? $product['product_image'] : '',
'2x' => ( isset( $product['product_image'] ) ) ? $product['product_image'] : '',
'default' => ( isset( $product['product_image'] ) ) ? $product['product_image'] : '',
)
);
$_transient_data->last_checked = time();
$_transient_data->response[ $template ] = $plugin;
}
return $_transient_data;
}
/**
* Function to update theme's transient.
*
* @param obj $_transient_data Transient Data.
* @return $_transient_data.
*/
public function brainstorm_update_themes_transient( $_transient_data ) {
global $pagenow;
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new stdClass();
}
if ( 'themes.php' !== $pagenow && 'update-core.php' !== $pagenow ) {
return $_transient_data;
}
$update_data = $this->bsf_update_transient_data( 'themes' );
foreach ( $update_data as $key => $product ) {
if ( false === $this->enable_auto_updates( $product['id'] ) ) {
continue;
}
if ( isset( $product['template'] ) && '' !== $product['template'] ) {
$template = $product['template'];
}
$themes = array();
$themes['theme'] = isset( $template ) ? $template : '';
if ( $this->use_beta_version( $product['id'] ) ) {
$themes['new_version'] = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
} else {
$themes['new_version'] = isset( $product['remote'] ) ? $product['remote'] : '';
}
$themes['url'] = isset( $product['purchase_url'] ) ? $product['purchase_url'] : '';
if ( BSF_License_Manager::bsf_is_active_license( $product['id'] ) === true ) {
$themes['package'] = $this->bsf_get_package_uri( $product['id'] );
} else {
$themes['package'] = '';
$themes['upgrade_notice'] = 'Please activate your license to receive automatic updates.';
}
$_transient_data->last_checked = time();
if ( isset( $template ) ) {
$_transient_data->response[ $template ] = $themes;
}
}
return $_transient_data;
}
/**
* Allow autoupdates to be enabled/disabled per product basis.
*
* @param String $product_id - Product ID.
* @return boolean True - IF updates are to be enabled. False if updates are to be disabled.
*/
private function enable_auto_updates( $product_id ) {
return apply_filters( "bsf_enable_product_autoupdates_{$product_id}", true );
}
/**
*
* Updates information on the "View version x.x details" page with custom data.
*
* @uses api_request()
*
* @param mixed $_data Data.
* @param string $_action Action.
* @param object $_args Arguments.
*
* @return object $_data
*/
public function bsf_get_plugin_information( $_data, $_action = '', $_args = null ) {
if ( 'plugin_information' !== $_action ) {
return $_data;
}
$brainstrom_products = apply_filters( 'bsf_get_plugin_information', get_option( 'brainstrom_products', array() ) );
$plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$all_products = $plugins + $themes;
foreach ( $all_products as $key => $product ) {
$product_slug = isset( $product['slug'] ) ? $product['slug'] : '';
if ( $product_slug === $_args->slug ) {
$id = isset( $product['id'] ) ? $product['id'] : '';
$info = new stdClass();
if ( $this->use_beta_version( $id ) ) {
$info->new_version = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
} else {
$info->new_version = isset( $product['remote'] ) ? $product['remote'] : '';
}
$product_name = isset( $product['name'] ) ? $product['name'] : '';
$info->name = bsf_get_white_lable_product_name( $id, $product_name );
$info->slug = $product_slug;
$info->version = isset( $product['remote'] ) ? $product['remote'] : '';
$info->author = apply_filters( "bsf_product_author_{$id}", 'Brainstorm Force' );
$info->url = isset( $product['changelog_url'] ) ? apply_filters( "bsf_product_url_{$id}", $product['changelog_url'] ) : apply_filters( "bsf_product_url_{$id}", '' );
$info->homepage = isset( $product['purchase_url'] ) ? apply_filters( "bsf_product_homepage_{$id}", $product['purchase_url'] ) : apply_filters( "bsf_product_homepage_{$id}", '' );
if ( BSF_License_Manager::bsf_is_active_license( $id ) === true ) {
$package_url = $this->bsf_get_package_uri( $id );
$info->package = $package_url;
$info->download_link = $package_url;
}
$info->sections = array();
$product_decription = isset( $product['description'] ) ? $product['description'] : '';
$info->sections['description'] = apply_filters( "bsf_product_description_{$id}", $product_decription );
$product_changelog = 'Thank you for using ' . $info->name . '. </br></br>To make your experience using ' . $info->name . ' better we release updates regularly, you can view the full changelog <a href="' . $info->url . '">here</a>';
$info->sections['changelog'] = apply_filters( "bsf_product_changelog_{$id}", $product_changelog );
$_data = $info;
}
}
return $_data;
}
/**
* Check if product is bundled.
*
* @param array $bsf_product Product.
* @param string $search_by Search By.
* @return $product_parent.
*/
public static function bsf_is_product_bundled( $bsf_product, $search_by = 'id' ) {
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
$product_parent = array();
foreach ( $brainstrom_bundled_products as $parent => $products ) {
foreach ( $products as $key => $product ) {
if ( 'init' === $search_by ) {
if ( $product->init === $bsf_product ) {
$product_parent[] = $parent;
}
} elseif ( 'id' === $search_by ) {
if ( $product->id === $bsf_product ) {
$product_parent[] = $parent;
}
} elseif ( 'name' === $search_by ) {
if ( strcasecmp( $product->name, $bsf_product ) === 0 ) {
$product_parent[] = $parent;
}
}
}
}
$product_parent = apply_filters( 'bsf_is_product_bundled', array_unique( $product_parent ), $bsf_product, $search_by );
return $product_parent;
}
/**
* Get package URL
*
* @param int $product_id Product Id.
* @return string $download_path.
*/
public function bsf_get_package_uri( $product_id ) {
$product = get_brainstorm_product( $product_id );
$status = BSF_License_Manager::bsf_is_active_license( $product_id );
$download_path = '';
$parent_product = isset( $product['parent'] ) ? $product['parent'] : '';
if ( $this->use_beta_version( $product_id ) ) {
$version = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
} else {
$version = isset( $product['remote'] ) ? $product['remote'] : '';
}
if ( '' !== $version && false !== $status ) {
$bundled_product = self::bsf_is_product_bundled( $product_id );
$purchase_key = $this->get_purchse_key( $product_id );
$is_bundled = ( ! empty( $bundled_product ) ) ? '1' : '0';
$download_params = array(
'version_no' => $version,
'purchase_key' => $purchase_key,
'site_url' => get_site_url(),
'is_bundled' => $is_bundled,
'parent_product' => $parent_product,
);
$download_path = bsf_get_api_site( false, true ) . 'download/' . $product_id . '?' . http_build_query( $download_params );
// Clear Product versions from transient after update.
bsf_clear_versions_cache( $product_id );
return $download_path;
}
return $download_path;
}
/**
* Update transient Data.
*
* @param string $product_type Product Type.
* @return $update_required.
*/
public function bsf_update_transient_data( $product_type ) {
$this->maybe_force_check_bsf_product_updates();
$all_products = array();
$update_required = array();
if ( 'plugins' === $product_type ) {
$all_products = $this->prepare_plugins_for_update( brainstorm_get_all_products( false, true, false ) );
}
if ( 'themes' === $product_type ) {
$all_products = brainstorm_get_all_products( true, false, true );
}
foreach ( $all_products as $key => $product ) {
$product_id = isset( $product['id'] ) ? $product['id'] : '';
$constant = strtoupper( str_replace( '-', '_', $product_id ) );
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
if ( defined( $constant ) && ( constant( $constant ) === 'false' || constant( $constant ) === false ) ) {
continue;
}
$remote = isset( $product['remote'] ) ? $product['remote'] : '';
$local = isset( $product['version'] ) ? $product['version'] : '';
$version_beta = isset( $product['version_beta'] ) ? $product['version_beta'] : $remote;
if ( $this->use_beta_version( $product_id ) ) {
$remote = $version_beta;
}
if ( version_compare( $remote, $local, '>' ) ) {
array_push( $update_required, $product );
}
}
return $update_required;
}
/**
* Remove plugins from the updates array which are not installed.
*
* @param Array $plugins Plugins.
* @return Array of plugins.
*/
public static function prepare_plugins_for_update( $plugins ) {
foreach ( $plugins as $key => $plugin ) {
if ( isset( $plugin['template'] ) && ! file_exists( dirname( realpath( WP_PLUGIN_DIR . '/' . $plugin['template'] ) ) ) ) {
unset( $plugins[ $key ] );
}
if ( isset( $plugin['init'] ) && ! file_exists( dirname( realpath( WP_PLUGIN_DIR . '/' . $plugin['init'] ) ) ) ) {
unset( $plugins[ $key ] );
}
}
return $plugins;
}
/**
* Force check BSF Product updates.
*/
public function maybe_force_check_bsf_product_updates() {
if ( true === bsf_time_since_last_versioncheck( 2, 'bsf_last_update_check' ) ) {
global $ultimate_referer;
$ultimate_referer = 'on-transient-delete-2-hours';
bsf_check_product_update();
update_option( 'bsf_last_update_check', (string) current_time( 'timestamp' ) );
}
}
/**
* Use Beta version.
*
* @param int $product_id Product ID.
* @return bool.
*/
public function use_beta_version( $product_id ) {
$product = get_brainstorm_product( $product_id );
$stable = isset( $product['remote'] ) ? $product['remote'] : '';
$beta = isset( $product['version_beta'] ) ? $product['version_beta'] : '';
// If beta version is not set, return.
if ( '' === $beta ) {
return false;
}
if ( version_compare( $stable, $beta, '<' ) &&
self::bsf_allow_beta_updates( $product_id ) ) {
return true;
}
return false;
}
/**
* Beta version normalized.
*
* @param array $beta Beta.
* @return $version.
*/
public function beta_version_normalized( $beta ) {
$beta_explode = explode( '-', $beta );
$version = $beta_explode[0] . '.' . str_replace( 'beta', '', $beta_explode[1] );
return $version;
}
/**
* Allow Beta updates.
*
* @param array $product_id Product ID.
* @return bool.
*/
public static function bsf_allow_beta_updates( $product_id ) {
return apply_filters( "bsf_allow_beta_updates_{$product_id}", false );
}
/**
* Get Plugin's slug.
*
* @param array $template Template.
* @return $slug.
*/
public function bsf_get_plugin_slug( $template ) {
$slug = explode( '/', $template );
if ( isset( $slug[0] ) ) {
return $slug[0];
}
return '';
}
/**
* Update display license link.
*/
public function bsf_update_display_license_link() {
$brainstorm_all_products = $this->brainstorm_all_products();
foreach ( $brainstorm_all_products as $key => $product ) {
if ( isset( $product['id'] ) ) {
$id = $product['id'];
if ( isset( $product['template'] ) && '' !== $product['template'] ) {
$template = $product['template'];
} elseif ( isset( $product['init'] ) && '' !== $product['init'] ) {
$template = $product['init'];
}
if ( BSF_License_Manager::bsf_is_active_license( $id ) === false ) {
if ( is_plugin_active( $template ) ) {
add_action(
"in_plugin_update_message-$template",
array(
$this,
'bsf_add_registration_message',
),
9,
2
);
}
} else {
add_action(
"in_plugin_update_message-$template",
array(
$this,
'add_beta_update_message',
),
9,
2
);
}
}
}
}
/**
* Brainstorm All Products.
*/
public function brainstorm_all_products() {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_products_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstrom_products_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
$bundled = array();
foreach ( $brainstrom_bundled_products as $parent => $children ) {
foreach ( $children as $key => $product ) {
$bundled[ $product->id ] = (array) $product;
}
}
// array of all the products.
$all_products = $brainstrom_products_plugins + $brainstrom_products_themes + $bundled;
return $all_products;
}
/**
* Add Registration message.
*
* @param array $plugin_data Plugin data.
* @param array $response Response.
*/
public function bsf_add_registration_message( $plugin_data, $response ) {
$plugin_init = isset( $plugin_data['plugin'] ) ? $plugin_data['plugin'] : '';
if ( '' !== $plugin_init ) {
$product_id = brainstrom_product_id_by_init( $plugin_init );
$bundled = self::bsf_is_product_bundled( $plugin_init, 'init' );
$registration_page = bsf_registration_page_url( '', $product_id );
} else {
$plugin_name = isset( $plugin_data['name'] ) ? $plugin_data['name'] : '';
$product_id = brainstrom_product_id_by_name( $plugin_name );
$bundled = self::bsf_is_product_bundled( $plugin_name, 'name' );
$registration_page = bsf_registration_page_url( '', $product_id );
}
if ( ! empty( $bundled ) ) {
$parent_id = $bundled[0];
$registration_page = bsf_registration_page_url( '', $parent_id );
$parent_name = bsf_get_white_lable_product_name( $parent_id, brainstrom_product_name( $parent_id ) );
/* translators: %1$s: $parent_name %2%s: $registration_page */
$message = sprintf( __( ' <br>This plugin is came bundled with the <i>%1$s</i>. For receiving updates, you need to register license of <i>%2$s</i> <a href="%3$s">here</a>.', 'bsf' ), $parent_name, $parent_name, $registration_page );
} else {
/* translators: %1$s: $registration_page %2%s: search term */
$message = sprintf( ' <i>%s</i>', sprintf( __( 'Please <a href="%1$s">activate your license</a> to update the plugin.', 'bsf' ), $registration_page ) );
}
if ( true === self::bsf_allow_beta_updates( $product_id ) && $this->is_beta_version( $plugin_data['new_version'] ) ) {
$message = $message . ' <i>It is recommended to use the beta version on a staging enviornment only.</i>';
}
echo wp_kses_post( $message );
}
/**
* Add Beta update message.
*
* @param array $plugin_data plugin data.
* @param array $response Response.
*/
public function add_beta_update_message( $plugin_data, $response ) {
$plugin_init = isset( $plugin_data['plugin'] ) ? $plugin_data['plugin'] : '';
if ( '' !== $plugin_init ) {
$product_id = brainstrom_product_id_by_init( $plugin_init );
} else {
$product_id = brainstrom_product_id_by_name( $plugin_name );
}
if ( true === self::bsf_allow_beta_updates( $product_id ) && $this->is_beta_version( $plugin_data['new_version'] ) ) {
echo ' <i>It is recommended to use the beta version on a staging enviornment only.</i>';
}
}
/**
* Is Beta version
*
* @param string $version Version.
* @return bool.
*/
private function is_beta_version( $version ) {
return strpos( $version, 'beta' ) ||
strpos( $version, 'alpha' );
}
/**
* Modify download package message to hide download URL.
*
* @param string $reply Reply.
* @param string $package Package.
* @param string $current Current.
* @return string $reply.
*/
public function modify_download_package_message( $reply, $package, $current ) {
// Read atts into separate veriables so that easy to reference below.
$strings = $current->strings;
if ( isset( $current->skin->plugin_info ) ) {
$plugin_info = $current->skin->plugin_info;
if ( ( isset( $plugin_info['author'] ) && 'Brainstorm Force' === $plugin_info['author'] ) || ( isset( $plugin_info['AuthorName'] ) && 'Brainstorm Force' === $plugin_info['AuthorName'] ) ) {
$strings['downloading_package'] = __( 'Downloading the update...', 'bsf-core' );
}
} elseif ( isset( $current->skin->theme_info ) ) {
$theme_info = $current->skin->theme_info;
$theme_author = $theme_info->get( 'Author' );
if ( 'Brainstorm Force' === $theme_author ) {
$strings['downloading_package'] = __( 'Downloading the update...', 'bsf-core' );
}
} elseif ( isset( $_GET['action'] ) && 'bsf_rollback' === $_GET['action'] && check_admin_referer( 'bsf_rollback' ) ) {
// In case of rollback version.
$strings['downloading_package'] = __( 'Downloading the update...', 'bsf-core' );
}
// restore the strings back to WP_Upgrader.
$current->strings = $strings;
// We are not changing teh return parameter.
return $reply;
}
/**
* Install Pluigns Filter
*
* Add brainstorm bundle products in plugin installer list though filter.
*
* @since 1.0.0
*
* @param array $brainstrom_products Brainstorm Products.
* @return array Brainstorm Products merged with Brainstorm Bundle Products.
*/
public function plugin_information( $brainstrom_products = array() ) {
$main_products = (array) get_option( 'brainstrom_bundled_products', array() );
foreach ( $main_products as $single_product_key => $single_product ) {
foreach ( $single_product as $bundle_product_key => $bundle_product ) {
if ( is_object( $bundle_product ) ) {
$type = $bundle_product->type;
$slug = $bundle_product->slug;
} else {
$type = $bundle_product['type'];
$slug = $bundle_product['slug'];
}
// Add bundled plugin in installer list.
if ( 'plugin' === $type ) {
$brainstrom_products['plugins'][ $slug ] = (array) $bundle_product;
}
}
}
return $brainstrom_products;
}
/**
* Get the prurchase key for product download API.
* If the product is bundeled then return it's parent product purchase key.
*
* @param string $product_id Product ID.
* @return string Purchase Key.
*/
public function get_purchse_key( $product_id ) {
$all_products = brainstorm_get_all_products();
$is_bundled = self::bsf_is_product_bundled( $product_id );
$product = isset( $all_products[ $product_id ] ) ? $all_products[ $product_id ] : array();
if ( ! empty( $is_bundled ) ) {
$product = isset( $all_products[ $product['parent'] ] ) ? $all_products[ $product['parent'] ] : array();
}
return isset( $product['purchase_key'] ) ? $product['purchase_key'] : '';
}
} // class BSF_Update_Manager
new BSF_Update_Manager();
}

View File

@@ -0,0 +1,113 @@
<?php
/**
* WP CLI Commands to manage Brainstorm Force products.
*
* @package bsf-core
*/
/**
* Class BSF_WP_CLI_Command
*/
class BSF_WP_CLI_Command extends WP_CLI_Command {
/**
* BSF_License Manager instance.
*
* @var $license_manager
*/
private $license_manager = '';
/**
* Initiator.
*/
public function __construct() {
$this->license_manager = new BSF_License_Manager();
}
/**
* WP CLI Command to activate and deactivate licenses for brainstormforce products.
*
* ## OPTIONS
*
* <action>
* activate or deactivate
*
* <priduct-id>
* Product id is unique for each brainstorm product, it can be found in the file <product-root-directory>/admin/.bsf.yml
*
* <license-key>
* Your purchase key.
*
* ## EXAMPLES
*
* 1. wp brainstormforce license activate uabb <purchase-key>
* - This will activate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
* 2. wp brainstormforce license deactivate uabb <purchase-key>
* - This will deactivate the license for plugin Ultimate Addons for beaver builder with purchase key <purchase-key>
*
* @param array $args Arguments.
* @param array $assoc_args Associative Arguments.
*/
public function license( $args, $assoc_args ) {
if ( isset( $args[0] ) && 'activate' === $args[0] || 'deactivate' === $args[0] ) {
$action = $args[0];
} else {
WP_CLI::error( 'Please enter the correct action.' );
}
if ( isset( $args[1] ) ) {
$poduct_id = $args[1];
} else {
WP_CLI::error( 'Please enter a product id.' );
}
if ( isset( $args[2] ) ) {
$purchase_key = $args[2];
} else {
WP_CLI::error( 'Please enter the purchase key.' );
}
// Setup brainstorm_products data.
init_bsf_core();
$_POST = array(
'bsf_license_manager' => array(
'license_key' => $purchase_key,
'product_id' => $poduct_id,
),
);
$bsf_action = '';
if ( 'activate' === $action ) {
$bsf_action = 'bsf_license_activation';
$_POST['bsf_activate_license'] = true;
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
$this->license_manager->bsf_activate_license();
} else {
$bsf_action = 'bsf_license_deactivation';
$_POST['bsf_deactivate_license'] = true;
$_POST['bsf_graupi_nonce'] = wp_create_nonce( 'bsf_license_activation_deactivation_nonce' );
$this->license_manager->bsf_deactivate_license();
}
if ( '' !== $bsf_action ) {
if ( isset( $_POST[ $bsf_action ]['success'] ) && ( true === $_POST[ $bsf_action ]['success'] || 'true' === $_POST[ $bsf_action ]['success'] ) && isset( $_POST['bsf_graupi_nonce'] ) && wp_verify_nonce( $_POST['bsf_graupi_nonce'], 'bsf_license_activation_deactivation_nonce' ) ) {
$success_message = esc_attr( $_POST[ $bsf_action ]['message'] );
WP_CLI::success( $success_message );
} else {
$error_message = esc_attr( $_POST[ $bsf_action ]['message'] );
WP_CLI::error( $error_message );
}
}
}
}
if ( class_exists( 'WP_CLI' ) ) {
WP_CLI::add_command( 'brainstormforce', 'BSF_WP_CLI_Command' );
}

View File

@@ -0,0 +1,117 @@
<?php
/**
* BSF Core REST API
*
* @package bsf-core
*/
/**
* License Activation/Deactivation REST API.
*/
class Bsf_Core_Rest {
/**
* Member Variable
*
* @var instance
*/
private static $instance;
/**
* The namespace of this controller's route.
*
* @var string
*/
public $namespace;
/**
* The base of this controller's route.
*
* @var string
*/
public $rest_base;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor.
*/
public function __construct() {
$this->namespace = 'bsf-core/v1';
$this->rest_base = '/license';
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
}
/**
* Register the routes for the objects of the controller.
*/
public function register_routes() {
register_rest_route(
$this->namespace,
$this->rest_base . '/activate',
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $this, 'activate_license' ),
'permission_callback' => array( $this, 'get_items_permissions_check' ),
'args' => array(
'product-id' => array(
'type' => 'string',
'required' => true,
'sanitize_callback' => 'sanitize_text_field',
),
'license-key' => array(
'type' => 'string',
'required' => true,
'sanitize_callback' => 'sanitize_text_field',
),
),
)
);
}
/**
* Check if a given request has access to activate license.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_Error|boolean
*/
public function get_items_permissions_check( $request ) {
if ( current_user_can( 'manage_options' ) ) {
return true;
}
return false;
}
/**
* Activate License Key.
*
* @param WP_REST_Request $request Full details about the request.
* @return WP_REST_Response Rest Response with access key.
*/
public function activate_license( $request ) {
$product_id = $request->get_param( 'product-id' );
$license_key = $request->get_param( 'license-key' );
$data = array(
'privacy_consent' => true,
'terms_conditions_consent' => true,
'product_id' => $product_id,
'license_key' => $license_key,
);
return rest_ensure_response( BSF_License_Manager::instance()->bsf_process_license_activation( $data ) );
}
}
Bsf_Core_Rest::get_instance();

View File

@@ -0,0 +1,98 @@
<?php
/**
* BSF Core Update
*
* @package Astra
* @author Astra
* @copyright Copyright (c) 2020, Astra
* @link http://wpastra.com/
* @since Astra 1.0.0
*/
if ( ! class_exists( 'BSF_Core_Update' ) ) {
/**
* BSF_Core_Update initial setup
*
* @since 1.0.0
*/
class BSF_Core_Update {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
// Theme Updates.
add_action( 'admin_init', __CLASS__ . '::init', 0 );
add_filter( 'all_plugins', array( $this, 'update_products_slug' ), 10, 1 );
}
/**
* Implement theme update logic.
*
* @since 1.0.0
*/
public static function init() {
do_action( 'astra_update_before' );
// Get auto saved version number.
$saved_version = get_option( 'bsf-updater-version', false );
// If equals then return.
if ( version_compare( $saved_version, BSF_UPDATER_VERSION, '=' ) ) {
return;
}
// // Update auto saved version number.
update_option( 'bsf-updater-version', BSF_UPDATER_VERSION );
do_action( 'astra_update_after' );
}
/**
* Update bsf product slug in WP installed plugins data which will be used in enable/disablestaged updates products.
*
* @param array $plugins All installed plugins.
*
* @return array
*/
public function update_products_slug( $plugins ) {
$bsf_products = bsf_get_brainstorm_products( true );
foreach ( $bsf_products as $product => $data ) {
$plugin_file = isset( $data['template'] ) ? sanitize_text_field( $data['template'] ) : '';
if ( isset( $plugins[ $plugin_file ] ) && ! empty( $data['slug'] ) ) {
$plugins[ $plugin_file ]['slug'] = $data['slug'];
}
}
return $plugins;
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
BSF_Core_Update::get_instance();

View File

@@ -0,0 +1,89 @@
<?php
/**
* BSF extension installer class file.
*
* @package bsf-core
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF_Extension_Installer Extension installer.
*/
class BSF_Extension_Installer {
/**
* Constructor
*/
public function __construct() {
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ) );
add_action( 'wp_ajax_bsf-extention-activate', array( $this, 'activate_plugin' ) );
}
/**
* Load scripts needed for extension installer.
*
* @param hook $hook current page hook.
* @return void
*/
public function load_scripts( $hook ) {
$bsf_ext_inst = apply_filters( 'bsf_extension_installer_screens', array( 'bsf-extensions' ), $hook );
foreach ( $bsf_ext_inst as $key => $value ) {
if ( false !== strpos( $hook, $value ) ) {
wp_register_script( 'bsf-extension-installer', bsf_core_url( '/assets/js/extension-installer.js' ), array( 'jquery', 'wp-util', 'updates' ), BSF_UPDATER_VERSION, true );
wp_enqueue_script( 'bsf-extension-installer' );
}
}
}
/**
* Activates plugin.
*
* @return void
*/
public function activate_plugin() {
if ( ! wp_verify_nonce( $_POST['security'], 'bsf_activate_extension_nonce' ) ) {
wp_send_json_error(
array(
'success' => false,
'message' => __( 'You are not authorized to perform this action.', 'bsf' ),
)
);
}
if ( ! current_user_can( 'install_plugins' ) || ! isset( $_POST['init'] ) || ! $_POST['init'] ) {
wp_send_json_error(
array(
'success' => false,
'message' => __( 'No plugin specified', 'bsf' ),
)
);
}
$plugin_init = ( isset( $_POST['init'] ) ) ? esc_attr( $_POST['init'] ) : '';
$activate = activate_plugin( $plugin_init, '', false, true );
if ( is_wp_error( $activate ) ) {
wp_send_json_error(
array(
'success' => false,
'message' => $activate->get_error_message(),
)
);
}
wp_send_json_success(
array(
'success' => true,
'message' => __( 'Plugin Activated', 'bsf' ),
)
);
}
}
new BSF_Extension_Installer();

View File

@@ -0,0 +1,242 @@
<?php
/**
* BSF Rollback Version
*
* @package bsf-core
* @author Brainstorm Force
* @link http://wpastra.com/
*/
/**
* BSF_Core_Update initial setup
*/
class BSF_Rollback_Version {
/**
* Package URL.
*
* Holds the package URL.
* This will be the actual download URL od zip file.
*
* @access protected
*
* @var string Package URL.
*/
protected $package_url;
/**
* Product URL.
*
* @access protected
* @var string Product URL.
*/
protected $product_url;
/**
* Version.
*
* Holds the version.
*
* @access protected
*
* @var string Package URL.
*/
protected $version;
/**
* Plugin name.
*
* Holds the plugin name.
*
* @access protected
*
* @var string Plugin name.
*/
protected $plugin_name;
/**
* Plugin slug.
*
* Holds the plugin slug.
*
* @access protected
*
* @var string Plugin slug.
*/
protected $plugin_slug;
/**
* Product Title.
*
* Holds the Product Title.
*
* @access protected
*
* @var string Plugin Title.
*/
protected $product_title;
/**
* HOlds the Product ID.
*
* @access protected
* @var string Product ID.
*/
protected $product_id;
/**
*
* Initializing Rollback.
*
* @access public
*
* @param array $args Optional.Rollback arguments. Default is an empty array.
*/
public function __construct( $args = array() ) {
foreach ( $args as $key => $value ) {
$this->{$key} = $value;
}
}
/**
* Apply package.
*
* @since 1.0.0
* @access protected
*/
protected function apply_package() {
$update_products = get_site_transient( 'update_plugins' );
if ( ! is_object( $update_products ) ) {
$update_products = new stdClass();
}
$product_info = new stdClass();
$product_info->new_version = $this->version;
$product_info->slug = $this->plugin_slug;
$product_info->package = $this->package_url; // This will be the actual download URL of zip file..
$product_info->url = $this->product_url;
$update_products->response[ $this->plugin_name ] = $product_info;
set_site_transient( 'update_plugins', $update_products );
}
/**
* Upgrade.
*
* Run WordPress upgrade to Rollback to previous version.
*
* @since 1.0.0
* @access protected
*/
protected function upgrade() {
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader_args = array(
'url' => 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $this->plugin_name ),
'plugin' => $this->plugin_name,
'nonce' => 'upgrade-plugin_' . $this->plugin_name,
'title' => apply_filters( 'bsf_rollback_' . $this->product_id . '_title', '<h1>Rollback ' . bsf_get_white_lable_product_name( $this->product_id, $this->product_title ) . ' to version ' . $this->version . ' </h1>' ),
);
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( $upgrader_args ) );
$upgrader->upgrade( $this->plugin_name );
}
/**
*
* Rollback to previous versions.
*
* @since 1.0.0
* @access public
*/
public function run() {
$this->apply_package();
$this->upgrade();
}
/**
* Get All versions of product.
*
* @param string $product_id Product ID.
*/
public static function bsf_get_product_versions( $product_id ) {
if ( empty( $product_id ) ) {
return array();
}
// Check is transient is expire or User has Enalbed/Disabled the beta version.
$versions_transient = get_site_transient( 'bsf-product-versions-' . $product_id );
if ( false !== $versions_transient && false === self::is_beta_enabled_rollback( $product_id ) ) {
return $versions_transient;
}
$per_page = apply_filters( 'bsf_show_versions_to_rollback_' . $product_id, 10 );
$path = bsf_get_api_site( false, true ) . 'versions/' . $product_id . '?per_page=' . $per_page;
if ( BSF_Update_Manager::bsf_allow_beta_updates( $product_id ) ) {
$path = add_query_arg( 'include_beta', 'true', $path );
}
$response = wp_remote_get(
$path,
array(
'timeout' => '10',
)
);
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) {
return array();
}
$response_versions = json_decode( wp_remote_retrieve_body( $response ), true );
// Cache product version for 24 hrs.
set_site_transient( 'bsf-product-versions-' . $product_id, $response_versions, 24 * HOUR_IN_SECONDS );
return $response_versions;
}
/**
* This will filter the versions and return the versions less than current installed version.
*
* @param array $version_arr array of versions.
* @param string $current_version Current install version.
*
* @return array
*/
public static function sort_product_versions( $version_arr, $current_version ) {
$rollback_versions = array();
foreach ( $version_arr as $version ) {
if ( version_compare( $version, $current_version, '>=' ) ) {
continue;
}
$rollback_versions[] = $version;
}
return $rollback_versions;
}
/**
* This function is added to update the trasient data of product version on beta update enabled/disabled action.
* This will set the flag in db options that should beta versions include/removed in the rollback versions list based on enabled/disabled beta updates for the product.
*
* @param string $product_id Product ID.
*
* @return bool
*/
public static function is_beta_enabled_rollback( $product_id ) {
$allow_beta_update = BSF_Update_Manager::bsf_allow_beta_updates( $product_id );
$is_beta_enable = ( false === $allow_beta_update ) ? '0' : '1';
// Set the initial flag for is beta enelbled/ disabled.
if ( false === get_option( 'is_beta_enable_rollback_' . $product_id ) ) {
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
return false;
}
// If user has enalbed/ disabled beta update then upadate the rollback version transient data.
if ( get_option( 'is_beta_enable_rollback_' . $product_id ) !== $is_beta_enable ) {
update_option( 'is_beta_enable_rollback_' . $product_id, $is_beta_enable );
return true;
}
return false;
}
}

View File

@@ -0,0 +1,26 @@
{
"name": "brainstormforce/bsf-core",
"type": "wordpress-plugin",
"description": "WordPress updater for Premium Products from Brainstorm Force",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Brainstorm Force",
"email": "hello@bsf.io"
}
],
"require": {
"composer/installers": "^2.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"phpcompatibility/phpcompatibility-wp": "*",
"wp-cli/dist-archive-command": "^2.0",
"wp-coding-standards/wpcs": "dev-master"
},
"minimum-stability": "stable",
"scripts": {
"format": "vendor/bin/phpcbf --standard=phpcs.xml.dist",
"lint": "vendor/bin/phpcs --standard=phpcs.xml.dist"
}
}

View File

@@ -0,0 +1,403 @@
<?php
/**
* Helper functions for BSF Core.
*
* @author Brainstorm Force
* @package bsf-core
*/
/**
* BSF get API site.
*
* @param bool $prefer_unsecure Prefer unsecure.
* @param bool $is_rest_api use rest api base URL.
* @return $bsf_api_site.
*/
function bsf_get_api_site( $prefer_unsecure = false, $is_rest_api = false ) {
$rest_api_endoint = ( true === $is_rest_api ) ? 'wp-json/bsf-products/v1/' : '';
if ( defined( 'BSF_API_URL' ) ) {
$bsf_api_site = BSF_API_URL . $rest_api_endoint;
} else {
$bsf_api_site = 'http://support.brainstormforce.com/' . $rest_api_endoint;
if ( false === $prefer_unsecure && wp_http_supports( array( 'ssl' ) ) ) {
$bsf_api_site = set_url_scheme( $bsf_api_site, 'https' );
}
}
return $bsf_api_site;
}
/**
* BSF get API URL.
*
* @param bool $prefer_unsecure Prefer unsecure.
* @return $url.
*/
function bsf_get_api_url( $prefer_unsecure = false ) {
$url = bsf_get_api_site( $prefer_unsecure ) . 'wp-admin/admin-ajax.php';
return $url;
}
/**
* BSF time since last version check.
*
* @param int $hours_completed Hours completed.
* @param string $option Option.
* @return $url.
*/
function bsf_time_since_last_versioncheck( $hours_completed, $option ) {
$seconds = $hours_completed * HOUR_IN_SECONDS;
$status = false;
$last_update_timestamp = (int) get_option( $option, false );
if ( false !== $last_update_timestamp ) {
// Find seconds passed since the last timestamp update (i.e. last request made).
$elapsed_seconds = (int) current_time( 'timestamp' ) - $last_update_timestamp;
// IF time is more than the required seconds allow a new HTTP request.
if ( $elapsed_seconds > $seconds ) {
$status = true;
}
} else {
// If timestamp is not yet set - allow the HTTP request.
$status = true;
}
return $status;
}
if ( ! function_exists( 'bsf_convert_core_path_to_relative' ) ) {
/**
* Depracate bsf_convert_core_path_to_relative() to in favour of bsf_core_url()
*
* @param $path $path deprecated.
* @return String URL of bsf-core directory.
*/
function bsf_convert_core_path_to_relative( $path ) {
_deprecated_function( __FUNCTION__, '1.22.46', 'bsf_core_url' );
return bsf_core_url( '' );
}
}
if ( ! function_exists( 'bsf_core_url' ) ) {
/**
* BSF Core URL
*
* @param string $append Append.
* @return String URL of bsf-core directory.
*/
function bsf_core_url( $append = '' ) {
$path = wp_normalize_path( BSF_UPDATER_PATH );
$theme_dir = wp_normalize_path( get_template_directory() );
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
if ( strpos( $path, $theme_dir ) !== false ) {
return rtrim( get_template_directory_uri() . '/admin/bsf-core/', '/' ) . $append;
} elseif ( strpos( $path, $plugin_dir ) !== false ) {
return rtrim( plugin_dir_url( BSF_UPDATER_FILE ), '/' ) . $append;
} elseif ( strpos( $path, dirname( plugin_basename( BSF_UPDATER_FILE ) ) ) !== false ) {
return rtrim( plugin_dir_url( BSF_UPDATER_FILE ), '/' ) . $append;
}
return false;
}
}
if ( ! function_exists( 'get_brainstorm_product' ) ) {
/**
* Get BSF product.
*
* @param string $product_id Product ID.
* @return array Product.
*/
function get_brainstorm_product( $product_id = '' ) {
$all_products = brainstorm_get_all_products();
foreach ( $all_products as $key => $product ) {
$product_id_bsf = isset( $product['id'] ) ? ( is_numeric( $product['id'] ) ? (int) $product['id'] : $product['id'] ) : '';
if ( $product_id === $product_id_bsf ) {
return $product;
}
}
return array();
}
}
if ( ! function_exists( 'brainstorm_get_all_products' ) ) {
/**
* Get BSF all products.
*
* @param bool $skip_plugins Skip plugins.
* @param bool $skip_themes Skip themes.
* @param bool $skip_bundled Skip bundled.
*
* @return array All Products.
*/
function brainstorm_get_all_products( $skip_plugins = false, $skip_themes = false, $skip_bundled = false ) {
$all_products = array();
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
$brainstorm_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstorm_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
if ( true === $skip_plugins ) {
$all_products = $brainstorm_themes;
} elseif ( true === $skip_themes ) {
$all_products = $brainstorm_plugins;
} else {
$all_products = $brainstorm_plugins + $brainstorm_themes;
}
if ( false === $skip_bundled ) {
foreach ( $brainstrom_bundled_products as $parent_id => $parent ) {
foreach ( $parent as $key => $product ) {
if ( isset( $all_products[ $product->id ] ) ) {
$all_products[ $product->id ] = array_merge( $all_products[ $product->id ], (array) $product );
} else {
$all_products[ $product->id ] = (array) $product;
}
}
}
}
return $all_products;
}
}
if ( ! function_exists( 'bsf_extension_nag' ) ) {
/**
* Generate's markup to generate notice to ask users to install required extensions.
*
* @since Graupi 1.9
*
* @param string $product_id (string) Product ID of the brainstorm product.
* @param bool $mu_updater (bool) If True - give nag to separately install brainstorm updater multisite plugin.
*/
function bsf_extension_nag( $product_id = '', $mu_updater = false ) {
$display_nag = get_user_meta( get_current_user_id(), $product_id . '-bsf_nag_dismiss', true );
if ( true === $mu_updater ) {
bsf_nag_brainstorm_updater_multisite();
}
if ( '1' === $display_nag ||
! user_can( get_current_user_id(), 'activate_plugins' ) ||
! user_can( get_current_user_id(), 'install_plugins' ) ) {
return;
}
$bsf_installed_plugins = '';
$bsf_not_installed_plugins = '';
$bsf_not_activated_plugins = '';
$installer = '';
$bsf_install = false;
$bsf_activate = false;
$bsf_bundled_products = bsf_bundled_plugins( $product_id );
$bsf_product_name = brainstrom_product_name( $product_id );
foreach ( $bsf_bundled_products as $key => $plugin ) {
if ( ! isset( $plugin->id ) || '' === $plugin->id || ! isset( $plugin->must_have_extension ) || 'false' === $plugin->must_have_extension ) {
continue;
}
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $plugin->init;
if ( is_file( $plugin_abs_path ) ) {
if ( ! is_plugin_active( $plugin->init ) ) {
$bsf_not_activated_plugins .= $bsf_bundled_products[ $key ]->name . ', ';
}
} else {
$bsf_not_installed_plugins .= $bsf_bundled_products[ $key ]->name . ', ';
}
}
$bsf_not_activated_plugins = rtrim( $bsf_not_activated_plugins, ', ' );
$bsf_not_installed_plugins = rtrim( $bsf_not_installed_plugins, ', ' );
if ( '' !== $bsf_not_activated_plugins || '' !== $bsf_not_installed_plugins ) {
echo '<div class="updated notice is-dismissible"><p></p>';
if ( '' !== $bsf_not_activated_plugins ) {
echo '<p>';
echo esc_html( $bsf_product_name ) . esc_html__( ' requires following plugins to be active : ', 'bsf' );
echo '<strong><em>';
echo esc_html( $bsf_not_activated_plugins );
echo '</strong></em>';
echo '</p>';
$bsf_activate = true;
}
if ( '' !== $bsf_not_installed_plugins ) {
echo '<p>';
echo esc_html( $bsf_product_name ) . esc_html__( ' requires following plugins to be installed and activated : ', 'bsf' );
echo '<strong><em>';
echo esc_html( $bsf_not_installed_plugins );
echo '</strong></em>';
echo '</p>';
$bsf_install = true;
}
if ( true === $bsf_activate ) {
$installer .= '<a href="' . get_admin_url() . 'plugins.php?plugin_status=inactive">' . __( 'Begin activating plugins', 'bsf' ) . '</a> | ';
}
if ( true === $bsf_install ) {
$installer .= '<a href="' . bsf_exension_installer_url( $product_id ) . '">' . __( 'Begin installing plugins', 'bsf' ) . '</a> | ';
}
$installer .= '<a href="' . esc_url( add_query_arg( 'bsf-dismiss-notice', $product_id ) ) . '">' . __( 'Dismiss This Notice', 'bsf' ) . '</a>';
$installer = ltrim( $installer, '| ' );
wp_nonce_field( 'bsf-extension-nag', 'bsf-extension-nag-nonce', true, 1 );
echo '<p><strong>';
echo esc_html( rtrim( $installer, ' |' ) );
echo '</p></strong>';
echo '<p></p></div>';
}
}
}
if ( ! function_exists( 'bsf_nag_brainstorm_updater_multisite' ) ) {
/**
* BSF Updater multisite.
*/
function bsf_nag_brainstorm_updater_multisite() {
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_multisite() || is_plugin_active_for_network( 'brainstorm-updater/index.php' ) ) {
return;
}
echo '<div class="notice notice-error uct-notice is-dismissible"><p>';
/* translators: %1$s: strong tag %2%s: strong tag %3%s: anchor tag %4%s: closing anchor tag */
sprintf( __( 'Looks like you are on a WordPress Multisite, you will need to install and network activate %1$s Brainstorm Updater for Multisite %2$s plugin. Download it from %3$s here %4$s', 'bsf' ), '<strong><em>', '<strong><em>', '<a href="http://bsf.io/bsf-updater-mu" target="_blank">', '</a>' );
echo '</p>';
echo '</div>';
}
}
/**
* Get product name from BSF core is loaded.
*/
function bsf_get_loaded_bsf_core_name() {
$path = wp_normalize_path( BSF_UPDATER_PATH );
$theme_dir = wp_normalize_path( WP_CONTENT_DIR . '/themes/' );
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
$product_name = '';
if ( false !== strpos( $path, $theme_dir ) ) {
// This is a theme path.
$product_slug = str_replace( array( $theme_dir, '/admin/bsf-core' ), '', $path );
} elseif ( false !== strpos( $path, $plugin_dir ) ) {
// This is plugin path.
$product_slug = str_replace( array( $plugin_dir . '/', '/admin/bsf-core' ), '', $path );
}
$brainstrom_products = get_option( 'brainstrom_products', array() );
foreach ( $brainstrom_products as $type => $products ) {
foreach ( $products as $product ) {
if ( $product['slug'] === $product_slug ) {
$product_name = $product['name'];
}
}
}
return $product_name;
}
/**
* Clear versions form trasinent.
*
* @param string $product_id Product ID.
*/
function bsf_clear_versions_cache( $product_id ) {
if ( false !== get_transient( 'bsf-product-versions-' . $product_id ) ) {
delete_transient( 'bsf-product-versions-' . $product_id );
}
}
/**
* Get white labled for product name.
*
* @param string $product_id Product ID.
* @param string $product_name Product Name.
*
* @return string Product name.
*/
function bsf_get_white_lable_product_name( $product_id, $product_name ) {
$white_label_name = apply_filters( "bsf_product_name_{$product_id}", $product_name );
return ! empty( $white_label_name ) ? $white_label_name : $product_name;
}
/**
* Get installed version of the product.
*
* @param string $type plugins/themes.
* @param string $product_id Product ID.
*/
function bsf_get_product_current_version( $type, $product_id ) {
$brainstrom_products = get_option( 'brainstrom_products' );
return isset( $brainstrom_products[ $type ][ $product_id ]['version'] ) ? $brainstrom_products[ $type ][ $product_id ]['version'] : '';
}
/**
* Check is user has permisson to view the product rollback version form.
*
* @param string $product_id Product ID.
*
* @return bool
*/
function bsf_display_rollback_version_form( $product_id ) {
if ( ! BSF_License_Manager::bsf_is_active_license( $product_id ) ) {
return false;
}
if ( is_multisite() && ! current_user_can( 'manage_network_plugins' ) ) {
return false;
}
if ( ! current_user_can( 'update_plugins' ) ) {
return false;
}
return true;
}
/**
* Get installed PHP version.
*
* @return float|false PHP version.
* @since 1.0.0
*/
function bsf_get_php_version() {
if ( defined( 'PHP_MAJOR_VERSION' ) && defined( 'PHP_MINOR_VERSION' ) && defined( 'PHP_RELEASE_VERSION' ) ) { // phpcs:ignore
return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
}
return phpversion();
}

View File

@@ -0,0 +1,292 @@
<?php
/**
* System Info File.
*
* @author Brainstorm Force
* @package bsf-core
*/
/**
* Display system info.
*/
function bsf_systeminfo() {
?>
<table class="wp-list-table widefat fixed bsf-sys-info">
<tbody>
<tr class="alternate">
<th colspan="2"><?php esc_html_e( 'WordPress Environment', 'bsf' ); ?></th>
</tr>
<tr>
<td>Home URL</td>
<td><?php echo esc_url( site_url() ); ?></td>
</tr>
<tr>
<td>Site URL</td>
<td><?php echo esc_url( site_url() ); ?></td>
</tr>
<tr>
<?php global $wp_version; ?>
<td>WP Version</td>
<td><?php echo floatval( $wp_version ); ?></td>
</tr>
<tr>
<td>Multisite</td>
<td><?php echo ( is_multisite() ) ? 'Yes' : 'No'; ?></td>
</tr>
<?php
$limit = (int) ini_get( 'memory_limit' );
$usage = function_exists( 'memory_get_usage' ) ? round( memory_get_usage() / 1024 / 1024, 2 ) : 0;
?>
<tr>
<td>Memory Usage</td>
<td>
<?php echo floatval( $usage ); ?>
MB of
<?php echo intval( $limit ); ?>
MB
</td>
</tr>
<tr>
<td>WP Memory Limit</td>
<td>
<?php echo intval( WP_MEMORY_LIMIT ); ?>
</td>
</tr>
<tr>
<td>WP Debug</td>
<td><?php echo ( WP_DEBUG ) ? 'Enabled' : 'Disabled'; ?></td>
</tr>
<tr>
<td>WP Lang</td>
<?php $currentlang = get_bloginfo( 'language' ); ?>
<td><?php echo esc_html( $currentlang ); ?></td>
</tr>
<tr>
<td>WP Uploads Directory</td>
<td>
<?php
$wp_up = wp_upload_dir();
echo ( is_writable( $wp_up['basedir'] ) ) ? 'Writable' : 'Readable';
?>
</td>
</tr>
<tr>
<td>BSF Updater Path</td>
<td>
<?php echo '(v' . esc_attr( BSF_UPDATER_VERSION ) . ') ' . esc_attr( BSF_UPDATER_PATH ); ?>
</td>
</tr>
<?php if ( defined( 'WPB_VC_VERSION' ) ) : ?>
<tr>
<td>vc_shortcode_output Filter</td>
<td>
<?php echo ( has_filter( 'vc_shortcode_output' ) ) ? 'Available' : 'Not Available'; ?>
</td>
</tr>
<?php endif; ?>
<?php
$mix = bsf_get_brainstorm_products( true );
$temp_constant = '';
if ( ! empty( $mix ) ) :
foreach ( $mix as $key => $product ) :
$constant = strtoupper( str_replace( '-', '_', $product['id'] ) );
$constant = 'BSF_' . $constant . '_CHECK_UPDATES';
if ( defined( $constant ) && ( constant( $constant ) === 'false' || constant( $constant ) === false ) ) {
$temp_constant .= $constant . '<br/>';
continue;
}
endforeach;
endif;
if ( defined( 'BSF_CHECK_PRODUCT_UPDATES' ) && false === BSF_CHECK_PRODUCT_UPDATES ) {
$temp_constant .= 'BSF_CHECK_PRODUCT_UPDATES';
}
if ( '' !== $temp_constant ) {
if ( ! defined( 'BSF_RESTRICTED_UPDATES' ) ) {
define( 'BSF_RESTRICTED_UPDATES', $temp_constant );
}
}
?>
<?php if ( defined( 'BSF_RESTRICTED_UPDATES' ) ) : ?>
<tr>
<td>Restrited Updates Filter</td>
<td>
<?php echo esc_html( BSF_RESTRICTED_UPDATES ); ?>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
<table class="wp-list-table widefat fixed bsf-sys-info">
<tbody>
<tr class="alternate">
<th colspan="2"><?php esc_html_e( 'Server Environment', 'bsf' ); ?></th>
</tr>
<tr>
<td>Server Info</td>
<td><?php echo esc_html( $_SERVER['SERVER_SOFTWARE'] ); ?></td>
</tr>
<tr>
<td>PHP Version</td>
<td><?php echo ( function_exists( 'phpversion' ) ) ? floatval( phpversion() ) : 'Not sure'; ?></td>
</tr>
<tr>
<td>MYSQL Version</td>
<td>
<?php
global $wpdb;
echo floatval( $wpdb->db_version() );
?>
</td>
</tr>
<tr>
<td>PHP Post Max Size</td>
<td><?php echo esc_attr( ini_get( 'post_max_size' ) ); ?></td>
</tr>
<tr>
<td>PHP Max Execution Time</td>
<td><?php echo esc_attr( ini_get( 'max_execution_time' ) ); ?> Seconds</td>
</tr>
<tr>
<td>PHP Max Input Vars</td>
<td><?php echo intval( ini_get( 'max_input_vars' ) ); // PHPCS:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound ?></td>
</tr>
<tr>
<td>Max Upload Size</td>
<td><?php echo intval( ini_get( 'upload_max_filesize' ) ); ?></td>
</tr>
<tr>
<td>Default Time Zone</td>
<td>
<?php
if ( date_default_timezone_get() ) {
echo esc_html( date_default_timezone_get() );
}
if ( ini_get( 'date.timezone' ) ) {
echo ' ' . esc_html( ini_get( 'date.timezone' ) );
}
?>
</td>
</tr>
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
<td>SimpleXML</td>
<td>
<?php
if ( extension_loaded( 'simplexml' ) ) {
echo 'SimpleXML extension is installed';
} else {
echo 'SimpleXML extension is not enabled.';
}
?>
</td>
</tr>
<tr class="<?php echo ( ! function_exists( 'curl_version' ) ) ? 'bsf-alert' : ''; ?>">
<td>cURL</td>
<td>
<?php
if ( function_exists( 'curl_version' ) ) {
$curl_info = curl_version();
?>
<div>Version : <strong><?php echo floatval( $curl_info['version'] ); ?></strong></div>
<div>SSL Version : <strong><?php echo floatval( $curl_info['ssl_version'] ); ?></strong></div>
<div>Host : <strong><?php echo esc_html( $curl_info['host'] ); ?></strong></div>
<?php
} else {
echo 'Not Enabled';
}
?>
</td>
</tr>
<?php
$connection = wp_remote_get( bsf_get_api_site() );
$support_class = ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) ? 'bsf-alert' : '';
?>
<tr class="<?php echo esc_attr( $support_class ); ?>">
<td>Connection to Support API</td>
<td>
<?php
if ( is_wp_error( $connection ) || 200 !== wp_remote_retrieve_response_code( $connection ) ) {
echo 'Connection to Support API has error';
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
echo '<p class="description">Error Message: ' . esc_attr( $connection->get_error_message() ) . '</p>';
} else {
echo 'Connecion to Support API was successful';
echo '<p class="description">Status Code: ' . esc_attr( wp_remote_retrieve_response_code( $connection ) ) . '</p>';
}
?>
</td>
</tr>
</tbody>
</table>
<table class="wp-list-table widefat fixed bsf-sys-info">
<tbody>
<tr class="alternate">
<th colspan="2"><?php esc_html_e( 'Theme Information', 'bsf' ); ?></th>
</tr>
<?php $theme_data = wp_get_theme(); ?>
<tr>
<td>Name</td>
<td><?php echo esc_html( $theme_data->Name ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
</tr>
<tr>
<td>Version</td>
<td><?php echo floatval( $theme_data->Version ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?></td>
</tr>
<tr>
<td>Author</td>
<td>
<?php echo wp_kses_post( $theme_data->Author ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase ?>
</td>
</tr>
</tbody>
</table>
<table class="wp-list-table widefat fixed bsf-sys-info bsf-table-active-plugin">
<tbody>
<tr class="alternate">
<th colspan="4"><?php esc_html_e( 'Installed Plugins', 'bsf' ); ?></th>
</tr>
<?php
$plugins = get_plugins();
asort( $plugins );
foreach ( $plugins as $plugin_file => $plugin_data ) {
?>
<tr>
<td><?php echo esc_html( str_pad( $plugin_data['Title'], 30 ) ); ?></td>
<td>
<?php
if ( is_plugin_active( $plugin_file ) ) {
echo esc_html( str_pad( 'Active', 10 ) );
} else {
echo esc_html( str_pad( 'Inactive', 10 ) );
}
?>
</td>
<td><?php echo esc_html( str_pad( $plugin_data['Version'], 10 ) ); ?></td>
<td><?php echo esc_html( $plugin_data['Author'] ); ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
/**
* Get BSF systeminfo.
*/
function get_bsf_systeminfo() {
$table = '<div class="bsf-system-info-wrapper">';
ob_start();
bsf_systeminfo();
$table .= ob_get_clean();
$table .= '</div>';
return $table;
}

View File

@@ -0,0 +1,84 @@
<?php
/**
* Plugin installer.
*
* @package bsf-core
*/
/**
* Prevent direct access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
$current_page = '';
if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$current_page = sanitize_text_field( $_GET['page'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$arr = explode( 'bsf-extensions-', $current_page );
$product_id = $arr[1];
}
$redirect_url = network_admin_url( 'admin.php?page=' . $current_page );
$extensions_installer_heading = apply_filters( "bsf_extinstaller_heading_{$product_id}", 'iMedica Extensions' );
$extensions_installer_subheading = apply_filters( "bsf_extinstaller_subheading_{$product_id}", 'iMedica is already very flexible & feature rich theme. It further aims to be all-in-one solution for your WordPress needs. Install any necessary extensions you like from below and take it on the steroids.' );
$reset_bundled_url = bsf_exension_installer_url( $product_id . '&remove-bundled-products&redirect=' . $redirect_url );
?>
<div class="clear"></div>
<div class="wrap about-wrap bsf-sp-screen bend <?php echo 'extension-installer-' . sanitize_html_class( $product_id ); ?>">
<div class="bend-heading-section extension-about-header">
<h1><?php echo esc_html( $extensions_installer_heading ); ?></h1>
<h3><?php echo esc_html( $extensions_installer_subheading ); ?></h3>
<div class="bend-head-logo">
<div class="bend-product-ver"><?php esc_html_e( 'Extensions ', 'bsf' ); ?></div>
</div>
</div> <!--heading section-->
<div class="bend-content-wrap">
<hr class="bsf-extensions-lists-separator">
<h3 class="bf-ext-sub-title"><?php esc_html_e( 'Available Extensions', 'bsf' ); ?></h3>
<?php $nonce = wp_create_nonce( 'bsf_activate_extension_nonce' ); ?>
<input type="hidden" id="bsf_activate_extension_nonce" value="<?php echo esc_attr( $nonce ); ?>" >
<?php
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
if ( isset( $brainstrom_bundled_products[ $product_id ] ) ) {
$brainstrom_bundled_products = $brainstrom_bundled_products[ $product_id ];
}
usort( $brainstrom_bundled_products, 'bsf_sort' );
if ( empty( $brainstrom_bundled_products ) ) {
?>
<div class="bsf-extensions-no-active">
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-download"></span></div>
<p class="bsf-text-light"><em><?php esc_html_e( 'No extensions available yet!', 'bsf' ); ?></em></p>
<div class="bsf-cp-rem-bundle" style="margin-top: 30px;">
<a class="button-primary" href="<?php echo( htmlentities( $reset_bundled_url, ENT_QUOTES, 'utf-8' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>"><?php esc_html_e( 'Refresh Bundled Products', 'bsf' ); ?></a>
</div>
</div>
<?php
} else {
?>
<ul class="bsf-extensions-list">
<?php echo wp_kses_post( bsf_render_bundled_products( $product_id, false ) ); ?>
</ul>
<hr class="bsf-extensions-lists-separator">
<h3 class="bf-ext-sub-title"><?php esc_html_e( 'Installed Extensions', 'bsf' ); ?></h3>
<ul class="bsf-extensions-list">
<?php echo wp_kses_post( bsf_render_bundled_products( $product_id, true ) ); ?>
</ul>
<?php
}
?>
</div>
</div>

View File

@@ -0,0 +1,931 @@
<?php
/**
* Plugin Name: Brainstorm Core
* Plugin URI: https://brainstormforce.com
* Author: Brainstorm Force
* Author URI: https://brainstormforce.com
* Version: 1.0
* Description: Brainstorm Core
*
* @package BSF_Core
* Text Domain: bsf
*/
/*
Instrunctions - Product Registration & Updater
# Copy "auto-upadater" folder to admin folder
# Change "include_once" and "require_once" directory path as per your "auto-updater" path (Line no. 72, 78, 79)
*/
defined( 'ABSPATH' ) || exit;
// abspath of groupi.
if ( ! defined( 'BSF_UPDATER_PATH' ) ) {
define( 'BSF_UPDATER_PATH', dirname( __FILE__ ) );
}
if ( ! defined( 'BSF_UPDATER_FILE' ) ) {
define( 'BSF_UPDATER_FILE', __FILE__ );
}
if ( ! defined( 'BSF_UPDATER_FULLNAME' ) ) {
define( 'BSF_UPDATER_FULLNAME', apply_filters( 'agency_updater_fullname', 'Brainstorm Force' ) );
}
if ( ! defined( 'BSF_UPDATER_SHORTNAME' ) ) {
define( 'BSF_UPDATER_SHORTNAME', apply_filters( 'agency_updater_shortname', 'Brainstorm' ) );
}
if ( ! defined( 'BSF_UPDATER_VERSION' ) ) {
global $bsf_core_version;
define( 'BSF_UPDATER_VERSION', sanitize_text_field( $bsf_core_version ) );
}
// Do not initialize graupi in the customizer.
if ( is_customize_preview() ) {
return;
}
/* product registration */
require_once 'includes/helpers.php';
require_once 'includes/system-info.php';
require_once 'auto-update/admin-functions.php';
require_once 'auto-update/updater.php';
require_once 'class-bsf-update-manager.php';
require_once 'class-bsf-rollback-version-manager.php';
require_once 'class-bsf-license-manager.php';
require_once 'classes/class-bsf-extension-installer.php';
require_once 'classes/class-bsf-core-update.php';
require_once 'classes/class-bsf-core-rest.php';
require_once 'classes/class-bsf-rollback-version.php';
if ( defined( 'WP_CLI' ) ) {
require 'class-bsf-wp-cli-command.php';
}
add_action( 'admin_init', 'set_bsf_core_constant', 1 );
if ( ! function_exists( 'set_bsf_core_constant' ) ) {
/**
* Set BSF Core constant.
*/
function set_bsf_core_constant() {
if ( ! defined( 'BSF_CORE' ) ) {
define( 'BSF_CORE', true );
}
}
}
/*
Instrunctions - Plugin Installer
# Copy "plugin-installer" folder to theme's admin folder
# Change "include_once" and "require_once" directory path as per your "plugin-installer" path (Line no. 101, 113)
*/
if ( ! function_exists( 'init_bsf_plugin_installer' ) ) {
/**
* BSF Plugin installer.
*/
function init_bsf_plugin_installer() {
require_once 'plugin-installer/admin-functions.php';
/**
* Action will run after plugin installer is loaded
*/
do_action( 'bsf_after_plugin_installer' );
}
}
add_action( 'admin_init', 'init_bsf_plugin_installer', 0 );
add_action( 'network_admin_init', 'init_bsf_plugin_installer', 0 );
if ( ! is_multisite() ) {
add_action( 'admin_menu', 'register_bsf_extension_page', 999 );
} else {
add_action( 'network_admin_menu', 'register_bsf_extension_page_network', 999 );
}
if ( ! function_exists( 'register_bsf_extension_page' ) ) {
/**
* Register BSF extension Page.
*/
function register_bsf_extension_page() {
add_submenu_page(
'imedica_options',
__( 'Extensions', 'bsf' ),
__( 'Extensions', 'bsf' ),
'manage_options',
'bsf-extensions-10395942',
'bsf_extensions_callback'
);
}
}
if ( ! function_exists( '_bsf_maybe_add_dashboard_menu' ) ) {
/**
* Check if the dashboard menu for installer should be added.
* Checks if theme or plugin is active, if it is not active, the menu for installer should not be registered.
*
* @param int $product_id Product if of brainstorm product.
*
* @return boolean true - If menu is to be shown | false - if menu is not to be displayed.
*/
function _bsf_maybe_add_dashboard_menu( $product_id ) {
$brainstrom_products = ( get_option( 'brainstrom_products' ) ) ? get_option( 'brainstrom_products' ) : array();
$template_plugin = '';
$template_theme = '';
$is_theme = false;
if ( is_multisite() ) {
// Do not register menu if we are on multisite, multisite menu will be registered below the brainstorm menu.
return false;
}
if ( ! empty( $brainstrom_products ) ) {
if ( isset( $brainstrom_products['plugins'] ) && isset( $brainstrom_products['plugins'][ $product_id ] ) ) {
$template_plugin = $brainstrom_products['plugins'][ $product_id ]['template'];
}
if ( isset( $brainstrom_products['themes'] ) && isset( $brainstrom_products['themes'][ $product_id ] ) ) {
$template_theme = $brainstrom_products['themes'][ $product_id ]['product_name'];
$is_theme = true;
}
if ( true === $is_theme && '' !== $template_theme ) {
$themes = wp_get_theme();
$theme_name = '';
$parent = $themes->parent();
if ( empty( $parent ) ) {
$theme_name = $themes->get( 'Name' );
} else {
$theme_name = $themes->parent()->get( 'Name' );
}
if ( $theme_name === $template_theme ) {
// Theme / Parent theme is active, hence display menu.
return true;
}
// don't display menu if theme/parent theme does not need extension installer.
return false;
} elseif ( false === $is_theme && '' !== $template_plugin ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( $template_plugin ) || is_plugin_active_for_network( $template_plugin ) ) {
// Plugin is active, hence display menu.
return true;
}
// don't display menu if plugin does not need extension installer.
return false;
}
}
// do not register menu if all conditions fail.
return false;
}
}
if ( ! function_exists( 'register_bsf_extension_page_network' ) ) {
/**
* Register BSF extension page Network
*/
function register_bsf_extension_page_network() {
$themes = wp_get_themes( array( 'allowed' => 'network' ) );
$parent_slug = 'bsf-registration';
if ( defined( 'BSF_REG_MENU_TO_SETTINGS' ) && ( BSF_REG_MENU_TO_SETTINGS === true || BSF_REG_MENU_TO_SETTINGS === 'true' ) ) {
$parent_slug = 'settings.php';
}
foreach ( $themes as $theme ) {
if ( 'iMedica' === $theme->Name ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
add_submenu_page( $parent_slug, __( 'iMedica Extensions', 'bsf' ), __( 'iMedica Extensions', 'bsf' ), 'manage_options', 'bsf-extensions-10395942', 'bsf_extensions_callback' );
break;
}
}
}
}
if ( ! function_exists( 'bsf_extensions_callback' ) ) {
/**
* BSF extensions callback
*/
function bsf_extensions_callback() {
include_once 'plugin-installer/index.php';
}
}
if ( ! function_exists( 'bsf_extract_product_id' ) ) {
/**
* BSF extract Product ID.
*
* @param string $path Path.
*/
function bsf_extract_product_id( $path ) {
$id = false;
$file = rtrim( $path, '/' ) . '/admin/bsf.yml';
$file_fallback = rtrim( $path, '/' ) . '/bsf.yml';
if ( is_file( $file ) ) {
$file = $file;
} elseif ( is_file( $file_fallback ) ) {
$file = $file_fallback;
} else {
return apply_filters( 'bsf_extract_product_id', $id, $path );
}
// Use of file_get_contents() - https://github.com/WordPress/WordPress-Coding-Standards/pull/1374/files#diff-400e43bc09c24262b43f26fce487fdabR43-R52.
$filelines = file_get_contents( $file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Reading local file is OK.
if ( stripos( $filelines, 'ID:[' ) !== false ) {
preg_match_all( '/ID:\[(.*?)\]/', $filelines, $matches );
if ( isset( $matches[1] ) ) {
$id = ( isset( $matches[1][0] ) ) ? $matches[1][0] : '';
}
}
return apply_filters( 'bsf_extract_product_id', $id, $path );
}
}
if ( ! function_exists( 'init_bsf_core' ) ) {
/**
* Init BSF Core
*/
function init_bsf_core() {
$plugins = get_plugins();
$themes = wp_get_themes();
$theme_directories = search_theme_directories();
$bsf_products = array();
$bsf_authors = apply_filters(
'bsf_authors_list',
array(
'Brainstorm Force',
)
);
foreach ( $plugins as $plugin => $plugin_data ) {
if ( in_array( trim( $plugin_data['Author'] ), $bsf_authors, true ) ) {
$plugin_data['type'] = 'plugin';
$plugin_data['template'] = $plugin;
$plugin_data['path'] = dirname( realpath( WP_PLUGIN_DIR . '/' . $plugin ) );
$id = bsf_extract_product_id( $plugin_data['path'] );
if ( false !== $id ) {
$plugin_data['id'] = $id;
} // without readme.txt filename
array_push( $bsf_products, $plugin_data );
}
}
foreach ( $themes as $theme => $theme_data ) {
$temp = array();
$theme_author = trim( $theme_data->display( 'Author', false ) );
if ( 'Brainstorm Force' === $theme_author ) {
$temp['Name'] = $theme_data->get( 'Name' );
$temp['ThemeURI'] = $theme_data->get( 'ThemeURI' );
$temp['Description'] = $theme_data->get( 'Description' );
$temp['Author'] = $theme_data->get( 'Author' );
$temp['AuthorURI'] = $theme_data->get( 'AuthorURI' );
$temp['Version'] = $theme_data->get( 'Version' );
$temp['type'] = 'theme';
$temp['template'] = $theme;
$temp['path'] = realpath( get_theme_root() . '/' . $theme );
$id = bsf_extract_product_id( $temp['path'] );
if ( false !== $id ) {
$temp['id'] = $id;
} // without readme.txt filename
array_push( $bsf_products, $temp );
}
}
$brainstrom_products = get_option( 'brainstrom_products', array() );
$bundled_products = get_option( 'brainstrom_bundled_products', array() );
if ( ! empty( $brainstrom_products ) ) {
if ( isset( $brainstrom_products['plugins'] ) ) {
foreach ( $brainstrom_products['plugins'] as $key => $value ) {
if ( ! array_key_exists( $value['template'], $plugins ) ) {
unset( $brainstrom_products['plugins'][ $key ] );
}
}
}
if ( isset( $brainstrom_products['themes'] ) ) {
foreach ( $brainstrom_products['themes'] as $key => $value ) {
if ( ! array_key_exists( $value['template'], $theme_directories ) ) {
unset( $brainstrom_products['themes'][ $key ] );
}
}
}
}
// Update newly added brainstorm_products.
if ( ! empty( $bsf_products ) ) {
foreach ( $bsf_products as $key => $product ) {
if ( ! ( isset( $product['id'] ) ) || '' === $product['id'] ) {
continue;
}
if ( isset( $brainstrom_products[ $product['type'] . 's' ][ $product['id'] ] ) ) {
$bsf_product_info = $brainstrom_products[ $product['type'] . 's' ][ $product['id'] ];
} else {
$bsf_product_info = array();
do_action( 'brainstorm_updater_new_product_added' );
}
$bsf_product_info['template'] = $product['template'];
$bsf_product_info['type'] = $product['type'];
$bsf_product_info['id'] = $product['id'];
$brainstrom_products[ $product['type'] . 's' ][ $product['id'] ] = $bsf_product_info;
}
}
// Update bundled products.
foreach ( $bundled_products as $key => $product ) {
$bsf_product = get_brainstorm_product( $key );
if ( empty( $bsf_product ) ) {
unset( $bundled_products[ $key ] );
}
}
update_option( 'brainstrom_products', $brainstrom_products );
update_option( 'brainstrom_bundled_products', $bundled_products );
}
}
add_action( 'admin_init', 'init_bsf_core' );
// assets.
add_action( 'admin_enqueue_scripts', 'register_bsf_core_admin_styles', 1 );
if ( ! function_exists( 'register_bsf_core_admin_styles' ) ) {
/**
* Register BSF Core Admin Styles
*
* @param string $hook Hook.
*/
function register_bsf_core_admin_styles( $hook ) {
// bsf core style.
$hook_array = array(
'toplevel_page_bsf-registration',
'update-core.php',
'dashboard_page_bsf-registration',
'index_page_bsf-registration',
'admin_page_bsf-extensions',
'settings_page_bsf-registration',
'admin_page_bsf-registration',
'plugins.php',
'imedica_page_product-license',
);
$hook_array = apply_filters( 'bsf_core_style_screens', $hook_array );
if ( in_array( $hook, $hook_array, true ) || strpos( $hook, 'bsf-extensions' ) !== false ) {
$envato_activation_nonce = wp_create_nonce( 'envato_activation_nonce' );
wp_register_style( 'bsf-core-admin', bsf_core_url( '/assets/css/style.css' ), array(), BSF_UPDATER_VERSION );
wp_enqueue_style( 'bsf-core-admin' );
wp_register_style( 'brainstorm-switch', bsf_core_url( '/assets/css/switch.css' ), array(), BSF_UPDATER_VERSION );
wp_enqueue_style( 'brainstorm-switch' );
wp_register_script( 'brainstorm-switch', bsf_core_url( '/assets/js/switch.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
wp_enqueue_script( 'brainstorm-switch' );
wp_register_script( 'bsf-core', bsf_core_url( '/assets/js/bsf-core.js' ), array( 'jquery' ), BSF_UPDATER_VERSION, true );
wp_localize_script( 'bsf-core', 'bsf_core', array( 'envato_activation_nonce' => $envato_activation_nonce ) );
wp_enqueue_script( 'bsf-core' );
}
// frosty script.
$hook_frosty_array = array();
$hook_frosty_array = apply_filters( 'bsf_core_frosty_screens', $hook_frosty_array );
if ( in_array( $hook, $hook_frosty_array, true ) ) {
wp_register_script( 'bsf-core-frosty', bsf_core_url( '/assets/js/frosty.js' ), array(), BSF_UPDATER_VERSION, false );
wp_enqueue_script( 'bsf-core-frosty' );
wp_register_style( 'bsf-core-frosty-style', bsf_core_url( '/assets/css/frosty.css' ), array(), BSF_UPDATER_VERSION );
wp_enqueue_style( 'bsf-core-frosty-style' );
}
}
}
if ( is_multisite() ) {
add_action( 'admin_print_scripts', 'print_bsf_styles' );
if ( ! function_exists( 'print_bsf_styles' ) ) {
/**
* Print BSF styles.
*/
function print_bsf_styles() {
$path = bsf_core_url( '/assets/fonts' );
echo "<style>
@font-face {
font-family: 'brainstorm';
src:url('" . esc_url( $path ) . "/brainstorm.eot');
src:url('" . esc_url( $path ) . "/brainstorm.eot') format('embedded-opentype'),
url('" . esc_url( $path ) . "/brainstorm.woff') format('woff'),
url('" . esc_url( $path ) . "/brainstorm.ttf') format('truetype'),
url('" . esc_url( $path ) . "/brainstorm.svg') format('svg');
font-weight: normal;
font-style: normal;
}
.toplevel_page_bsf-registration > div.wp-menu-image:before {
content: \"\\e603\" !important;
font-family: 'brainstorm' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
</style>";
}
}
}
if ( ! function_exists( 'bsf_flush_bundled_products' ) ) {
/**
* BSF flush Bundled products.
*/
function bsf_flush_bundled_products() {
$bsf_force_check_extensions = (bool) get_site_option( 'bsf_force_check_extensions', false );
if ( $bsf_force_check_extensions ) {
delete_site_option( 'brainstrom_bundled_products' );
global $ultimate_referer;
if ( empty( $ultimate_referer ) ) {
$ultimate_referer = 'on-flush-bundled-products';
}
get_bundled_plugins();
update_site_option( 'bsf_force_check_extensions', false );
}
}
}
add_action( 'bsf_after_plugin_installer', 'bsf_flush_bundled_products' );
add_action( 'deleted_plugin', 'bsf_flush_bundled_products' );
/**
* Return array of bundled plugins for a specific
*
* @since Graupi 1.9
*/
if ( ! function_exists( 'bsf_bundled_plugins' ) ) {
/**
* BSF bundled plugins.
*
* @param int $product_id Product ID.
*/
function bsf_bundled_plugins( $product_id = '' ) {
$products = array();
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', '' );
if ( '' !== $brainstrom_bundled_products ) {
if ( array_key_exists( $product_id, $brainstrom_bundled_products ) ) {
$products = $brainstrom_bundled_products[ $product_id ];
}
}
return $products;
}
}
/**
* Get product name from product ID
*
* @since Graupi 1.9
*/
if ( ! function_exists( 'brainstrom_product_name' ) ) {
/**
* Brainstorm product name.
*
* @param int $product_id Product ID.
*/
function brainstrom_product_name( $product_id = '' ) {
$product_name = '';
$brainstrom_products = get_option( 'brainstrom_products', array() );
foreach ( $brainstrom_products as $key => $value ) {
foreach ( $value as $key => $product ) {
if ( $product_id === $key ) {
$product_name = isset( $product['product_name'] ) ? $product['product_name'] : '';
}
}
}
return $product_name;
}
}
/**
* Get product id from product name
*
* @since Graupi 1.19
*/
if ( ! function_exists( 'brainstrom_product_id_by_name' ) ) {
/**
* Brainstorm product ID by name.
*
* @param int $product_name Product name.
*/
function brainstrom_product_id_by_name( $product_name ) {
$product_id = '';
$brainstrom_products = get_option( 'brainstrom_products', array() );
foreach ( $brainstrom_products as $key => $value ) {
foreach ( $value as $key => $product ) {
if ( isset( $product['product_name'] ) && strcasecmp( $product['product_name'], $product_name ) === 0 ) {
$product_id = isset( $product['id'] ) ? $product['id'] : '';
}
}
}
return $product_id;
}
}
if ( ! function_exists( 'brainstrom_product_id_by_init' ) ) {
/**
* BrainstormProduct Id by init.
*
* @param string $plugin_init Plugin init.
*/
function brainstrom_product_id_by_init( $plugin_init ) {
$brainstrom_products = get_option( 'brainstrom_products', array() );
$brainstorm_plugins = isset( $brainstrom_products['plugins'] ) ? $brainstrom_products['plugins'] : array();
$brainstorm_themes = isset( $brainstrom_products['themes'] ) ? $brainstrom_products['themes'] : array();
$all_products = $brainstorm_plugins + $brainstorm_themes;
foreach ( $all_products as $key => $product ) {
$template = isset( $product['template'] ) ? $product['template'] : '';
if ( $plugin_init === $template ) {
return isset( $product['id'] ) ? $product['id'] : false;
}
}
}
}
/**
* Dismiss Extension installer nag
*
* @since Graupi 1.9
*/
if ( ! function_exists( 'bsf_dismiss_extension_nag' ) ) {
/**
* BSF dismiss extension nag.
*/
function bsf_dismiss_extension_nag() {
if ( isset( $_REQUEST['bsf-extension-nag-nonce'] ) && wp_verify_nonce( $_REQUEST['bsf-extension-nag-nonce'], 'bsf-extension-nag' ) && isset( $_GET['bsf-dismiss-notice'] ) ) {
$product_id = sanitize_text_field( $_GET['bsf-dismiss-notice'] );
update_user_meta( get_current_user_id(), $product_id . '-bsf_nag_dismiss', true );
}
}
}
add_action( 'admin_head', 'bsf_dismiss_extension_nag' );
// For debugging uncomment line below and remove query var &bsf-dismiss-notice from url and nag will be restored.
// delete_user_meta( get_current_user_id(), 'bsf-next-bsf_nag_dismiss');.
/*
* Load BSF core frosty scripts on front end
*/
add_action( 'wp_enqueue_scripts', 'register_bsf_core_styles', 1 );
/**
* Register BSF Core styles
*
* @param string $hook Hook.
*/
function register_bsf_core_styles( $hook ) {
// Register Frosty script and style.
wp_register_script( 'bsf-core-frosty', bsf_core_url( '/assets/js/frosty.js' ), array(), BSF_UPDATER_VERSION, false );
wp_register_style( 'bsf-core-frosty-style', bsf_core_url( '/assets/css/frosty.css' ), array(), BSF_UPDATER_VERSION );
}
/**
* Add link to debug settings for braisntorm updater on license registration page
*/
if ( ! function_exists( 'bsf_core_debug_link' ) ) {
/**
* Register BSF Core styles
*
* @param string $text Text.
*/
function bsf_core_debug_link( $text ) {
$screen = get_current_screen();
$screens = array(
'dashboard_page_bsf-registration',
'toplevel_page_bsf-registration-network',
'settings_page_bsf-registration',
'settings_page_bsf-registration-network',
);
$screens = apply_filters( 'bsf_core_debug_link_screens', $screens );
if ( ! in_array( $screen->id, $screens, true ) ) {
return $text;
}
$url = bsf_registration_page_url( '&author' );
$link = '<a href="' . $url . '">' . BSF_UPDATER_SHORTNAME . ' Updater debug settings</a>';
$text = $link . ' | ' . $text;
return $text;
}
}
add_filter( 'update_footer', 'bsf_core_debug_link', 999 );
/**
* Return brainstorm registration page URL
*
* @param $append (string) - Append at string at the end of the url
*/
if ( ! function_exists( 'bsf_registration_page_url' ) ) {
/**
* BSF Registration Page URL
*
* @param string $append Append.
* @param int $product_id Product ID.
*/
function bsf_registration_page_url( $append = '', $product_id = '' ) {
$bsf_updater_options = get_option( 'bsf_updater_options', array() );
$option = false;
$constant = false;
$skip_brainstorm_menu = get_site_option( 'bsf_skip_braisntorm_menu', false );
$product_registration_link = apply_filters( "bsf_registration_page_url_{$product_id}", '' );
// If Brainstorm meu is not registered.
if ( ( defined( 'BSF_UNREG_MENU' ) && ( BSF_UNREG_MENU === true || BSF_UNREG_MENU === 'true' ) ) ||
true === $skip_brainstorm_menu
) {
if ( '&author' === $append ) {
return admin_url( 'options.php?page=bsf-registration' . $append );
}
}
if ( isset( $bsf_updater_options['brainstorm_menu'] ) && '1' === $bsf_updater_options['brainstorm_menu'] ) {
$option = true;
}
if ( defined( 'BSF_REG_MENU_TO_SETTINGS' ) && 'BSF_REG_MENU_TO_SETTINGS' === true || 'BSF_REG_MENU_TO_SETTINGS' === 'true' ) {
$constant = true;
}
if ( '' !== $product_registration_link ) {
return $product_registration_link . '' . $append;
} else {
if ( true === $option || true === $constant ) {
// bsf menu in settings.
if ( is_multisite() ) {
return network_admin_url( 'settings.php?page=bsf-registration' . $append );
} else {
return admin_url( 'options-general.php?page=bsf-registration' . $append );
}
} else {
if ( is_multisite() ) {
return network_admin_url( 'admin.php?page=bsf-registration' . $append );
} else {
return admin_url( 'index.php?page=bsf-registration' . $append );
}
}
}
}
}
/**
* Return extension installer page URL
*/
if ( ! function_exists( 'bsf_exension_installer_url' ) ) {
/**
* BSF extension installer URL
*
* @param int $priduct_id Product ID.
* @return string URL.
*/
function bsf_exension_installer_url( $priduct_id ) {
if ( is_multisite() ) {
if ( defined( 'BSF_REG_MENU_TO_SETTINGS' ) && ( BSF_REG_MENU_TO_SETTINGS === true || BSF_REG_MENU_TO_SETTINGS === 'true' ) ) {
return network_admin_url( 'settings.php?page=bsf-extensions-' . $priduct_id );
} else {
return network_admin_url( 'admin.php?page=bsf-extensions-' . $priduct_id );
}
} else {
return admin_url( 'admin.php?page=bsf-extensions-' . $priduct_id );
}
}
}
if ( ! function_exists( 'bsf_set_options' ) ) {
/**
* Set options based on reading $_GET parameters and $_POST parameters
*
* 1. force Check updates
* 2. Skip Brainstorm Account Registration
* 3. Reset Brainstorm Registration data
*/
function bsf_set_options() {
// Force check updates.
if ( isset( $_GET['force-check-update'] ) || isset( $_GET['force-check'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
global $pagenow;
global $ultimate_referer;
if ( 'update-core.php' === $pagenow && '1' === $_GET['force-check'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$ultimate_referer = 'on-force-check-update-update-core';
} else {
$ultimate_referer = 'on-force-check-update';
}
bsf_check_product_update();
update_option( 'bsf_last_update_check', current_time( 'timestamp' ) );
}
// Skip Author registration.
$skip_author_products = apply_filters( 'bsf_skip_author_registration', $products = array() );
$ids = array();
$skip_author_option = get_site_option( 'bsf_skip_author', false );
$brainstorm_products = bsf_get_brainstorm_products( true );
foreach ( $brainstorm_products as $key => $product ) {
if ( isset( $product['id'] ) && ! in_array( $product['id'], $skip_author_products, true ) ) {
$ids[] = $product['id'];
}
}
if ( isset( $_REQUEST['bsf-skip-author-nonce'] ) && wp_verify_nonce( $_REQUEST['bsf-skip-author-nonce'], 'bsf-skip-author' ) && isset( $_GET['bsf-skip-author'] ) || empty( $ids ) && '' === $skip_author_option ) {
update_site_option( 'bsf_skip_author', true );
} elseif ( ! empty( $ids ) && '1' === $skip_author_option ) {
update_site_option( 'bsf_skip_author', false );
}
// Skip Brainstorm Menu.
$default_skip_brainstorm_menu = array(
'uabb',
'convertpro',
'astra-addon',
'astra-pro-sites',
'wp-schema-pro',
'6892199', // UAVC.
'10395942', // iMedica.
'14058953', // Convert Plus.
'5159016', // Baslider.
'imedica-mu-companion',
'astra-sites-showcase',
'uael',
'brainstorm-updater',
'astra-portfolio',
'7155037', // VC Modal Popups.
'astra',
);
$skip_brainstorm_menu_products = apply_filters( 'bsf_skip_braisntorm_menu', $default_skip_brainstorm_menu );
$ids = array();
$skip_brainstorm_menu = get_site_option( 'bsf_skip_braisntorm_menu', false );
foreach ( $brainstorm_products as $key => $product ) {
if ( isset( $product['id'] ) && ! in_array( $product['id'], $skip_brainstorm_menu_products, true ) ) {
$ids[] = $product['id'];
}
}
if ( empty( $ids ) && '' === $skip_brainstorm_menu ) {
update_site_option( 'bsf_skip_braisntorm_menu', true );
} elseif ( ! empty( $ids ) && '1' === $skip_brainstorm_menu ) {
update_site_option( 'bsf_skip_braisntorm_menu', false );
}
// Reset Brainstorm Registration.
if ( isset( $_GET['reset-bsf-users'] ) ) {
delete_option( 'brainstrom_users' );
delete_option( 'brainstrom_products' );
delete_option( 'brainstrom_bundled_products' );
delete_site_option( 'bsf_skip_author' );
}
// Reset Bundled products.
if ( isset( $_GET['remove-bundled-products'] ) ) {
global $ultimate_referer;
$ultimate_referer = 'on-refresh-bundled-products';
delete_option( 'brainstrom_bundled_products' );
get_bundled_plugins();
$redirect = isset( $_GET['redirect'] ) ? esc_url_raw( urldecode( esc_attr( $_GET['redirect'] ) ) ) : '';
if ( '' !== $redirect && filter_var( $redirect, FILTER_VALIDATE_URL ) ) {
$redirect = add_query_arg( 'bsf-reload-page', '', $redirect );
wp_safe_redirect( $redirect );
exit;
}
}
}
}
add_action( 'admin_init', 'bsf_set_options', 0 );
add_action( 'network_admin_init', 'bsf_set_options', 0 );
/**
* Flush skip registration option when any new brainstorm product is installed on the site.
*/
function bsf_flush_skip_registration() {
delete_site_option( 'bsf_skip_author' );
}
add_action( 'brainstorm_updater_new_product_added', 'bsf_flush_skip_registration' );
/**
* Return site option brainstorm_products
*
* Brainstorm_options option saves the data related to all the brainstorm products required for license management and updates.
*
* @param (boolean) $mix true: the output will be combined array of themes and plugins.
* @return (array) $brainstorm_products
*/
if ( ! function_exists( 'bsf_get_brainstorm_products' ) ) {
/**
* BSF Get Brainstorm products.
*
* @param bool $mix Mix.
* @return array $brainstorm_products.
*/
function bsf_get_brainstorm_products( $mix = false ) {
$brainstorm_products = get_option( 'brainstrom_products', array() );
if ( true === $mix ) {
$plugins = ( isset( $brainstorm_products['plugins'] ) ) ? $brainstorm_products['plugins'] : array();
$themes = ( isset( $brainstorm_products['themes'] ) ) ? $brainstorm_products['themes'] : array();
$brainstorm_products = array_merge( $plugins, $themes );
}
return $brainstorm_products;
}
}
/**
* BSF envatoredirect URL callback.
*/
function bsf_envato_redirect_url_callback() {
check_ajax_referer( 'envato_activation_nonce', 'envato_activation_nonce' );
// bail if current user cannot manage_options.
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
$envato_activate = new BSF_Envato_Activate();
$form_data = array();
$form_data['product_id'] = isset( $_GET['product_id'] ) ? esc_attr( $_GET['product_id'] ) : '';
$form_data['url'] = isset( $_GET['url'] ) ? esc_url_raw( $_GET['url'] ) : '';
$form_data['redirect'] = isset( $_GET['redirect'] ) ? rawurlencode( $_GET['redirect'] ) : '';
$form_data['privacy_consent'] = ( isset( $_GET['privacy_consent'] ) && 'true' === $_GET['privacy_consent'] ) ? true : false;
$form_data['terms_conditions_consent'] = ( isset( $_GET['terms_conditions_consent'] ) && 'true' === $_GET['terms_conditions_consent'] ) ? true : false;
$url = $envato_activate->envato_activation_url( $form_data );
$data = array(
'url' => esc_url_raw( $url ),
);
return wp_send_json_success( $data );
}
add_action( 'wp_ajax_bsf_envato_redirect_url', 'bsf_envato_redirect_url_callback' );

View File

@@ -0,0 +1,300 @@
<?php
/**
* Admin functions for bsf core.
*
* @package BSF core
*/
/**
* Prevent direct access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
if ( ! function_exists( 'check_bsf_product_status' ) ) {
/**
* Get status of product.
*
* @param int $id product id.
* @return bool
*/
function check_bsf_product_status( $id ) {
$brainstrom_products = ( get_option( 'brainstrom_products' ) ) ? get_option( 'brainstrom_products' ) : array();
$bsf_product_themes = ( isset( $brainstrom_products['themes'] ) ) ? $brainstrom_products['themes'] : array();
if ( empty( $brainstrom_products ) ) {
return false;
}
$status = false;
foreach ( $brainstrom_products as $products ) {
foreach ( $products as $key => $product ) {
if ( $product['id'] === $id ) {
$status = ( isset( $product['status'] ) ) ? $product['status'] : '';
break;
}
}
}
return $status;
}
}
if ( ! function_exists( 'get_bundled_plugins' ) ) {
/**
* Retrieves bundled plugin data.
*
* @param string $template product template.
* @return void
*/
function get_bundled_plugins( $template = '' ) {
global $ultimate_referer;
$brainstrom_products = get_option( 'brainstrom_products', array() );
$prd_ids = array();
// If brainstrom_products is not yet set, call bsf core init.
if ( is_array( $brainstrom_products ) ) {
init_bsf_core();
$brainstrom_products = get_option( 'brainstrom_products', array() );
}
foreach ( $brainstrom_products as $key => $value ) {
foreach ( $value as $key => $value2 ) {
array_push( $prd_ids, $key );
}
}
$path = bsf_get_api_url() . '?referer=' . $ultimate_referer;
$data = array(
'action' => 'bsf_fetch_brainstorm_products',
'id' => $prd_ids,
);
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '10',
)
);
// Request http URL if the https version fails.
if ( is_wp_error( $request ) && wp_remote_retrieve_response_code( $request ) !== 200 ) {
$path = bsf_get_api_url( true ) . '?referer=' . $ultimate_referer;
$request = wp_remote_post(
$path,
array(
'body' => $data,
'timeout' => '8',
)
);
}
if ( ! is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) === 200 ) {
$result = json_decode( $request['body'] );
$bundled = array();
$simple = array();
if ( ! empty( $result ) ) {
if ( ! empty( $result->bundled ) ) {
$bundled = $result->bundled;
}
if ( ! empty( $result->simple ) ) {
$simple = $result->simple;
}
}
foreach ( $bundled as $key => $value ) {
if ( empty( $value ) ) {
unset( $bundled->$key );
}
}
$brainstrom_bundled_products = (array) $bundled;
update_option( 'brainstrom_bundled_products', $brainstrom_bundled_products );
// update 'brainstorm_products'.
$simple = json_decode( wp_json_encode( $simple ), 1 );
foreach ( $brainstrom_products as $type => $products ) {
foreach ( $products as $key => $product ) {
$old_id = isset( $product['id'] ) ? $product['id'] : '';
$simple[ $type ][ $old_id ]['template'] = isset( $brainstrom_products[ $type ][ $old_id ]['template'] ) ? $brainstrom_products[ $type ][ $old_id ]['template'] : '';
$simple[ $type ][ $old_id ]['remote'] = isset( $simple[ $type ][ $old_id ]['version'] ) ? $simple[ $type ][ $old_id ]['version'] : '';
$simple[ $type ][ $old_id ]['version'] = isset( $brainstrom_products[ $type ][ $old_id ]['version'] ) ? $brainstrom_products[ $type ][ $old_id ]['version'] : '';
$simple[ $type ][ $old_id ]['purchase_key'] = isset( $brainstrom_products[ $type ][ $old_id ]['purchase_key'] ) ? $brainstrom_products[ $type ][ $old_id ]['purchase_key'] : '';
$simple[ $type ][ $old_id ]['status'] = isset( $brainstrom_products[ $type ][ $old_id ]['status'] ) ? $brainstrom_products[ $type ][ $old_id ]['status'] : '';
$simple[ $type ][ $old_id ]['message'] = isset( $brainstrom_products[ $type ][ $old_id ]['message'] ) ? $brainstrom_products[ $type ][ $old_id ]['message'] : '';
}
}
update_option( 'brainstrom_products', $simple );
}
}
}
/**
* Displays bundled product list for product.
*
* @param string $product_id Product ID.
* @param bool $installed Show installed products?.
* @return string
*/
function bsf_render_bundled_products( $product_id, $installed ) {
$product_status = check_bsf_product_status( $product_id );
$brainstrom_bundled_products = get_option( 'brainstrom_bundled_products', array() );
if ( isset( $brainstrom_bundled_products[ $product_id ] ) ) {
$brainstrom_bundled_products = $brainstrom_bundled_products[ $product_id ];
}
usort( $brainstrom_bundled_products, 'bsf_sort' );
$global_plugin_installed = 0;
$global_plugin_activated = 0;
$total_bundled_plugins = count( $brainstrom_bundled_products );
foreach ( $brainstrom_bundled_products as $key => $product ) {
if ( ! isset( $product->id ) || empty( $product->id ) ) {
continue;
}
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
continue;
}
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
if ( is_file( $plugin_abs_path ) ) {
$global_plugin_installed++;
if ( is_plugin_active( $product->init ) ) {
$global_plugin_activated++;
}
}
}
ob_start();
if ( $total_bundled_plugins === $global_plugin_installed ) {
?>
<div class="bsf-extensions-no-active">
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-smiley"></span></div>
<p class="bsf-text-light"><em><?php esc_html_e( 'All available extensions have been installed!', 'bsf' ); ?></em></p>
</div>
<?php
return ob_get_clean();
}
if ( empty( $brainstrom_bundled_products ) ) {
?>
<div class="bsf-extensions-no-active">
<div class="bsf-extensions-title-icon"><span class="dashicons dashicons-download"></span></div>
<p class="bsf-text-light"><em><?php esc_html_e( 'No extensions available yet!', 'bsf' ); ?></em></p>
<div class="bsf-cp-rem-bundle" style="margin-top: 30px;">
<a class="button-primary" href="<?php echo esc_url( $reset_bundled_url ); ?>"><?php esc_html_e( 'Refresh Bundled Products', 'bsf' ); ?></a>
</div>
</div>
<?php
return ob_get_clean();
}
foreach ( $brainstrom_bundled_products as $key => $product ) {
if ( ! isset( $product->id ) || empty( $product->id ) ) {
continue;
}
if ( isset( $request_product_id ) && $request_product_id !== $product->id ) {
continue;
}
$is_plugin_installed = false;
$is_plugin_activated = false;
$plugin_abs_path = WP_PLUGIN_DIR . '/' . $product->init;
if ( is_file( $plugin_abs_path ) ) {
$is_plugin_installed = true;
if ( is_plugin_active( $product->init ) ) {
$is_plugin_activated = true;
}
}
if ( ( $is_plugin_installed && ! $installed ) || ( ! $is_plugin_installed && $installed ) ) {
continue;
}
if ( $is_plugin_installed && $is_plugin_activated ) {
$class = 'active-plugin';
} elseif ( $is_plugin_installed && ! $is_plugin_activated ) {
$class = 'inactive-plugin';
} else {
$class = 'plugin-not-installed';
}
?>
<li id="ext-<?php echo esc_attr( $key ); ?>" class="bsf-extension <?php echo esc_attr( $class ); ?> bsf-extension-<?php echo esc_attr( $product->slug ); ?>" data-init="<?php echo esc_attr( $product->init ); ?>">
<?php if ( ! $is_plugin_installed ) { ?>
<div class="bsf-extension-start-install">
<div class="bsf-extension-start-install-content">
<h2><?php esc_html_e( 'Downloading', 'bsf' ); ?><div class="bsf-css-loader"></div></h2>
</div>
</div>
<?php } ?>
<div class="top-section">
<?php if ( ! empty( $product->product_image ) ) { ?>
<div class="bsf-extension-product-image">
<div class="bsf-extension-product-image-stick">
<img src="<?php echo esc_url( $product->product_image ); ?>" class="img" alt="image"/>
</div>
</div>
<?php } ?>
<div class="bsf-extension-info">
<?php $name = ( isset( $product->short_name ) ) ? $product->short_name : $product->name; ?>
<h4 class="title"><?php echo esc_html( $name ); ?></h4>
<p class="desc"><?php echo esc_html( $product->description ); ?><span class="author"><cite>By <?php echo esc_html( $product->author ); ?></cite></span></p>
</div>
</div>
<div class="bottom-section">
<?php
$button_class = '';
if ( ! $is_plugin_installed ) {
if ( ( ! $product->licence_require || 'false' === $product->licence_require ) || 'registered' === $product_status ) {
$installer_url = bsf_exension_installer_url( $product_id );
$button = __( 'Install', 'bsf' );
$button_class = 'bsf-install-button install-now';
} elseif ( ( $product->licence_require || 'true' === $product->licence_require ) && 'registered' !== $product_status ) {
$installer_url = bsf_registration_page_url( '&id=' . $product_id, $product_id );
$button = __( 'Validate Purchase', 'bsf' );
$button_class = 'bsf-validate-licence-button';
}
} else {
$current_name = strtolower( bsf_get_current_name( $product->init, $product->type ) );
$current_name = preg_replace( '![^a-z0-9]+!i', '-', $current_name );
if ( is_multisite() ) {
$installer_url = network_admin_url( 'plugins.php#' . $current_name );
} else {
$installer_url = admin_url( 'plugins.php#' . $current_name );
}
$button = __( 'Installed', 'bsf' );
}
?>
<a class="button button-primary extension-button <?php echo esc_attr( $button_class ); ?>" href="<?php echo esc_url( $installer_url ); ?>" data-slug="<?php echo esc_html( $product->slug ); ?>" data-ext="<?php echo esc_attr( $key ); ?>" data-pid="<?php echo esc_attr( $product->id ); ?>" data-bundled="true" data-action="install"><?php echo esc_html( $button ); ?></a>
</div>
</li>
<?php
}
return ob_get_clean();
}

View File

@@ -0,0 +1,15 @@
<?php
/**
* Plugin installer.
*
* @package bsf-core
*/
/**
* Prevent direct access.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
require_once BSF_UPDATER_PATH . '/includes/views/list-bundled-products.php';

View File

@@ -0,0 +1 @@
1.29.9

View File

@@ -0,0 +1,2 @@
/* Do not change otherwise you won't get updates */
ID:[wp-schema-pro]

View File

@@ -0,0 +1,440 @@
v2.7.12
# Improvement: Added Timezone setting field to Event schema for Online events and added timezone offset to date properties.
# Improvement: Compatibility with WordPress VIP Go rules.
# Fix: ACF checkbox field values are not getting fetched.
# Fix: ACF User field value not fetched in Schema fields.
# Fix: PHP fatal error while saving ACF field group settings.
v2.7.11
# Improvement: Added new required properties in Course Schema - offers, courseWorkload / courseSchedule.
# Fix: Corrected syntax for FAQ schema type.
v2.7.10
# Improvement: Improved codebase for improved security.
# Improvement: Added Clip and SeekToAction fields in Video Object schema.
# Fix: Invalid value errors for some fields in Job Posting schema when set to none.
# Fix: Resolved PHP error while editing Posts/Pages in some cases.
v2.7.9
# Fix: Addressed a Broken Access Control security bug. Props to Patchstack for privately reporting it to our team.
# Fix: Issue with the custom image setting for How To Block.
v2.7.8
# New: Rollback to previous versions feature.
# Improvement: Addressed nonces verification more effectively.
# Improvement: Allowed HTML format for the Description field in Job Posting Schema as per Google's guidelines.
# Improvement: Updated Interaction Count field markup in the Video Object schema as per Google guidelines.
# Fix: Invalid value error for Rating and Review Count fields when set to none in Local Business schema.
v2.7.7
# Improvement: Updated markup for educationRequirements and experienceRequirements fields in Job Posting schema.
# Fix: Resolved PHP warning for Site Logo.
# Fix: Custom Fields used in schema not showing correct value.
v2.7.6
# Fix: Schema fields not showing after saving in the page editor.
v2.7.5
# Improvement: Added compatibility to PHP v8.1.
v2.7.4
# Fix: Added Credit Text, Creator and Copy Right Notice fields in the Image schema.
# Fix: Updated brand type markup in the product schema.
# Fix: Added content URL as required field in the recipe schema.
# Fix: Review type field validation in the Review schema.
v2.7.3
# Fix: ACF field value is not added properly on global settings.
# Fix: FAQ block schema is showing error issue on search page.
# Fix: Fixed license redirect URL is not working on the plugin activation form.
# Fix: Updated publisher and author URL field mapping in the review schema.
v2.7.2
# New:`wp_schema_pro_exclude_logo_optimize` Filter to to disable default logo size changes.
# Fix: Skip Rendering Invalid Schema option not generating schema markup on page or post.
# Fix: The Brand field type warning issue in the Product item review type in the review schema
# Fix: Fixed author URl fetch issue in the Article schema.
# Fix: Fixed syntax issue inthe WPML config file.
v2.7.1
Fix: Fixed syntax error on the schema configuration page.
v2.7.0
New: Image License schema type.
Improvements: added How-to block compatibility with WPML 4.5
Improvements: Added Author.URL field in the article schema.
Improvements: Added backorder availability option in the Product schema.
Improvements: Added Day as base salary option in the Job posting schema.
Fix: Fatal Error issue with ACF on all singulars target rules.
Fix: Fixed Breadcrumb archive URL issue on the archive page.
Fix: Fixed index notice issue on the page level configuration.
v2.6.5
Fix: Fixed image field markup issue in the Review schema.
v2.6.4
Improvements: Compatibility with the latest Sonarlint PHP code standard.
Improvements: Added multiple fields option for job applicant Location Requirement.
Fix: Other custom field image map issue in the Review Schema.
Fix: Removed deprecated Professional Service business type from Local Business Schema.
Fix: Duplicate Breadcrumb schema visible with Yoast SEO pluign.
Fix: Woocommerce plugin conflict on the setup wizard.
Fix: Fixed array offset error on multisite websites.
Fix: Updated deprecated block category hook in schema blocks.
v2.6.3
# Improvements: Compatible with WordPress v5.8
# Fix: Fixed Custom schema markup showing issue on the frontend.
v2.6.2
# Fix: Fixed Person schema markup null error issue.
v2.6.1
# New: Implemented Lazy loading for the SCSS.
# Improvements: Loading the minified JS and CSS in the back-end and front-end.
# Fix: PHP notice due to undefined index issue in the Sitelink schema.
# Fix: Typography is not working on the editor for How-to steps.
# Fix: Removed unnecessary Inherit from theme option for How-to steps link.
# Fix: Markup issue into the FAQ Block schema.
v2.6.0
# New: Added Dynamic fields option for Social profiles setting.
# New: Implemented Lazy loading functionality for Schema blocks.
# Improvements: Optimized blocks JS loading on the editor page.
# Improvements: Refactor FAQ and how-to blocks code-based structure.
# Improvements: Compatibility with the latest JavaScript standard rule.
# Improvements: Compatibility with the latest CSS standard rule.
# Fix: Fixed UI icon issue on the post or page.
# Fix Trim function console error issue in the FAQ schema.
# Fix: The URL warning issue in the Product item review type in the review schema.
v2.5.2
# Improvement: Remote work fields in job posting schema as per google guidelines.
# Fix:- UI is not working properly on posts/pages in the RTL mode.
# Fix: The toggle button is not working properly for Enable/Disable schema type filter.
# Fix:- Fixed half rating issue on the frontend.
v2.5.1
# Fix: Decimal value is not accepted into the Geolocation fields of Local Business Schema.
# Fix: FAQ block schema accessibility issue.
v2.5.0
# New: Custom schema markup on post or page.
# Improvement: Ajax-based schema type required field validation.
# Improvement: Added Geolocation fields in the Local business schema.
# Fix: Fixed tab index issue in the FAQ block schema.
# Fix: Fixed undefined index notice issue in the review schema.
# Fix: 'unstableOnSplit' property warning issue in the How-to schema.
# Fix: 'onnRemove' Unknown event handler property warning issue in the how-to schema.
# Fix: Fixed the border issue on the setup wizard.
v2.4.0
# New: How-to block schema.
# Improvement: Added Review fields in the product schema.
# Improvement: Added filter to automatically fetch schema markup for WooCommerce product reviews.
# Fix: Fixed review count field visible issue in the Review Schema.
# Fix: Added missing recommended field inside the Event type of Review Schema.
# Fix: Removed deprecated Item name, Review image, and URL field in the Review Schema.
# Fix: Fixed different language string translation issues in the plugin.
# Fix: Fixed HTTPS not showing in test schema URL.
v2.3.0
# New: Dynamic repeater fields on the post or page.
# Improvement: Added optimised Logo image size in the Organization schema.
# Improvement: Added Validation on published date and modified date in the Article schema.
# Fix: FAQ Schema - Fixed child block not inheriting question tag from the parent block when adding a new question.
# Fix: Bulk schema type select issue in the schema dashboard.
# Fix: Fixed schema markup error issue in the about page and contact page schema.
# Fix: Fixed Event attendance mode option select issue on the event schema.
# Fix: FAQ console error when accessing child by id in the FAQ block schema.
# Fix: Select other custom field option issue on the post or page.
# Fix: Fixed online location markup issue inside Course schema.
# Fix: Fixed test link is not shown on the admin bar.
v2.2.3
# Improvement:PHP Deprecated: Required parameters follows optional parameters in get meta markup function - Compatibility with PHP v8.0
# Improvement: Compatible with WordPress v5.6
# Improvement: Added Preview of FAQ block schema.
# Improvement: Added how to fields missing in the Recipe schema.
# Improvement: Added the Brand field type into the product schema.
# Improvement: Skipped loading of dependent JS file for Grid layout into the FAQ Block Schema.
# Fix: Fixed the General tab UI issue into the Dashboard.
v2.2.2
# Improvement: Added the Publisher SameAs field in the Review schema.
# Improvement: Added none option for search specific page fields in the configuration settings.
# Fix: Fixed Front page target rule issue in the schema type settings.
# Fix: Publisher type error issue in the about page and contact page schema.
# Fix: The Event Attendance Mode field warning issue with event schema types.
v2.2.1
# Fix: Undefined constant SECURE_AUTH_COOKIE warning issue with multisite fixed.
# Fix: array_intersect warning issue on plugin activation fixed.
# Fix: The dashboard logo was not visible in the multisite fixed.
v2.2.0
# New: FAQ block Schema.
# New: Added multiple FAQ block schema support.
# New: Added WPML compatibility for FAQ block.
# Improvement: Added post or page schema fields setting visible only for the administrator role.
# Improvement: Added `wp_schema_pro_role`filter to visible schema configuration setting on post or page.
# Fix: Updated required fields status for Product and Organization item review type as per google guidelines.
# Fix: Fixed JSON-LD code format issues with different languages.
# Fix: Fixed exclude category fields configuration issue in the target rule setting.
# Fix: Fixed the border issue after WP5.5 at the backend.
# Fix: Fixed notice show position issue on the schema settings.
# Fix: A knowledge base section is not showing on the settings tab.
v2.1.2
# New: Added new social share link options for Wikipedia and MySpace.
# Improvements: Updated settings in Setup Wizard.
# Improvements: Restructure Configuration settings.
# Improvements: Google+ field deprecated in the social profile section.
# Improvements: Added new types in the organization type option.
# Improvements: Organization schema is now only targeted on the home page.
# Improvements: Removed extra contact information field in the corporate contact.
# Improvements: Added search box for search page option for a contact and about page schema.
# Improvements: Added backward compatibility for deprecated extra fields of corporate contact.
# Improvements: Added breadcrumb enable/disable the setting option in the breadcrumb tab.
# Improvements: Added knowledge base link in a sidebar.
# Improvements: Added Fetch logo from theme customizer automatically for the logo field.
# Fix: Fixed time select issue on datetimepicker.
# Fix: Fixed selecting years ahead range in the datetimepicker.
# Fix: Fixed Logo validation issue on the post or page.
# Fix: To accept rating step point value in the fixed rating option.
v2.1.1
# Fix: Fixed the error of few arguments to function on plugin update.
v2.1.0
# New: How-to Schema.
# Improvements: Added tool-tips for schema fields.
# Improvements: UI strings improvements.
# Improvements: Updated Test schema link as per new Google guidelines.
# Fix: Empty field error issue in the FAQ schema markup.
# Fix: Fixed year select issue in the person schema.
# Fix: Accept user rating not showing for item review type fields in the review schema.
# Fix: Remove autoload wp_schema_pro_optimized_structured_data option on plugin update.
v2.0.1
# New: Users can now share non-personal usage data to help us test and develop better products.
# Improvements: Added required field validation label on Corporate Contact.
# Improvements: Added the Toggle button for the Enable Schema Markup filter.
# Fix: Fixed the close button not showing into the FAQ schema.
# Fix: Logo accepts from schema configuration into schema types.
# Fix: Update the UI and fixed the Enable schema markup filter issue.
# Fix: Updated Reset star rating functionality.
# Fix: Schema Markup is not generating for the Contact page and About us page.
# Fix: Notice not showing for required repeater fields in the schema configuration settings.
v2.0.0
# New: Frontend required field validation.
# New: UI improvements of schema fields setting on the post and page.
# New: Added the select meta-list on the specific post and page setting.
# New: Added search box for custom field or third party custom field fetch setting.
# New: Added global data and local data saving compatibility.
# New: Added option Enable Skip Rendering Invalid Schema in the advanced setting.
# New: Added Tool-tip for Global field mapped on the post.
# New: Added ACF field Compatibility for the post and page.
# Improvements: Optimized Schema types structure on the Global setting.
# Improvements: Updated Recommended fields in the Course schema.
# Improvements: Updated Organizer field in the Event schema.
# Improvements: Allows the HTML element inside answer field in the FAQ Schema.
# Improvements: Added Validation on start and end date in the Event schema.
# Improvements: Added the Clear button on the Date-picker.
# Fix: Fixed the date field's issue not showing into the Date picker in the review schema.
# Fix: PHP notice issue on the admin page at the time of activation.
# Fix: Date issue when time zone change for online events in the Event Schema.
# Fix: The extra schema markup was generating for the category or tag.
# Fix: Translation issue for the date fields for languages.
v1.7.0
# New: FAQ schema.
# New: Added the Regenerate Schema Markup feature.
# Improvement: Added Date and Time picker.
# Fix: Removed a Day/Hour/Minute/Second field with backward & forward compatibility from review schema.
# Fix: Fixed update schema markup issue on the configuration page.
# Fix: Added home page URL in Website schema.
# Fix: Delete Data Uninstall setting is not visible at the backend.
# Fix: Fixed language translation issue in the schema markup.
# Fix: Fixed issue of Trying to access array offset on the value of type bool with PHP 7.4 compatibility.
v1.6.1
# Improvement: Hardened the security of the plugin.
# Fix: JSON-LD Schema markup formatting according to google guidelines.
v1.6.0
# New: Added new fields in Event Schema type for the canceled/rescheduled/postponed events as per new Google guidelines.
# New: Added Movie as an item review type in the review schema.
# New: Added Organization as an item type in the review schema.
# Improvement: Added Article types in the Article schema.
# Improvement: UI appearance changes as per new Google guidelines.
# Improvement: Added description tooltip for required fields in the schema configuration page.
# Fix: Aggregate rating was not updating through the front-end.
# Fix: Autoload issue with optimized cache structured data.
v1.5.2
# Improvement: Hardened the security of the plugin.
# Improvement: Compatibility with the latest WordPress PHP_CodeSniffer rules.
# Improvement: Added categories for software application schema.
# Improvement: Added reviewer type in for author field in Recipe schema.
# Improvement: Optimized number of function calls in the frontend and backend.
# Improvement: Optimized number of queries executed on the admin page.
# Improvement: Re-structured and optimized the codebase to improve security.
# Fix: gmdate() insted of date() function and phpcs changes.
# Fix: The software application price field issue in the review schema.
v1.5.1
# Security Fix: Cross-site scripting (XSS) vulnerability.
v1.5.0
# New: Added schema markup for amp pages or posts compatibility.
# New: Delete schema data and settings on the uninstalled plugin with a delete option.
# New: Added Event schema types added in Event schema.
# New:`wp_schema_pro_remove_amp_schema_markup` Filter to disable schema markup for AMP pages or posts on Reader mode.
# Fix: Permalink added for the sameAs field in Review schema.
v1.4.1
# Improvement: Added new fields for product ItemReviewed type of review schema.
# Improvement: Added MPN field in product schema.
# Improvement: Added dependency to the SameAS field for Book ItemReviewed type in review schema.
# Improvement: Organization logo field in job posting schema.
# Fix: reviewBody and description fields are not working correctly in review schema.
# Fix: Post_type notice issue in the schema pro menu option.
v1.4.0
# New: Added ItemReviewed types in Review schema.
# Fix: Review schema given an error `Thing is not a known valid target type for the item reviewed the property`.
v1.3.2
# Improvement: Removed Aggregate rating markup from article and service schema according to the google requirement.
v1.3.1
# New: `wp_schema_pro_comment_before_markup_enabled` Filter to remove comment before schema Markup.
# Improvement: Added site link on Schema Pro logo, updated labels and tooltip description.
# Improvement: Replace Google documents links with schema pro documents links in the plugin.
# Fix: Added Ingredients separately and video type for video fields in Recipe schema.
v1.3.0
# New: Introducing White Label feature.
# New: Default image option in advanced settings.
# New: Contact point information control in configuration settings.
# Fix: Image URL issue with Service schema.
# Fix: Instructions steps issue with Recipe schema.
v1.2.0
# New: Improved BreadcrumbList schema by providing control settings.
# New: `wp_schema_pro_link_to_specificpage` Filter to remove shop(archive page) item from product schema.
# New: Added Organisation types option in Configuration settings.
# Improvement: Added Version number with plugin title.
# Improvement: Added Logo guidelines in Configuration settings.
v1.1.13
# Improvement: `bsf_target_rules_include_parent_taxanomy` Filter to allow subcategories to be select in Enable On option.
# Improvement: Replaced default Select string option to None.
# Improvement: Text updated of rule set buttons in target option.
# Improvement: Updated Select2 library.
# Fix: Updated default selection of schema type for Local business and Review schema.
v1.1.12
# Improvement: Added Google recommended fields for product schema.
# Improvement: Added Reviewer type option in review schema.
# Improvement: Added new value for Gender option in Person Schema.
# Fix: Updated `wp_schema_pro_schema_recipe ` filter to `wp_schema_pro_schema_service` for service schema.
# Fix: Yoast SEO compatibility issue.
v1.1.11
# Improvement: updated image-object case for the logo for organization schema.
# Improvement: updated enqueue method to load script and style file for rating in frontend.
# Improvement: Added Locksmith type option in the Local Business schema.
# Fix: Rating stars color fill issue on hover.
v1.1.10
# Improvement: Added MedicalBusiness type option in the Local Business schema.
# Improvement: `wp_schema_pro_remove_product_offers` Filter to remove offers from product schema.
# Fix: A compatible issue of rating markup not changing instantly.
# Fix: Admin notice to start wizard not display for configuration.
# Fix: Notice issues on setup wizard.
v1.1.9
# Improvement: Optimize plugin code and improved performance.
v1.1.8
# Improvement: ACF Compatibility Updated.
# Improvement: Improved SiteNavigationElement schema.
# Fix: Use logo from customizer option issue.
v1.1.7
# Improvement: Added Address, Member Of, Nationality, Same As, Birth Date and Gender in Person schema.
# Improvement: Added Rating option in Course and Service schema.
# Improvement: Added Business types option in Local Business schema.
# Improvement: Added Front Page in the target options.
# Fix: CourseInstance option validation issue in course schema.
v1.1.6
# Fix: Updated event schema StartDate and EndDate field type.
v1.1.5
# Fix: License activation link is not working.
v1.1.4
# Improvement: Added Keywords, Category, Cuisine, Instructions and video fields for recipe schema.
# Improvement: Updated license registration process with Privacy Policy.
# Improvement: Min and Max salary option added in job posting schema.
# Improvement: Taxonomies options are added to the specific target for the schema.
# Improvement: Added rating option in article schema.
# Improvement: Decimal value can be added in product price.
# Improvement: Added `wp_schema_pro_schema_enabled` and `wp_schema_pro_global_schema_enabled` filters to disable schemas globally.
# Fix: The publisher should appear in schemas according to the site represent.
# Fix: Shortcode appears in the description field in schemas.
# Fix: Class conflict issue in person schema.
v1.1.3
# Improvement: Added `wp_schema_pro_link_to_frontpage` filter to remove home list item from BreadcrumbList schema.
# Improvement: Added image-object case for the logo without width and height for article schema.
# Improvement: Added `add_ratings_schema_pro_markup` filter and `wp_schema_pro_rating_shortcode` shortcode to add rating more than one time in page/post.
# Improvement: Updated logo field as a common field in global setting for both organization and person schema.
# Improvement: Support added for Mobile App & Web App categories in Software Application schema.
# Improvement: Support added for 0 price schema field.
# Fix: Time formate updated in schema markup.
# Fix: Updated URL format Http to Https in schema's context type.
v1.1.2
# Improvement: ACF Pro compatibility implemented.
# Fixed: Star rating conflict with WooCommerce.
# Fixed: Undefined index meta-created schema wizard.
# Fixed: Undefined function call 'get_pages'.
v1.1.1
# Added: `wp_schema_pro_default_markup` Filter to display Enable Schema Markup option on edit page/post.
# Fixed: PHP notice: undefined `description` index.
# Fixed: PHP notice: invalid argument passed in foreach.
v1.1.0
# Added: Setup Wizard to configure global schema step by step
# Added: New Support for sitewide schema types: Organization/Person, AboutPage, ContactPage, Sitelink Search Box, Breadcrumb, Site Navigation Element.
# Fixed: Schema not rendering on the frontpage.
# Fixed: Frontpage meta fields not getting saved while Yoast SEO enabled.
v1.0.3
# Enhancement: Updated plugin name `All-in-one Schema Pro` to `Schema Pro`.
# Enhancement: All Fiters prefix updated with `wp_schema_pro`.
# Fixed: Image selection not working in edit post.
v1.0.2
# Enhancement: Listed all Country & Currency in related option.
# Enhancement: Updated required & recommended schema fields for Course.
# Fixed: Repeater fields value not getting saved on edit post/page.
# Fixed: Fixed logo size issue on "Google Structured Data Testing Tool"
# Fixed: Strip HTML markup from schema.
v1.0.1
# Enhancement: Updated field types for Fixed value in Schema Post.
# Enhancement: Updated required & recommended schema fields for Book & VideoObject Schema. You should test your schema configurations if you are using one of these schemas.
# Fixed: Telephone number field not accepting all telephone format
# Fixed: Test Schema link having `http://` instead of `https://` when SSL is enabled.
v1.0.0
# New: "Accept User Rating" option added for aggregate ratings in Mapping options.
v1.0.0-beta.3
# Initial Release

View File

@@ -0,0 +1,197 @@
<?php
/**
* Brainstorm_Update_AIOSRS_Pro initial setup
*
* @package Schema Pro
* @since 1.0.0
*/
if ( ! class_exists( 'Brainstorm_Update_AIOSRS_Pro' ) ) :
/**
* Brainstorm Update
*/
class Brainstorm_Update_AIOSRS_Pro {
/**
* Instance
*
* @var object Class object.
* @access private
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
self::version_check();
add_action( 'init', array( $this, 'load' ), 999 );
add_filter( 'bsf_get_license_message_wp-schema-pro', array( $this, 'license_message_aiosrs_pro' ), 10, 2 );
add_filter( 'bsf_skip_braisntorm_menu', array( $this, 'skip_menu' ) );
add_filter( 'bsf_skip_author_registration', array( $this, 'skip_menu' ) );
add_filter( 'bsf_remove_wp-schema-pro_from_registration_listing', '__return_true' );
add_filter( 'agency_updater_productname_wp-schema-pro', array( $this, 'product_name' ) );
// Add popup license form on plugin list page.
add_action( 'plugin_action_links_' . BSF_AIOSRS_PRO_BASE, array( $this, 'bsf_aiosrs_pro_license_form_and_links' ) );
add_action( 'network_admin_plugin_action_links_' . BSF_AIOSRS_PRO_BASE, array( $this, 'bsf_aiosrs_pro_license_form_and_links' ) );
add_filter( 'bsf_registration_page_url_wp-schema-pro', array( $this, 'bsf_aiosrs_pro_bsf_registration_page_url' ) );
add_filter( 'bsf_product_activation_notice_wp-schema-pro', __class__ . '::update_aiosrs_license_notice', 10, 3 );
}
/**
* Updated the license notice when white label is activated.
*
* @param string $message for license notice.
* @param string $url for activate button.
* @param string $product_name replace the name with white label.
* @return string message.
*/
public static function update_aiosrs_license_notice( $message, $url, $product_name ) {
$branding = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
if ( isset( $branding['sp_plugin_name'] ) && '' !== $branding['sp_plugin_name'] ) {
$product_name = $branding['sp_plugin_name'];
}
/* translators: %s: search term */
return sprintf( __( 'Please <a href= %1$s class="bsf-core-license-form-btn" plugin-slug="wp-schema-pro"> activate </a>your copy of the<i> %2$s </i>to get update notifications, access to support features & other resources!', 'wp-schema-pro' ), $url, $product_name );
}
/**
* Show action links on the plugin screen.
*
* @param mixed $links Plugin Action links.
* @return array Filtered plugin action links.
*/
public function bsf_aiosrs_pro_license_form_and_links( $links = array() ) {
if ( function_exists( 'get_bsf_inline_license_form' ) ) {
$args = array(
'product_id' => 'wp-schema-pro',
'popup_license_form' => true,
);
return get_bsf_inline_license_form( $links, $args, 'edd' );
}
return $links;
}
/**
* Bsf registration page
*
* @since 1.1.0
*/
public function bsf_aiosrs_pro_bsf_registration_page_url() { // phpcs:ignore WordPressVIPMinimum.Hooks.AlwaysReturnInFilter.MissingReturnStatement
if ( is_multisite() ) {
return network_admin_url( 'plugins.php?bsf-inline-license-form=wp-schema-pro' );
} else {
return admin_url( 'plugins.php?bsf-inline-license-form=wp-schema-pro' );
}
}
/**
* Product Name.
*
* @param string $name Product Name.
* @return string product name.
*/
public function product_name( $name ) {
$branding = get_option( 'wp-schema-pro-branding-settings' );
if ( isset( $branding['sp_plugin_name'] ) && '' !== $branding['sp_plugin_name'] ) {
$name = $branding['sp_plugin_name'];
}
return $name;
}
/**
* Skip Menu.
*
* @param array $products products.
* @return array $products updated products.
*/
public function skip_menu( $products ) {
$products[] = 'wp-schema-pro';
return $products;
}
/**
* Update brainstorm product version and product path.
*
* @return void
*/
public static function version_check() {
$bsf_core_version_file = realpath( BSF_AIOSRS_PRO_DIR . '/admin/bsf-core/version.yml' );
// Is file 'version.yml' exist?
if ( is_file( $bsf_core_version_file ) ) {
global $bsf_core_version, $bsf_core_path;
$bsf_core_dir = realpath( BSF_AIOSRS_PRO_DIR . '/admin/bsf-core/' );
$version = file_get_contents( realpath( plugin_dir_path( BSF_AIOSRS_PRO_FILE ) . '/admin/bsf-core/version.yml' ) );
// Compare versions.
if ( version_compare( $version, (string) $bsf_core_version, '>' ) ) {
$bsf_core_version = $version;
$bsf_core_path = $bsf_core_dir;
}
}
}
/**
* Add Message for license.
*
* @param string $content Content.
* @param string $purchase_url purchase_url.
* @return string output message.
*/
public function license_message_aiosrs_pro( $content, $purchase_url ) {
$purchase_url = apply_filters( 'wp_schema_pro_licence_url', $purchase_url );
$message = "<p><a target='_blank' href='" . esc_url( $purchase_url ) . "'>" . esc_html__( 'Get the license >>', 'wp-schema-pro' ) . '</a></p>';
$branding = get_option( 'wp-schema-pro-branding-settings' );
if ( isset( $branding['sp_plugin_name'] ) && '' !== $branding['sp_plugin_name'] ) {
$message = '';
}
return $message;
}
/**
* Load the brainstorm updater.
*
* @return void
*/
public function load() {
global $bsf_core_version, $bsf_core_path;
if ( is_file( realpath( $bsf_core_path . '/index.php' ) ) ) {
include_once realpath( $bsf_core_path . '/index.php' );
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
Brainstorm_Update_AIOSRS_Pro::get_instance();
endif;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
<?php
/**
* AMP for Schema Pro
*
* @package Schema Pro
*/
/**
* Exit if accessed directly.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* BSF_AIOSRS_Pro_Amp initial setup
*
* @since 1.5.0
*/
/**
* This class initializes Schema for AMP
*
* @class BSF_AIOSRS_Pro_Amp
*/
final class BSF_AIOSRS_Pro_Amp {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*
* @access public
* @var $amp_activated set default to false.
*/
public static $amp_activated = false;
/**
* AMP Options.
*
* @access private
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor function.
*/
public function __construct() {
add_action( 'init', array( $this, 'amp_schema_markup' ) );
}
/**
* Rendering the Schema markup for AMP Template.
*/
public static function amp_schema_markup() {
if ( apply_filters( 'wp_schema_pro_remove_amp_schema_markup', true ) ) {
$settings = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
$schema_markup = BSF_AIOSRS_Pro_Markup::get_instance();
if ( isset( $settings['schema-location'] ) ) {
switch ( $settings['schema-location'] ) {
case 'head':
add_action( 'amp_post_template_head', array( $schema_markup, 'schema_markup' ) );
add_action( 'amp_post_template_head', array( $schema_markup, 'global_schemas_markup' ) );
break;
case 'footer':
add_action( 'amp_post_template_footer', array( $schema_markup, 'schema_markup' ) );
add_action( 'amp_post_template_footer', array( $schema_markup, 'global_schemas_markup' ) );
break;
default:
break;
}
}
}
}
}
BSF_AIOSRS_Pro_Amp::get_instance();

View File

@@ -0,0 +1,80 @@
<?php
/**
* White labeling for Schema Pro
*
* @package Schema Pro
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Branding' ) ) {
/**
* BSF_AIOSRS_Pro_Branding initial setup
*
* @since 1.3.0
*/
/**
* This class initializes Schema Branding
*
* @class BSF_AIOSRS_Pro_Branding
*/
final class BSF_AIOSRS_Pro_Branding {
/**
* Function that initializes necessary filters
*
* @return void
*/
public static function init() {
add_filter( 'all_plugins', __CLASS__ . '::plugins_page' );
}
/**
* Branding on the plugins page.
*
* @since 1.3.0
* @param array $plugins An array data for each plugin.
* @return array
*/
public static function plugins_page( $plugins ) {
if ( is_multisite() ) {
$branding = get_site_option( 'wp-schema-pro-branding-settings' );
} else {
$branding = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
}
$basename = plugin_basename( BSF_AIOSRS_PRO_DIR . 'wp-schema-pro.php' );
if ( isset( $plugins[ $basename ] ) && is_array( $branding ) ) {
$sp_plugin_name = ( array_key_exists( 'sp_plugin_name', $branding ) ) ? $branding['sp_plugin_name'] : '';
$sp_plugin_desc = ( array_key_exists( 'sp_plugin_desc', $branding ) ) ? $branding['sp_plugin_desc'] : '';
$sp_author_name = ( array_key_exists( 'sp_plugin_author_name', $branding ) ) ? $branding['sp_plugin_author_name'] : '';
$sp_author_url = ( array_key_exists( 'sp_plugin_author_url', $branding ) ) ? $branding['sp_plugin_author_url'] : '';
if ( '' !== $sp_plugin_name ) {
$plugins[ $basename ]['Name'] = $sp_plugin_name;
$plugins[ $basename ]['Title'] = $sp_plugin_name;
}
if ( '' !== $sp_plugin_desc ) {
$plugins[ $basename ]['Description'] = $sp_plugin_desc;
}
if ( '' !== $sp_author_name ) {
$plugins[ $basename ]['Author'] = $sp_author_name;
$plugins[ $basename ]['AuthorName'] = $sp_author_name;
}
if ( '' !== $sp_author_url ) {
$plugins[ $basename ]['AuthorURI'] = $sp_author_url;
$plugins[ $basename ]['PluginURI'] = $sp_author_url;
}
}
return $plugins;
}
}
}
BSF_AIOSRS_Pro_Branding::init();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,191 @@
<?php
/**
* Utils.
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Class BSF_AIOSRS_Pro_Helper.
*/
class BSF_AIOSRS_Pro_Helper {
/**
* Member Variable
*
* @var instance
*/
private static $instance;
/**
* Member Variable
*
* @var settings
*/
public static $settings;
/**
* Default static array
*
* @var default_options
*/
private static $default_options = array(
// General Settings.
'wp-schema-pro-general-settings' => array(
'organization' => '',
'site-represent' => '',
'site-name' => '',
'person-name' => '',
'site-logo' => 'custom',
'site-logo-custom' => '',
),
// Social Profiles.
'wp-schema-pro-social-profiles' => array(
'facebook' => '',
'twitter' => '',
'google-plus' => '',
'instagram' => '',
'youtube' => '',
'linkedin' => '',
'pinterest' => '',
'soundcloud' => '',
'tumblr' => '',
'wikipedia' => '',
'myspace' => '',
'other' => array(),
),
// Global Schemas.
'wp-schema-pro-global-schemas' => array(
'about-page' => '',
'contact-page' => '',
'site-navigation-element' => '',
'breadcrumb' => '1',
'sitelink-search-box' => '1',
),
// Advanced Settings.
'aiosrs-pro-settings' => array(
'quick-test' => '1',
'menu-position' => 'options-general.php',
'schema-location' => 'head',
'yoast-compatibility' => '1',
'schema-validation' => '',
'default_image' => '',
'delete-schema-data' => '',
),
// Corporate Contact.
'wp-schema-pro-corporate-contact' => array(
'contact-type' => '',
'telephone' => '',
'url' => '',
'email' => '',
'areaServed' => '',
'contact-hear' => '',
'contact-toll' => '',
'availableLanguage' => '',
'cp-schema-type' => '',
'areaserved-type' => '',
'country' => array(),
'place' => '',
'contact-page-id' => '',
'contact-type-other' => '',
),
// Branding Settings.
'wp-schema-pro-branding-settings' => array(
'sp_plugin_name' => '',
'sp_plugin_sname' => '',
'sp_plugin_desc' => '',
'sp_plugin_author_name' => '',
'sp_plugin_author_url' => '',
'sp_hide_label' => 'disabled',
),
'wp-schema-pro-breadcrumb-setting' => array(
'product' => '',
'product_cat' => '',
'product_tag' => '',
'enable_bread' => '1',
),
);
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
self::prepare_schema_pro_options();
}
/**
* Prepare options from database.
*/
public static function prepare_schema_pro_options() {
$options = array_keys( self::$default_options );
foreach ( $options as $option ) {
self::$settings[ $option ] = get_option( $option );
}
}
/**
* Enqueue the scripts at the backend.
*/
public static function bsf_schema_pro_enqueue_admin_script() {
global $pagenow;
return 'post-new.php' === $pagenow || 'post.php' === $pagenow;
}
/**
* Set default options.
*/
public static function bsf_schema_pro_set_default_options() {
foreach ( self::$default_options as $key => $default_option ) {
$settings = get_option( $key );
if ( ! get_option( $key ) ) {
update_option( $key, $default_option );
} else {
foreach ( $default_option as $name => $setting ) {
if ( ! isset( $settings[ $name ] ) ) {
$settings[ $name ] = $default_option[ $name ];
}
}
// Updated settings if new settings added.
update_option( $key, $settings );
}
}
// Delete decrypted cached structured option data.
delete_option( BSF_AIOSRS_PRO_CACHE_KEY );
}
/**
* Return the WP_debug.
*/
public static function bsf_schema_pro_is_wp_debug_enable() {
return true === ( defined( 'WP_DEBUG' ) && WP_DEBUG );
}
}
BSF_AIOSRS_Pro_Helper::get_instance();

View File

@@ -0,0 +1,516 @@
<?php
/**
* Schemas - Markup.
*
* @package Schema Pro
* @since 1.0.0
*/
if ( ! class_exists( 'BSF_AIOSRS_Pro_Markup' ) ) {
/**
* AIOSRS Schemas Initialization
*
* @since 1.0.0
*/
class BSF_AIOSRS_Pro_Markup {
/**
* Member Variable
*
* @var instance
*/
private static $instance;
/**
* Member Variable
*
* @var instance
*/
private static $schema_post_result = array();
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
$this->init();
}
/**
* Initalize
*
* @return void
*/
public function init() {
$settings = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
add_action( 'wp', array( $this, 'disable_astra_theme_schema' ) );
add_filter( 'the_content', array( $this, 'rating_markup' ) );
add_shortcode( 'wp_schema_pro_rating_shortcode', array( $this, 'rating_markup' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'wp_ajax_aiosrs_user_rating', array( $this, 'aiosrs_user_rating_callback' ) );
add_action( 'wp_ajax_nopriv_aiosrs_user_rating', array( $this, 'aiosrs_user_rating_callback' ) );
add_filter( 'body_class', array( $this, 'wp_schema_body_class' ) );
if ( isset( $settings['schema-location'] ) ) {
switch ( $settings['schema-location'] ) {
case 'head':
add_action( 'wp_head', array( $this, 'schema_markup' ) );
add_action( 'wp_head', array( $this, 'global_schemas_markup' ) );
break;
case 'footer':
add_action( 'wp_footer', array( $this, 'schema_markup' ) );
add_action( 'wp_footer', array( $this, 'global_schemas_markup' ) );
break;
default:
break;
}
}
}
/**
* Adding class to body
*
* @param array $classes body classes.
* @return array
*/
public function wp_schema_body_class( $classes ) {
$classes[] = 'wp-schema-pro-' . BSF_AIOSRS_PRO_VER;
return $classes;
}
/**
* Add Guest user rating
*
* @return void
*/
public function aiosrs_user_rating_callback() {
check_ajax_referer( 'schema-pro-user-rating', 'nonce' );
$response = array(
'success' => false,
);
if ( isset( $_POST['post_id'] ) && isset( $_POST['rating'] ) && isset( $_POST['schemaId'] ) ) {
$post_id = absint( $_POST['post_id'] );
$schema_id = absint( $_POST['schemaId'] );
$new_rating = absint( $_POST['rating'] );
if ( $new_rating > 5 ) {
$new_rating = 5;
}
$new_rating = $new_rating <= 0 ? 1 : $new_rating;
$client_ip = $this->get_client_ip();
$all_ratings = get_post_meta( $post_id, 'bsf-schema-pro-reviews-' . $schema_id, true );
if ( empty( $all_ratings ) ) {
update_post_meta( $post_id, 'bsf-schema-pro-rating-' . $schema_id, $new_rating );
update_post_meta( $post_id, 'bsf-schema-pro-review-counts-' . $schema_id, 1 );
update_post_meta( $post_id, 'bsf-schema-pro-reviews-' . $schema_id, array( $client_ip => $new_rating ) );
$response['success'] = true;
$response['rating'] = $new_rating;
$response['rating-avg'] = sprintf(
/* translators: 1: rating */
_x( '%s/5', 'rating out of', 'wp-schema-pro' ),
esc_html( $new_rating )
);
$response['review-count'] = __( '1 Review', 'wp-schema-pro' );
} else {
$all_ratings[ $client_ip ] = $new_rating;
$all_ratings = array_filter( $all_ratings );
$review_count = count( $all_ratings );
$avg_rating = round( array_sum( $all_ratings ) / $review_count, 1 );
update_post_meta( $post_id, 'bsf-schema-pro-rating-' . $schema_id, $avg_rating );
update_post_meta( $post_id, 'bsf-schema-pro-review-counts-' . $schema_id, $review_count );
update_post_meta( $post_id, 'bsf-schema-pro-reviews-' . $schema_id, $all_ratings );
$response['success'] = true;
$response['rating'] = $avg_rating;
$response['rating-avg'] = sprintf(
/* translators: 1: rating */
_x( '%s/5', 'rating out of', 'wp-schema-pro' ),
esc_html( $avg_rating )
);
$response['review-count'] = sprintf(
/* translators: 1: number of reviews */
_n( '(%1s Review)', '(%1s Reviews)', absint( $review_count ), 'wp-schema-pro' ),
absint( $review_count )
);
}
// Deleting cached structured data.
delete_post_meta( $post_id, BSF_AIOSRS_PRO_CACHE_KEY );
do_action( 'wp_schema_pro_after_update_user_rating', $post_id );
}
wp_send_json( $response );
}
/**
* Function to get the client IP address
*
* @return string
*/
public function get_client_ip() {
if ( getenv( 'HTTP_CLIENT_IP' ) ) {
$ipaddress = getenv( 'HTTP_CLIENT_IP' );
} elseif ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
$ipaddress = getenv( 'HTTP_X_FORWARDED_FOR' );
} elseif ( getenv( 'HTTP_X_FORWARDED' ) ) {
$ipaddress = getenv( 'HTTP_X_FORWARDED' );
} elseif ( getenv( 'HTTP_FORWARDED_FOR' ) ) {
$ipaddress = getenv( 'HTTP_FORWARDED_FOR' );
} elseif ( getenv( 'HTTP_FORWARDED' ) ) {
$ipaddress = getenv( 'HTTP_FORWARDED' );
} elseif ( getenv( 'REMOTE_ADDR' ) ) {
$ipaddress = getenv( 'REMOTE_ADDR' );
} else {
$ipaddress = 'UNKNOWN';
}
return $ipaddress;
}
/**
* Script & Styles for frontend.
*
* @return void
*/
public function enqueue_scripts() {
if ( is_singular() ) {
$post_id = get_the_ID();
$minfy_css = BSF_AIOSRS_Pro_Helper::bsf_schema_pro_is_wp_debug_enable() ? 'css/frontend.css' : 'min-css/frontend.min.css';
$minfy_js = BSF_AIOSRS_Pro_Helper::bsf_schema_pro_is_wp_debug_enable() ? 'js/frontend.js' : 'min-js/frontend.min.js';
wp_enqueue_style( 'dashicons' );
wp_register_script( 'wp-schema-pro-fontend-script', BSF_AIOSRS_PRO_URI . 'admin/assets/' . $minfy_js, array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
wp_register_style( 'wp-schema-pro-fontend-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . $minfy_css, array(), BSF_AIOSRS_PRO_VER );
wp_localize_script(
'wp-schema-pro-fontend-script',
'AIOSRS_Frontend',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'post_id' => $post_id,
'user_rating_nonce' => wp_create_nonce( 'schema-pro-user-rating' ),
'success_msg' => __( 'Thanks!', 'wp-schema-pro' ),
)
);
}
}
/**
* Add rating markup in content
*
* @param html $content Post content.
* @return html
*/
public function rating_markup( $content = '' ) {
if ( ! is_singular() ) {
return $content;
}
$rating_enabled = array();
$result = self::get_schema_posts();
if ( is_array( $result ) && ! empty( $result ) ) {
$current_post_id = get_the_id();
foreach ( $result as $post_id => $post_data ) {
$schema_type = get_post_meta( $post_id, 'bsf-aiosrs-schema-type', true );
$schema_meta = get_post_meta( $post_id, 'bsf-aiosrs-' . $schema_type, true );
$schema_enabled = BSF_AIOSRS_Pro_Custom_Fields_Markup::enable_schema_post_option();
$schema_enabled_meta_key = $schema_type . '-' . $post_id . '-enabled-schema';
$schema_enabled_meta_value = get_post_meta( $current_post_id, $schema_enabled_meta_key, true );
$schema_enabled_meta_value = ! empty( $schema_enabled_meta_value ) ? $schema_enabled_meta_value : 'disabled';
$schema_rating_value = isset( $schema_meta['schema-type'] ) ? $schema_meta['schema-type'] . '-rating' : '';
if ( empty( $current_post_id ) || empty( $schema_type ) || empty( $schema_meta ) || ( $schema_enabled && 'disabled' === $schema_enabled_meta_value ) ) {
continue;
}
foreach ( $schema_meta as $meta_key => $metavalue ) {
if ( $meta_key === $schema_rating_value && 'accept-user-rating' === $metavalue ) {
$rating_enabled[] = $post_id;
}
}
if ( ( isset( $schema_meta['rating'] ) && 'accept-user-rating' === $schema_meta['rating'] ) || ( 'accept-user-rating' === $schema_rating_value ) ) {
$rating_enabled[] = $post_id;
}
}
}
$post_id = get_the_ID();
if ( ! empty( $rating_enabled ) ) {
ob_start();
foreach ( $rating_enabled as $index => $schema_id ) {
if ( 'publish' !== get_post_status( $schema_id ) ) {
unset( $rating_enabled[ $index ] );
update_post_meta( $post_id, 'bsf-schema-pro-accept-user-rating', $rating_enabled );
continue;
}
$review_counts = get_post_meta( $post_id, 'bsf-schema-pro-review-counts-' . $schema_id, true );
$review_counts = ! empty( $review_counts ) ? $review_counts : 0;
$avg_rating = get_post_meta( $post_id, 'bsf-schema-pro-rating-' . $schema_id, true );
$avg_rating = ! empty( $avg_rating ) ? $avg_rating : 0;
wp_enqueue_script( 'wp-schema-pro-fontend-script' );
wp_enqueue_style( 'wp-schema-pro-fontend-style' );
$avg_rating = apply_filters( 'update_avg_star_ratings_schema_pro_markup', $avg_rating );
apply_filters( 'add_ratings_schema_pro_markup', $review_counts, $avg_rating );
?>
<div class="aiosrs-rating-wrap" data-schema-id="<?php echo esc_attr( $schema_id ); ?>">
<?php
BSF_AIOSRS_Pro_Custom_Fields_Markup::get_star_rating_markup( $avg_rating );
?>
<div class="aiosrs-rating-summary-wrap">
<span class="aiosrs-rating">
<?php
printf(
/* translators: 1: rating */
esc_attr_x( '%s/5', 'rating out of', 'wp-schema-pro' ),
esc_html( $avg_rating )
);
?>
</span>
<span class="aiosrs-rating-count">
<?php
printf(
/* translators: 1: number of reviews */
esc_html( _n( '(%1s Review)', '(%1s Reviews)', absint( $review_counts ), 'wp-schema-pro' ) ),
absint( $review_counts )
);
?>
</span>
</div>
</div>
<?php
}
$content .= ob_get_clean();
}
return $content;
}
/**
* Get current page schemas.
*
* @return array
*/
public static function get_schema_posts() {
if ( is_singular() ) {
if ( empty( self::$schema_post_result ) ) {
$option = array(
'location' => 'bsf-aiosrs-schema-location',
'exclusion' => 'bsf-aiosrs-schema-exclusion',
);
self::$schema_post_result = BSF_Target_Rule_Fields::get_instance()->get_posts_by_conditions( 'aiosrs-schema', $option );
}
}
return self::$schema_post_result;
}
/**
* Disable astra theme schemas.
*
* @return void
*/
public function disable_astra_theme_schema() {
$result = self::get_schema_posts();
if ( is_array( $result ) && ! empty( $result ) ) {
// Disable default Astra article schema.
add_filter( 'astra_article_schema_enabled', '__return_false' );
}
}
/**
* Schema Markup in JSON-LD form.
*
* @return void
*/
public function schema_markup() {
$current_post_id = get_the_id();
$result = self::get_schema_posts();
if ( is_array( $result ) && ! empty( $result ) ) {
$json_ld_markup = get_post_meta( $current_post_id, BSF_AIOSRS_PRO_CACHE_KEY, true );
if ( $json_ld_markup ) {
echo $json_ld_markup; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return;
}
foreach ( $result as $post_id => $post_data ) {
$schema_type = get_post_meta( $post_id, 'bsf-aiosrs-schema-type', true );
$schema_meta = get_post_meta( $post_id, 'bsf-aiosrs-' . $schema_type, true );
$schema_enabled = BSF_AIOSRS_Pro_Custom_Fields_Markup::enable_schema_post_option();
$schema_enabled_meta_key = $schema_type . '-' . $post_id . '-enabled-schema';
$schema_enabled_meta_value = get_post_meta( $current_post_id, $schema_enabled_meta_key, true );
$schema_enabled_meta_value = ! empty( $schema_enabled_meta_value ) ? $schema_enabled_meta_value : 'disabled';
if ( empty( $current_post_id ) || empty( $schema_type ) || empty( $schema_meta ) || ( $schema_enabled && 'disabled' === $schema_enabled_meta_value ) ) {
continue;
}
do_action( "wp_schema_before_schema_markup_{$schema_type}", $current_post_id, $schema_type );
$enabled = apply_filters( 'wp_schema_pro_schema_enabled', true, $current_post_id, $schema_type );
$enabled_comment = apply_filters( 'wp_schema_pro_comment_before_markup_enabled', true );
if ( true === $enabled_comment ) {
$json_ld_markup .= '<!-- Schema optimized by Schema Pro -->';
}
if ( true === $enabled ) {
if ( 'custom-markup' === $schema_type ) {
$custom_markup = BSF_AIOSRS_Pro_Schema_Template::get_schema( $current_post_id, $post_id, $schema_type, $schema_meta );
if ( isset( $custom_markup[ $schema_type ] ) && ! empty( $custom_markup[ $schema_type ] ) ) {
$custom_markup[ $schema_type ] = trim( $custom_markup[ $schema_type ] );
$first_schema_character = substr( $custom_markup[ $schema_type ], 0, 1 );
$last_schema_character = substr( $custom_markup[ $schema_type ], -1, 1 );
if ( '{' === $first_schema_character && '}' === $last_schema_character ) {
$json_ld_markup .= '<script type="application/ld+json">';
$json_ld_markup .= $custom_markup[ $schema_type ];
$json_ld_markup .= '</script>';
} else {
$json_ld_markup .= $custom_markup[ $schema_type ];
}
}
} else {
// @codingStandardsIgnoreStart
$json_ld_markup .= '<script type="application/ld+json">';
if ( version_compare( PHP_VERSION, '5.3', '>' ) ) {
$json_ld_markup .= wp_json_encode( BSF_AIOSRS_Pro_Schema_Template::get_schema( $current_post_id, $post_id, $schema_type, $schema_meta ),JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
} else {
$json_ld_markup .= wp_json_encode( BSF_AIOSRS_Pro_Schema_Template::get_schema( $current_post_id, $post_id, $schema_type, $schema_meta ));
}
// @codingStandardsIgnoreEnd
$json_ld_markup .= '</script>';
}
if ( true === $enabled_comment ) {
$json_ld_markup .= '<!-- / Schema optimized by Schema Pro -->';
}
}
do_action( "wp_schema_after_schema_markup_{$schema_type}", $current_post_id, $schema_type );
}
echo $json_ld_markup; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$json_ld_markup = addcslashes( $json_ld_markup, '"\\/' );
update_post_meta( $current_post_id, 'wp_schema_pro_optimized_structured_data', $json_ld_markup );
}
}
/**
* Global Schema
*
* @since 1.1.0
* @param int $post_id Post Id.
* @param string $type Schema type.
*/
public static function global_schema_markup( $post_id, $type ) {
do_action( "wp_schema_before_global_schema_markup_{$type}", $post_id, $type );
$enabled_global_schema = apply_filters( 'wp_schema_pro_global_schema_enabled', true, $post_id, $type );
$enabled_global_comment = apply_filters( 'wp_schema_pro_comment_before_markup_enabled', true );
if ( true === $enabled_global_schema ) {
if ( true === $enabled_global_comment ) {
echo '<!-- ' . esc_html( $type ) . ' Schema optimized by Schema Pro -->';
}
// @codingStandardsIgnoreStart
echo '<script type="application/ld+json">';
if ( ! version_compare( PHP_VERSION, '5.3', '>' ) ) {
echo wp_json_encode( BSF_AIOSRS_Pro_Schema_Template::get_global_schema( $post_id, $type ),JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );
} else {
echo wp_json_encode( BSF_AIOSRS_Pro_Schema_Template::get_global_schema( $post_id, $type ));
}
// @codingStandardsIgnoreEnd
echo '</script>';
if ( true === $enabled_global_comment ) {
echo '<!-- / ' . esc_html( $type ) . ' Schema optimized by Schema Pro -->';
}
}
do_action( "wp_schema_after_global_schema_markup_{$type}", $post_id, $type );
}
/**
* Global Schemas
*
* @since 1.1.0
*/
public function global_schemas_markup() {
$yoast_enabled = WP_Schema_Pro_Yoast_Compatibility::get_option( 'wp_schema_pro_yoast_enabled' );
$yoast_company_person = WP_Schema_Pro_Yoast_Compatibility::get_option( 'company_or_person' );
$yoast_advanced_meta = WP_Schema_Pro_Yoast_Compatibility::get_option( 'disableadvanced_meta' );
$yoast_breadcrumb = WP_Schema_Pro_Yoast_Compatibility::get_option( 'breadcrumbs-enable' );
$post_id = get_the_ID();
$general_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
$global_settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-global-schemas'];
if ( 'person' === $general_settings['site-represent'] || 'personblog' === $general_settings['site-represent'] ) {
$general_settings['site-represent'] = 'person';
}
if ( 'organization' === $general_settings['site-represent'] || 'Webshop' === $general_settings['site-represent'] || 'Smallbusiness' === $general_settings['site-represent'] || 'Otherbusiness' === $general_settings['site-represent'] ) {
$general_settings['site-represent'] = 'organization';
}
if ( is_front_page() && ( ! $yoast_company_person || empty( $yoast_company_person ) ) && ! empty( $general_settings['site-represent'] ) ) {
echo esc_html( self::global_schema_markup( $post_id, $general_settings['site-represent'] ) );
}
if ( ! empty( $global_settings['site-navigation-element'] ) ) {
echo esc_html( self::global_schema_markup( $post_id, 'site-navigation-element' ) );
}
if ( ! $yoast_enabled && '1' === $global_settings['sitelink-search-box'] ) {
echo esc_html( self::global_schema_markup( $post_id, 'sitelink-search-box' ) );
}
if ( ! is_front_page() && ! ( $yoast_advanced_meta && $yoast_breadcrumb ) && '1' === $global_settings['breadcrumb'] ) {
echo esc_html( self::global_schema_markup( $post_id, 'breadcrumb' ) );
}
if ( ! is_singular() ) {
return;
}
if ( absint( $global_settings['about-page'] ) === $post_id ) {
echo esc_html( self::global_schema_markup( $post_id, 'about-page' ) );
}
if ( absint( $global_settings['contact-page'] ) === $post_id ) {
echo esc_html( self::global_schema_markup( $post_id, 'contact-page' ) );
}
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
BSF_AIOSRS_Pro_Markup::get_instance();

View File

@@ -0,0 +1,92 @@
<?php
/**
* Schemas Template.
*
* @package Schema Pro
* @since 1.5.0
*/
/**
* Exit if accessed directly.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* This class initializes Schema for AMP
*
* @class BSF_AIOSRS_Pro_Schema_Global_Uninstall
*/
class BSF_AIOSRS_Pro_Schema_Global_Uninstall {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Constructor function.
*/
public function __construct() {
$this->delete_all_plugin_data();
}
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Delete function.
*/
public function delete_queries() {
global $wpdb;
$delete_keys = BSF_AIOSRS_Pro_Helper::$settings;
$delete_keys_options = array_keys( $delete_keys );
$delete_options_placeholders = implode( ', ', array_fill( 0, count( $delete_keys_options ), '%s' ) );
$wpdb->query( $wpdb->prepare( " DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE %s", '%' . $wpdb->esc_like( 'bsf-aiosrs-' ) . '%' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$wpdb->query( $wpdb->prepare( " DELETE FROM {$wpdb->posts} WHERE post_type LIKE %s", '%' . $wpdb->esc_like( 'aiosrs-schema' ) . '%' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$query = "DELETE FROM {$wpdb->options} WHERE option_name IN ($delete_options_placeholders)";
// @codingStandardsIgnoreStart
$wpdb->query( $wpdb->prepare( $query, $delete_keys_options ) );
wp_cache_delete($delete_options_placeholders,'options');
// @codingStandardsIgnoreEnd
}
/**
* Delete Schema from single site or multisite.
*/
public function delete_all_plugin_data() {
if ( ! is_multisite() ) {
$option_schema = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
$delete_schema = isset( $option_schema['delete-schema-data'] ) ? $option_schema['delete-schema-data'] : '';
if ( '1' === $delete_schema ) {
self::delete_queries();
}
} else {
global $wpdb;
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$original_blog_id = get_current_blog_id();
$option_schema = BSF_AIOSRS_Pro_Helper::$settings['aiosrs-pro-settings'];
$delete_schema = isset( $option_schema['delete-schema-data'] ) ? $option_schema['delete-schema-data'] : '';
foreach ( $blog_ids as $blog_id ) {
switch_to_blog( $blog_id );
if ( '1' === $delete_schema ) {
self::delete_queries();
}
}
switch_to_blog( $original_blog_id );
}
}
}
BSF_AIOSRS_Pro_Schema_Global_Uninstall::get_instance();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,477 @@
<?php
/**
* Schema Pro - Schema Wizard
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'BSF_AIOSRS_Pro_Schema_Wizard' ) ) :
/**
* BSF_AIOSRS_Pro_Schema_Wizard class.
*/
class BSF_AIOSRS_Pro_Schema_Wizard {
/**
* Hook in tabs.
*/
public function __construct() {
if ( apply_filters( 'wp_schema_pro_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) {
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
add_action( 'admin_init', array( $this, 'setup_wizard' ) );
}
}
/**
* Add admin menus/screens.
*/
public function admin_menus() {
add_dashboard_page( '', '', 'manage_options', 'aiosrs-pro-setup', '' );
}
/**
* Show the setup wizard.
*/
public function setup_wizard() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
if ( empty( $_GET['page'] ) || 'aiosrs-pro-setup' !== $_GET['page'] ) {
return;
}
$this->steps = array(
'basic-config' => array(
'name' => __( 'Choose Schema Type', 'wp-schema-pro' ),
'view' => array( $this, 'choose_schema_type' ),
'handler' => array( $this, 'choose_schema_type_save' ),
),
'enable-on' => array(
'name' => __( 'Set Target Pages', 'wp-schema-pro' ),
'view' => array( $this, 'implement_on_callback' ),
'handler' => array( $this, 'implement_on_callback_save' ),
),
'setup-ready' => array(
'name' => __( 'Ready!', 'wp-schema-pro' ),
'view' => array( $this, 'schema_ready' ),
'handler' => '',
),
);
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
wp_enqueue_style( 'aiosrs-pro-setup', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, array( 'dashicons', 'install' ), BSF_AIOSRS_PRO_VER );
wp_enqueue_style( 'aiosrs-pro-admin-edit-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'style.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, BSF_AIOSRS_PRO_VER, 'false' );
wp_register_script( 'aiosrs-pro-admin-edit-script', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'script.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery', 'jquery-ui-tooltip' ), BSF_AIOSRS_PRO_VER, true );
wp_register_script( 'aiosrs-pro-setup', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
wp_enqueue_style( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.css', '', BSF_AIOSRS_PRO_VER, false );
wp_enqueue_style( 'bsf-target-rule', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/target-rule.css', '', BSF_AIOSRS_PRO_VER, false );
wp_register_script( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.js', array( 'jquery', 'backbone', 'wp-util' ), BSF_AIOSRS_PRO_VER, true );
wp_register_script( 'bsf-target-rule', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/target-rule.js', array( 'jquery', 'bsf-target-rule-select2' ), BSF_AIOSRS_PRO_VER, true );
wp_register_script( 'bsf-user-role', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/user-role.js', array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
wp_enqueue_media();
wp_localize_script(
'bsf-target-rule',
'Targetrule',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'security' => wp_create_nonce( 'schema_nonce' ),
)
);
if ( ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( $_POST['_wpnonce'] ), 'aiosrs-pro-setup' ) ) && ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
call_user_func( $this->steps[ $this->step ]['handler'] );
}
ob_start();
$this->setup_wizard_header();
$this->setup_wizard_steps();
$this->setup_wizard_content();
$this->setup_wizard_footer();
exit;
}
/**
* Get next step link
*/
public function get_next_step_link() {
$keys = array_keys( $this->steps );
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) + 1 ] );
}
/**
* Setup Wizard Header.
*/
public function setup_wizard_header() {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php esc_html_e( 'Schema Setup', 'wp-schema-pro' ); ?></title>
<script type="text/javascript">
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
var ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ); ?>';
</script>
<?php wp_print_scripts( array( 'bsf-target-rule-select2', 'bsf-target-rule', 'bsf-user-role', 'aiosrs-pro-admin-edit-script', 'aiosrs-pro-setup' ) ); ?>
<?php do_action( 'admin_print_styles' ); ?>
</head>
<body class="aiosrs-pro-setup wp-core-ui">
<div id="aiosrs-pro-logo">
<?php
$brand_adv = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
if ( '' !== $brand_adv['sp_plugin_name'] ) {
?>
<h2 class="wpsp-setup-pro-title"><?php echo esc_html( $brand_adv['sp_plugin_name'] ); ?></h2>
<?php } else { ?>
<a href="<?php echo esc_url( BSF_AIOSRS_PRO_WEBSITE_URL ); ?>" target="_blank"><img src="<?php echo esc_url( BSF_AIOSRS_PRO_URI . '/admin/assets/images/schema-pro.png' ); ?>" alt="<?php esc_attr_e( 'Schema Pro', 'wp-schema-pro' ); ?>" ></a>
<?php } ?>
</div>
<?php
}
/**
* Setup Wizard Footer.
*/
public function setup_wizard_footer() {
$admin_url = BSF_AIOSRS_Pro_Admin::get_page_url( BSF_AIOSRS_Pro_Admin::$parent_page_slug );
?>
<div class="close-button-wrapper">
<a href="<?php echo esc_url( $admin_url ); ?>" class="wizard-close-link" ><?php esc_html_e( 'Exit Setup Wizard', 'wp-schema-pro' ); ?></a>
</div>
</body>
</html>
<?php
}
/**
* Output the steps.
*/
public function setup_wizard_steps() {
$ouput_steps = $this->steps;
?>
<ol class="aiosrs-pro-setup-steps">
<?php
foreach ( $ouput_steps as $step_key => $step ) :
$classes = '';
if ( $step_key === $this->step ) {
$classes = 'active';
} elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) {
$classes = 'done';
}
?>
<li class="<?php echo esc_attr( $classes ); ?>">
<span><?php echo esc_html( $step['name'] ); ?></span>
</li>
<?php endforeach; ?>
</ol>
<?php
}
/**
* Output the content for the current step.
*/
public function setup_wizard_content() {
echo '<div class="aiosrs-pro-setup-content">';
call_user_func( $this->steps[ $this->step ]['view'] );
echo '</div>';
}
/**
* Introduction step.
*/
public function choose_schema_type() {
?>
<h1><?php esc_html_e( 'Select the Schema Type:', 'wp-schema-pro' ); ?></h1>
<form method="post">
<input type="hidden" id="bsf-aiosrs-schema-title" name="bsf-aiosrs-schema-title" class="bsf-aiosrs-schema-title" >
<input type="hidden" id="bsf-aiosrs-schema-type" name="bsf-aiosrs-schema-type" class="bsf-aiosrs-schema-type" >
<table class="form-table aiosrs-pro-basic-config">
<tr>
<td><!-- Comment
<?php foreach ( BSF_AIOSRS_Pro_Schema::$schema_meta_fields as $key => $schema_field ) { ?>
--><span class="aiosrs-pro-schema-temp-wrap" data-schema-type="<?php echo esc_attr( $schema_field['key'] ); ?>" data-schema-title="<?php echo isset( $schema_field['label'] ) ? esc_attr( $schema_field['label'] ) : ''; ?>" >
<i class="<?php echo isset( $schema_field['icon'] ) ? esc_attr( $schema_field['icon'] ) : 'dashicons dashicons-media-default'; ?>"></i>
<?php echo isset( $schema_field['label'] ) ? esc_attr( $schema_field['label'] ) : ''; ?>
</span><!-- Comment
<?php } ?>
--></td>
</tr>
</table>
<p class="aiosrs-pro-setup-actions step">
<input type="submit" class="uct-activate button-primary button button-large button-next" disabled="true" value="<?php esc_attr_e( 'Next', 'wp-schema-pro' ); ?>" name="save_step" />
<?php wp_nonce_field( 'aiosrs-pro-setup' ); ?>
</p>
</form>
<?php
}
/**
* Save Locale Settings.
*/
public function choose_schema_type_save() {
check_admin_referer( 'aiosrs-pro-setup' );
// Update site title & tagline.
$redirect_url = $this->get_next_step_link();
$title = isset( $_POST['bsf-aiosrs-schema-title'] ) ? sanitize_text_field( $_POST['bsf-aiosrs-schema-title'] ) : 0;
$type = isset( $_POST['bsf-aiosrs-schema-type'] ) ? sanitize_text_field( $_POST['bsf-aiosrs-schema-type'] ) : 0;
$default_fields = array();
if ( isset( BSF_AIOSRS_Pro_Schema::$schema_meta_fields[ 'bsf-aiosrs-' . $type ]['subkeys'] ) ) {
$default_data = BSF_AIOSRS_Pro_Schema::$schema_meta_fields[ 'bsf-aiosrs-' . $type ]['subkeys'];
foreach ( $default_data as $key => $value ) {
if ( 'repeater' === $value['type'] ) {
foreach ( $value['fields'] as $subkey => $subvalue ) {
if ( isset( $subvalue['default'] ) && 'none' !== $subvalue['default'] ) {
$default_fields[ $key ][0][ $subkey ] = $subvalue['default'];
} else {
$default_fields[ $key ][0][ $subkey ] = 'create-field';
}
}
} else {
if ( isset( $value['default'] ) && 'none' !== $value['default'] ) {
$default_fields[ $key ] = $value['default'];
} else {
$default_fields[ $key ] = 'create-field';
}
}
}
}
$postarr = array(
'post_type' => 'aiosrs-schema',
'post_title' => $title,
'post_status' => 'publish',
'meta_input' => array(
'bsf-aiosrs-schema-type' => $type,
'bsf-aiosrs-' . $type => $default_fields,
),
);
$post_id = wp_insert_post( $postarr );
if ( ! is_wp_error( $post_id ) ) {
$redirect_url = add_query_arg( 'schema-id', $post_id, $redirect_url );
}
wp_safe_redirect( esc_url_raw( $redirect_url ) );
exit;
}
/**
* Locale settings
*/
public function implement_on_callback() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
$schema_id = 0;
$title = '';
$redirect_url = $this->get_next_step_link();
if ( isset( $_GET['schema-id'] ) && ! empty( $_GET['schema-id'] ) ) {
$schema_id = intval( $_GET['schema-id'] );
$redirect_url = add_query_arg( 'schema-id', $schema_id, $redirect_url );
$title = get_the_title( $schema_id );
}
$meta_values = array(
'include-locations' => array(
'rule' => array( 'basic-singulars' ),
),
'exclude-locations' => array(),
);
?>
<h1>
<?php
printf(
/* translators: 1 schema title */
wp_kses_post( 'Where %s schema should be integrated?', 'wp-schema-pro' ),
esc_html( $title )
);
?>
</h1>
<form method="post">
<input type="hidden" name="schema-id" value="<?php echo esc_attr( $schema_id ); ?>">
<table class="bsf-aiosrs-schema-table widefat">
<tr class="bsf-aiosrs-schema-row">
<td class="bsf-aiosrs-schema-row-heading">
<label><?php esc_html_e( 'Enable On', 'wp-schema-pro' ); ?></label>
<i class="bsf-aiosrs-schema-heading-help dashicons dashicons-editor-help" title="<?php echo esc_attr__( 'Add target pages where this Schema should appear.', 'wp-schema-pro' ); ?>"></i>
</td>
<td class="bsf-aiosrs-schema-row-content">
<?php
BSF_Target_Rule_Fields::target_rule_settings_field(
'bsf-aiosrs-schema-location',
array(
'title' => __( 'Display Rules', 'wp-schema-pro' ),
'value' => '[{"type":"basic-global","specific":null}]',
'tags' => 'site,enable,target,pages',
'rule_type' => 'display',
'add_rule_label' => __( 'Add “AND” Rule', 'wp-schema-pro' ),
),
$meta_values['include-locations']
);
?>
</td>
</tr>
<tr class="bsf-aiosrs-schema-row">
<td class="bsf-aiosrs-schema-row-heading">
<label><?php esc_html_e( 'Exclude From', 'wp-schema-pro' ); ?></label>
<i class="bsf-aiosrs-schema-heading-help dashicons dashicons-editor-help" title="<?php echo esc_attr__( 'This Schema will not appear at these pages.', 'wp-schema-pro' ); ?>"></i>
</td>
<td class="bsf-aiosrs-schema-row-content">
<?php
BSF_Target_Rule_Fields::target_rule_settings_field(
'bsf-aiosrs-schema-exclusion',
array(
'title' => __( 'Exclude On', 'wp-schema-pro' ),
'value' => '[]',
'tags' => 'site,enable,target,pages',
'add_rule_label' => __( 'Add “OR” Rule', 'wp-schema-pro' ),
'rule_type' => 'exclude',
),
$meta_values['exclude-locations']
);
?>
</td>
</tr>
</table>
<p class="aiosrs-pro-setup-actions step">
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Next', 'wp-schema-pro' ); ?>" name="save_step" />
<?php wp_nonce_field( 'aiosrs-pro-setup' ); ?>
</p>
</form>
<?php
}
/**
* Save Locale Settings.
*/
public function implement_on_callback_save() {
check_admin_referer( 'aiosrs-pro-setup' );
$schema_id = isset( $_POST['schema-id'] ) ? sanitize_text_field( $_POST['schema-id'] ) : 0;
$enabled_on = BSF_Target_Rule_Fields::get_format_rule_value( $_POST, 'bsf-aiosrs-schema-location' );
$exclude_from = BSF_Target_Rule_Fields::get_format_rule_value( $_POST, 'bsf-aiosrs-schema-exclusion' );
$redirect_url = $this->get_next_step_link();
if ( $schema_id ) {
$redirect_url = add_query_arg( 'schema-id', $schema_id, $redirect_url );
update_post_meta( $schema_id, 'bsf-aiosrs-schema-location', $enabled_on );
update_post_meta( $schema_id, 'bsf-aiosrs-schema-exclusion', $exclude_from );
}
wp_safe_redirect( esc_url_raw( $redirect_url ) );
exit;
}
/**
* Get Location rules of schema for Custom meta box.
*
* @param array $enabled_on Enabled on rules.
* @param array $exclude_from Exlcude on rules.
* @return array
*/
public static function get_display_rules_for_meta_box( $enabled_on, $exclude_from ) {
$locations = array();
$enabled_location = array();
$exclude_location = array();
$args = array(
'public' => true,
'_builtin' => true,
);
$post_types = get_post_types( $args );
unset( $post_types['attachment'] );
$args['_builtin'] = false;
$custom_post_type = get_post_types( $args );
$post_types = array_merge( $post_types, $custom_post_type );
if ( ! empty( $enabled_on ) && isset( $enabled_on['rule'] ) ) {
$enabled_location = $enabled_on['rule'];
}
if ( ! empty( $exclude_from ) && isset( $exclude_from['rule'] ) ) {
$exclude_location = $exclude_from['rule'];
}
if ( in_array( 'specifics', $enabled_location, true ) || ( in_array( 'basic-singulars', $enabled_location, true ) && ! in_array( 'basic-singulars', $exclude_location, true ) ) ) {
foreach ( $post_types as $post_type ) {
$locations[ $post_type ] = 1;
}
} else {
foreach ( $post_types as $post_type ) {
$key = $post_type . '|all';
if ( in_array( $key, $enabled_location, true ) && ! in_array( $key, $exclude_location, true ) ) {
$locations[ $post_type ] = 1;
}
}
}
return $locations;
}
/**
* Final step.
*/
public function schema_ready() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
$schema_id = 0;
$title = '';
if ( isset( $_GET['schema-id'] ) && ! empty( $_GET['schema-id'] ) ) {
$schema_id = intval( $_GET['schema-id'] );
$title = get_the_title( $schema_id );
}
?>
<h1><?php esc_html_e( 'Your Schema is Ready!', 'wp-schema-pro' ); ?></h1>
<div class="aiosrs-pro-setup-next-steps">
<div class="aiosrs-pro-setup-next-steps-last">
<p class="success">
<?php
printf(
/* translators: 1 schema title */
wp_kses_post( 'Congratulations! The <i>%s</i> Schema has been added and enabled on selected target locations.', 'wp-schema-pro' ),
esc_html( $title )
);
?>
</p>
<p class="success">
<strong><?php esc_html_e( 'Heres what to do next:', 'wp-schema-pro' ); ?></strong><br>
<?php esc_html_e( 'Step 1: Complete the setup and proceed to fill the required properties of this schema.', 'wp-schema-pro' ); ?><br>
<?php esc_html_e( 'Step 2: Add necessary Schema information on individual pages and posts.', 'wp-schema-pro' ); ?><br>
<?php esc_html_e( 'Step 3: Test if Schema is integrated correctly.', 'wp-schema-pro' ); ?>
</p>
<table class="form-table aiosrs-pro-schema-ready">
<tr>
<td>
<a href="<?php echo ( $schema_id ) ? esc_attr( get_edit_post_link( $schema_id ) ) : '#'; ?>" type="button" class="button button-primary button-hero" ><?php esc_html_e( 'Complete Setup', 'wp-schema-pro' ); ?></a>
</td>
</tr>
</table>
</div>
</div>
<?php
}
}
new BSF_AIOSRS_Pro_Schema_Wizard();
endif;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,670 @@
<?php
/**
* Schema Pro - Setup Wizard
*
* @package Schema Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'BSF_AIOSRS_Pro_Setup_Wizard' ) ) :
/**
* BSF_AIOSRS_Pro_Setup_Wizard class.
*/
class BSF_AIOSRS_Pro_Setup_Wizard {
/**
* Hook in tabs.
*/
public function __construct() {
if ( apply_filters( 'wp_schema_pro_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) {
if ( get_transient( 'wp-schema-pro-activated' ) ) {
delete_transient( 'wp-schema-pro-activated' );
}
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
add_action( 'admin_init', array( $this, 'setup_wizard' ) );
}
}
/**
* Add admin menus/screens.
*/
public function admin_menus() {
add_dashboard_page( '', '', 'manage_options', 'aiosrs-pro-setup-wizard', '' );
}
/**
* Show the setup wizard.
*/
public function setup_wizard() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
if ( empty( $_GET['page'] ) || 'aiosrs-pro-setup-wizard' !== $_GET['page'] ) {
return;
}
$this->steps = array(
'welcome' => array(
'name' => __( 'Welcome', 'wp-schema-pro' ),
'view' => array( $this, 'welcome' ),
),
'general-setting' => array(
'name' => __( 'General', 'wp-schema-pro' ),
'view' => array( $this, 'general_setting' ),
'handler' => array( $this, 'general_setting_save' ),
),
'social-profiles' => array(
'name' => __( 'Social Profiles', 'wp-schema-pro' ),
'view' => array( $this, 'social_profiles' ),
'handler' => array( $this, 'social_profiles_save' ),
),
'global-schemas' => array(
'name' => __( 'Other Schemas', 'wp-schema-pro' ),
'view' => array( $this, 'global_schemas' ),
'handler' => array( $this, 'global_schemas_save' ),
),
'success' => array(
'name' => __( 'Done', 'wp-schema-pro' ),
'view' => array( $this, 'success' ),
'handler' => '',
),
);
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
wp_enqueue_style( 'aiosrs-pro-setup-wizard', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, array( 'dashicons', 'install' ), BSF_AIOSRS_PRO_VER );
wp_enqueue_style( 'aiosrs-pro-admin-edit-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'style.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, BSF_AIOSRS_PRO_VER, 'false' );
wp_enqueue_style( 'aiosrs-pro-admin-settings-style', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_css . 'settings-style.' . BSF_AIOSRS_Pro_Admin::$minfy_css_ext, BSF_AIOSRS_PRO_VER, 'false' );
wp_register_script( 'aiosrs-pro-settings-script', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'settings-script.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery', 'bsf-target-rule-select2', 'wp-i18n' ), BSF_AIOSRS_PRO_VER, true );
wp_enqueue_media();
wp_enqueue_script( 'media' );
wp_enqueue_style( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.css', '', BSF_AIOSRS_PRO_VER, false );
wp_register_script( 'bsf-target-rule-select2', BSF_AIOSRS_PRO_URI . 'classes/lib/target-rule/select2.js', array( 'jquery', 'backbone', 'wp-util' ), BSF_AIOSRS_PRO_VER, true );
wp_localize_script(
'aiosrs-pro-settings-script',
'AIOSRS_search',
apply_filters(
'aiosrs_pro_settings_script_localize',
array(
'search_field' => wp_create_nonce( 'spec_schema' ),
)
)
);
wp_register_script( 'aiosrs-pro-setup-wizard', BSF_AIOSRS_PRO_URI . 'admin/assets/' . BSF_AIOSRS_Pro_Admin::$minfy_js . 'setup-wizard.' . BSF_AIOSRS_Pro_Admin::$minfy_js_ext, array( 'jquery' ), BSF_AIOSRS_PRO_VER, true );
if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( $_POST['_wpnonce'] ), 'aiosrs-pro-setup-wizard' ) && ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
call_user_func( $this->steps[ $this->step ]['handler'] );
}
ob_start();
$this->setup_wizard_header();
$this->setup_wizard_steps();
$this->setup_wizard_content();
$this->setup_wizard_footer();
exit;
}
/**
* Get previous step link
*/
public function get_prev_step_link() {
$keys = array_keys( $this->steps );
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) - 1 ] );
}
/**
* Get next step link
*/
public function get_next_step_link() {
$keys = array_keys( $this->steps );
return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ), true ) + 1 ] );
}
/**
* Setup Wizard Header.
*/
public function setup_wizard_header() {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php esc_html_e( 'Schema Setup', 'wp-schema-pro' ); ?></title>
<script type="text/javascript">
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
var ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ); ?>';
</script>
<?php wp_print_scripts( array( 'aiosrs-pro-admin-edit-script', 'aiosrs-pro-settings-script', 'aiosrs-pro-setup-wizard' ) ); ?>
<?php do_action( 'admin_print_styles' ); ?>
<?php do_action( 'admin_print_scripts' ); ?>
</head>
<body class="aiosrs-pro-setup-wizard wp-core-ui">
<div id="aiosrs-pro-logo">
<?php
$brand_adv = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
if ( '' !== $brand_adv['sp_plugin_name'] ) {
?>
<h2 class="wpsp-setup-pro-title"><?php echo esc_html( $brand_adv['sp_plugin_name'] ); ?></h2>
<?php } else { ?>
<a href="https://wpschema.com/" target="_blank"><img src="<?php echo esc_url( BSF_AIOSRS_PRO_URI . '/admin/assets/images/schema-pro.png' ); ?>" alt="<?php esc_attr_e( 'Schema Pro', 'wp-schema-pro' ); ?>" ></a>
<?php } ?>
</div>
<?php
}
/**
* Setup Wizard Footer.
*/
public function setup_wizard_footer() {
$admin_url = BSF_AIOSRS_Pro_Admin::get_page_url( 'settings' );
?>
<div class="close-button-wrapper">
<a href="<?php echo esc_url( $admin_url ); ?>" class="wizard-close-link" ><?php esc_html_e( 'Exit Setup Wizard', 'wp-schema-pro' ); ?></a>
</div>
</body>
<?php do_action( 'admin_footer' ); ?>
<?php do_action( 'admin_print_footer_scripts' ); ?>
</html>
<?php
}
/**
* Output the steps.
*/
public function setup_wizard_steps() {
$ouput_steps = $this->steps;
?>
<ol class="aiosrs-pro-setup-wizard-steps">
<?php
foreach ( $ouput_steps as $step_key => $step ) :
$classes = '';
if ( $step_key === $this->step ) {
$classes = 'active';
} elseif ( array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true ) ) {
$classes = 'done';
}
$url = add_query_arg( 'step', $step_key )
?>
<li class="<?php echo esc_attr( $classes ); ?>">
<a href="<?php echo esc_url( $url ); ?>"><span><?php echo esc_html( $step['name'] ); ?></span></a>
</li>
<?php endforeach; ?>
</ol>
<?php
}
/**
* Output the content for the current step.
*/
public function setup_wizard_content() {
echo '<div class="aiosrs-pro-setup-wizard-content ' . esc_attr( $this->step ) . '-content-wrap">';
call_user_func( $this->steps[ $this->step ]['view'] );
echo '</div>';
}
/**
* Welcome.
*/
public function welcome() {
if ( is_multisite() ) {
$branding_msg = get_site_option( 'wp-schema-pro-branding-settings' );
} else {
$branding_msg = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
}
$sp_name = isset( $branding_msg['sp_plugin_name'] ) ? $branding_msg['sp_plugin_name'] : '';
if ( '' !== $sp_name ) {
/* translators: %s: search term */
$brand_msg = sprintf( __( 'Welcome to %s setup wizard !', 'wp-schema-pro' ), $sp_name );
/* translators: %s: search term */
$brand_steup = sprintf( __( '%s adds Google-recommended schema markups across your site and specific pages. This improves your SEO and allows search engines to display rich snippets for your website.', 'wp-schema-pro' ), $sp_name );
?>
<h1><?php echo esc_html( $brand_msg ); ?></h1>
<p class="success"><?php echo esc_html( $brand_steup ); ?></p>
<?php
} else {
?>
<h1><?php esc_html_e( 'Welcome To Schema Pro Setup Wizard!', 'wp-schema-pro' ); ?></h1>
<p class="success">
<?php esc_html_e( 'Schema Pro adds Google-recommended schema markups across your site and specific pages. This improves your SEO and allows search engines to display rich snippets for your website.', 'wp-schema-pro' ); ?>
</p>
<?php
}
?>
<p class="success">
<?php esc_html_e( 'This wizard is the first step to making Google understand your site better. Just fill in the required basic information. Its easy!', 'wp-schema-pro' ); ?>
</p>
<?php if ( '' === $sp_name ) { ?>
<p class="success">
<?php echo sprintf( wp_kses_post( '<a href="https://www.youtube.com/watch?v=xOiMA0am9QY" target="_blank">Watch a detailed video on the setup wizard tutorial.</a>', 'wp-schema-pro' ) ); ?>
</p>
<?php } ?>
<p class="aiosrs-pro-setup-wizard-actions step">
<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="button-primary button button-large button-next" ><?php esc_html_e( 'Start', 'wp-schema-pro' ); ?> &raquo;</a>
<?php wp_nonce_field( 'aiosrs-pro-setup-wizard' ); ?>
</p>
<?php
}
/**
* General Setting
*/
public function general_setting() {
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-general-settings'];
?>
<h1><?php esc_html_e( 'General', 'wp-schema-pro' ); ?></h1>
<p class="success"><?php esc_html_e( 'To help Google understand what your website is about, select the most suitable type for your website below, and fill in the required basic information.', 'wp-schema-pro' ); ?></p>
<form method="post">
<table class="form-table">
<tr>
<th id =''><?php esc_html_e( 'This Website Represents ', 'wp-schema-pro' ); ?></th>
<td>
<select name="wp-schema-pro-general-settings[site-represent]">
<option <?php selected( $settings['site-represent'], '' ); ?> value=""> <?php esc_html_e( '--None--', 'wp-schema-pro' ); ?></option>
<option <?php selected( $settings['site-represent'], 'person' ); ?> value="person"> <?php esc_html_e( 'Personal Website', 'wp-schema-pro' ); ?></option>
<option <?php selected( $settings['site-represent'], 'Otherbusiness' ); ?> value="Otherbusiness"> <?php esc_html_e( 'Business Website', 'wp-schema-pro' ); ?></option>
<option <?php selected( $settings['site-represent'], 'organization' ); ?> value="organization"> <?php esc_html_e( 'Organization', 'wp-schema-pro' ); ?></option>
<option <?php selected( $settings['site-represent'], 'personblog' ); ?> value="personblog"> <?php esc_html_e( 'Personal Blog', 'wp-schema-pro' ); ?></option>
<option <?php selected( $settings['site-represent'], 'Smallbusiness' ); ?> value="Smallbusiness"> <?php esc_html_e( 'Community Blog/News Website ', 'wp-schema-pro' ); ?></option>
<option <?php selected( $settings['site-represent'], 'Webshop' ); ?> value="Webshop"> <?php esc_html_e( 'Webshop', 'wp-schema-pro' ); ?></option>
</select>
</td>
</tr>
<?php
if ( 'person' === $settings['site-represent'] || 'personblog' === $settings['site-represent'] ) {
$settings['site-represent'] = 'person';
}
if ( 'organization' === $settings['site-represent'] || 'Webshop' === $settings['site-represent'] || 'Smallbusiness' === $settings['site-represent'] || 'Otherbusiness' === $settings['site-represent'] ) {
$settings['site-represent'] = 'organization';
}
?>
<tr class="wp-schema-pro-site-logo-wrap">
<th id =''><?php esc_html_e( 'Website Logo', 'wp-schema-pro' ); ?></th>
<td>
<select style='display:none' name="wp-schema-pro-general-settings[site-logo]" class="wp-schema-pro-custom-option-select">
<option <?php selected( $settings['site-logo'], 'custom' ); ?> value="custom"><?php esc_html_e( 'Add Custom Logo', 'wp-schema-pro' ); ?></option>
</select>
<div class="custom-field-wrapper site-logo-custom-wrap" >
<input type="hidden" class="single-image-field" name="wp-schema-pro-general-settings[site-logo-custom]" value="<?php echo esc_attr( $settings['site-logo-custom'] ); ?>" />
<?php
if ( ! empty( $settings['site-logo-custom'] ) ) {
$image_url = wp_get_attachment_url( $settings['site-logo-custom'] );
} else {
$logo_id = '';
if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) {
$logo_id = get_theme_mod( 'custom_logo' );
}
$image_url = wp_get_attachment_url( $logo_id );
}
?>
<div class="image-field-wrap <?php echo ( ! empty( $image_url ) ) ? 'bsf-custom-image-selected' : ''; ?>"">
<a href="#" class="aiosrs-image-select button"><span class="dashicons dashicons-format-image"></span><?php esc_html_e( 'Select Image', 'wp-schema-pro' ); ?></a>
<a href="#" class="aiosrs-image-remove dashicons dashicons-no-alt wp-ui-text-highlight"></a>
<?php if ( isset( $image_url ) && ! empty( $image_url ) ) : ?>
<a href="#" class="aiosrs-image-select img"><img src="<?php echo esc_url( $image_url ); ?>" /></a>
<?php endif; ?>
</div>
</div>
<p class= 'aiosrs-pro-field-description'><?php esc_html_e( 'Recommended minimum logo size 112 x 112 pixels.', 'wp-schema-pro' ); ?></p>
<p class= 'aiosrs-pro-field-description'><?php esc_html_e( 'The image must be in .jpg, .png, .gif, .svg, or .webp format.', 'wp-schema-pro' ); ?></p>
</td>
</tr>
<tr class="wp-schema-pro-person-name-wrap" <?php echo ( 'person' !== $settings['site-represent'] ) ? 'style="display: none;"' : ''; ?>>
<th class = 'wpsp-organization-label'><?php esc_html_e( 'Website Owner Name', 'wp-schema-pro' ); ?></th>
<td>
<input type="text" name="wp-schema-pro-general-settings[person-name]" value="<?php echo esc_attr( $settings['person-name'] ); ?>" placeholder="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" />
</td>
</tr>
<tr class="wp-schema-pro-site-name-wrap" <?php echo ( 'organization' !== $settings['site-represent'] ) ? 'style="display: none;"' : ''; ?>>
<th class = 'wpsp-organization-label'><?php esc_html_e( 'Organization Name', 'wp-schema-pro' ); ?></th>
<td>
<input type="text" name="wp-schema-pro-general-settings[site-name]" value="<?php echo esc_attr( $settings['site-name'] ); ?>" placeholder="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" />
</td>
</tr>
<tr class="wp-schema-pro-site-name-wrap " <?php echo ( 'organization' !== $settings['site-represent'] ) ? 'style="display: none;"' : ''; ?>>
<th>
<?php
esc_html_e(
'Organization Type',
'wp-schema-pro'
);
?>
</th>
<td>
<?php
$option_list = BSF_AIOSRS_Pro_Schema::get_dropdown_options( 'Organization-type' );
?>
<select class ="wpsp-setup-configuration-settings" name="wp-schema-pro-general-settings[organization]" >
<?php
if ( ! empty( $option_list ) ) {
foreach ( $option_list as $key => $value ) {
if ( '-- None --' !== $value ) {
?>
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $settings['organization'], $key ); ?>><?php echo esc_html( $value ); ?></option>
<?php
}
}
}
?>
</select>
<p style="font-style: italic;">
<?php
$brand_bread = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
if ( ( '1' === $brand_bread['sp_hide_label'] ) || true === ( defined( 'WP_SP_WL' ) && WP_SP_WL ) ) {
esc_html_e( 'Select the type that best describes your website. If you can\'t find one that applies exactly, use the generic "General/Other" type. Further create Local Business schema for "General/Other" type.', 'wp-schema-pro' );
} else {
esc_html_e( 'Select the type that best describes your website. If you can\'t find one that applies exactly, use the generic "General/Other" type. Further create Local Business schema for "General/Other" type. ', 'wp-schema-pro' );
echo sprintf(
wp_kses_post( '<a href="https://wpschema.com/docs/organization-type-in-setup-wizard/" target="_blank">Learn more</a>', 'wp-schema-pro' )
);
}
?>
</p>
</td>
</tr>
</table>
<p class="aiosrs-pro-setup-wizard-actions step">
<?php wp_nonce_field( 'aiosrs-pro-setup-wizard' ); ?>
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Next', 'wp-schema-pro' ); ?> &raquo;" name="save_step" />
<a href="<?php echo esc_url( $this->get_prev_step_link() ); ?>" class="button-primary button button-large button-prev" >&laquo; <?php esc_html_e( 'Previous', 'wp-schema-pro' ); ?></a>
</p>
</form>
<?php
}
/**
* General Setting Save.
*/
public function general_setting_save() {
check_admin_referer( 'aiosrs-pro-setup-wizard' );
if ( isset( $_POST['wp-schema-pro-general-settings'] ) ) {
update_option( 'wp-schema-pro-general-settings', array_map( 'sanitize_text_field', $_POST['wp-schema-pro-general-settings'] ) );
}
$redirect_url = $this->get_next_step_link();
wp_safe_redirect( esc_url_raw( $redirect_url ) );
exit;
}
/**
* Social Profiles
*/
public function social_profiles() {
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-social-profiles'];
?>
<h1><?php esc_html_e( 'Social Profiles', 'wp-schema-pro' ); ?></h1>
<p class="success"><?php esc_html_e( 'Please enter all your possible social media profiles. These links can appear in the knowledge panel of the search results for your website.', 'wp-schema-pro' ); ?></p>
<form method="post">
<table class="form-table">
<tr>
<th id='' ><?php esc_html_e( 'Facebook', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[facebook]" value="<?php echo esc_attr( $settings['facebook'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr>
<th id=''><?php esc_html_e( 'Instagram', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[instagram]" value="<?php echo esc_attr( $settings['instagram'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr>
<th id=''><?php esc_html_e( 'YouTube', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[youtube]" value="<?php echo esc_attr( $settings['youtube'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr>
<th id=''><?php esc_html_e( 'Twitter', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[twitter]" value="<?php echo esc_attr( $settings['twitter'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr>
<th id=''><?php esc_html_e( 'Pinterest', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[pinterest]" value="<?php echo esc_attr( $settings['pinterest'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr>
<th id=''><?php esc_html_e( 'LinkedIn', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[linkedin]" value="<?php echo esc_attr( $settings['linkedin'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr>
<th id=''><?php esc_html_e( 'SoundCloud', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[soundcloud]" value="<?php echo esc_attr( $settings['soundcloud'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr>
<th id=''><?php esc_html_e( 'Tumblr', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[tumblr]" value="<?php echo esc_attr( $settings['tumblr'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr>
<th id=''><?php esc_html_e( 'Wikipedia', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[wikipedia]" value="<?php echo esc_attr( $settings['wikipedia'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr>
<th id=''><?php esc_html_e( 'MySpace', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[myspace]" value="<?php echo esc_attr( $settings['myspace'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<tr style="display:none">
<th id=''><?php esc_html_e( 'Google+', 'wp-schema-pro' ); ?></th>
<td><input type="url" name="wp-schema-pro-social-profiles[google-plus]" value="<?php echo esc_attr( $settings['google-plus'] ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /></td>
</tr>
<?php
if ( isset( $settings ) && ! empty( $settings ) && isset( $settings['other'] ) ) {
foreach ( $settings['other'] as $sub_social_profiles => $value ) {
if ( isset( $value ) && ! empty( $value ) ) {
?>
<tr style="display:none">
<th id='' class="wpsp-other-th"><?php esc_html_e( 'Other', 'wp-schema-pro' ); ?></th>
<td><input type="url" class="wpsp-other" name="wp-schema-pro-social-profiles[other][<?php echo esc_attr( $sub_social_profiles ); ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /><span class ="wpsp-field-close remove-row dashicons dashicons-dismiss "><a href="#" class=""></a></span></td>
</tr>
<?php
}
}
}
?>
<tr style="display:none" class="empty-row screen-reader-text"> <!-- empty hidden one for jQuery -->
<th id='' class="wpsp-other-th"><?php esc_html_e( 'Other', 'wp-schema-pro' ); ?></th>
<td><input type="url" class="wpsp-other" name="wp-schema-pro-social-profiles[other][]" value="" placeholder="<?php echo esc_attr( 'Enter URL' ); ?>" /><span class ="wpsp-field-close remove-row dashicons dashicons-dismiss "><a href="#" class="remove-row"></a></span></td>
</tr>
</table>
<p class="aiosrs-pro-setup-wizard-actions step">
<?php wp_nonce_field( 'aiosrs-pro-setup-wizard' ); ?>
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Next', 'wp-schema-pro' ); ?> &raquo;" name="save_step" />
<a href="<?php echo esc_url( $this->get_prev_step_link() ); ?>" class="button-primary button button-large button-prev" >&laquo; <?php esc_html_e( 'Previous', 'wp-schema-pro' ); ?></a>
</p>
</form>
<?php
}
/**
* Social Profiles Save.
*/
public function social_profiles_save() {
check_admin_referer( 'aiosrs-pro-setup-wizard' );
if ( isset( $_POST['wp-schema-pro-social-profiles'] ) ) {
update_option( 'wp-schema-pro-social-profiles', array_map( 'sanitize_text_field', $_POST['wp-schema-pro-social-profiles'] ) );
}
$redirect_url = $this->get_next_step_link();
wp_safe_redirect( esc_url_raw( $redirect_url ) );
exit;
}
/**
* Global Schemas
*/
public function global_schemas() {
$settings = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-global-schemas'];
?>
<h1><?php esc_html_e( 'Other Schemas', 'wp-schema-pro' ); ?></h1>
<p class="success"><?php esc_html_e( 'Fill in additional information about your website to make sure that search engines fully understand what its about. This will help improve your SEO further.', 'wp-schema-pro' ); ?></p>
<form method="post">
<table class="form-table">
<tr>
<th id=''>
<?php esc_html_e( 'Select About Page', 'wp-schema-pro' ); ?>
<?php
$message = __( 'Select your about page from the dropdown list. This will add AboutPage schema on the selected page.', 'wp-schema-pro' );
BSF_AIOSRS_Pro_Admin::get_tooltip( $message );
?>
</th>
<td>
<select class ="wp-select2 wpsp-setup-configuration-settings" name="wp-schema-pro-global-schemas[about-page]">
<option value=""><?php esc_html_e( '--None--', 'wp-schema-pro' ); ?></option>
<?php foreach ( BSF_AIOSRS_Pro_Admin::$pages as $page_id => $page_title ) { ?>
<option <?php selected( $page_id, $settings['about-page'] ); ?> value="<?php echo esc_attr( $page_id ); ?>"><?php echo esc_html( $page_title ); ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<th id=''>
<?php esc_html_e( 'Select Contact Page', 'wp-schema-pro' ); ?>
<?php
$message = __( 'Select your contact page from the dropdown list. This will add ContactPage schema on the selected page.', 'wp-schema-pro' );
BSF_AIOSRS_Pro_Admin::get_tooltip( $message );
?>
</th>
<td>
<select class ="wp-select2 wpsp-setup-configuration-settings" name="wp-schema-pro-global-schemas[contact-page]">
<option value=""><?php esc_html_e( '--None--', 'wp-schema-pro' ); ?></option>
<?php foreach ( BSF_AIOSRS_Pro_Admin::$pages as $page_id => $page_title ) { ?>
<option <?php selected( $page_id, $settings['contact-page'] ); ?> value="<?php echo esc_attr( $page_id ); ?>"><?php echo esc_html( $page_title ); ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<th id='' class="tooltip-with-image-wrapper">
<?php esc_html_e( 'Select Menu for SiteLinks Schema', 'wp-schema-pro' ); ?>
<?php
$message = '<img class="tooltip-image" src="' . esc_url( BSF_AIOSRS_PRO_URI . '/admin/assets/images/sitelinks.jpg' ) . '" />';
BSF_AIOSRS_Pro_Admin::get_tooltip( $message );
?>
</th>
<td>
<?php $nav_menus = wp_get_nav_menus(); ?>
<select name="wp-schema-pro-global-schemas[site-navigation-element]" >
<option <?php selected( '', $settings['site-navigation-element'] ); ?> value=""><?php esc_html_e( '--None--', 'wp-schema-pro' ); ?></option>
<?php foreach ( $nav_menus as $menu ) { ?>
<option <?php selected( $menu->term_id, $settings['site-navigation-element'] ); ?> value="<?php echo esc_attr( $menu->term_id ); ?>"><?php echo esc_html( $menu->name ); ?></option>
<?php } ?>
</select>
<p class="success aiosrs-pro-field-description"><?php esc_html_e( 'This helps Google understand the most important pages on your website and can generate Rich Snippets.', 'wp-schema-pro' ); ?></p>
</td>
</tr>
<tr>
<th id='' class="tooltip-with-image-wrapper">
<?php esc_html_e( 'Enable SiteLinks Search Box', 'wp-schema-pro' ); ?>
<?php
$message = '<img class="tooltip-image" src="' . esc_url( BSF_AIOSRS_PRO_URI . '/admin/assets/images/sitelink-search.jpg' ) . '" />';
BSF_AIOSRS_Pro_Admin::get_tooltip( $message );
?>
</th>
<td>
<label>
<input type="hidden" name="wp-schema-pro-global-schemas[sitelink-search-box]" value="disabled" />
<input type="checkbox" name="wp-schema-pro-global-schemas[sitelink-search-box]" <?php checked( '1', $settings['sitelink-search-box'] ); ?> value="1" /> <?php esc_html_e( 'Yes', 'wp-schema-pro' ); ?>
</label>
<p class="success aiosrs-pro-field-description"><?php esc_html_e( 'If enabled, Google can display a search box on your search websites search results.', 'wp-schema-pro' ); ?></p>
</td>
</tr>
<tr>
<th id='' class="tooltip-with-image-wrapper">
<?php esc_html_e( 'Enable Breadcrumbs', 'wp-schema-pro' ); ?>
<?php
$message = '<img class="tooltip-image" src="' . esc_url( BSF_AIOSRS_PRO_URI . '/admin/assets/images/breadcrumbs.jpg' ) . '" />';
BSF_AIOSRS_Pro_Admin::get_tooltip( $message );
?>
</th>
<td>
<label>
<input type="hidden" name="wp-schema-pro-global-schemas[breadcrumb]" value="disabled" />
<input type="checkbox" name="wp-schema-pro-global-schemas[breadcrumb]" <?php checked( '1', $settings ['breadcrumb'] ); ?> value="1" /> <?php esc_html_e( 'Yes', 'wp-schema-pro' ); ?>
</label>
<p class="success aiosrs-pro-field-description"><?php esc_html_e( 'If enabled, Google can add breadcrumbs to your websites and pages search results.', 'wp-schema-pro' ); ?></p>
</td>
</tr>
</table>
<p class="aiosrs-pro-setup-wizard-actions step">
<?php wp_nonce_field( 'aiosrs-pro-setup-wizard' ); ?>
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Next', 'wp-schema-pro' ); ?> &raquo;" name="save_step" />
<a href="<?php echo esc_url( $this->get_prev_step_link() ); ?>" class="button-primary button button-large button-prev" >&laquo; <?php esc_html_e( 'Previous', 'wp-schema-pro' ); ?></a>
</p>
</form>
<?php
}
/**
* Global Schemas Save.
*/
public function global_schemas_save() {
check_admin_referer( 'aiosrs-pro-setup-wizard' );
if ( isset( $_POST['wp-schema-pro-global-schemas'] ) ) {
update_option( 'wp-schema-pro-global-schemas', array_map( 'sanitize_text_field', $_POST['wp-schema-pro-global-schemas'] ) );
$new_data = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-breadcrumb-setting'];
if ( isset( $new_data['enable_bread'] ) ) {
$old_data = isset( $_POST['wp-schema-pro-global-schemas']['breadcrumb'] ) ? sanitize_text_field( $_POST['wp-schema-pro-global-schemas']['breadcrumb'] ) : '';
$new_data['enable_bread'] = $old_data;
update_option( 'wp-schema-pro-breadcrumb-setting', $new_data );
}
}
$redirect_url = $this->get_next_step_link();
wp_safe_redirect( esc_url_raw( $redirect_url ) );
exit;
}
/**
* Final step.
*/
public function success() {
?>
<h1><?php esc_html_e( 'Well done!', 'wp-schema-pro' ); ?></h1>
<div class="aiosrs-pro-setup-wizard-next-steps">
<div class="aiosrs-pro-setup-wizard-next-steps-last">
<p class="success">
<?php esc_html_e( 'You\'ve successfully added schema to your website! Youre on your way to get rich snippets for your pages.', 'wp-schema-pro' ); ?>
</p>
<p class="success">
<?php esc_html_e( 'The information you provided is globally applied to the website. You can always go back, change, and add more to this later from your dashboard.', 'wp-schema-pro' ); ?>
</p>
<p class="success">
<?php esc_html_e( 'From the dashboard, you can also explore other advanced features like breadcrumbs and white label services.', 'wp-schema-pro' ); ?>
</p>
<p class="success">
<span class ="wpsp-text-strong"><?php esc_html_e( 'Wondering whats next?', 'wp-schema-pro' ); ?></span>
<?php esc_html_e( ' The next step would be to create and set schema markups for your individual pages.', 'wp-schema-pro' ); ?>
</p>
<p class="success">
<?php esc_html_e( 'Give it a try now!', 'wp-schema-pro' ); ?>
</p>
<table class="form-table">
<tr>
<td>
<a href="<?php echo esc_url( admin_url( 'index.php?page=aiosrs-pro-setup' ) ); ?>" type="button" class="button button-primary button-hero" ><?php esc_html_e( 'Create First Schema', 'wp-schema-pro' ); ?></a>
</td>
</tr>
</table>
</div>
</div>
<?php
}
}
new BSF_AIOSRS_Pro_Setup_Wizard();
endif;
?>

View File

@@ -0,0 +1,130 @@
<?php
/**
* Schema Pro Init
*
* @package Schema Pro
*/
define( 'BSF_REMOVE_WP-SCHEMA-PRO_FROM_REGISTRATION_LISTING', true );
if ( ! class_exists( 'BSF_AIOSRS_Pro' ) ) {
/**
* BSF_AIOSRS_Pro initial setup
*
* @since 1.0.0
*/
class BSF_AIOSRS_Pro {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor
*/
public function __construct() {
// Includes Required Files.
$this->includes();
add_action( 'admin_notices', array( $this, 'setup_wizard_notice' ) );
add_action( 'wp_ajax_wp_schema_pro_setup_wizard_notice', array( $this, 'wp_schema_pro_setup_wizard_notice_callback' ) );
}
/**
* Setup Wizard
*
* @since 1.1.0
*/
public function setup_wizard_notice() {
if ( get_transient( 'wp-schema-pro-activated' ) ) {
$url = admin_url( 'index.php?page=aiosrs-pro-setup-wizard' );
$branding_notice = BSF_AIOSRS_Pro_Helper::$settings['wp-schema-pro-branding-settings'];
echo '<div class="wp-schema-pro-setup-wizard-notice notice notice-success is-dismissible">';
if ( '' !== $branding_notice['sp_plugin_name'] ) {
/* translators: %s: search term */
$brand_notice = sprintf( esc_html__( 'Configure %s step by step. ', 'wp-schema-pro' ), $branding_notice['sp_plugin_name'] );
echo '<p>' . esc_html( $brand_notice ) . '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Start Setup Wizard &raquo;', 'wp-schema-pro' ) . '</a></p>';
} else {
echo '<p>' . esc_html__( 'Not sure where to start with Schema Pro? Check out our initial ', 'wp-schema-pro' ) . '<a href="' . esc_url( $url ) . '">' . esc_html__( 'setup wizard first &raquo;', 'wp-schema-pro' ) . '</a></p>';
}
echo '</div>';
?>
<script type="text/javascript">
(function($){
$(document).on('click', '.wp-schema-pro-setup-wizard-notice .notice-dismiss', function(){
$.ajax({
url: ajaxurl,
type: 'POST',
data: {
action : 'wp_schema_pro_setup_wizard_notice',
nonce : '<?php echo esc_attr( wp_create_nonce( 'wp-schema-pro-setup-wizard-notice' ) ); ?>'
},
});
});
})(jQuery);
</script>
<?php
}
}
/**
* Dismiss Notice
*
* @return void
*/
public function wp_schema_pro_setup_wizard_notice_callback() {
check_ajax_referer( 'wp-schema-pro-setup-wizard-notice', 'nonce' );
delete_transient( 'wp-schema-pro-activated' );
wp_send_json_success();
}
/**
* Include required files.
*
* @since 1.0.0
* @return void
*/
public function includes() {
require_once BSF_AIOSRS_PRO_DIR . 'classes/lib/target-rule/class-bsf-target-rule-fields.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/lib/class-bsf-custom-post-list-table.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-wp-schema-pro-yoast-compatibility.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-admin.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-schema.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-custom-fields-markup.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-branding.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-amp.php';
/**
* Frontend.
*/
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-schema-template.php';
require_once BSF_AIOSRS_PRO_DIR . 'classes/class-bsf-aiosrs-pro-markup.php';
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
BSF_AIOSRS_Pro::get_instance();

View File

@@ -0,0 +1,91 @@
<?php
/**
* Schema Pro Yoast Compatibilty
*
* @since 1.1.0
* @package Schema Pro
*/
if ( ! class_exists( 'WP_Schema_Pro_Yoast_Compatibility' ) ) {
/**
* WP_Schema_Pro_Yoast_Compatibility initial setup
*
* @since 1.1.0
*/
class WP_Schema_Pro_Yoast_Compatibility {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Yoast SEO is activated or not.
*
* @access private
* @var $activated Yoast SEO is activated or not.
*/
public static $activated = false;
/**
* Yoast SEO Options.
*
* @access private
* @var $wpseo Yoast SEO options.
*/
private static $wpseo = array();
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor function.
*/
public function __construct() {
if ( defined( 'WPSEO_VERSION' ) && class_exists( 'WPSEO_Options' ) ) {
self::$activated = true;
}
}
/**
* Get Yoast Options
*
* @param string $key Yoast Option key.
* @return array Get yoast compatibility options.
*/
public static function get_option( $key = '' ) {
$settings = get_option( 'aiosrs-pro-settings', array() );
if ( ! self::$activated || ( isset( $settings['yoast-compatibility'] ) && '1' !== $settings['yoast-compatibility'] ) ) {
return false;
}
if ( 'wp_schema_pro_yoast_enabled' === $key ) {
return true;
}
if ( empty( self::$wpseo ) && method_exists( 'WPSEO_Options', 'get_options' ) ) {
self::$wpseo = WPSEO_Options::get_options( array( 'wpseo', 'wpseo_social', 'wpseo_internallinks', 'wpseo_titles' ) );
}
return isset( self::$wpseo[ $key ] ) ? self::$wpseo[ $key ] : false;
}
}
}
/**
* Kicking this off by calling 'get_instance()' method
*/
WP_Schema_Pro_Yoast_Compatibility::get_instance();

View File

@@ -0,0 +1,612 @@
<?php
/**
* Schema List Table
*
* @package Schema Pro
**/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Load WP_List_Table if not loaded.
if ( ! class_exists( 'WP_List_Table' ) ) {
include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
/**
* Customizer Initialization
*
* @since 1.0.0
*/
class BSF_Custom_Post_List_Table extends WP_List_Table {
/**
* Member Variable
*
* @var int $per_page items per page
* @since 1.0.0
*/
public $per_page = 30;
/**
* Member Variable
*
* @var int $per_page items per page
* @since 1.0.0
*/
public $custom_post_type = 'post';
/**
* BSF_Custom_Post_List_Table
*
* @param string $post_type Custom post type slug.
*/
public function __construct( $post_type ) {
global $status, $page;
$this->custom_post_type = $post_type;
parent::__construct(
array(
'singular' => $post_type,
'plural' => $post_type . 's',
'ajax' => false,
)
);
}
/**
* No Advanced Headers found message
*/
public function no_items() {
$post_type_object = get_post_type_object( $this->custom_post_type );
echo sprintf(
/* translators: %s: post type label */
esc_html__( 'No %s found', 'wp-schema-pro' ),
esc_html( $post_type_object->labels->singular_name )
);
}
/**
* Set default columns
*
* @param array $item default column items.
* @param array $column_name default column names.
* @return void
*/
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'post_title':
case 'date':
default:
}
do_action( 'manage_' . $this->custom_post_type . '_posts_custom_column', $column_name, $item['ID'] );
}
/**
* Set sortable columns
*
* @return sortable_columns sortable columns.
*/
public function get_sortable_columns() {
$sortable_columns = array(
'post_title' => array( 'post_title', false ),
'date' => array( 'date', false ),
);
return apply_filters( 'manage_' . $this->custom_post_type . '_sortable_columns', $sortable_columns );
}
/**
* Sort columns
*
* @param array $a default column items.
* @param array $b default column names.
* @return array $result sortable columns.
*/
public function usort_reorder( $a, $b ) {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
// If no sort, default to title.
$orderby = ( ! empty( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'post_title';
// If no order, default to asc.
$order = ( ! empty( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'asc';
// Determine sort order.
$result = strcmp( $a[ $orderby ], $b[ $orderby ] );
// Send final sort direction to usort.
return ( 'asc' === $order ) ? $result : -$result;
}
/**
* Get columns
*
* @return array $columns display columns.
*/
public function get_columns() {
$columns = array(
'cb' => '<input type="checkbox" />',
'post_title' => esc_html__( 'Title', 'wp-schema-pro' ),
'date' => esc_html__( 'Date', 'wp-schema-pro' ),
);
return apply_filters( 'manage_' . $this->custom_post_type . '_posts_columns', $columns );
}
/**
* Get bulk actions
*
* @return array $actions bulk actions.
*/
public function get_bulk_actions() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
$current = ( ! empty( $_REQUEST['post_status'] ) ? sanitize_text_field( $_REQUEST['post_status'] ) : 'all' );
if ( 'trash' === $current ) {
$actions = array(
'restore' => esc_html__( 'Restore', 'wp-schema-pro' ),
'delete' => esc_html__( 'Delete Permanently', 'wp-schema-pro' ),
);
} elseif ( 'draft' === $current ) {
$actions = array(
'trash' => esc_html__( 'Move to Trash', 'wp-schema-pro' ),
);
} else {
$actions = array(
'draft' => esc_html__( 'Draft', 'wp-schema-pro' ),
'trash' => esc_html__( 'Move to Trash', 'wp-schema-pro' ),
);
}
return $actions;
}
/**
* Process bulk actions
*/
public function process_bulk_action() {
// security check!
$action = $this->current_action();
if ( 'trash' === $action || 'delete' === $action || 'draft' === $action || 'restore' === $action ) {
if ( isset( $_POST['_wpnonce'] ) && ! empty( $_POST['_wpnonce'] ) ) {
$nonce = sanitize_text_field( $_POST['_wpnonce'] );
$action = 'bulk-' . $this->_args['plural'];
if ( ! wp_verify_nonce( $nonce, $action ) ) {
wp_die( 'Nope! Security check failed!' );
}
} else {
wp_die( 'Nope! Security check failed!' );
}
// Detect when a bulk action is being triggered...
if ( 'trash' === $this->current_action() && isset( $_POST[ $this->_args['singular'] ] ) ) {
foreach ( array_map( 'sanitize_text_field', $_POST[ $this->_args['singular'] ] ) as $id ) {
wp_trash_post( $id );
}
}
if ( 'delete' === $this->current_action() && isset( $_POST[ $this->_args['singular'] ] ) ) {
foreach ( array_map( 'sanitize_text_field', $_POST[ $this->_args['singular'] ] ) as $id ) {
wp_delete_post( $id );
}
}
if ( 'draft' === $this->current_action() && isset( $_POST[ $this->_args['singular'] ] ) ) {
foreach ( array_map( 'sanitize_text_field', $_POST[ $this->_args['singular'] ] ) as $id ) {
$post = array(
'ID' => $id,
'post_status' => 'draft',
);
wp_update_post( $post );
}
}
if ( 'restore' === $this->current_action() && isset( $_POST[ $this->_args['singular'] ] ) ) {
foreach ( array_map( 'sanitize_text_field', $_POST[ $this->_args['singular'] ] ) as $id ) {
wp_untrash_post( $id );
}
}
} else {
return;
}
}
/**
* Get bulk actions
*
* @param array $item first columns checkbox.
* @return array check box columns.
*/
public function column_cb( $item ) {
return sprintf(
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
$this->_args['singular'],
$item['ID']
);
}
/**
* Get columns headers
*
* @param array $item columns header item.
* @return array columns.
*/
public function column_post_title( $item ) {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
$edit_post_link = get_edit_post_link( $item['ID'] );
$post_type_object = get_post_type_object( $this->custom_post_type );
$can_edit_post = current_user_can( 'edit_post', $item['ID'] );
$actions = array();
$title = _draft_or_post_title();
$post_status = ( ! empty( $_REQUEST['post_status'] ) ) ? sanitize_text_field( $_REQUEST['post_status'] ) : 'all';
if ( $can_edit_post && 'trash' !== $post_status ) {
$actions['edit'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
get_edit_post_link( $item['ID'] ),
/* translators: %s: post title */
esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;', 'wp-schema-pro' ), $title ) ),
__( 'Edit', 'wp-schema-pro' )
);
}
if ( current_user_can( 'delete_post', $item['ID'] ) ) {
if ( 'trash' === $post_status ) {
$actions['untrash'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $item['ID'] ) ), 'untrash-post_' . $item['ID'] ),
/* translators: %s: post title */
esc_attr( sprintf( __( 'Restore &#8220;%s&#8221; from the Trash', 'wp-schema-pro' ), $title ) ),
__( 'Restore', 'wp-schema-pro' )
);
} elseif ( EMPTY_TRASH_DAYS ) {
$actions['trash'] = sprintf(
'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
get_delete_post_link( $item['ID'] ),
/* translators: %s: post title */
esc_attr( sprintf( __( 'Move &#8220;%s&#8221; to the Trash', 'wp-schema-pro' ), $title ) ),
_x( 'Trash', 'verb', 'wp-schema-pro' )
);
}
if ( 'trash' === $post_status || ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = sprintf(
'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
get_delete_post_link( $item['ID'], '', true ),
/* translators: %s: post title */
esc_attr( sprintf( __( 'Delete &#8220;%s&#8221; permanently', 'wp-schema-pro' ), $title ) ),
__( 'Delete Permanently', 'wp-schema-pro' )
);
}
}
if ( is_post_type_viewable( $post_type_object ) ) {
if ( in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) ) {
if ( $can_edit_post ) {
$preview_link = get_preview_post_link( $post );
$actions['view'] = sprintf(
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
esc_url( $preview_link ),
/* translators: %s: post title */
esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;', 'wp-schema-pro' ), $title ) ),
__( 'Preview', 'wp-schema-pro' )
);
}
} elseif ( 'trash' !== $post_status ) {
$actions['view'] = sprintf(
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>',
get_permalink( $item['ID'] ),
/* translators: %s: post title */
esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'wp-schema-pro' ), $title ) ),
__( 'View', 'wp-schema-pro' )
);
}
}
global $post;
$post = get_post( $item['ID'], OBJECT ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
setup_postdata( $post );
ob_start();
_post_states( $post );
$post_states = ob_get_clean();
$actions = apply_filters( 'post_row_actions', $actions, $post );
wp_reset_postdata();
if ( 'trash' === $post_status ) {
return sprintf( '<strong>%1$s%2$s</strong>%3$s', $item['post_title'], $post_states, $this->row_actions( $actions ) );
} else {
return sprintf( '<strong><a class="row-title" href="%1$s" aria-label="%2$s">%2$s</a>%3$s</strong>%4$s', $edit_post_link, $item['post_title'], $post_states, $this->row_actions( $actions ) );
}
}
/**
* Retrieve the current page number
*
* @since 1.0.0
* @return int Current page number
*/
public function get_paged() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
}
/**
* Get date column
*
* @param array $post date column.
*/
public function column_date( $post ) {
global $mode;
$post_id = $post['ID'];
if ( '0000-00-00 00:00:00' === $post['date'] ) {
$t_time = __( 'Unpublished', 'wp-schema-pro' );
$h_time = __( 'Unpublished', 'wp-schema-pro' );
$time_diff = 0;
} else {
$t_time = get_the_time( __( 'Y/m/d g:i:s a', 'wp-schema-pro' ) );
$m_time = $post['date'];
$time = get_post_time( 'G', true, $post );
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
/* translators: 1: time */
$h_time = sprintf( __( '%s ago', 'wp-schema-pro' ), human_time_diff( $time ) );
} else {
$h_time = mysql2date( __( 'Y/m/d', 'wp-schema-pro' ), $m_time );
}
}
if ( 'publish' === get_post_status( $post_id ) ) {
$status = __( 'Published', 'wp-schema-pro' );
} elseif ( 'future' === get_post_status( $post_id ) ) {
if ( $time_diff > 0 ) {
$status = '<strong class="error-message">' . __( 'Missed schedule', 'wp-schema-pro' ) . '</strong>';
} else {
$status = __( 'Scheduled', 'wp-schema-pro' );
}
} else {
$status = __( 'Last Modified', 'wp-schema-pro' );
}
/**
* Filters the status text of the post.
*
* @since 4.8.0
*
* @param string $status The status text.
* @param WP_Post $post Post object.
* @param string $column_name The column name.
* @param string $mode The list display mode ('excerpt' or 'list').
*/
$status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode );
if ( $status ) {
echo esc_html( $status ) . '<br />';
}
if ( 'excerpt' === $mode ) {
/**
* Filters the published time of the post.
*
* If `$mode` equals 'excerpt', the published time and date are both displayed.
* If `$mode` equals 'list' (default), the publish date is displayed, with the
* time and date together available as an abbreviation definition.
*
* @since 2.5.1
*
* @param string $t_time The published time.
* @param WP_Post $post Post object.
* @param string $column_name The column name.
* @param string $mode The list display mode ('excerpt' or 'list').
*/
echo esc_html( apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ) );
} else {
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
echo '<abbr title="' . esc_attr( $t_time ) . '">' . esc_html( apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) ) . '</abbr>';
}
}
/**
* Retrieve the total number of {{custom-post}}
*
* @since 1.0.0
* @return int $total Total number of {{custom-post}}
*/
public function get_total_custom_posts() {
$num_posts = wp_count_posts( $this->custom_post_type, 'readable' );
$total_posts = array_sum( (array) $num_posts );
// Subtract post types that are not included in the admin all list.
foreach ( get_post_stati(
array(
'show_in_admin_all_list' => false,
)
) as $state ) {
$total_posts -= $num_posts->$state;
}
return $total_posts;
}
/**
* Get all items.
*
* @param string $search search string.
*/
public function prepare_items( $search = '' ) {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
$post_status = ( ! empty( $_REQUEST['post_status'] ) ) ? sanitize_text_field( $_REQUEST['post_status'] ) : 'any';
$data = array();
$args = array(
'post_type' => $this->custom_post_type,
'posts_per_page' => $this->per_page,
'paged' => $this->get_paged(),
's' => $search,
'post_status' => $post_status,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
$key = 0;
while ( $the_query->have_posts() ) :
$the_query->the_post();
$data[ $key ] = array(
'ID' => get_the_ID(),
'post_title' => get_the_title(),
'date' => get_the_date(),
);
$key++;
endwhile;
endif;
wp_reset_postdata();
$columns = $this->get_columns();
$hidden = array(); // No hidden columns.
$sortable = $this->get_sortable_columns();
$this->_column_headers = array( $columns, $hidden, $sortable );
$this->process_bulk_action();
usort( $data, array( $this, 'usort_reorder' ) );
$total_items = $this->get_total_custom_posts();
$this->items = $data;
$this->set_pagination_args(
array(
'total_items' => $total_items,
'per_page' => $this->per_page,
'total_pages' => ceil( $total_items / $this->per_page ),
)
);
}
/**
* Get Views.
*
* @return array list of all views.
*/
public function get_views() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
$status_links = array();
$num_posts = wp_count_posts( $this->custom_post_type, 'readable' );
$class = '';
$total_posts = array_sum( (array) $num_posts );
// Subtract post types that are not included in the admin all list.
foreach ( get_post_stati(
array(
'show_in_admin_all_list' => false,
)
) as $state ) {
$total_posts -= $num_posts->$state;
}
$class = empty( $class ) && empty( $_REQUEST['post_status'] ) ? ' class="current"' : '';
$query_all_var = remove_query_arg( 'post_status' );
/* translators: %s: count */
$status_links['all'] = "<a href='" . esc_url( $query_all_var ) . "'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts', 'wp-schema-pro' ), number_format_i18n( $total_posts ) ) . '</a>';
foreach ( get_post_stati(
array(
'show_in_admin_status_list' => true,
),
'objects'
) as $status ) {
$class = '';
$status_name = $status->name;
if ( ! in_array( $status_name, array( 'publish', 'draft', 'pending', 'trash', 'future', 'private', 'auto-draft' ), true ) ) {
continue;
}
if ( empty( $num_posts->$status_name ) ) {
continue;
}
if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) {
$class = ' class="current"';
}
$label = $status->label_count;
$query_var = add_query_arg( 'post_status', $status_name );
$status_links[ $status_name ] = "<a href='" . esc_url( $query_var ) . "'$class>" . sprintf( translate_nooped_plural( $label, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>';
}
return $status_links;
}
/**
* Render List Table Markup.
*/
public function render_markup() {
if ( isset( $_REQUEST['wp_schema_pro_admin_page_nonce'] ) && ! wp_verify_nonce( sanitize_text_field( $_REQUEST['wp_schema_pro_admin_page_nonce'] ), 'wp_schema_pro_admin_page' ) ) {
return;
}
$this->prepare_items();
$post_type = $this->_args['singular'];
$post_obj = get_post_type_object( $post_type );
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?php echo esc_html( $post_obj->labels->name ); ?></h1>
<?php
$post_new_file = 'post-new.php?post_type=' . $post_type;
if ( isset( $post_new_file ) && current_user_can( $post_obj->cap->create_posts ) ) {
echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_obj->labels->add_new_item ) . '</a>';
}
// Search results for.
$s = isset( $_REQUEST['s'] ) && strlen( sanitize_text_field( $_REQUEST['s'] ) ) ? sanitize_text_field( $_REQUEST['s'] ) : null;
if ( $s ) {
/* translators: %s: search keywords */
printf( '<span class="subtitle">' . esc_html__( 'Search results for &#8220;%s&#8221;', 'wp-schema-pro' ) . '</span>', esc_html( $s ) );
}
?>
<br><br>
<?php
// table post views with count.
$this->views();
?>
<form id="<?php echo esc_attr( $post_type ); ?>-filter" method="post">
<?php
if ( $s ) {
$this->prepare_items( $s );
} else {
$this->prepare_items();
}
$this->search_box(
sprintf(
/* translators: %s: Post Label */
esc_html__( 'Search %s', 'wp-schema-pro' ),
$post_obj->labels->name
),
'search_id'
);
$this->display();
?>
</form>
</div>
<?php
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,484 @@
.select2-container {
box-sizing: border-box;
display: inline-block;
margin: 0;
position: relative;
vertical-align: middle; }
.select2-container .select2-selection--single {
box-sizing: border-box;
cursor: pointer;
display: block;
height: 30px;
user-select: none;
-webkit-user-select: none; }
.select2-container .select2-selection--single .select2-selection__rendered {
display: block;
padding-left: 8px;
padding-right: 20px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap; }
.select2-container .select2-selection--single .select2-selection__clear {
position: relative; }
.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered {
padding-right: 8px;
padding-left: 20px; }
.select2-container .select2-selection--multiple {
box-sizing: border-box;
cursor: pointer;
display: block;
min-height: 32px;
user-select: none;
-webkit-user-select: none; }
.select2-container .select2-selection--multiple .select2-selection__rendered {
display: inline-block;
overflow: hidden;
padding-left: 8px;
text-overflow: ellipsis;
white-space: nowrap; }
.select2-container .select2-search--inline {
float: left; }
.select2-container .select2-search--inline .select2-search__field {
box-sizing: border-box;
border: none;
font-size: 100%;
margin-top: 5px;
padding: 0; }
.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button {
-webkit-appearance: none; }
.select2-dropdown {
background-color: white;
border: 1px solid #aaa;
border-radius: 4px;
box-sizing: border-box;
display: block;
position: absolute;
left: -100000px;
width: 100%;
z-index: 1051; }
.select2-results {
display: block; }
.select2-results__options {
list-style: none;
margin: 0;
padding: 0; }
.select2-results__option {
padding: 6px;
user-select: none;
-webkit-user-select: none; }
.select2-results__option[aria-selected] {
cursor: pointer; }
.select2-container--open .select2-dropdown {
left: 0; }
.select2-container--open .select2-dropdown--above {
border-bottom: none;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0; }
.select2-container--open .select2-dropdown--below {
border-top: none;
border-top-left-radius: 0;
border-top-right-radius: 0; }
.select2-search--dropdown {
display: block;
padding: 4px; }
.select2-search--dropdown .select2-search__field {
padding: 4px;
width: 100%;
box-sizing: border-box; }
.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button {
-webkit-appearance: none; }
.select2-search--dropdown.select2-search--hide {
display: none; }
.select2-close-mask {
border: 0;
margin: 0;
padding: 0;
display: block;
position: fixed;
left: 0;
top: 0;
min-height: 100%;
min-width: 100%;
height: auto;
width: auto;
opacity: 0;
z-index: 99;
background-color: #fff;
filter: alpha(opacity=0); }
.select2-hidden-accessible {
border: 0 !important;
clip: rect(0 0 0 0) !important;
height: 1px !important;
margin: -1px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important; }
.select2-container--default .select2-selection--single {
background-color: #fff;
border: 1px solid #aaa;
border-radius: 4px; }
.select2-container--default .select2-selection--single .select2-selection__rendered {
color: #444;
line-height: 28px; }
.select2-container--default .select2-selection--single .select2-selection__clear {
cursor: pointer;
float: right;
font-weight: bold; }
.select2-container--default .select2-selection--single .select2-selection__placeholder {
color: #999; }
.select2-container--default .select2-selection--single .select2-selection__arrow {
height: 26px;
position: absolute;
top: 1px;
right: 1px;
width: 20px; }
.select2-container--default .select2-selection--single .select2-selection__arrow b {
border-color: #888 transparent transparent transparent;
border-style: solid;
border-width: 5px 4px 0 4px;
height: 0;
left: 50%;
margin-left: -4px;
margin-top: -2px;
position: absolute;
top: 50%;
width: 0; }
.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear {
float: left; }
.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow {
left: 1px;
right: auto; }
.select2-container--default.select2-container--disabled .select2-selection--single {
background-color: #eee;
cursor: default; }
.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear {
display: none; }
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
border-color: transparent transparent #888 transparent;
border-width: 0 4px 5px 4px; }
.select2-container--default .select2-selection--multiple {
background-color: white;
border: 1px solid #aaa;
border-radius: 4px;
cursor: text; }
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
box-sizing: border-box;
list-style: none;
margin: 0;
padding: 0 5px;
width: 100%; }
.select2-container--default .select2-selection--multiple .select2-selection__rendered li {
list-style: none; }
.select2-container--default .select2-selection--multiple .select2-selection__placeholder {
color: #999;
margin-top: 5px;
float: left; }
.select2-container--default .select2-selection--multiple .select2-selection__clear {
cursor: pointer;
float: right;
font-weight: bold;
margin-top: 5px;
margin-right: 10px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice {
background-color: #e4e4e4;
border: 1px solid #aaa;
border-radius: 4px;
cursor: default;
float: left;
margin-right: 5px;
margin-top: 5px;
padding: 0 5px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
color: #999;
cursor: pointer;
display: inline-block;
font-weight: bold;
margin-right: 2px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
color: #333; }
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
float: right; }
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
margin-left: 5px;
margin-right: auto; }
.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
margin-left: 2px;
margin-right: auto; }
.select2-container--default.select2-container--focus .select2-selection--multiple {
border: solid black 1px;
outline: 0; }
.select2-container--default.select2-container--disabled .select2-selection--multiple {
background-color: #eee;
cursor: default; }
.select2-container--default.select2-container--disabled .select2-selection__choice__remove {
display: none; }
.select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple {
border-top-left-radius: 0;
border-top-right-radius: 0; }
.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0; }
.select2-container--default .select2-search--dropdown .select2-search__field {
border: 1px solid #aaa; }
.select2-container--default .select2-search--inline .select2-search__field {
background: transparent;
border: none;
outline: 0;
box-shadow: none;
-webkit-appearance: textfield; }
.select2-container--default .select2-results > .select2-results__options {
max-height: 200px;
overflow-y: auto; }
.select2-container--default .select2-results__option[role=group] {
padding: 0; }
.select2-container--default .select2-results__option[aria-disabled=true] {
color: #999; }
.select2-container--default .select2-results__option[aria-selected=true] {
background-color: #ddd; }
.select2-container--default .select2-results__option .select2-results__option {
padding-left: 1em; }
.select2-container--default .select2-results__option .select2-results__option .select2-results__group {
padding-left: 0; }
.select2-container--default .select2-results__option .select2-results__option .select2-results__option {
margin-left: -1em;
padding-left: 2em; }
.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
margin-left: -2em;
padding-left: 3em; }
.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
margin-left: -3em;
padding-left: 4em; }
.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
margin-left: -4em;
padding-left: 5em; }
.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
margin-left: -5em;
padding-left: 6em; }
.select2-container--default .select2-results__option--highlighted[aria-selected] {
background-color: #5897fb;
color: white; }
.select2-container--default .select2-results__group {
cursor: default;
display: block;
padding: 6px; }
.select2-container--classic .select2-selection--single {
background-color: #f7f7f7;
border: 1px solid #aaa;
border-radius: 4px;
outline: 0;
background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%);
background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%);
background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
.select2-container--classic .select2-selection--single:focus {
border: 1px solid #5897fb; }
.select2-container--classic .select2-selection--single .select2-selection__rendered {
color: #444;
line-height: 28px; }
.select2-container--classic .select2-selection--single .select2-selection__clear {
cursor: pointer;
float: right;
font-weight: bold;
margin-right: 10px; }
.select2-container--classic .select2-selection--single .select2-selection__placeholder {
color: #999; }
.select2-container--classic .select2-selection--single .select2-selection__arrow {
background-color: #ddd;
border: none;
border-left: 1px solid #aaa;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
height: 26px;
position: absolute;
top: 1px;
right: 1px;
width: 20px;
background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); }
.select2-container--classic .select2-selection--single .select2-selection__arrow b {
border-color: #888 transparent transparent transparent;
border-style: solid;
border-width: 5px 4px 0 4px;
height: 0;
left: 50%;
margin-left: -4px;
margin-top: -2px;
position: absolute;
top: 50%;
width: 0; }
.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear {
float: left; }
.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow {
border: none;
border-right: 1px solid #aaa;
border-radius: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
left: 1px;
right: auto; }
.select2-container--classic.select2-container--open .select2-selection--single {
border: 1px solid #5897fb; }
.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow {
background: transparent;
border: none; }
.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b {
border-color: transparent transparent #888 transparent;
border-width: 0 4px 5px 4px; }
.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single {
border-top: none;
border-top-left-radius: 0;
border-top-right-radius: 0;
background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%);
background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%);
background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single {
border-bottom: none;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%);
background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%);
background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); }
.select2-container--classic .select2-selection--multiple {
background-color: white;
border: 1px solid #aaa;
border-radius: 4px;
cursor: text;
outline: 0; }
.select2-container--classic .select2-selection--multiple:focus {
border: 1px solid #5897fb; }
.select2-container--classic .select2-selection--multiple .select2-selection__rendered {
list-style: none;
margin: 0;
padding: 0 5px; }
.select2-container--classic .select2-selection--multiple .select2-selection__clear {
display: none; }
.select2-container--classic .select2-selection--multiple .select2-selection__choice {
background-color: #e4e4e4;
border: 1px solid #aaa;
border-radius: 4px;
cursor: default;
float: left;
margin-right: 5px;
margin-top: 5px;
padding: 0 5px; }
.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove {
color: #888;
cursor: pointer;
display: inline-block;
font-weight: bold;
margin-right: 2px; }
.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover {
color: #555; }
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
float: right; }
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
margin-left: 5px;
margin-right: auto; }
.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
margin-left: 2px;
margin-right: auto; }
.select2-container--classic.select2-container--open .select2-selection--multiple {
border: 1px solid #5897fb; }
.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple {
border-top: none;
border-top-left-radius: 0;
border-top-right-radius: 0; }
.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple {
border-bottom: none;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0; }
.select2-container--classic .select2-search--dropdown .select2-search__field {
border: 1px solid #aaa;
outline: 0; }
.select2-container--classic .select2-search--inline .select2-search__field {
outline: 0;
box-shadow: none; }
.select2-container--classic .select2-dropdown {
background-color: white;
border: 1px solid transparent; }
.select2-container--classic .select2-dropdown--above {
border-bottom: none; }
.select2-container--classic .select2-dropdown--below {
border-top: none; }
.select2-container--classic .select2-results > .select2-results__options {
max-height: 200px;
overflow-y: auto; }
.select2-container--classic .select2-results__option[role=group] {
padding: 0; }
.select2-container--classic .select2-results__option[aria-disabled=true] {
color: grey; }
.select2-container--classic .select2-results__option--highlighted[aria-selected] {
background-color: #3875d7;
color: white; }
.select2-container--classic .select2-results__group {
cursor: default;
display: block;
padding: 6px; }
.select2-container--classic.select2-container--open .select2-dropdown {
border-color: #5897fb; }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,103 @@
/* Select2 */
span.select2.select2-container.select2-container--default {
margin-top: 0;
}
li.select2-results__option.select2-results__message {
background: #ecebeb;
margin-bottom: 0;
}
tr td .select2-container {
display: inline-block;
position: relative;
vertical-align: middle;
width: 100% !important;
}
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default .select2-selection--multiple {
border: 1px solid #ddd;
margin-top: 10px;
}
.select2-container .select2-search--inline,
.select2-container--default .select2-search--inline .select2-search__field {
width: 100% !important;
}
/* Target Rule field */
.bsf-target-rule-condition,
.bsf-user-role-condition {
position: relative;
padding: 0 30px 0 0;
margin-top: 10px;
}
.target_rule-specific-page-wrap {
position: relative;
padding: 0 30px 0 0;
}
.user_role-add-rule-wrap,
.target_rule-add-rule-wrap,
.target_rule-add-exclusion-rule,
.user_role-add-rule-wrap {
margin-top: 15px;
}
.bsf-target-rule-display-on,
.bsf-target-rule-exclude-on {
margin-bottom: 10px;
}
.target_rule-condition-delete,
.user_role-condition-delete {
position: absolute;
color: #999;
right: 0px;
top: 0px;
font-size: 18px;
line-height: 18px;
width: 18px;
height: 18px;
display: inline-block;
cursor: pointer;
top: 50%;
transform: translateY(-50%);
}
.target_rule-condition-delete:hover {
color: #d54e21;
}
.target_rule-add-rule-wrap {
display: inline-block;
}
.target_rule-add-exclusion-rule {
display: inline-block;
margin-left: 10px;
}
.configure-content [data-element="exclude_from"],
.configure-content [data-element="exclusive_on"] {
padding-bottom: 0;
}
.configure-content .bsf-allow-specific-posts input,
.configure-content .bsf-post-types {
margin-right: 3px;
}
.hide-on-devices input[type=checkbox] {
margin-right: 5px;
}
.search-panel.search-close-icon {
pointer-events: auto;
cursor: pointer;
}
.bsf-hidden {
display: none !important;
}

View File

@@ -0,0 +1,279 @@
/* eslint-env jquery */
(function ($) {
const initTargetRuleSelect2 = function (selector) {
$(selector).select2({
placeholder: 'Search pages / post / archives',
ajax: {
url: ajaxurl,
dataType: 'json',
method: 'post',
delay: 250,
data(params) {
return {
q: params.term, // search term
page: params.page,
action: 'bsf_get_posts_by_query',
nonce: Targetrule.security,
};
},
processResults(data) {
// console.log(data);
// console.log("inside");
// parse the results into the format expected by Select2.
// since we are using custom formatting functions we do not need to
// alter the remote JSON data
return {
results: data,
};
},
cache: true,
},
minimumInputLength: 2,
});
};
const updateTargetRuleInput = function (wrapper) {
const ruleInput = wrapper.find('.bsf-target_rule-input');
const newValue = [];
wrapper.find('.bsf-target-rule-condition').each(function () {
const $this = $(this);
let tempObj = {};
const ruleCondition = $this.find('select.target_rule-condition');
const specificPage = $this.find('select.target_rule-specific-page');
const ruleConditionVal = ruleCondition.val();
const specificPageVal = specificPage.val();
if ('' !== ruleConditionVal) {
tempObj = {
type: ruleConditionVal,
specific: specificPageVal,
};
newValue.push(tempObj);
}
});
const rulesString = JSON.stringify(newValue);
ruleInput.val(rulesString);
};
const updateCloseButton = function (wrapper) {
const type = wrapper
.closest('.bsf-target-rule-wrapper')
.attr('data-type');
const rules = wrapper.find('.bsf-target-rule-condition');
let showClose = false;
if ('display' === type) {
if (rules.length > 1) {
showClose = true;
}
} else {
showClose = true;
}
rules.each(function () {
if (showClose) {
jQuery(this)
.find('.target_rule-condition-delete')
.removeClass('bsf-hidden');
} else {
jQuery(this)
.find('.target_rule-condition-delete')
.addClass('bsf-hidden');
}
});
};
const updateExclusionButton = function (forceShow, forceHide) {
const displayOn = $('.bsf-target-rule-display-on-wrap');
const excludeOn = $('.bsf-target-rule-exclude-on-wrap');
const excludeFieldWrap = excludeOn.closest('tr');
const addExcludeBlock = displayOn.find(
'.target_rule-add-exclusion-rule'
);
const excludeConditions = excludeOn.find('.bsf-target-rule-condition');
if (true === forceHide) {
excludeFieldWrap.addClass('bsf-hidden');
addExcludeBlock.removeClass('bsf-hidden');
} else if (true === forceShow) {
excludeFieldWrap.removeClass('bsf-hidden');
addExcludeBlock.addClass('bsf-hidden');
} else if (
1 === excludeConditions.length &&
'' ===
$(excludeConditions[0])
.find('select.target_rule-condition')
.val()
) {
excludeFieldWrap.addClass('bsf-hidden');
addExcludeBlock.removeClass('bsf-hidden');
} else {
excludeFieldWrap.removeClass('bsf-hidden');
addExcludeBlock.addClass('bsf-hidden');
}
};
$(document).ready(function () {
jQuery('.bsf-target-rule-condition').each(function () {
const $this = $(this),
condition = $this.find('select.target_rule-condition'),
conditionVal = condition.val(),
specificPage = $this.next('.target_rule-specific-page-wrap');
if ('specifics' === conditionVal) {
specificPage.slideDown(300);
}
});
jQuery(
'.bsf-target-rule-selector-wrapper select.target-rule-select2'
).each(function (index, el) {
initTargetRuleSelect2(el);
});
jQuery('.bsf-target-rule-selector-wrapper').each(function () {
updateCloseButton(jQuery(this));
});
jQuery(document).on(
'change',
'.bsf-target-rule-condition select.target_rule-condition',
function () {
const $this = jQuery(this),
thisVal = $this.val(),
fieldWrap = $this.closest('.bsf-target-rule-wrapper');
if ('specifics' === thisVal) {
$this
.closest('.bsf-target-rule-condition')
.next('.target_rule-specific-page-wrap')
.slideDown(300);
} else {
$this
.closest('.bsf-target-rule-condition')
.next('.target_rule-specific-page-wrap')
.slideUp(300);
}
updateTargetRuleInput(fieldWrap);
}
);
jQuery('.bsf-target-rule-selector-wrapper').on(
'change',
'.target-rule-select2',
function () {
const $this = jQuery(this),
fieldWrap = $this.closest('.bsf-target-rule-wrapper');
updateTargetRuleInput(fieldWrap);
}
);
jQuery('.bsf-target-rule-selector-wrapper').on(
'click',
'.target_rule-add-rule-wrap a',
function (e) {
e.preventDefault();
e.stopPropagation();
const $this = jQuery(this),
id = $this.attr('data-rule-id'),
newId = parseInt(id) + 1,
type = $this.attr('data-rule-type'),
ruleWrap = $this
.closest('.bsf-target-rule-selector-wrapper')
.find('.target_rule-builder-wrap'),
template = wp.template(
'bsf-target-rule-' + type + '-condition'
),
fieldWrap = $this.closest('.bsf-target-rule-wrapper');
ruleWrap.append(template({ id: newId, type }));
initTargetRuleSelect2(
'.bsf-target-rule-' + type + '-on .target-rule-select2'
);
$this.attr('data-rule-id', newId);
updateCloseButton(fieldWrap);
}
);
jQuery('.bsf-target-rule-selector-wrapper').on(
'click',
'.target_rule-condition-delete',
function () {
const $this = jQuery(this),
ruleCondition = $this.closest('.bsf-target-rule-condition'),
fieldWrap = $this.closest('.bsf-target-rule-wrapper');
let cnt = 0;
const dataType = fieldWrap.attr('data-type');
if (
'exclude' === dataType &&
fieldWrap.find('.bsf-target-rule-condition').length === 1
) {
fieldWrap.find('.target_rule-condition').val('');
fieldWrap.find('.target_rule-specific-page').val('');
fieldWrap.find('.target_rule-condition').trigger('change');
updateExclusionButton(false, true);
} else {
$this
.parent('.bsf-target-rule-condition')
.next('.target_rule-specific-page-wrap')
.remove();
ruleCondition.remove();
}
fieldWrap.find('.bsf-target-rule-condition').each(function (i) {
const condition = jQuery(this),
oldRuleId = condition.attr('data-rule'),
selectLocation = condition.find(
'.target_rule-condition'
),
locationName = selectLocation.attr('name');
condition.attr('data-rule', i);
selectLocation.attr(
'name',
locationName.replace(
'[' + oldRuleId + ']',
'[' + i + ']'
)
);
condition
.removeClass('bsf-target-rule-' + oldRuleId)
.addClass('bsf-target-rule-' + i);
cnt = i;
});
fieldWrap
.find('.target_rule-add-rule-wrap a')
.attr('data-rule-id', cnt);
updateCloseButton(fieldWrap);
updateTargetRuleInput(fieldWrap);
}
);
jQuery('.bsf-target-rule-selector-wrapper').on(
'click',
'.target_rule-add-exclusion-rule a',
function (e) {
e.preventDefault();
e.stopPropagation();
updateExclusionButton(true);
}
);
});
})(jQuery);

View File

@@ -0,0 +1,97 @@
/* eslint-env jquery */
( function ( $ ) {
const userRoleUpdateCloseButton = function ( wrapper ) {
const rules = wrapper.find( '.bsf-user-role-condition' );
let showClose = false;
if ( rules.length > 1 ) {
showClose = true;
}
rules.each( function () {
if ( showClose ) {
jQuery( this )
.find( '.user_role-condition-delete' )
.removeClass( 'bsf-hidden' );
} else {
jQuery( this )
.find( '.user_role-condition-delete' )
.addClass( 'bsf-hidden' );
}
} );
};
$( document ).ready( function () {
jQuery( '.bsf-user-role-selector-wrapper' ).each( function () {
userRoleUpdateCloseButton( jQuery( this ) );
} );
jQuery( '.bsf-user-role-selector-wrapper' ).on(
'click',
'.user_role-add-rule-wrap a',
function ( e ) {
e.preventDefault();
e.stopPropagation();
const $this = jQuery( this ),
id = $this.attr( 'data-rule-id' ),
newId = parseInt( id ) + 1,
ruleWrap = $this
.closest( '.bsf-user-role-selector-wrapper' )
.find( '.user_role-builder-wrap' ),
template = wp.template( 'bsf-user-role-condition' ),
fieldWrap = $this.closest( '.bsf-user-role-wrapper' );
ruleWrap.append( template( { id: newId } ) );
$this.attr( 'data-rule-id', newId );
userRoleUpdateCloseButton( fieldWrap );
}
);
jQuery( '.bsf-user-role-selector-wrapper' ).on(
'click',
'.user_role-condition-delete',
function () {
const $this = jQuery( this ),
ruleCondition = $this.closest( '.bsf-user-role-condition' ),
fieldWrap = $this.closest( '.bsf-user-role-wrapper' );
let cnt = 0;
ruleCondition.remove();
fieldWrap
.find( '.bsf-user-role-condition' )
.each( function ( i ) {
const condition = jQuery( this ),
oldRuleId = condition.attr( 'data-rule' ),
selectLocation = condition.find(
'.user_role-condition'
),
locationName = selectLocation.attr( 'name' );
condition.attr( 'data-rule', i );
selectLocation.attr(
'name',
locationName.replace(
'[' + oldRuleId + ']',
'[' + i + ']'
)
);
condition
.removeClass( 'bsf-user-role-' + oldRuleId )
.addClass( 'bsf-user-role-' + i );
cnt = i;
} );
fieldWrap
.find( '.user_role-add-rule-wrap a' )
.attr( 'data-rule-id', cnt );
userRoleUpdateCloseButton( fieldWrap );
}
);
} );
} )( jQuery );

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