This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,193 @@
<?php
/**
* Plugin Name: Easy Post Views Count
* Plugin URI: https://wordpress.org/plugins/easy-post-views-count/
* Description: Easy Post Views Count is easy to use and light weight plugin. it allow you to count of post views
* Version: 1.0.5
* Author: AlphaBPO
* Author URI: http://www.alphabpo.com
* Text Domain: epvc
* Domain Path: languages
*
* License: GPLv2 or later
* Domain Path: languages
*
* @package Easy Post View Count
* @category Core
* @author Alpha BPO
*/
// Create a helper function for easy SDK access.
function epvc_fs() {
global $epvc_fs;
if ( ! isset( $epvc_fs ) ) {
// Include Freemius SDK.
require_once dirname(__FILE__) . '/freemius/start.php';
$epvc_fs = fs_dynamic_init( array(
'id' => '2767',
'slug' => 'easy-post-views-count',
'type' => 'plugin',
'public_key' => 'pk_d540ce3e38853340d7d4e868e96e8',
'is_premium' => false,
'has_addons' => false,
'has_paid_plans' => false,
'menu' => array(
'slug' => 'epvc-settings',
'account' => false,
'contact' => false,
'support' => false,
),
) );
}
return $epvc_fs;
}
// Init Freemius.
epvc_fs();
// Signal that SDK was initiated.
do_action( 'epvc_fs_loaded' );
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* Basic plugin definitions
*
* @package Easy Post Views Count
* @since 1.0.0
*/
if( !defined( 'EPVC_VERSION' ) ) {
define( 'EPVC_VERSION', '1.0.5' ); // plugin version
}
if( !defined( 'EPVC_PLUGIN_DIR' ) ) {
define( 'EPVC_PLUGIN_DIR', dirname( __FILE__ ) ); // plugin dir
}
if( !defined( 'EPVC_ADMIN_DIR' ) ) {
define( 'EPVC_ADMIN_DIR', EPVC_PLUGIN_DIR . '/includes/admin' ); // plugin admin dir
}
if( !defined( 'EPVC_PLUGIN_URL' ) ) {
define( 'EPVC_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); // plugin url
}
/**
* Load Text Domain
*
* Locales found in:
*
*@package Easy Post Views Count
* @since 1.0.3
*/
function epvc_load_plugin_textdomain() {
$locale = apply_filters( 'plugin_locale', get_locale(), 'epvc' );
load_textdomain( 'epvc', WP_LANG_DIR . '/easy-post-view-count/epvc-' . $locale . '.mo' );
load_plugin_textdomain( 'epvc', false, EPVC_PLUGIN_DIR . '/languages' );
}
add_action( 'load_plugins', 'epvc_load_plugin_textdomain' );
/**
* Activation hook
*
* Register plugin activation hook.
*
* @package Easy Post Views Count
* @since 1.0.3
*/
register_activation_hook( __FILE__, 'epvc_plugin_install' );
/**
* Deactivation hook
*
* Register plugin deactivation hook.
*
* @package Easy Post Views Count
* @since 1.0.0
*/
register_deactivation_hook( __FILE__, 'epvc_plugin_uninstall' );
/**
* Plugin Setup Activation hook call back
*
* Initial setup of the plugin setting default options
* and database tables creations.
*
* @package Easy Post Views Count
* @since 1.0.0
*/
function epvc_plugin_install() {
global $wpdb, $epvc_settings;
$epvs_version = get_option( 'epvs_version' );
if( empty($epvs_version) ) {
$epvc_settings = array(
'post_types' => array( 'post' => 'yes' ),
'display_icon' => 'yes',
'display_label' => 'yes',
'label_text' => 'Views',
'position' => 'before_content',
'login_users' => 'no',
'ips' => ''
);
update_option( 'epvc_settings', $epvc_settings );
update_option( 'epvs_version', '1.0.5' );
}
$epvs_version = get_option( 'epvs_version' );
if( $epvs_version == '1.0.5' ) {
// Fetuare update code will be here
}
}
/**
* Plugin Setup (On Deactivation)
*
* Does the drop tables in the database and
* delete plugin options.
*
* @package Easy Post Views Count
* @since 1.0.0
*/
function epvc_plugin_uninstall() {
global $wpdb;
}
/**
* Change Footer text for Reviews
*/
add_filter( 'admin_footer_text', 'epvc_remove_footer_admin' );
function epvc_remove_footer_admin() {
$screen = get_current_screen();
if( $screen->id == "toplevel_page_epvc-settings" ){
echo '<span id="footer-thankyou">';
echo sprintf( __('If you like %1sEasy Post Views Count%2s please leave us a %3s★★★★★%4s rating. A huge thanks in advance!', 'wpens'),
'<strong>', '</strong>',
'<a href="https://wordpress.org/support/plugin/easy-post-views-count/reviews/?rate=5#new-post" target="_blank" class="epvc-rating-link">',
'</a>'
);
echo '</span>';
}
}
/**
* Initialize all global variables
*
* @package Easy Post Views Count
* @since 1.0.0
*/
global $epvc_settings;
$epvc_settings = get_option( 'epvc_settings' );
//Includes public class file
require_once ( EPVC_PLUGIN_DIR . '/includes/class-epvc-public.php');
//Includes plugin functions
require_once ( EPVC_PLUGIN_DIR . '/includes/epvc-misc-functions.php');
//Includes Admin file
require_once ( EPVC_ADMIN_DIR . '/class-epvc-admin.php');

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,282 @@
Freemius WordPress SDK
======================
Welcome to the official repository for the Freemius SDK! Adding the SDK to your WordPress plugin, theme, or add-ons, enables all the benefits that come with using the [Freemius platform](https://freemius.com) such as:
* [Software Licensing](https://freemius.com/wordpress/software-licensing/)
* [Secure Checkout](https://freemius.com/wordpress/checkout/)
* [Subscriptions](https://freemius.com/wordpress/recurring-payments-subscriptions/)
* [Automatic Updates](https://freemius.com/wordpress/automatic-software-updates/)
* [Seamless EU VAT](https://freemius.com/wordpress/collecting-eu-vat-europe/)
* [Cart Abandonment Recovery](https://freemius.com/wordpress/cart-abandonment-recovery/)
* [Affiliate Platform](https://freemius.com/wordpress/affiliate-platform/)
* [Analytics & Usage Tracking](https://freemius.com/wordpress/insights/)
* [User Dashboard](https://freemius.com/wordpress/user-dashboard/)
* [Monetization](https://freemius.com/wordpress/)
* [Analytics](https://freemius.com/wordpress/insights/)
* [More...](https://freemius.com/wordpress/features-comparison/)
Freemius truly empowers developers to create prosperous subscription-based businesses.
If you're new to Freemius then we recommend taking a look at our [Getting Started](https://freemius.com/help/documentation/getting-started/) guide first.
If you're a WordPress plugin or theme developer and are interested in monetizing with Freemius then you can [sign-up for a FREE account](https://dashboard.freemius.com/register/):
https://dashboard.freemius.com/register/
Once you have your account setup and are familiar with how it all works you're ready to begin [integrating Freemius](https://freemius.com/help/documentation/wordpress-sdk/integrating-freemius-sdk/) into your WordPress product
You can see some of the existing WordPress.org plugins & themes that are already utilizing the power of Freemius here:
* https://profiles.wordpress.org/freemius/#content-plugins
* https://includewp.com/freemius/#focus
## Code Documentation
You can find the SDK's documentation here:
https://freemius.com/help/documentation/wordpress-sdk/
## Integrating & Initializing the SDK
As part of the integration process, you'll need to [add the latest version](https://freemius.com/help/documentation/getting-started/#add_the_latest_wordpress_sdk_into_your_product) of the Freemius SDK into your WordPress project.
Then, when you've completed the [SDK integration form](https://freemius.com/help/documentation/getting-started/#fill_out_the_sdk_integration_form) a snippet of code is generated which you'll need to copy and paste into the top of your main plugin's PHP file, right after the plugin's header comment.
Note: For themes, this will be in the root `functions.php` file instead.
A typical SDK snippet will look similar to the following (your particular snippet may differ slightly depending on your integration):
```php
if ( ! function_exists( 'my_prefix_fs' ) ) {
// Create a helper function for easy SDK access.
function my_prefix_fs() {
global $my_prefix_fs;
if ( ! isset( $my_prefix_fs ) ) {
// Include Freemius SDK.
require_once dirname(__FILE__) . '/freemius/start.php';
$my_prefix_fs = fs_dynamic_init( array(
'id' => '1234',
'slug' => 'my-new-plugin',
'premium_slug' => 'my-new-plugin-premium',
'type' => 'plugin',
'public_key' => 'pk_bAEfta69seKymZzmf2xtqq8QXHz9y',
'is_premium' => true,
// If your plugin is a serviceware, set this option to false.
'has_premium_version' => true,
'has_paid_plans' => true,
'is_org_compliant' => true,
'menu' => array(
'slug' => 'my-new-plugin',
'parent' => array(
'slug' => 'options-general.php',
),
),
// Set the SDK to work in a sandbox mode (for development & testing).
// IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
'secret_key' => 'sk_ubb4yN3mzqGR2x8#P7r5&@*xC$utE',
) );
}
return $my_prefix_fs;
}
// Init Freemius.
my_prefix_fs();
// Signal that SDK was initiated.
do_action( 'my_prefix_fs_loaded' );
}
```
## Usage example
You can call anySDK methods by prefixing them with the shortcode function for your particular plugin/theme (specified when completing the SDK integration form in the Developer Dashboard):
```php
<?php my_prefix_fs()->get_upgrade_url(); ?>
```
Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:
```php
<?php
global $my_prefix_fs;
$my_prefix_fs->get_account_url();
?>
```
There are many other SDK methods available that you can use to enhance the functionality of your WordPress product. Some of the more common use-cases are covered in the [Freemius SDK Gists](https://freemius.com/help/documentation/wordpress-sdk/gists/) documentation.
## Adding license based logic examples
Add marketing content to encourage your users to upgrade for your paid version:
```php
<?php
if ( my_prefix_fs()->is_not_paying() ) {
echo '<section><h1>' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '</h1>';
echo '<a href="' . my_prefix_fs()->get_upgrade_url() . '">' .
esc_html__('Upgrade Now!', 'my-plugin-slug') .
'</a>';
echo '</section>';
}
?>
```
Add logic which will only be available in your premium plugin version:
```php
<?php
// This "if" block will be auto removed from the Free version.
if ( my_prefix_fs()->is__premium_only() ) {
// ... premium only logic ...
}
?>
```
To add a function which will only be available in your premium plugin version, simply add __premium_only as the suffix of the function name. Just make sure that all lines that call that method directly or by hooks, are also wrapped in premium only logic:
```php
<?php
class My_Plugin {
function init() {
...
// This "if" block will be auto removed from the free version.
if ( my_prefix_fs()->is__premium_only() ) {
// Init premium version.
$this->admin_init__premium_only();
add_action( 'admin_init', array( &$this, 'admin_init_hook__premium_only' );
}
...
}
// This method will be only included in the premium version.
function admin_init__premium_only() {
...
}
// This method will be only included in the premium version.
function admin_init_hook__premium_only() {
...
}
}
?>
```
Add logic which will only be executed for customers in your 'professional' plan:
```php
<?php
if ( my_prefix_fs()->is_plan('professional', true) ) {
// .. logic related to Professional plan only ...
}
?>
```
Add logic which will only be executed for customers in your 'professional' plan or higher plans:
```php
<?php
if ( my_prefix_fs()->is_plan('professional') ) {
// ... logic related to Professional plan and higher plans ...
}
?>
```
Add logic which will only be available in your premium plugin version AND will only be executed for customers in your 'professional' plan (and higher plans):
```php
<?php
// This "if" block will be auto removed from the Free version.
if ( my_prefix_fs()->is_plan__premium_only('professional') ) {
// ... logic related to Professional plan and higher plans ...
}
?>
```
Add logic only for users in trial:
```php
<?php
if ( my_prefix_fs()->is_trial() ) {
// ... logic for users in trial ...
}
?>
```
Add logic for specified paid plan:
```php
<?php
// This "if" block will be auto removed from the Free version.
if ( my_prefix_fs()->is__premium_only() ) {
if ( my_prefix_fs()->is_plan( 'professional', true ) ) {
// ... logic related to Professional plan only ...
} else if ( my_prefix_fs()->is_plan( 'business' ) ) {
// ... logic related to Business plan and higher plans ...
}
}
?>
```
## Excluding files and folders from the free plugin version
There are [two ways](https://freemius.com/help/documentation/wordpress-sdk/software-licensing/#excluding_files_and_folders_from_the_free_plugin_version) to exclude files from your free version.
1. Add `__premium_only` just before the file extension. For example, functions__premium_only.php will be only included in the premium plugin version. This works for all types of files, not only PHP.
2. Add `@fs_premium_only` a special meta tag to the plugin's main PHP file header. Example:
```php
<?php
/**
* Plugin Name: My Very Awesome Plugin
* Plugin URI: http://my-awesome-plugin.com
* Description: Create and manage Awesomeness right in WordPress.
* Version: 1.0.0
* Author: Awesomattic
* Author URI: http://my-awesome-plugin.com/me/
* License: GPLv2
* Text Domain: myplugin
* Domain Path: /langs
*
* @fs_premium_only /lib/functions.php, /premium-files/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// ... my code ...
?>
```
In the example plugin header above, the file `/lib/functions.php` and the directory `/premium-files/` will be removed from the free plugin version.
# WordPress.org Compliance
Based on [WordPress.org Guidelines](https://wordpress.org/plugins/about/guidelines/) you are not allowed to submit a plugin that has premium code in it:
> All code hosted by WordPress.org servers must be free and fully-functional. If you want to sell advanced features for a plugin (such as a "pro" version), then you must sell and serve that code from your own site, we will not host it on our servers.
Therefore, if you want to deploy your free plugin's version to WordPress.org, make sure you wrap all your premium code with `if ( my_prefix_fs()->{{ method }}__premium_only() )` or use [some of the other methods](https://freemius.com/help/documentation/wordpress-sdk/software-licensing/) provided by the SDK to exclude premium features & files from the free version.
## Deployment
Zip your Freemius products root folder and [upload it in the Deployment section](https://freemius.com/help/documentation/selling-with-freemius/deployment/) in the *Freemius Developer's Dashboard*.
The plugin/theme will automatically be scanned and processed by a custom-developed *PHP Processor* which will auto-generate two versions of your plugin:
1. **Premium version**: Identical to your uploaded version, including all code (except your `secret_key`). Will be enabled for download ONLY for your paying or in trial customers.
2. **Free version**: The code stripped from all your paid features (based on the logic added wrapped in `{ method }__premium_only()`).
The free version is the one that you should give your users to download. Therefore, download the free generated version and upload to your site. Or, if your plugin was WordPress.org compliant and you made sure to exclude all your premium code with the different provided techniques, you can deploy the downloaded free version to the .org repo.
## License
Copyright (c) Freemius®, Inc.
Licensed under the GNU general public license (version 3).

View File

@ -0,0 +1 @@
label.fs-tag,span.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn,span.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-info,span.fs-tag.fs-info{background:#00a0d2}label.fs-tag.fs-success,span.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error,span.fs-tag.fs-error{background:#dc3232}.fs-notice[data-id="license_not_whitelabeled"].success,.fs-notice[data-id="license_whitelabeled"].success{color:inherit;border-left-color:#00a0d2}.fs-notice[data-id="license_not_whitelabeled"].success label.fs-plugin-title,.fs-notice[data-id="license_whitelabeled"].success label.fs-plugin-title{display:none}#fs_account .postbox,#fs_account .widefat{max-width:800px}#fs_account h3{font-size:1.3em;padding:12px 15px;margin:0 0 12px 0;line-height:1.4;border-bottom:1px solid #F1F1F1}#fs_account h3 .dashicons{width:26px;height:26px;font-size:1.3em}#fs_account i.dashicons{font-size:1.2em;height:1.2em;width:1.2em}#fs_account .dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}#fs_account_details .button-group{float:right}.rtl #fs_account .fs-header-actions{left:15px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table code{line-height:28px}.fs-key-value-table var,.fs-key-value-table code,.fs-key-value-table input[type="text"]{color:#0073AA;font-size:16px;background:none}.fs-key-value-table input[type="text"]{width:100%;font-weight:bold}.fs-field-beta_program label{margin-left:7px}label.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error{background:#dc3232}#fs_sites .fs-scrollable-table .fs-table-body{max-height:200px;overflow:auto;border:1px solid #e5e5e5}#fs_sites .fs-scrollable-table .fs-table-body>table.widefat{border:none !important}#fs_sites .fs-scrollable-table .fs-main-column{width:100%}#fs_sites .fs-scrollable-table .fs-site-details td:first-of-type{text-align:right;color:grey;width:1px}#fs_sites .fs-scrollable-table .fs-site-details td:last-of-type{text-align:right}#fs_sites .fs-scrollable-table .fs-install-details table tr td{width:1px;white-space:nowrap}#fs_sites .fs-scrollable-table .fs-install-details table tr td:last-of-type{width:auto}#fs_addons h3{border:none;margin-bottom:0;padding:4px 5px}#fs_addons td{vertical-align:middle}#fs_addons thead{white-space:nowrap}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}#fs_billing_address{width:100%}#fs_billing_address tr td{width:50%;padding:5px}#fs_billing_address tr:first-of-type td{padding-top:0}#fs_billing_address span{font-weight:bold}#fs_billing_address input,#fs_billing_address select{display:block;width:100%;margin-top:5px}#fs_billing_address input::-moz-placeholder,#fs_billing_address select::-moz-placeholder{color:transparent;opacity:1}#fs_billing_address input:-ms-input-placeholder,#fs_billing_address select:-ms-input-placeholder{color:transparent}#fs_billing_address input::-webkit-input-placeholder,#fs_billing_address select::-webkit-input-placeholder{color:transparent}#fs_billing_address input.fs-read-mode,#fs_billing_address select.fs-read-mode{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode td span{display:none}#fs_billing_address.fs-read-mode input,#fs_billing_address.fs-read-mode select{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode input::-moz-placeholder,#fs_billing_address.fs-read-mode select::-moz-placeholder{color:#ccc;opacity:1}#fs_billing_address.fs-read-mode input:-ms-input-placeholder,#fs_billing_address.fs-read-mode select:-ms-input-placeholder{color:#ccc}#fs_billing_address.fs-read-mode input::-webkit-input-placeholder,#fs_billing_address.fs-read-mode select::-webkit-input-placeholder{color:#ccc}#fs_billing_address button{display:block;width:100%}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
@charset "UTF-8";#fs_affiliation_content_wrapper #messages{margin-top:25px}#fs_affiliation_content_wrapper h3{font-size:24px;padding:0;margin-left:0}#fs_affiliation_content_wrapper ul li{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;list-style-type:none}#fs_affiliation_content_wrapper ul li:before{content:'✓';margin-right:10px;font-weight:bold}#fs_affiliation_content_wrapper p:not(.description),#fs_affiliation_content_wrapper li,#fs_affiliation_content_wrapper label{font-size:16px !important;line-height:26px !important}#fs_affiliation_content_wrapper .button{margin-top:20px;margin-bottom:7px;line-height:35px;height:40px;font-size:16px}#fs_affiliation_content_wrapper .button#cancel_button{margin-right:5px}#fs_affiliation_content_wrapper form .input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form .input-container .input-label{font-weight:bold;display:block;width:100%}#fs_affiliation_content_wrapper form .input-container.input-container-text label,#fs_affiliation_content_wrapper form .input-container.input-container-text input,#fs_affiliation_content_wrapper form .input-container.input-container-text textarea{display:block}#fs_affiliation_content_wrapper form .input-container #add_domain,#fs_affiliation_content_wrapper form .input-container .remove-domain{text-decoration:none;display:inline-block;margin-top:3px}#fs_affiliation_content_wrapper form .input-container #add_domain:focus,#fs_affiliation_content_wrapper form .input-container .remove-domain:focus{box-shadow:none}#fs_affiliation_content_wrapper form .input-container #add_domain.disabled,#fs_affiliation_content_wrapper form .input-container .remove-domain.disabled{color:#aaa;cursor:default}#fs_affiliation_content_wrapper form #extra_domains_container .description{margin-top:0;position:relative;top:-4px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain{display:inline-block;margin-right:5px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain:last-of-type{margin-bottom:0}

View File

@ -0,0 +1 @@
@media screen and (max-width: 782px){#wpbody-content{padding-bottom:0 !important}}

View File

@ -0,0 +1,2 @@
.fs-badge{position:absolute;top:10px;right:0;background:#71ae00;color:white;text-transform:uppercase;padding:5px 10px;-moz-border-radius:3px 0 0 3px;-webkit-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;font-weight:bold;border-right:0;-moz-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);box-shadow:0 2px 1px -1px rgba(0,0,0,0.3)}.theme-browser .theme .fs-premium-theme-badge-container{position:absolute;right:0;top:0}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge{position:relative;top:0;margin-top:10px;text-align:center}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-premium-theme-badge{font-size:1.1em}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-beta-theme-badge{background:#00a0d2}.fs-switch{position:relative;display:inline-block;color:#ccc;text-shadow:0 1px 1px rgba(255,255,255,0.8);height:18px;padding:6px 6px 5px 6px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);background:#ececec;box-shadow:0 0 4px rgba(0,0,0,0.1),inset 0 1px 3px 0 rgba(0,0,0,0.1);cursor:pointer}.fs-switch span{display:inline-block;width:35px;text-transform:uppercase}.fs-switch .fs-toggle{position:absolute;top:1px;width:37px;height:25px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.3);border-radius:4px;background:#fff;background-color:#fff;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #ececec), color-stop(1, #fff));background-image:-webkit-linear-gradient(top, #ececec, #fff);background-image:-moz-linear-gradient(top, #ececec, #fff);background-image:-ms-linear-gradient(top, #ececec, #fff);background-image:-o-linear-gradient(top, #ececec, #fff);background-image:linear-gradient(top, bottom, #ececec, #fff);box-shadow:inset 0 1px 0 0 rgba(255,255,255,0.5);z-index:999;-moz-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-o-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-ms-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-webkit-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1)}.fs-switch.fs-off .fs-toggle{left:2%}.fs-switch.fs-on .fs-toggle{left:54%}.fs-switch.fs-round{top:8px;padding:4px 25px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round .fs-toggle{top:0;width:24px;height:24px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round.fs-off .fs-toggle{left:-1px}.fs-switch.fs-round.fs-on{background:#0085ba}.fs-switch.fs-round.fs-on .fs-toggle{left:25px}.fs-switch.fs-small.fs-round{padding:1px 19px}.fs-switch.fs-small.fs-round .fs-toggle{top:0;width:18px;height:18px;-moz-border-radius:18px;-webkit-border-radius:18px;border-radius:18px}.fs-switch.fs-small.fs-round.fs-on .fs-toggle{left:19px}.fs-switch-feedback{margin-left:10px}.fs-switch-feedback.success{color:#71ae00}.rtl .fs-switch-feedback{margin-left:0;margin-right:10px}#fs_frame{line-height:0;font-size:0}.fs-full-size-wrapper{margin:40px 0 -65px -20px}@media (max-width: 600px){.fs-full-size-wrapper{margin:0 0 -65px -10px}}
.fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-notice-body{margin:.5em 0;padding:2px}.fs-notice .fs-close{cursor:pointer;color:#aaa;float:right}.fs-notice .fs-close:hover{color:#666}.fs-notice .fs-close>*{margin-top:7px;display:inline-block}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;top:100%;bottom:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}div.fs-notice.updated,div.fs-notice.success,div.fs-notice.promotion{display:block !important}.rtl .fs-notice .fs-close{float:left}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;-moz-box-shadow:0 2px 2px rgba(6,113,6,0.3);-webkit-box-shadow:0 2px 2px rgba(6,113,6,0.3);box-shadow:0 2px 2px rgba(6,113,6,0.3);opacity:0.95;filter:alpha(opacity=95)}.fs-secure-notice:hover{opacity:1;filter:alpha(opacity=100)}.fs-secure-notice a.fs-security-proof{color:green;text-decoration:none}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@media screen and (max-width: 600px){.fs-secure-notice{display:none}}@media screen and (max-width: 1250px){#fs_promo_tab{display:none}}@media screen and (max-width: 782px){.fs-secure-notice{left:0;top:46px;text-align:center}}span.fs-submenu-item.fs-sub:before{content:'\21B3';padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:'\21B2'}.fs-submenu-item.pricing.upgrade-mode{color:greenyellow}.fs-submenu-item.pricing.trial-mode{color:#83e2ff}#adminmenu .update-plugins.fs-trial{background-color:#00b9eb}.fs-ajax-spinner{border:0;width:20px;height:20px;margin-right:5px;vertical-align:sub;display:inline-block;background:url("/wp-admin/images/wpspin_light-2x.gif");background-size:contain;margin-bottom:-2px}.wrap.fs-section h2{text-align:left}.plugins p.fs-upgrade-notice{border:0;background-color:#d54e21;padding:10px;color:#f9f9f9;margin-top:10px}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
.fs-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,0.6)}.fs-modal .fs-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media (max-width: 650px){.fs-modal .fs-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.fs-modal .fs-modal-dialog .fs-modal-panel>h3>strong{font-size:1.3em}.fs-modal .fs-modal-dialog li.reason{margin-bottom:10px}.fs-modal .fs-modal-dialog li.reason .reason-input,.fs-modal .fs-modal-dialog li.reason .internal-message{margin-left:29px}.fs-modal .fs-modal-dialog li.reason label{display:table}.fs-modal .fs-modal-dialog li.reason label>span{display:table-cell;font-size:1.3em}}.fs-modal.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body h2{font-size:20px}.fs-modal .fs-modal-body>div{margin-top:10px}.fs-modal .fs-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.fs-modal .fs-modal-footer{border-top:#eeeeee solid 1px;text-align:right}.fs-modal .fs-modal-footer>.button{margin:0 7px}.fs-modal .fs-modal-footer>.button:first-child{margin:0}.fs-modal .fs-modal-panel:not(.active){display:none}.fs-modal .reason-input,.fs-modal .internal-message{margin:3px 0 3px 22px}.fs-modal .reason-input input,.fs-modal .reason-input textarea,.fs-modal .internal-message input,.fs-modal .internal-message textarea{width:100%}.fs-modal li.reason.has-internal-message .internal-message{border:1px solid #ccc;padding:7px;display:none}body.has-fs-modal{overflow:hidden}#the-list .deactivate>.fs-slug{display:none}

View File

@ -0,0 +1 @@
.fs-switch-label{font-size:20px;line-height:31px;margin:0 5px}#fs_log_book table{font-family:Consolas,Monaco,monospace;font-size:12px}#fs_log_book table th{color:#ccc}#fs_log_book table tr{background:#232525}#fs_log_book table tr.alternate{background:#2b2b2b}#fs_log_book table tr td.fs-col--logger{color:#5a7435}#fs_log_book table tr td.fs-col--type{color:#ffc861}#fs_log_book table tr td.fs-col--function{color:#a7b7b1;font-weight:bold}#fs_log_book table tr td.fs-col--message,#fs_log_book table tr td.fs-col--message a{color:#9a73ac !important}#fs_log_book table tr td.fs-col--file{color:#d07922}#fs_log_book table tr td.fs-col--timestamp{color:#6596be}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
.fs-notice[data-id^="gdpr_optin_actions"] .underlined{text-decoration:underline}.fs-notice[data-id^="gdpr_optin_actions"] ul .button,.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{vertical-align:middle}.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{display:inline-block;margin-left:3px}

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

View File

@ -0,0 +1 @@
.fs-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,0.6)}.fs-modal .fs-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media (max-width: 650px){.fs-modal .fs-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.fs-modal .fs-modal-dialog .fs-modal-panel>h3>strong{font-size:1.3em}}.fs-modal.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body .license-activation-message{margin:0;display:none}.fs-modal .fs-modal-body input.license_key{width:100%}.fs-modal .fs-modal-body p{font-size:14px}.fs-modal .fs-modal-body h2{font-size:20px}.fs-modal .fs-modal-body>div{margin-top:10px}.fs-modal .fs-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.fs-modal .fs-modal-footer{border-top:#eeeeee solid 1px;text-align:right}.fs-modal .fs-modal-footer>.button{margin:0 7px}.fs-modal .fs-modal-footer>.button:first-child{margin:0}.fs-modal .fs-modal-panel:not(.active){display:none}body.has-fs-modal{overflow:hidden}

View File

@ -0,0 +1 @@
#fs_customizer_upsell .fs-customizer-plan{padding:10px 20px 20px 20px;border-radius:3px;background:#fff}#fs_customizer_upsell .fs-customizer-plan h2{position:relative;margin:0;line-height:2em;text-transform:uppercase}#fs_customizer_upsell .fs-customizer-plan h2 .button-link{top:-2px}#fs_customizer_upsell .fs-feature{position:relative}#fs_customizer_upsell .dashicons-yes{color:#0085ba;font-size:2em;vertical-align:bottom;margin-left:-7px;margin-right:10px}.rtl #fs_customizer_upsell .dashicons-yes{margin-left:10px;margin-right:-7px}#fs_customizer_upsell .dashicons-editor-help{color:#bbb;cursor:help}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{opacity:0;visibility:hidden;-moz-transition:opacity 0.3s ease-in-out;-o-transition:opacity 0.3s ease-in-out;-ms-transition:opacity 0.3s ease-in-out;-webkit-transition:opacity 0.3s ease-in-out;transition:opacity 0.3s ease-in-out;position:absolute;background:#000;color:#fff;font-family:'arial', serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:0;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);line-height:1.3em;font-weight:bold;text-align:left}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{text-align:right}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{content:' ';display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:#000 transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{right:21px;left:auto}#fs_customizer_upsell .dashicons-editor-help:hover .fs-feature-desc{visibility:visible;opacity:1}#fs_customizer_upsell .button-primary{display:block;text-align:center;margin-top:10px}#fs_customizer_support{display:block !important}#fs_customizer_support .button{float:right}#fs_customizer_support .button-group{width:100%;display:block;margin-top:10px}#fs_customizer_support .button-group .button{float:none;width:50%;text-align:center}#customize-theme-controls #accordion-section-freemius_upsell{border-top:1px solid #0085ba !important;border-bottom:1px solid #0085ba !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title{color:#fff;background-color:#0085ba;border-left:4px solid #0085ba;transition:.15s background-color ease-in-out, .15s border-color ease-in-out;outline:none;border-bottom:none !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:hover{background-color:#008ec2;border-left-color:#0073aa}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:after{color:#fff}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title{border-left:none;border-right:4px solid #0085ba}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title:hover{border-right-color:#0073aa}

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

View File

@ -0,0 +1,140 @@
/*!
* jQuery postMessage - v0.5 - 9/11/2009
* http://benalman.com/projects/jquery-postmessage-plugin/
*
* Copyright (c) 2009 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* Non-jQuery fork by Jeff Lee
*
* This fork consists of the following changes:
* 1. Basic code cleanup and restructuring, for legibility.
* 2. The `postMessage` and `receiveMessage` functions can be bound arbitrarily,
* in terms of both function names and object scope. Scope is specified by
* the the "this" context of NoJQueryPostMessageMixin();
* 3. I've removed the check for Opera 9.64, which used `$.browser`. There were
* at least three different GitHub users requesting the removal of this
* "Opera sniff" on the original project's Issues page, so I figured this
* would be a relatively safe change.
* 4. `postMessage` no longer uses `$.param` to serialize messages that are not
* strings. I actually prefer this structure anyway. `receiveMessage` does
* not implement a corresponding deserialization step, and as such it seems
* cleaner and more symmetric to leave both data serialization and
* deserialization to the client.
* 5. The use of `$.isFunction` is replaced by a functionally-identical check.
* 6. The `$:nomunge` YUI option is no longer necessary.
*/
function NoJQueryPostMessageMixin(postBinding, receiveBinding) {
var setMessageCallback, unsetMessageCallback, currentMsgCallback,
intervalId, lastHash, cacheBust = 1;
if (window.postMessage) {
if (window.addEventListener) {
setMessageCallback = function(callback) {
window.addEventListener('message', callback, false);
}
unsetMessageCallback = function(callback) {
window.removeEventListener('message', callback, false);
}
} else {
setMessageCallback = function(callback) {
window.attachEvent('onmessage', callback);
}
unsetMessageCallback = function(callback) {
window.detachEvent('onmessage', callback);
}
}
this[postBinding] = function(message, targetUrl, target) {
if (!targetUrl) {
return;
}
// The browser supports window.postMessage, so call it with a targetOrigin
// set appropriately, based on the targetUrl parameter.
target.postMessage( message, targetUrl.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
}
// Since the browser supports window.postMessage, the callback will be
// bound to the actual event associated with window.postMessage.
this[receiveBinding] = function(callback, sourceOrigin, delay) {
// Unbind an existing callback if it exists.
if (currentMsgCallback) {
unsetMessageCallback(currentMsgCallback);
currentMsgCallback = null;
}
if (!callback) {
return false;
}
// Bind the callback. A reference to the callback is stored for ease of
// unbinding.
currentMsgCallback = setMessageCallback(function(e) {
switch(Object.prototype.toString.call(sourceOrigin)) {
case '[object String]':
if (sourceOrigin !== e.origin) {
return false;
}
break;
case '[object Function]':
if (sourceOrigin(e.origin)) {
return false;
}
break;
}
callback(e);
});
};
} else {
this[postBinding] = function(message, targetUrl, target) {
if (!targetUrl) {
return;
}
// The browser does not support window.postMessage, so set the location
// of the target to targetUrl#message. A bit ugly, but it works! A cache
// bust parameter is added to ensure that repeat messages trigger the
// callback.
target.location = targetUrl.replace( /#.*$/, '' ) + '#' + (+new Date) + (cacheBust++) + '&' + message;
}
// Since the browser sucks, a polling loop will be started, and the
// callback will be called whenever the location.hash changes.
this[receiveBinding] = function(callback, sourceOrigin, delay) {
if (intervalId) {
clearInterval(intervalId);
intervalId = null;
}
if (callback) {
delay = typeof sourceOrigin === 'number'
? sourceOrigin
: typeof delay === 'number'
? delay
: 100;
intervalId = setInterval(function(){
var hash = document.location.hash,
re = /^#?\d+&/;
if ( hash !== lastHash && re.test( hash ) ) {
lastHash = hash;
callback({ data: hash.replace( re, '' ) });
}
}, delay );
}
};
}
return this;
}

View File

@ -0,0 +1,12 @@
/*
* nojquery-postmessage by Jeff Lee
* a non-jQuery fork of:
*
* jQuery postMessage - v0.5 - 9/11/2009
* http://benalman.com/projects/jquery-postmessage-plugin/
*
* Copyright (c) 2009 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
function NoJQueryPostMessageMixin(g,a){var b,h,e,d,f,c=1;if(window.postMessage){if(window.addEventListener){b=function(i){window.addEventListener("message",i,false)};h=function(i){window.removeEventListener("message",i,false)}}else{b=function(i){window.attachEvent("onmessage",i)};h=function(i){window.detachEvent("onmessage",i)}}this[g]=function(i,k,j){if(!k){return}j.postMessage(i,k.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))};this[a]=function(k,j,i){if(e){h(e);e=null}if(!k){return false}e=b(function(l){switch(Object.prototype.toString.call(j)){case"[object String]":if(j!==l.origin){return false}break;case"[object Function]":if(j(l.origin)){return false}break}k(l)})}}else{this[g]=function(i,k,j){if(!k){return}j.location=k.replace(/#.*$/,"")+"#"+(+new Date)+(c++)+"&"+i};this[a]=function(k,j,i){if(d){clearInterval(d);d=null}if(k){i=typeof j==="number"?j:typeof i==="number"?i:100;d=setInterval(function(){var m=document.location.hash,l=/^#?\d+&/;if(m!==f&&l.test(m)){f=m;k({data:m.replace(l,"")})}},i)}}}return this};

View File

@ -0,0 +1,135 @@
(function ($, undef) {
var global = this;
// Namespace.
global.FS = global.FS || {};
global.FS.PostMessage = function ()
{
var
_is_child = false,
_postman = new NoJQueryPostMessageMixin('postMessage', 'receiveMessage'),
_callbacks = {},
_base_url,
_parent_url = decodeURIComponent(document.location.hash.replace(/^#/, '')),
_parent_subdomain = _parent_url.substring(0, _parent_url.indexOf('/', ('https://' === _parent_url.substring(0, ('https://').length)) ? 8 : 7)),
_init = function () {
_postman.receiveMessage(function (e) {
var data = JSON.parse(e.data);
if (_callbacks[data.type]) {
for (var i = 0; i < _callbacks[data.type].length; i++) {
// Execute type callbacks.
_callbacks[data.type][i](data.data);
}
}
}, _base_url);
},
_hasParent = ('' !== _parent_url),
$window = $(window),
$html = $('html');
return {
init : function (url, iframes)
{
_base_url = url;
_init();
// Automatically receive forward messages.
FS.PostMessage.receiveOnce('forward', function (data){
window.location = data.url;
});
iframes = iframes || [];
if (iframes.length > 0) {
$window.on('scroll', function () {
for (var i = 0; i < iframes.length; i++) {
FS.PostMessage.postScroll(iframes[i]);
}
});
}
},
init_child : function ()
{
this.init(_parent_subdomain);
_is_child = true;
// Post height of a child right after window is loaded.
$(window).bind('load', function () {
FS.PostMessage.postHeight();
// Post message that window was loaded.
FS.PostMessage.post('loaded');
});
},
hasParent : function ()
{
return _hasParent;
},
postHeight : function (diff, wrapper) {
diff = diff || 0;
wrapper = wrapper || '#wrap_section';
this.post('height', {
height: diff + $(wrapper).outerHeight(true)
});
},
postScroll : function (iframe) {
this.post('scroll', {
top: $window.scrollTop(),
height: ($window.height() - parseFloat($html.css('paddingTop')) - parseFloat($html.css('marginTop')))
}, iframe);
},
post : function (type, data, iframe)
{
console.debug('PostMessage.post', type);
if (iframe)
{
// Post to iframe.
_postman.postMessage(JSON.stringify({
type: type,
data: data
}), iframe.src, iframe.contentWindow);
}
else {
// Post to parent.
_postman.postMessage(JSON.stringify({
type: type,
data: data
}), _parent_url, window.parent);
}
},
receive: function (type, callback)
{
console.debug('PostMessage.receive', type);
if (undef === _callbacks[type])
_callbacks[type] = [];
_callbacks[type].push(callback);
},
receiveOnce: function (type, callback)
{
if (this.is_set(type))
return;
this.receive(type, callback);
},
// Check if any callbacks assigned to a specified message type.
is_set: function (type)
{
return (undef != _callbacks[type]);
},
parent_url: function ()
{
return _parent_url;
},
parent_subdomain: function ()
{
return _parent_subdomain;
}
};
}();
})(jQuery);

View File

@ -0,0 +1,79 @@
$menu-hover-color: #333;
$darkest-color: #000;
$fms-live-color: #71ae00;
$fms-test-color: #f7941d;
$fms-link-color: #29abe1;
$fms-link-hover-color: darken(#29abe1, 10%);
$body-bkg: #111;
$special-color: #d3135a;
$body-color: #f1f1f1;
$fms-white: #f1f1f1;
$container-bkg: #222;
$container-bkg-odd: #262626;
$container-border-color: #333;
$table-head-bkg: #333;
$table-head-color: #999;
$info-color: #999;
$error-color: #ff0000;
$fs-logo-blue-color: #29abe1;
$fs-logo-green-color: #71ae00;
$fs-logo-magenta-color: #d3135a;
// WordPress colors.
$page-header-bkg: #333;
$page-header-color: $fms-white;
$text-dark-color: #333;
$text-light-color: #666;
$text-lightest-color: #999;
// Notices.
$wp-notice-success-color: #f7fff7;
$wp-notice-success-dark-color: #46b450;
$wp-notice-error-color: #ffeaea;
$wp-notice-error-dark-color: #dc3232;
$wp-notice-warn-color: #fff8e5;
$wp-notice-warn-dark-color: #ffb900;
$fs-notice-promotion-border-color: #00a0d2;
$fs-notice-promotion-bkg: #f2fcff;
// WP Buttons.
$button-primary-bkg: #6bc406;
$button-primary-color: $fms-white;
$button-secondary-bkg: #333;
$button-secondary-color: $fms-white;
$featured-color: #6bc406;
$wp-selected-color: #0074a3;
$wp-button-alert-border-color: #d2593c;
$wp-button-alert-border-top-color: #ec6544;
$wp-button-alert-shadow-color: #d2593c;
$wp-button-alert-focused-shadow1-color: #dd6041;
$wp-button-alert-focused-shadow2-color: #e4a796;
$wp-button-alert-background-color: #f56a48;
$wp-button-alert-hovered-background-color: #fd6d4a;
$wp-button-alert-active-background-color: #dd6041;
$wp-button-alert-disabled-color: #f5b3a1;
$wp-button-alert-disabled-background-color: #e76444;
$wp-button-alert-disabled-border-color: #d85e40;
$wordpress_color: #01749A;
$blogger_color: #ff8100;
$wix_color: #fac102;
$shopify_color: #80d100;
$addthis_color: #fe6d4e;
$tumblr_color: #34506b;
$zepo_color: #00baf2;
$jquery_color: #000919;
$javascript_color: #00baf2;
$squarespace_color: #000;
$blog_color: #ff6600;
$facebook_color: #3b5998;
$twitter_color: #4099ff;
$linkedin_color: #4875b4;
$youtube_color: #ff3333;
$gplus_color: #c63d2d;
// Tooltip
$tooltip-color: #fff;
$tooltip-bkg-color: rgba(0,0,0,0.8);

View File

@ -0,0 +1,4 @@
@import 'mixins';
@import "vars";
@import "functions";
@import "colors";

View File

@ -0,0 +1,270 @@
// ---- CSS3 SASS MIXINS ----
// https://github.com/madr/css3-sass-mixins
//
// Copyright (C) 2011 by Anders Ytterström
//
// 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.
//
// ---- LEGACY IE SUPPORT USING FILTERS ----
// Should IE filters be used or not?
// PROS: gradients, drop shadows etc will be handled by css.
// CONS: will harm the site performance badly,
// especially on sites with heavy rendering and scripting.
$useIEFilters: 0;
// might be 0 or 1. disabled by default.
// ---- /LEGACY IE SUPPORT USING FILTERS ----
@mixin background-size ($value) {
-webkit-background-size: $value;
background-size: $value;
}
@mixin border-image ($path, $offsets, $repeats) {
-moz-border-image: $path $offsets $repeats;
-o-border-image: $path $offsets $repeats;
-webkit-border-image: $path $offsets $repeats;
border-image: $path $offsets $repeats;
}
@mixin border-radius ($values...) {
-moz-border-radius: $values;
-webkit-border-radius: $values;
border-radius: $values;
/*-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;*/
}
@mixin box-shadow ($values...) {
-moz-box-shadow: $values;
-webkit-box-shadow: $values;
box-shadow: $values;
}
//@mixin box-shadow ($x, $y, $offset, $hex, $ie: $useIEFilters, $inset: null, $spread:null) {
// -moz-box-shadow: $x $y $offset $spread $hex $inset;
// -webkit-box-shadow: $x $y $offset $spread $hex $inset;
// box-shadow: $x $y $offset $spread $hex $inset;
//
// @if $ie == 1 {
// $iecolor: '#' + red($hex) + green($hex) + blue($hex);
// filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}');
// -ms-filter: quote(progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}'));
// }
//}
@mixin box-sizing($value) {
-moz-box-sizing: $value;
-webkit-box-sizing: $value;
box-sizing: $value;
}
// requires sass 3.2
@mixin keyframes($name){
@-moz-keyframes #{$name} { @content; }
@-ms-keyframes #{$name} { @content; }
@-o-keyframes #{$name} { @content; }
@-webkit-keyframes #{$name} { @content; }
@keyframes #{$name} { @content; }
}
@mixin linear-gradient($from, $to, $ie: $useIEFilters) {
@if $ie != 1 { background-color: $to; }
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, $from),color-stop(1, $to));
background-image: -webkit-linear-gradient(top, $from, $to);
background-image: -moz-linear-gradient(top, $from, $to);
background-image: -ms-linear-gradient(top, $from, $to);
background-image: -o-linear-gradient(top, $from, $to);
background-image: linear-gradient(top, bottom, $from, $to);
@if $ie == 1 {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}');
}
}
@mixin horizontal-gradient($startColor: #555, $endColor: #333, $ie: $useIEFilters) {
@if $ie != 1 { background-color: $endColor; }
background-color: $endColor;
background-image: -webkit-gradient(linear, 0 0, 100% 0, from($startColor), to($endColor)); // Safari 4+, Chrome 2+
background-image: -webkit-linear-gradient(left, $startColor, $endColor); // Safari 5.1+, Chrome 10+
background-image: -moz-linear-gradient(left, $startColor, $endColor); // FF 3.6+
background-image: -o-linear-gradient(left, $startColor, $endColor); // Opera 11.10
background-image: linear-gradient(to right, $startColor, $endColor); // Standard, IE10
background-repeat: repeat-x;
@if $ie == 1 {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=1);
}
}
@mixin radial-gradient($from, $to, $ie: $useIEFilters) {
@if $ie != 1 { background-color: $to; }
background: -moz-radial-gradient(center, circle cover, $from 0%, $to 100%);
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, $from), color-stop(100%, $to));
background: -webkit-radial-gradient(center, circle cover, $from 0%, $to 100%);
background: -o-radial-gradient(center, circle cover, $from 0%, $to 100%);
background: -ms-radial-gradient(center, circle cover, $from 0%, $to 100%);
background: radial-gradient(center, circle cover, $from 0%, $to 100%);
background-color: $from;
@if $ie == 1 {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}', GradientType=1); /* IE6-9 fallback on horizontal gradient */
}
}
@mixin perspective($perspective) {
-moz-perspective: $perspective;
-ms-perspective: $perspective;
-webkit-perspective: $perspective;
perspective: $perspective;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
@mixin transform ($transforms) {
-moz-transform: $transforms;
-o-transform: $transforms;
-ms-transform: $transforms;
-webkit-transform: $transforms;
transform: $transforms;
}
@mixin matrix ($a, $b, $c, $d, $e, $f) {
-moz-transform: matrix($a, $b, $c, $d, #{$e}px, #{$f}px);
-o-transform: matrix($a, $b, $c, $d, $e, $f);
-ms-transform: matrix($a, $b, $c, $d, $e, $f);
-webkit-transform: matrix($a, $b, $c, $d, $e, $f);
transform: matrix($a, $b, $c, $d, $e, $f);
}
@mixin rotate ($deg) {
@include transform(rotate(#{$deg}deg));
}
@mixin scale ($size) {
@include transform(scale(#{$size}));
}
@mixin translate ($x, $y) {
@include transform(translate($x, $y));
}
@mixin transition ($value...) {
-moz-transition: $value;
-o-transition: $value;
-ms-transition: $value;
-webkit-transition: $value;
transition: $value;
}
@mixin animation($str) {
-webkit-animation: #{$str};
-moz-animation: #{$str};
-ms-animation: #{$str};
-o-animation: #{$str};
animation: #{$str};
}
@mixin animation-name($str) {
-webkit-animation-name: #{$str};
-moz-animation-name: #{$str};
-ms-animation-name: #{$str};
-o-animation-name: #{$str};
animation-name: #{$str};
}
@mixin animation-duration($str) {
-webkit-animation-duration: #{$str};
-moz-animation-duration: #{$str};
-ms-animation-duration: #{$str};
-o-animation-duration: #{$str};
animation-duration: #{$str};
}
@mixin animation-direction($str) {
-webkit-animation-direction: #{$str};
-moz-animation-direction: #{$str};
-ms-animation-direction: #{$str};
-o-animation-direction: #{$str};
animation-direction: #{$str};
}
@mixin animation-delay($str) {
animation-delay:#{$str};
-o-animation-delay:#{$str};
-ms-animation-delay:#{$str};
-webkit-animation-delay:#{$str};
-moz-animation-delay:#{$str};
}
@mixin animation-iteration-count($str) {
animation-iteration-count:#{$str};
-o-animation-iteration-count:#{$str};
-ms-animation-iteration-count:#{$str};
-webkit-animation-iteration-count:#{$str};
-moz-animation-iteration-count:#{$str};
}
@mixin animation-timing-function($str) {
-webkit-animation-timing-function: #{$str};
-moz-animation-timing-function: #{$str};
-ms-animation-timing-function: #{$str};
-o-animation-timing-function: #{$str};
animation-timing-function: #{$str};
}
// ==== /CSS3 SASS MIXINS ====
@mixin opacity($opacity) {
opacity: $opacity;
$opacity-ie: $opacity * 100;
filter: alpha(opacity=$opacity-ie); //IE8
}
@mixin size($width, $height: $width)
{
width: $width;
height: $height;
}
@mixin clearfix
{
&:after {
content: "";
display: table;
clear: both;
}
}
// Placeholder text
@mixin placeholder($color: $input-color-placeholder) {
// Firefox
&::-moz-placeholder {
color: $color;
opacity: 1; // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526
}
&:-ms-input-placeholder { color: $color; } // Internet Explorer 10+
&::-webkit-input-placeholder { color: $color; } // Safari and Chrome
}

View File

@ -0,0 +1,4 @@
@import "vars";
@import "colors";
@import "mixins";
@import "functions";

View File

@ -0,0 +1,6 @@
$is_production: true;
$img_common: if($is_production == true, '//img.freemius.com', 'http://img.freemius:8080');
$layout_width: 960px;
$admin_mobile_max_width: 782px;

View File

@ -0,0 +1,49 @@
$color: $wp-selected-color;
$bkg-color: #fff;
$size: 20;
.fs-ajax-loader
{
position: relative;
width: #{8*$size + 10}px;
height: #{$size}px;
margin: auto;
.fs-ajax-loader-bar
{
position: absolute;
top: 0;
background-color: $color;
width: #{$size}px;
height: #{$size}px;
@include animation-name(bounce_ajaxLoader);
@include animation-duration(1.5s);
@include animation-iteration-count(infinite);
@include animation-direction(normal);
@include transform(.3);
}
@for $i from 0 through 7
{
.fs-ajax-loader-bar-#{$i + 1}
{
left: #{$i*($size - 1)}px;
@include animation-delay(#{0.6 + $i*0.15}s);
}
}
}
@include keyframes(bounce_ajaxLoader)
{
0%
{
@include transform(scale(1));
background-color: $color;
}
100%
{
@include transform(scale(.3));
background-color: $bkg-color;
}
}

View File

@ -0,0 +1,33 @@
.fs-modal-auto-install
{
$max-width: 300px;
#request-filesystem-credentials-form
{
h2,
.request-filesystem-credentials-action-buttons
{
display: none;
}
input[type=password],
input[type=email],
input[type=text]
{
-webkit-appearance: none;
padding: 10px 10px 5px 10px;
width: $max-width;
max-width: 100%;
}
> div,
label,
fieldset
{
width: $max-width;
max-width: 100%;
margin: 0 auto;
display: block;
}
}
}

View File

@ -0,0 +1,28 @@
.button-primary.warn {
box-shadow: 0 1px 0 $wp-button-alert-shadow-color;
text-shadow: 0 -1px 1px $wp-button-alert-shadow-color, 1px 0 1px $wp-button-alert-shadow-color, 0 1px 1px $wp-button-alert-shadow-color, -1px 0 1px $wp-button-alert-shadow-color;
background: $wp-button-alert-background-color;
border-color: $wp-button-alert-border-top-color $wp-button-alert-border-color $wp-button-alert-border-color;
&:hover {
background: $wp-button-alert-hovered-background-color;
border-color: $wp-button-alert-border-color;
}
&:focus {
box-shadow: 0 1px 0 $wp-button-alert-focused-shadow1-color, 0 0 2px 1px $wp-button-alert-focused-shadow2-color;
}
&:active {
background: $wp-button-alert-active-background-color;
border-color: $wp-button-alert-border-color;
box-shadow: inset 0 2px 0 $wp-button-alert-shadow-color;
}
&.disabled {
color: $wp-button-alert-disabled-color !important;
background: $wp-button-alert-disabled-background-color !important;
border-color: $wp-button-alert-disabled-border-color !important;
text-shadow: 0 -1px 0 rgba(0,0,0,.1) !important;
}
}

View File

@ -0,0 +1,55 @@
@import "../colors";
.fs-modal.fs-modal-deactivation-feedback {
.reason-input, .internal-message {
margin: 3px 0 3px 22px;
input, textarea {
width: 100%;
}
}
li.reason {
&.has-internal-message .internal-message {
border: 1px solid lighten($darkest-color, 80%);
padding: 7px;
display: none;
}
@media (max-width: 650px) {
li.reason {
margin-bottom: 10px;
.reason-input, .internal-message {
margin-left: 29px;
}
label {
display: table;
> span {
display: table-cell;
font-size: 1.3em;
}
}
}
}
}
.anonymous-feedback-label {
float: left;
}
.fs-modal-panel {
margin-top: 0 !important;
h3 {
margin-top: 0;
line-height: 1.5em;
}
}
}
#the-list .deactivate > .fs-slug {
display: none;
}

View File

@ -0,0 +1,81 @@
#fs_marketing_optin
{
display: none;
margin-top: 10px;
border: 1px solid #ccc;
padding: 10px;
line-height: 1.5em;
.fs-message
{
display: block;
margin-bottom: 5px;
font-size: 1.05em;
font-weight: 600;
}
&.error
{
border: 1px solid $fs-logo-magenta-color;
background: #fee;
.fs-message
{
color: $fs-logo-magenta-color;
}
}
.fs-input-container
{
margin-top: 5px;
label
{
margin-top: 5px;
display: block;
input
{
float: left;
margin: 1px 0 0 0;
}
&:first-child
{
display: block;
margin-bottom: 2px;
}
}
}
.fs-input-label
{
display: block;
margin-left: 20px;
.underlined
{
text-decoration: underline;
}
}
}
.rtl
{
#fs_marketing_optin
{
.fs-input-container
{
label input
{
float: right;
}
}
.fs-input-label
{
margin-left: 0;
margin-right: 20px;
}
}
}

View File

@ -0,0 +1,47 @@
.fs-modal.fs-modal-license-activation {
.fs-modal-body {
input.license_key {
width: 100%;
}
}
}
#license_options_container {
table {
&, select, #available_license_key {
width: 100%;
}
td:first-child {
width: 1%;
}
#other_license_key_container {
label {
position: relative;
top: 6px;
float: left;
margin-right: 5px;
}
div {
overflow: hidden;
width: auto;
height: 30px;
display: block;
top: 2px;
position: relative;
input {
margin: 0;
}
}
}
}
}
#sites_list_container {
td {
cursor: pointer;
}
}

View File

@ -0,0 +1,68 @@
.fs-modal.fs-modal-license-key-resend
{
.email-address-container
{
overflow: hidden;
padding-right: 2px;
}
&.fs-freemium
{
input.email-address
{
width: 300px;
}
label
{
display: block;
margin-bottom: 10px;
}
}
&.fs-premium
{
input.email-address
{
width: 100%;
}
.button-container
{
float: right;
margin-left: 7px;
@media (max-width: 650px) {
margin-top: 2px;
}
}
}
}
.rtl
{
.fs-modal.fs-modal-license-key-resend
{
.fs-modal-body
{
.input-container > .email-address-container
{
padding-left: 2px;
padding-right: 0;
}
.button-container
{
float: left;
margin-right: 7px;
margin-left: 0;
}
}
}
}
a.show-license-resend-modal
{
margin-top: 4px;
display: inline-block;
}

View File

@ -0,0 +1,194 @@
@import "../colors";
@import "../mixins";
.fs-modal {
position: fixed;
overflow: auto;
height: 100%;
width: 100%;
top: 0;
z-index: 100000;
display: none;
background: rgba(0, 0, 0, 0.6);
.fs-modal-dialog {
background: transparent;
position: absolute;
left: 50%;
margin-left: -298px;
padding-bottom: 30px;
top: -100%;
z-index: 100001;
width: 596px;
@media (max-width: 650px) {
margin-left: -50%;
box-sizing: border-box;
padding-left: 10px;
padding-right: 10px;
width: 100%;
.fs-modal-panel > h3 > strong {
font-size: 1.3em;
}
}
}
&.active {
display: block;
&:before {
display: block;
}
.fs-modal-dialog {
top: 10%;
}
}
&.fs-success {
.fs-modal-header {
border-bottom-color: $wp-notice-success-dark-color;
}
.fs-modal-body {
background-color: $wp-notice-success-color;
}
}
&.fs-warn {
.fs-modal-header {
border-bottom-color: $wp-notice-warn-dark-color;
}
.fs-modal-body {
background-color: $wp-notice-warn-color;
}
}
&.fs-error {
.fs-modal-header {
border-bottom-color: $wp-notice-error-dark-color;
}
.fs-modal-body {
background-color: $wp-notice-error-color;
}
}
.fs-modal-body,
.fs-modal-footer {
border: 0;
background: #fefefe;
padding: 20px;
}
.fs-modal-header {
border-bottom: #eeeeee solid 1px;
background: #fbfbfb;
padding: 15px 20px;
position: relative;
margin-bottom: -10px;
// z-index: 2;
h4 {
margin: 0;
padding: 0;
text-transform: uppercase;
font-size: 1.2em;
font-weight: bold;
color: #cacaca;
text-shadow: 1px 1px 1px #fff;
letter-spacing: 0.6px;
-webkit-font-smoothing: antialiased;
}
.fs-close {
position: absolute;
right: 10px;
top: 12px;
cursor: pointer;
color: #bbb;
@include border-radius(20px);
padding: 3px;
@include transition(all 0.2s ease-in-out);
&:hover {
color: #fff;
background: #aaa;
}
&, &:hover
{
.dashicons
{
text-decoration: none;
}
}
}
}
.fs-modal-body {
border-bottom: 0;
p {
font-size: 14px;
}
h2 {
font-size: 20px;
line-height: 1.5em;
}
> div {
margin-top: 10px;
h2 {
font-weight: bold;
font-size: 20px;
margin-top: 0;
}
}
}
.fs-modal-footer {
border-top: #eeeeee solid 1px;
text-align: right;
> .button {
margin: 0 7px;
&:first-child {
margin: 0;
}
}
}
.fs-modal-panel {
> .notice.inline {
margin: 0;
display: none;
}
&:not(.active) {
display: none;
}
}
}
.rtl
{
.fs-modal {
.fs-modal-header {
.fs-close {
right: auto;
left: 20px;
}
}
}
}
body.has-fs-modal {
overflow: hidden;
}

View File

@ -0,0 +1,40 @@
#multisite_options_container {
margin-top: 10px;
border: 1px solid #ccc;
padding: 5px;
a {
text-decoration: none;
&:focus {
box-shadow: none;
}
&.selected {
font-weight: bold;
}
}
&.apply-on-all-sites {
border: 0 none;
padding: 0;
#all_sites_options {
border-spacing: 0;
td:not(:first-child) {
display: none;
}
}
}
#sites_list_container {
display: none;
overflow: auto;
table td {
border-top: 1px solid #ccc;
padding: 4px 2px;
}
}
}

View File

@ -0,0 +1,8 @@
.plugins p.fs-upgrade-notice
{
border: 0;
background-color: #d54e21;
padding: 10px;
color: #f9f9f9;
margin-top: 10px;
}

View File

@ -0,0 +1,30 @@
.fs-modal.fs-modal-subscription-cancellation {
.fs-price-increase-warning {
color: red;
font-weight: bold;
padding: 0 25px;
margin-bottom: 0;
}
ul.subscription-actions label {
input {
float: left;
top: 5px;
position: relative;
.rtl & {
float: right;
}
}
span {
display: block;
margin-left: 24px;
.rtl & {
margin-left: 0;
margin-right: 24px;
}
}
}
}

View File

@ -0,0 +1,21 @@
.theme-browser
{
.theme
{
.fs-premium-theme-badge
{
position: absolute;
top: 10px;
right: 0;
background: $fs-logo-green-color;
color: #fff;
text-transform: uppercase;
padding: 5px 10px;
@include border-radius(3px 0 0 3px);
font-weight: bold;
border-right: 0;
@include box-shadow(0 2px 1px -1px rgba(0, 0, 0, .3));
font-size: 1.1em;
}
}
}

View File

@ -0,0 +1,66 @@
.fs-tooltip-trigger
{
&:not(a)
{
cursor: help;
}
position: relative;
.fs-tooltip
{
opacity: 0;
visibility: hidden;
@include transition(opacity 0.3s ease-in-out);
position: absolute;
background: $tooltip-bkg-color;
color: $tooltip-color;
font-family: 'arial', serif;
font-size: 12px;
padding: 10px;
z-index: 999999;
bottom: 100%;
margin-bottom: 5px;
left: 0;
right: 0;
@include border-radius(5px);
@include box-shadow(1px 1px 1px rgba(0, 0, 0, 0.2));
line-height: 1.3em;
font-weight: bold;
text-align: left;
.rtl &
{
text-align: right;
}
&::after
{
content: ' ';
display: block;
width: 0;
height: 0;
border-style: solid;
border-width: 5px 5px 0 5px;
border-color: $tooltip-bkg-color transparent transparent transparent;
position: absolute;
top: 100%;
left: 21px;
.rtl &
{
right: 21px;
left: auto;
}
}
}
&:hover
{
.fs-tooltip
{
visibility: visible;
opacity: 1;
}
}
}

View File

@ -0,0 +1,302 @@
@import "../start";
#fs_account
{
.postbox,
.widefat
{
max-width: 700px;
}
h3
{
font-size: 1.3em;
padding: 12px 15px;
margin: 0 0 12px 0;
line-height: 1.4;
border-bottom: 1px solid #F1F1F1;
.dashicons {
width: 26px;
height: 26px;
font-size: 1.3em;
}
}
i.dashicons
{
font-size: 1.2em;
height: 1.2em;
width: 1.2em;
}
.dashicons
{
vertical-align: middle;
}
.fs-header-actions
{
position: absolute;
top: 17px;
right: 15px;
font-size: 0.9em;
ul
{
margin: 0;
}
li
{
form
{
display: inline-block;
}
float: left;
a
{
text-decoration: none;
}
}
}
}
#fs_account_details .button-group {
float: right;
}
.rtl #fs_account .fs-header-actions
{
left: 15px;
right: auto;
}
.fs-key-value-table
{
width: 100%;
form
{
display: inline-block;
}
tr
{
td:first-child
{
nobr
{
font-weight: bold;
}
text-align: right;
form
{
display: block;
}
}
td.fs-right
{
text-align: right;
}
&.fs-odd
{
background: #ebebeb;
}
}
td, th
{
padding: 10px;
}
code {
line-height: 28px;
}
var, code, input[type="text"]
{
color: #0073AA;
font-size: 16px;
background: none;
}
input[type="text"] {
width: 100%;
font-weight: bold;
}
}
label.fs-tag
{
background: #ffba00;
color: #fff;
display: inline-block;
border-radius: 3px;
padding: 5px;
font-size: 11px;
line-height: 11px;
vertical-align: baseline;
&.fs-warn
{
background: #ffba00;
}
&.fs-success
{
background: #46b450;
}
&.fs-error
{
background: #dc3232;
}
}
#fs_sites
{
.fs-scrollable-table
{
.fs-table-body {
max-height: 200px;
overflow: auto;
border: 1px solid #e5e5e5;
& > table.widefat {
border: none !important;
}
}
.fs-main-column {
width: 100%;
}
.fs-site-details
{
td:first-of-type
{
text-align: right;
color: grey;
width: 1px;
}
td:last-of-type
{
text-align: right;
}
}
.fs-install-details table
{
tr td
{
width: 1px;
white-space: nowrap;
&:last-of-type
{
width: auto;
}
}
}
}
}
#fs_addons
{
h3
{
border: none;
margin-bottom: 0;
padding: 4px 5px;
}
td
{
vertical-align: middle;
}
thead {
white-space: nowrap;
}
td:first-child,
th:first-child
{
text-align: left;
font-weight: bold;
}
td:last-child,
th:last-child
{
text-align: right;
}
th
{
font-weight: bold;
}
}
#fs_billing_address {
width: 100%;
tr {
td {
width: 50%;
padding: 5px;
}
&:first-of-type {
td {
padding-top: 0;
}
}
}
@mixin read-mode {
border-color: transparent;
color: #777;
border-bottom: 1px dashed #ccc;
padding-left: 0;
background: none;
}
span {
font-weight: bold;
}
input, select {
@include placeholder(transparent);
display: block;
width: 100%;
margin-top: 5px;
&.fs-read-mode {
@include read-mode();
}
}
&.fs-read-mode {
td span {
display: none;
}
input, select
{
@include read-mode();
@include placeholder(#ccc);
}
}
button {
display: block;
width: 100%;
}
}

View File

@ -0,0 +1,449 @@
@import "../start";
#fs_addons
{
.fs-cards-list
{
list-style: none;
.fs-card
{
float: left;
// height: 185px; // With reviews/ratings
height: 152px;
width: 310px;
padding: 0;
margin: 0 0 30px 30px;
font-size: 14px;
list-style: none;
border: 1px solid #ddd;
cursor: pointer;
position: relative;
.fs-overlay
{
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
z-index: 9;
}
.fs-inner
{
background-color: #fff;
overflow: hidden;
height: 100%;
position: relative;
ul
{
@include transition(all, 0.15s);
left: 0;
right: 0;
top: 0;
position: absolute;
}
li
{
list-style: none;
line-height: 18px;
padding: 0 15px;
width: 100%;
display: block;
@include box-sizing(border-box);
}
.fs-card-banner
{
padding: 0;
margin: 0;
line-height: 0;
display: block;
height: 100px;
background-repeat: repeat-x;
background-size: 100% 100%;
@include transition(all, 0.15s);
}
.fs-title
{
margin: 10px 0 0 0;
height: 18px;
overflow: hidden;
color: #000;
white-space: nowrap;
text-overflow: ellipsis;
font-weight: bold;
}
.fs-offer
{
font-size: 0.9em;
}
.fs-description
{
background-color: #f9f9f9;
padding: 10px 15px 100px 15px;
border-top: 1px solid #eee;
margin: 0 0 10px 0;
color: #777;
}
.fs-tag
{
position: absolute;
top: 10px;
right: 0px;
background: greenyellow;
display: block;
padding: 2px 10px;
@include box-shadow(1px 1px 1px rgba(0,0,0,0.3));
text-transform: uppercase;
font-size: 0.9em;
font-weight: bold;
}
.fs-cta
{
.button
{
position: absolute;
top: 112px;
right: 10px;
}
}
}
@media screen and (min-width: 960px) {
&:hover
{
.fs-overlay
{
border: 2px solid $fms-link-color;
margin-left: -1px;
margin-top: -1px;
}
.fs-inner
{
ul
{
top: -100px;
}
.fs-card-banner
{
// background-position: 50% -100px;
}
.fs-title,
.fs-offer
{
color: $fms-link-color;
}
}
}
}
}
}
}
#TB_window
{
&, iframe
{
width: 772px !important;
}
}
#plugin-information
{
#section-description
{
h2, h3, p, b, i, blockquote, li, ul, ol
{
clear: none;
}
.fs-selling-points
{
padding-bottom: 10px;
border-bottom: 1px solid #ddd;
ul
{
margin: 0;
li
{
padding: 0;
list-style: none outside none;
i.dashicons
{
color: $fs-logo-green-color;
font-size: 3em;
vertical-align: middle;
line-height: 30px;
float: left;
margin: 0 0 0 -15px;
}
h3
{
margin: 1em 30px !important;
}
}
}
}
.fs-screenshots
{
@include clearfix();
ul
{
list-style: none;
margin: 0;
li
{
width: 225px;
height: 225px;
float: left;
margin-bottom: 20px;
@include box-sizing(content-box);
a
{
display: block;
width: 100%;
height: 100%;
border: 1px solid;
@include box-shadow(1px 1px 1px rgba(0, 0, 0, 0.2));
background-size: cover;
}
&.odd
{
margin-right: 20px;
}
}
}
}
}
.plugin-information-pricing
{
$pricing_color: #FFFEEC;
$borders_color: #DDD;
margin: -16px;
// padding: 20px;
border-bottom: 1px solid $borders_color;
.fs-plan
{
h3
{
margin-top: 0;
padding: 20px;
font-size: 16px;
}
.nav-tab-wrapper
{
border-bottom: 1px solid $borders_color;
.nav-tab
{
cursor: pointer;
position: relative;
padding: 0 10px;
font-size: 0.9em;
label
{
text-transform: uppercase;
color: green;
background: greenyellow;
position: absolute;
left: -1px;
right: -1px;
bottom: 100%;
border: 1px solid darkgreen;
padding: 2px;
text-align: center;
font-size: 0.9em;
line-height: 1em;
}
&.nav-tab-active
{
cursor: default;
background: $pricing_color;
border-bottom-color: $pricing_color;
}
}
}
&.fs-single-cycle
{
h3
{
background: $pricing_color;
margin: 0;
padding-bottom: 0;
color: #0073aa;
}
.nav-tab-wrapper,
.fs-billing-frequency
{
display: none;
}
}
.fs-pricing-body
{
background: $pricing_color;
padding: 20px;
}
.button
{
width: 100%;
text-align: center;
font-weight: bold;
text-transform: uppercase;
font-size: 1.1em;
}
label
{
white-space: nowrap;
}
var {
font-style: normal;
}
.fs-billing-frequency,
.fs-annual-discount
{
text-align: center;
display: block;
font-weight: bold;
margin-bottom: 10px;
text-transform: uppercase;
background: #F3F3F3;
padding: 2px;
border: 1px solid #ccc;
}
.fs-annual-discount
{
text-transform: none;
color: green;
background: greenyellow;
}
ul.fs-trial-terms
{
font-size: 0.9em;
i
{
float: left;
margin: 0 0 0 -15px;
}
li
{
margin: 10px 0 0 0;
}
}
}
}
#section-features
{
.fs-features
{
margin: -20px -26px;
}
table
{
width: 100%;
border-spacing: 0;
border-collapse: separate;
thead
{
th
{
padding: 10px 0;
}
.fs-price
{
color: $fs-logo-green-color;
font-weight: normal;
display: block;
text-align: center;
}
}
tbody
{
td
{
border-top: 1px solid #ccc;
padding: 10px 0;
text-align: center;
width: 100px;
color: $fs-logo-green-color;
&:first-child
{
text-align: left;
width: auto;
color: inherit;
padding-left: 26px;
}
}
tr.fs-odd
{
td
{
background: #fefefe;
}
}
}
}
.dashicons-yes
{
width: 30px;
height: 30px;
font-size: 30px;
}
}
}
@media screen and (max-width: 961px) {
#fs_addons
{
.fs-cards-list
{
.fs-card
{
height: 265px;
}
}
}
}

View File

@ -0,0 +1,97 @@
@import "../start";
#fs_affiliation_content_wrapper {
#messages {
margin-top: 25px;
}
h3 {
font-size: 24px;
padding: 0;
margin-left: 0;
}
ul {
li {
@include box-sizing(border-box);
list-style-type: none;
&:before {
content: '';
margin-right: 10px;
font-weight: bold;
}
}
}
p:not(.description), li, label {
font-size: 16px !important;
line-height: 26px !important;
}
.button {
margin-top: 20px;
margin-bottom: 7px;
line-height: 35px;
height: 40px;
font-size: 16px;
&#cancel_button {
margin-right: 5px;
}
}
form {
.input-container {
.input-label {
font-weight: bold;
display: block;
width: 100%;
}
&.input-container-text {
label, input, textarea {
display: block;
}
}
margin-bottom: 15px;
#add_domain, .remove-domain {
text-decoration: none;
display: inline-block;
margin-top: 3px;
&:focus {
box-shadow: none;
}
&.disabled {
color: #aaa;
cursor: default;
}
}
}
#extra_domains_container {
.description {
margin-top: 0;
position: relative;
top: -4px;
}
.extra-domain-input-container {
margin-bottom: 15px;
.domain {
display: inline-block;
margin-right: 5px;
&:last-of-type {
margin-bottom: 0;
}
}
}
}
}
}

View File

@ -0,0 +1,5 @@
@media screen and (max-width: 782px) {
#wpbody-content {
padding-bottom: 0 !important;
}
}

View File

@ -0,0 +1,220 @@
@import "../start";
@import "themes";
#fs_frame
{
line-height: 0;
font-size: 0;
}
.fs-full-size-wrapper
{
margin: 40px 0 -65px -20px;
@media (max-width: 600px) {
margin: 0 0 -65px -10px;
}
}
.fs-notice
{
position: relative;
&.fs-has-title
{
margin-bottom: 30px !important;
}
&.success
{
color: green;
// font-weight: normal;
}
&.promotion
{
border-color: $fs-notice-promotion-border-color !important;
background-color: $fs-notice-promotion-bkg !important;
}
.fs-notice-body
{
margin: .5em 0;
padding: 2px;
}
.fs-close
{
// position: absolute;
// top: 2px;
// bottom: 2px;
// right: 2px;
// min-width: 100px;
// text-align: center;
// padding-right: 2px;
cursor: pointer;
color: #aaa;
float: right;
&:hover
{
color: #666;
// background: #A9A9A9;
}
> *
{
margin-top: 7px;
display: inline-block;
}
}
label.fs-plugin-title
{
background: rgba(0, 0, 0, 0.3);
color: #fff;
padding: 2px 10px;
position: absolute;
top: 100%;
bottom: auto;
right: auto;
@include border-radius(0 0 3px 3px);
left: 10px;
font-size: 12px;
font-weight: bold;
cursor: auto;
}
}
div.fs-notice
{
&.updated,
&.success,
&.promotion
{
display: block !important;
}
}
.rtl .fs-notice
{
.fs-close
{
// left: 2px;
// right: auto;
// padding-right: 0;
// padding-left: 2px;
float: left;
}
}
.fs-secure-notice
{
position: fixed;
top: 32px;
left: 160px;
right: 0;
background: rgb(235, 253, 235);
padding: 10px 20px;
color: green;
z-index: 9999;
@include box-shadow(0 2px 2px rgba(6, 113, 6, 0.3));
@include opacity(0.95);
&:hover
{
@include opacity(1);
}
a.fs-security-proof
{
color: green;
text-decoration: none;
}
}
@media screen and (max-width: 960px) {
.fs-secure-notice
{
left: 36px;
}
}
@media screen and (max-width: 600px) {
.fs-secure-notice
{
display: none;
}
}
@media screen and (max-width: 500px) {
#fs_promo_tab
{
display: none;
}
}
@media screen and (max-width: 782px) {
.fs-secure-notice
{
left: 0;
top: 46px;
text-align: center;
}
}
span.fs-submenu-item.fs-sub:before
{
// Add small arrow.
content: '\21B3';
padding: 0 5px;
}
.rtl
{
span.fs-submenu-item.fs-sub:before
{
// Add small RTL arrow.
content: '\21B2';
}
}
.fs-submenu-item
{
&.pricing
{
&.upgrade-mode
{
color: greenyellow;
}
&.trial-mode
{
color: #83e2ff;
}
}
}
#adminmenu .update-plugins.fs-trial
{
background-color: #00b9eb;
}
.fs-ajax-spinner
{
border: 0;
width: 20px;
height: 20px;
margin-right: 5px;
vertical-align: sub;
display: inline-block;
background: url('/wp-admin/images/wpspin_light-2x.gif');
background-size: contain;
}
.wrap.fs-section {
h2 {
text-align: left;
}
}
@import "plugin-upgrade-notice";

View File

@ -0,0 +1,548 @@
@import "../start";
$form_width: 480px;
#fs_connect
{
width: $form_width;
@include box-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));
margin: 20px 0;
@media screen and (max-width: ($form_width - 1)) {
@include box-shadow(none);
width: auto;
margin: 0 0 0 -10px;
}
.fs-content
{
background: #fff;
padding: 15px 20px;
.fs-error {
background: snow;
color: $fs-logo-magenta-color;
border: 1px solid $fs-logo-magenta-color;
@include box-shadow(0 1px 1px 0 rgba(0,0,0,.1));
text-align: center;
padding: 5px;
margin-bottom: 10px;
}
p
{
margin: 0;
padding: 0;
font-size: 1.2em;
}
}
.fs-license-key-container {
position: relative;
width: 280px;
margin: 10px auto 0 auto;
input {
width: 100%;
}
.dashicons {
position: absolute;
top: 5px;
right: 5px;
}
}
&.require-license-key {
#sites_list_container {
td {
cursor: pointer;
}
}
}
#delegate_to_site_admins {
margin-right: 15px;
float: right;
height: 26px;
vertical-align: middle;
line-height: 37px;
font-weight: bold;
border-bottom: 1px dashed;
text-decoration: none;
&.rtl {
margin-left: 15px;
margin-right: 0;
}
}
.fs-actions
{
padding: 10px 20px;
background: #C0C7CA;
.button
{
padding: 0 10px 1px;
line-height: 35px;
height: 37px;
font-size: 16px;
margin-bottom: 0;
.dashicons
{
font-size: 37px;
margin-left: -8px;
margin-right: 12px;
}
&.button-primary
{
padding-right: 15px;
padding-left: 15px;
&:after
{
content: ' \279C';
}
&.fs-loading
{
&:after
{
content: '';
}
}
}
&.button-secondary
{
float: right;
}
}
// .fs-skip
// {
// line-height: 38px;
// vertical-align: middle;
// text-decoration: none;
// margin-left: 10px;
// }
}
&.fs-anonymous-disabled
{
.fs-actions
{
.button.button-primary
{
width: 100%;
}
}
}
.fs-permissions
{
padding: 10px 20px;
background: #FEFEFE;
// background: #F1F1F1;
@include transition(background 0.5s ease);
.fs-license-sync-disclaimer {
text-align: center;
margin-top: 0;
}
.fs-trigger
{
font-size: 0.9em;
text-decoration: none;
text-align: center;
display: block;
}
ul
{
height: 0;
overflow: hidden;
margin: 0;
li
{
margin-bottom: 12px;
&:last-child
{
margin-bottom: 0;
}
i.dashicons
{
float: left;
font-size: 40px;
width: 40px;
height: 40px;
}
div
{
margin-left: 55px;
span
{
font-weight: bold;
text-transform: uppercase;
color: #23282d;
}
p
{
margin: 2px 0 0 0;
}
}
}
}
&.fs-open
{
background: #fff;
ul
{
height: auto;
margin: 20px 20px 10px 20px;
}
}
@media screen and (max-width: ($form_width - 1)) {
background: #fff;
.fs-trigger
{
display: none;
}
ul
{
height: auto;
margin: 20px;
}
}
}
.fs-freemium-licensing {
padding: 8px;
// background: #0085BA;
background: #777;
color: #fff;
p {
text-align: center;
display: block;
margin: 0;
padding: 0;
}
a {
color: #C2EEFF;
text-decoration: underline;
}
}
$icon_size: 80px;
$wp_logo_padding: $icon_size / 10;
$icons_top: 10px;
.fs-visual
{
padding: 12px;
line-height: 0;
background: #fafafa;
height: $icon_size;
position: relative;
.fs-site-icon
{
position: absolute;
left: 20px;
top: $icons_top;
}
.fs-connect-logo
{
position: absolute;
right: 20px;
top: $icons_top;
}
.fs-plugin-icon
{
position: absolute;
top: $icons_top;
left: 50%;
margin-left: - ($icon_size / 2);
}
.fs-plugin-icon,
.fs-site-icon,
img,
object
{
width: $icon_size;
height: $icon_size;
}
.dashicons-wordpress
{
font-size: $icon_size - ($wp_logo_padding * 2);
background: $wordpress_color;
color: #fff;
width: $icon_size - ($wp_logo_padding * 2);
height: $icon_size - ($wp_logo_padding * 2);
padding: $wp_logo_padding;
}
.dashicons-plus
{
position: absolute;
top: 50%;
font-size: 30px;
margin-top: -10px;
color: #bbb;
&.fs-first
{
left: 28%;
}
&.fs-second
{
left: 65%;
}
}
.fs-plugin-icon,
.fs-connect-logo,
.fs-site-icon
{
border: 1px solid #ccc;
padding: 1px;
background: #fff;
}
}
.fs-terms
{
text-align: center;
font-size: 0.85em;
padding: 5px;
background: rgba(0, 0, 0, 0.05);
&, a
{
color: #999;
}
a
{
text-decoration: none;
}
}
}
@import "multisite-options";
@import "tooltip";
@import "gdpr-consent";
.rtl
{
#fs_connect
{
.fs-actions
{
padding: 10px 20px;
background: #C0C7CA;
.button
{
.dashicons
{
font-size: 37px;
margin-left: -8px;
margin-right: 12px;
}
&.button-primary
{
&:after
{
content: ' \000bb';
}
&.fs-loading
{
&:after
{
content: '';
}
}
}
&.button-secondary
{
float: left;
}
}
}
.fs-permissions
{
ul
{
li
{
div
{
margin-right: 55px;
margin-left: 0;
}
i.dashicons
{
float: right;
}
}
}
}
.fs-visual
{
.fs-site-icon
{
right: 20px;
left: auto;
}
.fs-connect-logo
{
right: auto;
left: 20px;
}
}
}
}
#fs_theme_connect_wrapper {
position: fixed;
top: 0;
height: 100%;
width: 100%;
z-index: 99990;
background: rgba(0, 0, 0, 0.75);
text-align: center;
overflow-y: auto;
&:before {
content: "";
display: inline-block;
vertical-align: middle;
height: 100%;
}
> button.close {
color: white;
cursor: pointer;
height: 40px;
width: 40px;
position: absolute;
right: 0;
border: 0;
background-color: transparent;
top: 32px;
}
#fs_connect {
top: 0;
text-align: left;
display: inline-block;
vertical-align: middle;
margin-top: 52px;
margin-bottom: 20px;
.fs-terms
{
background: rgba(140, 140, 140, 0.64);
&, a
{
color: #c5c5c5;
}
}
}
}
.wp-pointer-content
{
#fs_connect
{
margin: 0;
@include box-shadow(none);
}
}
.fs-opt-in-pointer
{
.wp-pointer-content
{
padding: 0;
}
&.wp-pointer-top
{
.wp-pointer-arrow
{
border-bottom-color: #dfdfdf;
}
.wp-pointer-arrow-inner
{
border-bottom-color: #fafafa;
}
}
&.wp-pointer-bottom
{
.wp-pointer-arrow
{
border-top-color: #dfdfdf;
}
.wp-pointer-arrow-inner
{
border-top-color: #fafafa;
}
}
&.wp-pointer-left
{
.wp-pointer-arrow
{
border-right-color: #dfdfdf;
}
.wp-pointer-arrow-inner
{
border-right-color: #fafafa;
}
}
&.wp-pointer-right
{
.wp-pointer-arrow
{
border-left-color: #dfdfdf;
}
.wp-pointer-arrow-inner
{
border-left-color: #fafafa;
}
}
}

View File

@ -0,0 +1,135 @@
@import "../start";
.switch
{
position: relative;
display: inline-block;
font-size: 1.6em;
font-weight: bold;
color: #ccc;
text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.8);
height: 18px;
padding: 6px 6px 5px 6px;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 4px;
background: #ececec;
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.1), inset 0px 1px 3px 0px rgba(0, 0, 0, 0.1);
cursor: pointer;
span
{
display: inline-block; width: 35px;
text-transform: uppercase;
&.on
{
color: $button-primary-bkg;
}
}
.toggle
{
position: absolute;
top: 1px;
width: 37px;
height: 25px;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.3);
border-radius: 4px;
background: #fff;
background: -moz-linear-gradient(top, #ececec 0%, #fff 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ececec), color-stop(100%, #fff));
background: -webkit-linear-gradient(top, #ececec 0%, #fff 100%);
background: -o-linear-gradient(top, #ececec 0%, #fff 100%);
background: -ms-linear-gradient(top, #ececec 0%, #fff 100%);
background: linear-gradient(top, #ececec 0%, #fff 100%);
box-shadow: inset 0px 1px 0px 0px rgba(255, 255, 255, 0.5);
z-index: 999;
@include transition(all 0.15s ease-in-out);
}
&.on .toggle
{
left: 2%;
}
&.off .toggle
{
left: 54%;
}
/* Round switch */
&.round
{
padding: 0px 20px;
border-radius: 40px;
.toggle
{
border-radius: 40px;
width: 14px;
height: 14px;
}
&.on .toggle
{
left: 3%;
background: $button-primary-bkg;
}
&.off .toggle
{
left: 58%;
}
}
}
.switch-label
{
font-size: 20px;
line-height: 31px;
margin: 0 5px;
}
#fs_log_book {
table {
font-family: Consolas,Monaco,monospace;
font-size: 12px;
th {
color: #ccc;
}
tr {
background: #232525;
&.alternate {
background: #2b2b2b;
}
td {
&.fs-col--logger {
color: #5a7435;
}
&.fs-col--type {
color: #ffc861;
}
&.fs-col--function {
color: #a7b7b1;
font-weight: bold;
}
&.fs-col--message {
&, a
{
color: #9a73ac !important;
}
}
&.fs-col--file {
color: #d07922;
}
&.fs-col--timestamp {
color: #6596be;
}
}
}
}
}

View File

@ -0,0 +1,10 @@
@import "../start";
@import "modal-common";
@import "deactivation-feedback";
@import "subscription-cancellation";
@import "license-activation";
@import "multisite-options";
@import "license-key-resend";
@import "ajax-loader";
@import "auto-install";
@import "buttons";

View File

@ -0,0 +1,17 @@
.fs-notice[data-id^="gdpr_optin_actions"]
{
.underlined {
text-decoration: underline;
}
ul {
.button, .action-description {
vertical-align: middle;
}
.action-description {
display: inline-block;
margin-left: 3px;
}
}
}

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

View File

@ -0,0 +1,125 @@
@import "start";
#fs_customizer_upsell {
.fs-customizer-plan {
padding: 10px 20px 20px 20px;
border-radius: 3px;
background: #fff;
h2 {
position: relative;
margin: 0;
line-height: 2em;
text-transform: uppercase;
.button-link {
top: -2px;
}
}
}
.fs-feature {
position: relative;
}
.dashicons-yes {
color: #0085ba;
font-size: 2em;
vertical-align: bottom;
margin-left: -7px;
margin-right: 10px;
.rtl & {
margin-left: 10px;
margin-right: -7px;
}
}
.dashicons-editor-help
{
color: #bbb;
cursor: help;
$tooltip-color: #000;
.fs-feature-desc {
opacity: 0;
visibility: hidden;
@include transition(opacity 0.3s ease-in-out);
position: absolute;
background: $tooltip-color;
color: #fff;
font-family: 'arial', serif;
font-size: 12px;
padding: 10px;
z-index: 999999;
bottom: 100%;
margin-bottom: 5px;
left: 0;
right: 0;
@include border-radius(5px);
@include box-shadow(1px 1px 1px rgba(0,0,0,0.2));
line-height: 1.3em;
font-weight: bold;
text-align: left;
.rtl &
{
text-align: right;
}
&::after {
content: ' ';
display: block;
width: 0;
height: 0;
border-style: solid;
border-width: 5px 5px 0 5px;
border-color: $tooltip-color transparent transparent transparent;
position: absolute;
top: 100%;
left: 21px;
.rtl & {
right: 21px;
left: auto;
}
}
}
&:hover {
.fs-feature-desc {
visibility: visible;
opacity: 1;
}
}
}
.button-primary {
display: block;
text-align: center;
margin-top: 10px;
}
}
#fs_customizer_support
{
display: block !important;
.button {
float: right;
}
.button-group {
width: 100%;
display: block;
margin-top: 10px;
.button {
float: none;
width: 50%;
text-align: center;
}
}
}

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

View File

@ -0,0 +1,391 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! defined( 'WP_FS__SLUG' ) ) {
define( 'WP_FS__SLUG', 'freemius' );
}
if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
define( 'WP_FS__DEV_MODE', false );
}
#--------------------------------------------------------------------------------
#region API Connectivity Issues Simulation
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) {
define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false );
}
if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) {
define( 'WP_FS__SIMULATE_NO_CURL', false );
}
if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
}
if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
}
if ( WP_FS__SIMULATE_NO_CURL ) {
define( 'FS_SDK__SIMULATE_NO_CURL', true );
}
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
}
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
}
#endregion
if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) {
define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false );
}
if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) {
/**
* @since 1.1.7.3
* @author Vova Feldman (@svovaf)
*
* I'm not sure if shared servers periodically change IP, or the subdomain of the
* admin dashboard. Also, I've seen sites that have strange loop of switching
* between domains on a daily basis. Therefore, to eliminate the risk of
* multiple unwanted connectivity test pings, temporary ignore domain or
* server IP changes.
*/
define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false );
}
/**
* If your dev environment supports custom public network IP setup
* like VVV, please update WP_FS__LOCALHOST_IP with your public IP
* and uncomment it during dev.
*/
if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
// VVV default public network IP.
define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
// define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
}
/**
* If true and running with secret key, the opt-in process
* will skip the email activation process which is invoked
* when the email of the context user already exist in Freemius
* database (as a security precaution, to prevent sharing user
* secret with unauthorized entity).
*
* IMPORTANT:
* AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
* THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
* CLOCK IS SYNCED.
*/
if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) {
define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
}
#--------------------------------------------------------------------------------
#region Directories
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__DIR' ) ) {
define( 'WP_FS__DIR', dirname( __FILE__ ) );
}
if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) {
define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
}
if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) {
define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
}
if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) {
define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
}
if ( ! defined( 'WP_FS__DIR_CSS' ) ) {
define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
}
if ( ! defined( 'WP_FS__DIR_JS' ) ) {
define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
}
if ( ! defined( 'WP_FS__DIR_IMG' ) ) {
define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
}
if ( ! defined( 'WP_FS__DIR_SDK' ) ) {
define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
}
#endregion
/**
* Domain / URL / Address
*/
define( 'WP_FS__ROOT_DOMAIN_PRODUCTION', 'freemius.com' );
define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) {
define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
}
if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) {
define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
}
if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) {
define( 'WP_FS__TESTING_DOMAIN', 'fswp' );
}
#--------------------------------------------------------------------------------
#region HTTP
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) {
define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) );
}
if ( ! defined( 'WP_FS__IS_HTTPS' ) ) {
define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST &&
// Checks if CloudFlare's HTTPS (Flexible SSL support).
isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
) ||
// Check if HTTPS request.
( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
);
}
if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) {
define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST &&
strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
}
if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) {
define( 'WP_FS__REMOTE_ADDR', fs_get_ip() );
}
if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) {
if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) );
} else {
define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST &&
is_string( WP_FS__REMOTE_ADDR ) &&
( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' ||
WP_FS__REMOTE_ADDR === '::1' )
);
}
}
if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) {
define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST ||
false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
}
#endregion
if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) {
// By default, run with Freemius production servers.
define( 'WP_FS__IS_PRODUCTION_MODE', true );
}
if ( ! defined( 'WP_FS__ADDRESS' ) ) {
define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
}
#--------------------------------------------------------------------------------
#region API
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) {
define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius-local.com:8080' );
}
if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) {
define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' );
}
// Set API address for local testing.
if ( ! WP_FS__IS_PRODUCTION_MODE ) {
if ( ! defined( 'FS_API__ADDRESS' ) ) {
define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST );
}
if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST );
}
}
#endregion
#--------------------------------------------------------------------------------
#region Checkout
#--------------------------------------------------------------------------------
if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) {
define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' );
}
if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) {
define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius-local.com:8080' );
}
if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) {
define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) );
}
#endregion
define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
}
if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
}
if ( ! defined( 'WP_FS__GDPR_OPTION_NAME' ) ) {
define( 'WP_FS__GDPR_OPTION_NAME', WP_FS___OPTION_PREFIX . 'gdpr' );
}
define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
/**
* Module types
*
* @since 1.2.2
*/
define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' );
define( 'WP_FS__MODULE_TYPE_THEME', 'theme' );
/**
* Billing Frequencies
*/
define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
/**
* Plans
*/
define( 'WP_FS__PLAN_DEFAULT_PAID', false );
define( 'WP_FS__PLAN_FREE', 'free' );
define( 'WP_FS__PLAN_TRIAL', 'trial' );
/**
* Times in seconds
*/
if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) {
define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
}
if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) {
define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
}
// define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
if ( ! defined( 'WP_FS__TIME_12_HOURS_IN_SEC' ) ) {
define( 'WP_FS__TIME_12_HOURS_IN_SEC', 43200 );
}
if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) {
define( 'WP_FS__TIME_24_HOURS_IN_SEC', WP_FS__TIME_12_HOURS_IN_SEC * 2 );
}
if ( ! defined( 'WP_FS__TIME_WEEK_IN_SEC' ) ) {
define( 'WP_FS__TIME_WEEK_IN_SEC', 7 * WP_FS__TIME_24_HOURS_IN_SEC );
}
#--------------------------------------------------------------------------------
#region Debugging
#--------------------------------------------------------------------------------
if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) {
$debug_mode = get_option( 'fs_debug_mode', null );
if ( $debug_mode === null ) {
$debug_mode = false;
add_option( 'fs_debug_mode', $debug_mode );
}
define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE );
}
if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) {
define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) );
}
if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) {
define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' );
}
if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK );
}
if ( WP_FS__ECHO_DEBUG_SDK ) {
error_reporting( E_ALL );
}
#endregion
if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) {
define( 'WP_FS__SCRIPT_START_TIME', time() );
}
if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) {
define( 'WP_FS__DEFAULT_PRIORITY', 10 );
}
if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) {
define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
}
#--------------------------------------------------------------------------------
#region Multisite Network
#--------------------------------------------------------------------------------
/**
* Do not use this define directly, it will have the wrong value
* during plugin uninstall/deletion when the inclusion of the plugin
* is triggered due to registration with register_uninstall_hook().
*
* Instead, use fs_is_network_admin().
*
* @author Vova Feldman (@svovaf)
*/
if ( ! defined( 'WP_FS__IS_NETWORK_ADMIN' ) ) {
define( 'WP_FS__IS_NETWORK_ADMIN',
is_multisite() &&
( is_network_admin() ||
( ( defined( 'DOING_AJAX' ) && DOING_AJAX &&
( isset( $_REQUEST['_fs_network_admin'] ) /*||
( ! empty( $_REQUEST['action'] ) && 'delete-plugin' === $_REQUEST['action'] )*/ )
) ||
// Plugin uninstall.
defined( 'WP_UNINSTALL_PLUGIN' ) )
)
);
}
/**
* Do not use this define directly, it will have the wrong value
* during plugin uninstall/deletion when the inclusion of the plugin
* is triggered due to registration with register_uninstall_hook().
*
* Instead, use fs_is_blog_admin().
*
* @author Vova Feldman (@svovaf)
*/
if ( ! defined( 'WP_FS__IS_BLOG_ADMIN' ) ) {
define( 'WP_FS__IS_BLOG_ADMIN', is_blog_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['_fs_blog_admin'] ) ) );
}
if ( ! defined( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED' ) ) {
// Set to true to show network level settings even if delegated to site admins.
define( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED', false );
}
#endregion
if ( ! defined( 'WP_FS__DEMO_MODE' ) ) {
define( 'WP_FS__DEMO_MODE', false );
}
if ( ! defined( 'FS_SDK__SSLVERIFY' ) ) {
define( 'FS_SDK__SSLVERIFY', false );
}

View File

@ -0,0 +1,597 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.7
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* - Each instance of Freemius class represents a single plugin
* install by a single user (the installer of the plugin).
*
* - Each website can only have one install of the same plugin.
*
* - Install entity is only created after a user connects his account with Freemius.
*
* Class Freemius_Abstract
*/
abstract class Freemius_Abstract {
#----------------------------------------------------------------------------------
#region Identity
#----------------------------------------------------------------------------------
/**
* Check if user has connected his account (opted-in).
*
* Note:
* If the user opted-in and opted-out on a later stage,
* this will still return true. If you want to check if the
* user is currently opted-in, use:
* `$fs->is_registered() && $fs->is_tracking_allowed()`
*
* @since 1.0.1
* @return bool
*/
abstract function is_registered();
/**
* Check if the user skipped connecting the account with Freemius.
*
* @since 1.0.7
*
* @return bool
*/
abstract function is_anonymous();
/**
* Check if the user currently in activation mode.
*
* @since 1.0.7
*
* @return bool
*/
abstract function is_activation_mode();
#endregion
#----------------------------------------------------------------------------------
#region Usage Tracking
#----------------------------------------------------------------------------------
/**
* Returns TRUE if the user opted-in and didn't disconnect (opt-out).
*
* @author Leo Fajardo (@leorw)
* @since 1.2.1.5
*
* @return bool
*/
abstract function is_tracking_allowed();
/**
* Returns TRUE if the user never opted-in or manually opted-out.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @return bool
*/
function is_tracking_prohibited() {
return ! $this->is_registered() || ! $this->is_tracking_allowed();
}
/**
* Opt-out from usage tracking.
*
* Note: This will not delete the account information but will stop all tracking.
*
* Returns:
* 1. FALSE - If the user never opted-in.
* 2. TRUE - If successfully opted-out.
* 3. object - API Result on failure.
*
* @author Leo Fajardo (@leorw)
* @since 1.2.1.5
*
* @return bool|object
*/
abstract function stop_tracking();
/**
* Opt-in back into usage tracking.
*
* Note: This will only work if the user opted-in previously.
*
* Returns:
* 1. FALSE - If the user never opted-in.
* 2. TRUE - If successfully opted-in back to usage tracking.
* 3. object - API result on failure.
*
* @author Leo Fajardo (@leorw)
* @since 1.2.1.5
*
* @return bool|object
*/
abstract function allow_tracking();
#endregion
#----------------------------------------------------------------------------------
#region Module Type
#----------------------------------------------------------------------------------
/**
* Checks if the plugin's type is "plugin". The other type is "theme".
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*
* @return bool
*/
abstract function is_plugin();
/**
* Checks if the module type is "theme". The other type is "plugin".
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*
* @return bool
*/
function is_theme() {
return ( ! $this->is_plugin() );
}
#endregion
#----------------------------------------------------------------------------------
#region Permissions
#----------------------------------------------------------------------------------
/**
* Check if plugin must be WordPress.org compliant.
*
* @since 1.0.7
*
* @return bool
*/
abstract function is_org_repo_compliant();
/**
* Check if plugin is allowed to install executable files.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.5
*
* @return bool
*/
function is_allowed_to_install() {
return ( $this->is_premium() || ! $this->is_org_repo_compliant() );
}
#endregion
/**
* Check if user in trial or in free plan (not paying).
*
* @author Vova Feldman (@svovaf)
* @since 1.0.4
*
* @return bool
*/
function is_not_paying() {
return ( $this->is_trial() || $this->is_free_plan() );
}
/**
* Check if the user has an activated and valid paid license on current plugin's install.
*
* @since 1.0.9
*
* @return bool
*/
abstract function is_paying();
/**
* Check if the user is paying or in trial.
*
* @since 1.0.9
*
* @return bool
*/
function is_paying_or_trial() {
return ( $this->is_paying() || $this->is_trial() );
}
/**
* Check if user in a trial or have feature enabled license.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.7
*
* @return bool
*/
abstract function can_use_premium_code();
#----------------------------------------------------------------------------------
#region Premium Only
#----------------------------------------------------------------------------------
/**
* All logic wrapped in methods with "__premium_only()" suffix will be only
* included in the premium code.
*
* Example:
* if ( freemius()->is__premium_only() ) {
* ...
* }
*/
/**
* Returns true when running premium plugin code.
*
* @since 1.0.9
*
* @return bool
*/
function is__premium_only() {
return $this->is_premium();
}
/**
* Check if the user has an activated and valid paid license on current plugin's install.
*
* @since 1.0.9
*
* @return bool
*
*/
function is_paying__premium_only() {
return ( $this->is__premium_only() && $this->is_paying() );
}
/**
* All code wrapped in this statement will be only included in the premium code.
*
* @since 1.0.9
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
function is_plan__premium_only( $plan, $exact = false ) {
return ( $this->is_premium() && $this->is_plan( $plan, $exact ) );
}
/**
* Check if plan matches active license' plan or active trial license' plan.
*
* All code wrapped in this statement will be only included in the premium code.
*
* @since 1.0.9
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
function is_plan_or_trial__premium_only( $plan, $exact = false ) {
return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) );
}
/**
* Check if the user is paying or in trial.
*
* All code wrapped in this statement will be only included in the premium code.
*
* @since 1.0.9
*
* @return bool
*/
function is_paying_or_trial__premium_only() {
return $this->is_premium() && $this->is_paying_or_trial();
}
/**
* Check if the user has an activated and valid paid license on current plugin's install.
*
* @since 1.0.4
*
* @return bool
*
* @deprecated Method name is confusing since it's not clear from the name the code will be removed.
* @using Alias to is_paying__premium_only()
*/
function is_paying__fs__() {
return $this->is_paying__premium_only();
}
/**
* Check if user in a trial or have feature enabled license.
*
* All code wrapped in this statement will be only included in the premium code.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.9
*
* @return bool
*/
function can_use_premium_code__premium_only() {
return $this->is_premium() && $this->can_use_premium_code();
}
#endregion
#----------------------------------------------------------------------------------
#region Trial
#----------------------------------------------------------------------------------
/**
* Check if the user in a trial.
*
* @since 1.0.3
*
* @return bool
*/
abstract function is_trial();
/**
* Check if trial already utilized.
*
* @since 1.0.9
*
* @return bool
*/
abstract function is_trial_utilized();
#endregion
#----------------------------------------------------------------------------------
#region Plans
#----------------------------------------------------------------------------------
/**
* Check if the user is on the free plan of the product.
*
* @since 1.0.4
*
* @return bool
*/
abstract function is_free_plan();
/**
* @since 1.0.2
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
abstract function is_plan( $plan, $exact = false );
/**
* Check if plan based on trial. If not in trial mode, should return false.
*
* @since 1.0.9
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
abstract function is_trial_plan( $plan, $exact = false );
/**
* Check if plan matches active license' plan or active trial license' plan.
*
* @since 1.0.9
*
* @param string $plan Plan name.
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
*
* @return bool
*/
function is_plan_or_trial( $plan, $exact = false ) {
return $this->is_plan( $plan, $exact ) ||
$this->is_trial_plan( $plan, $exact );
}
/**
* Check if plugin has any paid plans.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @return bool
*/
abstract function has_paid_plan();
/**
* Check if plugin has any free plan, or is it premium only.
*
* Note: If no plans configured, assume plugin is free.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @return bool
*/
abstract function has_free_plan();
/**
* Check if plugin is premium only (no free plans).
*
* NOTE: is__premium_only() is very different method, don't get confused.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.9
*
* @return bool
*/
abstract function is_only_premium();
/**
* Check if module has a premium code version.
*
* Serviceware module might be freemium without any
* premium code version, where the paid features
* are all part of the service.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @return bool
*/
abstract function has_premium_version();
/**
* Check if module has any release on Freemius,
* or all plugin's code is on WordPress.org (Serviceware).
*
* @return bool
*/
function has_release_on_freemius() {
return ! $this->is_org_repo_compliant() ||
$this->has_premium_version();
}
/**
* Checks if it's a freemium plugin.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.9
*
* @return bool
*/
function is_freemium() {
return $this->has_paid_plan() &&
$this->has_free_plan();
}
/**
* Check if module has only one plan.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.7
*
* @return bool
*/
abstract function is_single_plan();
#endregion
/**
* Check if running payments in sandbox mode.
*
* @since 1.0.4
*
* @return bool
*/
abstract function is_payments_sandbox();
/**
* Check if running test vs. live plugin.
*
* @since 1.0.5
*
* @return bool
*/
abstract function is_live();
/**
* Check if running premium plugin code.
*
* @since 1.0.5
*
* @return bool
*/
abstract function is_premium();
/**
* Get upgrade URL.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.2
*
* @param string $period Billing cycle.
*
* @return string
*/
abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY );
/**
* Check if Freemius was first added in a plugin update.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.5
*
* @return bool
*/
function is_plugin_update() {
return ! $this->is_plugin_new_install();
}
/**
* Check if Freemius was part of the plugin when the user installed it first.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.5
*
* @return bool
*/
abstract function is_plugin_new_install();
#----------------------------------------------------------------------------------
#region Marketing
#----------------------------------------------------------------------------------
/**
* Check if current user purchased any other plugins before.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
abstract function has_purchased_before();
/**
* Check if current user classified as an agency.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
abstract function is_agency();
/**
* Check if current user classified as a developer.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
abstract function is_developer();
/**
* Check if current user classified as a business.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
abstract function is_business();
#endregion
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,321 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WP Admin notices manager both for site level and network level.
*
* Class FS_Admin_Notices
*/
class FS_Admin_Notices {
/**
* @since 1.2.2
*
* @var string
*/
protected $_module_unique_affix;
/**
* @var string
*/
protected $_id;
/**
* @var string
*/
protected $_title;
/**
* @var FS_Admin_Notice_Manager
*/
protected $_notices;
/**
* @var FS_Admin_Notice_Manager
*/
protected $_network_notices;
/**
* @var int The ID of the blog that is associated with the current site level options.
*/
private $_blog_id = 0;
/**
* @var bool
*/
private $_is_multisite;
/**
* @var FS_Admin_Notices[]
*/
private static $_instances = array();
/**
* @param string $id
* @param string $title
* @param string $module_unique_affix
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
* blog admin pages.
*
* @return FS_Admin_Notices
*/
static function instance( $id, $title = '', $module_unique_affix = '', $is_network_and_blog_admins = false ) {
if ( ! isset( self::$_instances[ $id ] ) ) {
self::$_instances[ $id ] = new FS_Admin_Notices( $id, $title, $module_unique_affix, $is_network_and_blog_admins );
}
return self::$_instances[ $id ];
}
/**
* @param string $id
* @param string $title
* @param string $module_unique_affix
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
* blog admin pages.
*/
protected function __construct( $id, $title = '', $module_unique_affix = '', $is_network_and_blog_admins = false ) {
$this->_id = $id;
$this->_title = $title;
$this->_module_unique_affix = $module_unique_affix;
$this->_is_multisite = is_multisite();
if ( $this->_is_multisite ) {
$this->_blog_id = get_current_blog_id();
$this->_network_notices = FS_Admin_Notice_Manager::instance(
$id,
$title,
$module_unique_affix,
$is_network_and_blog_admins,
true
);
}
$this->_notices = FS_Admin_Notice_Manager::instance(
$id,
$title,
$module_unique_affix,
false,
$this->_blog_id
);
}
/**
* Add admin message to admin messages queue, and hook to admin_notices / all_admin_notices if not yet hooked.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.4
*
* @param string $message
* @param string $title
* @param string $type
* @param bool $is_sticky
* @param string $id Message ID
* @param bool $store_if_sticky
* @param int|null $network_level_or_blog_id
*
* @uses add_action()
*/
function add(
$message,
$title = '',
$type = 'success',
$is_sticky = false,
$id = '',
$store_if_sticky = true,
$network_level_or_blog_id = null
) {
if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) {
$notices = $this->_network_notices;
} else {
$notices = $this->get_site_notices( $network_level_or_blog_id );
}
$notices->add(
$message,
$title,
$type,
$is_sticky,
$id,
$store_if_sticky
);
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @param string|string[] $ids
* @param int|null $network_level_or_blog_id
*/
function remove_sticky( $ids, $network_level_or_blog_id = null ) {
if ( ! is_array( $ids ) ) {
$ids = array( $ids );
}
if ( $this->should_use_network_notices( $ids[0], $network_level_or_blog_id ) ) {
$notices = $this->_network_notices;
} else {
$notices = $this->get_site_notices( $network_level_or_blog_id );
}
return $notices->remove_sticky( $ids );
}
/**
* Check if sticky message exists by id.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @param string $id
* @param int|null $network_level_or_blog_id
*
* @return bool
*/
function has_sticky( $id, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) {
$notices = $this->_network_notices;
} else {
$notices = $this->get_site_notices( $network_level_or_blog_id );
}
return $notices->has_sticky( $id );
}
/**
* Adds sticky admin notification.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @param string $message
* @param string $id Message ID
* @param string $title
* @param string $type
* @param int|null $network_level_or_blog_id
* @param number|null $wp_user_id
* @param string|null $plugin_title
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
* blog admin pages.
*/
function add_sticky(
$message,
$id,
$title = '',
$type = 'success',
$network_level_or_blog_id = null,
$wp_user_id = null,
$plugin_title = null,
$is_network_and_blog_admins = false
) {
if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) {
$notices = $this->_network_notices;
} else {
$notices = $this->get_site_notices( $network_level_or_blog_id );
}
$notices->add_sticky( $message, $id, $title, $type, $wp_user_id, $plugin_title, $is_network_and_blog_admins );
}
/**
* Clear all sticky messages.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int|null $network_level_or_blog_id
*/
function clear_all_sticky( $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ||
false === $network_level_or_blog_id ||
0 == $network_level_or_blog_id ||
is_null( $network_level_or_blog_id )
) {
$notices = $this->get_site_notices( $network_level_or_blog_id );
$notices->clear_all_sticky();
}
if ( $this->_is_multisite &&
( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
) {
$this->_network_notices->clear_all_sticky();
}
}
/**
* Add admin message to all admin messages queue, and hook to all_admin_notices if not yet hooked.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.4
*
* @param string $message
* @param string $title
* @param string $type
* @param bool $is_sticky
* @param string $id Message ID
*/
function add_all( $message, $title = '', $type = 'success', $is_sticky = false, $id = '' ) {
$this->add( $message, $title, $type, $is_sticky, true, $id );
}
#--------------------------------------------------------------------------------
#region Helper Methods
#--------------------------------------------------------------------------------
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*
* @return FS_Admin_Notice_Manager
*/
private function get_site_notices( $blog_id = 0 ) {
if ( 0 == $blog_id || $blog_id == $this->_blog_id ) {
return $this->_notices;
}
return FS_Admin_Notice_Manager::instance(
$this->_id,
$this->_title,
$this->_module_unique_affix,
false,
$blog_id
);
}
/**
* Check if the network notices should be used.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $id
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite notices (if there's a network). When `false`, use the current context blog notices. When `null`, the decision which notices manager to use (MS vs. Current S) will be handled internally and determined based on the $id and the context admin (blog admin vs. network level admin).
*
* @return bool
*/
private function should_use_network_notices( $id = '', $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ) {
// Not a multisite environment.
return false;
}
if ( is_numeric( $network_level_or_blog_id ) ) {
// Explicitly asked to use a specified blog storage.
return false;
}
if ( is_bool( $network_level_or_blog_id ) ) {
// Explicitly specified whether should use the network or blog level storage.
return $network_level_or_blog_id;
}
return fs_is_network_admin();
}
#endregion
}

View File

@ -0,0 +1,664 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Api
*
* Wraps Freemius API SDK to handle:
* 1. Clock sync.
* 2. Fallback to HTTP when HTTPS fails.
* 3. Adds caching layer to GET requests.
* 4. Adds consistency for failed requests by using last cached version.
*/
class FS_Api {
/**
* @var FS_Api[]
*/
private static $_instances = array();
/**
* @var FS_Option_Manager Freemius options, options-manager.
*/
private static $_options;
/**
* @var FS_Cache_Manager API Caching layer
*/
private static $_cache;
/**
* @var int Clock diff in seconds between current server to API server.
*/
private static $_clock_diff;
/**
* @var Freemius_Api_WordPress
*/
private $_api;
/**
* @var string
*/
private $_slug;
/**
* @var FS_Logger
* @since 1.0.4
*/
private $_logger;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var string
*/
private $_sdk_version;
/**
* @param string $slug
* @param string $scope 'app', 'developer', 'user' or 'install'.
* @param number $id Element's id.
* @param string $public_key Public key.
* @param bool $is_sandbox
* @param bool|string $secret_key Element's secret key.
* @param null|string $sdk_version
*
* @return FS_Api
*/
static function instance(
$slug,
$scope,
$id,
$public_key,
$is_sandbox,
$secret_key = false,
$sdk_version = null
) {
$identifier = md5( $slug . $scope . $id . $public_key . ( is_string( $secret_key ) ? $secret_key : '' ) . json_encode( $is_sandbox ) );
if ( ! isset( self::$_instances[ $identifier ] ) ) {
self::_init();
self::$_instances[ $identifier ] = new FS_Api( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox, $sdk_version );
}
return self::$_instances[ $identifier ];
}
private static function _init() {
if ( isset( self::$_options ) ) {
return;
}
if ( ! class_exists( 'Freemius_Api_WordPress' ) ) {
require_once WP_FS__DIR_SDK . '/FreemiusWordPress.php';
}
self::$_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true, true );
self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
self::$_clock_diff = self::$_options->get_option( 'api_clock_diff', 0 );
Freemius_Api_WordPress::SetClockDiff( self::$_clock_diff );
if ( self::$_options->get_option( 'api_force_http', false ) ) {
Freemius_Api_WordPress::SetHttp();
}
}
/**
* @param string $slug
* @param string $scope 'app', 'developer', 'user' or 'install'.
* @param number $id Element's id.
* @param string $public_key Public key.
* @param bool|string $secret_key Element's secret key.
* @param bool $is_sandbox
* @param null|string $sdk_version
*/
private function __construct(
$slug,
$scope,
$id,
$public_key,
$secret_key,
$is_sandbox,
$sdk_version
) {
$this->_api = new Freemius_Api_WordPress( $scope, $id, $public_key, $secret_key, $is_sandbox );
$this->_slug = $slug;
$this->_sdk_version = $sdk_version;
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_api', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
}
/**
* Find clock diff between server and API server, and store the diff locally.
*
* @param bool|int $diff
*
* @return bool|int False if clock diff didn't change, otherwise returns the clock diff in seconds.
*/
private function _sync_clock_diff( $diff = false ) {
$this->_logger->entrance();
// Sync clock and store.
$new_clock_diff = ( false === $diff ) ?
Freemius_Api_WordPress::FindClockDiff() :
$diff;
if ( $new_clock_diff === self::$_clock_diff ) {
return false;
}
self::$_clock_diff = $new_clock_diff;
// Update API clock's diff.
Freemius_Api_WordPress::SetClockDiff( self::$_clock_diff );
// Store new clock diff in storage.
self::$_options->set_option( 'api_clock_diff', self::$_clock_diff, true );
return $new_clock_diff;
}
/**
* Override API call to enable retry with servers' clock auto sync method.
*
* @param string $path
* @param string $method
* @param array $params
* @param bool $retry Is in retry or first call attempt.
*
* @return array|mixed|string|void
*/
private function _call( $path, $method = 'GET', $params = array(), $retry = false ) {
$this->_logger->entrance( $method . ':' . $path );
if ( self::is_temporary_down() ) {
$result = $this->get_temporary_unavailable_error();
} else {
/**
* @since 2.3.0 Include the SDK version with all API requests that going through the API manager. IMPORTANT: Only pass the SDK version if the caller didn't include it yet.
*/
if ( ! empty( $this->_sdk_version ) ) {
if ( false === strpos( $path, 'sdk_version=' ) &&
! isset( $params['sdk_version'] )
) {
// Always add the sdk_version param in the querystring. DO NOT INCLUDE IT IN THE BODY PARAMS, OTHERWISE, IT MAY LEAD TO AN UNEXPECTED PARAMS PARSING IN CASES WHERE THE $params IS A REGULAR NON-ASSOCIATIVE ARRAY.
$path = add_query_arg( 'sdk_version', $this->_sdk_version, $path );
}
}
$result = $this->_api->Api( $path, $method, $params );
if ( null !== $result &&
isset( $result->error ) &&
isset( $result->error->code ) &&
'request_expired' === $result->error->code
) {
if ( ! $retry ) {
$diff = isset( $result->error->timestamp ) ?
( time() - strtotime( $result->error->timestamp ) ) :
false;
// Try to sync clock diff.
if ( false !== $this->_sync_clock_diff( $diff ) ) {
// Retry call with new synced clock.
return $this->_call( $path, $method, $params, true );
}
}
}
}
if ( $this->_logger->is_on() && self::is_api_error( $result ) ) {
// Log API errors.
$this->_logger->api_error( $result );
}
return $result;
}
/**
* Override API call to wrap it in servers' clock sync method.
*
* @param string $path
* @param string $method
* @param array $params
*
* @return array|mixed|string|void
* @throws Freemius_Exception
*/
function call( $path, $method = 'GET', $params = array() ) {
return $this->_call( $path, $method, $params );
}
/**
* Get API request URL signed via query string.
*
* @param string $path
*
* @return string
*/
function get_signed_url( $path ) {
return $this->_api->GetSignedUrl( $path );
}
/**
* @param string $path
* @param bool $flush
* @param int $expiration (optional) Time until expiration in seconds from now, defaults to 24 hours
*
* @return stdClass|mixed
*/
function get( $path = '/', $flush = false, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
$this->_logger->entrance( $path );
$cache_key = $this->get_cache_key( $path );
// Always flush during development.
if ( WP_FS__DEV_MODE || $this->_api->IsSandbox() ) {
$flush = true;
}
$cached_result = self::$_cache->get( $cache_key );
if ( $flush || ! self::$_cache->has_valid( $cache_key, $expiration ) ) {
$result = $this->call( $path );
if ( ! is_object( $result ) || isset( $result->error ) ) {
// Api returned an error.
if ( is_object( $cached_result ) &&
! isset( $cached_result->error )
) {
// If there was an error during a newer data fetch,
// fallback to older data version.
$result = $cached_result;
if ( $this->_logger->is_on() ) {
$this->_logger->warn( 'Fallback to cached API result: ' . var_export( $cached_result, true ) );
}
} else {
if ( is_object( $result ) && isset( $result->error->http ) && 404 == $result->error->http ) {
/**
* If the response code is 404, cache the result for half of the `$expiration`.
*
* @author Leo Fajardo (@leorw)
* @since 2.2.4
*/
$expiration /= 2;
} else {
// If no older data version and the response code is not 404, return result without
// caching the error.
return $result;
}
}
}
self::$_cache->set( $cache_key, $result, $expiration );
$cached_result = $result;
} else {
$this->_logger->log( 'Using cached API result.' );
}
return $cached_result;
}
/**
* Check if there's a cached version of the API request.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1
*
* @param string $path
* @param string $method
* @param array $params
*
* @return bool
*/
function is_cached( $path, $method = 'GET', $params = array() ) {
$cache_key = $this->get_cache_key( $path, $method, $params );
return self::$_cache->has_valid( $cache_key );
}
/**
* Invalidate a cached version of the API request.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param string $path
* @param string $method
* @param array $params
*/
function purge_cache( $path, $method = 'GET', $params = array() ) {
$this->_logger->entrance( "{$method}:{$path}" );
$cache_key = $this->get_cache_key( $path, $method, $params );
self::$_cache->purge( $cache_key );
}
/**
* Invalidate a cached version of the API request.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $path
* @param int $expiration
* @param string $method
* @param array $params
*/
function update_cache_expiration( $path, $expiration = WP_FS__TIME_24_HOURS_IN_SEC, $method = 'GET', $params = array() ) {
$this->_logger->entrance( "{$method}:{$path}:{$expiration}" );
$cache_key = $this->get_cache_key( $path, $method, $params );
self::$_cache->update_expiration( $cache_key, $expiration );
}
/**
* @param string $path
* @param string $method
* @param array $params
*
* @return string
* @throws \Freemius_Exception
*/
private function get_cache_key( $path, $method = 'GET', $params = array() ) {
$canonized = $this->_api->CanonizePath( $path );
// $exploded = explode('/', $canonized);
// return $method . '_' . array_pop($exploded) . '_' . md5($canonized . json_encode($params));
return strtolower( $method . ':' . $canonized ) . ( ! empty( $params ) ? '#' . md5( json_encode( $params ) ) : '' );
}
/**
* Test API connectivity.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9 If fails, try to fallback to HTTP.
* @since 1.1.6 Added a 5-min caching mechanism, to prevent from overloading the server if the API if
* temporary down.
*
* @return bool True if successful connectivity to the API.
*/
static function test() {
self::_init();
$cache_key = 'ping_test';
$test = self::$_cache->get_valid( $cache_key, null );
if ( is_null( $test ) ) {
$test = Freemius_Api_WordPress::Test();
if ( false === $test && Freemius_Api_WordPress::IsHttps() ) {
// Fallback to HTTP, since HTTPS fails.
Freemius_Api_WordPress::SetHttp();
self::$_options->set_option( 'api_force_http', true, true );
$test = Freemius_Api_WordPress::Test();
if ( false === $test ) {
/**
* API connectivity test fail also in HTTP request, therefore,
* fallback to HTTPS to keep connection secure.
*
* @since 1.1.6
*/
self::$_options->set_option( 'api_force_http', false, true );
}
}
self::$_cache->set( $cache_key, $test, WP_FS__TIME_5_MIN_IN_SEC );
}
return $test;
}
/**
* Check if API is temporary down.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @return bool
*/
static function is_temporary_down() {
self::_init();
$test = self::$_cache->get_valid( 'ping_test', null );
return ( false === $test );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @return object
*/
private function get_temporary_unavailable_error() {
return (object) array(
'error' => (object) array(
'type' => 'TemporaryUnavailable',
'message' => 'API is temporary unavailable, please retry in ' . ( self::$_cache->get_record_expiration( 'ping_test' ) - WP_FS__SCRIPT_START_TIME ) . ' sec.',
'code' => 'temporary_unavailable',
'http' => 503
)
);
}
/**
* Ping API for connectivity test, and return result object.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @param null|string $unique_anonymous_id
* @param array $params
*
* @return object
*/
function ping( $unique_anonymous_id = null, $params = array() ) {
$this->_logger->entrance();
if ( self::is_temporary_down() ) {
return $this->get_temporary_unavailable_error();
}
$pong = is_null( $unique_anonymous_id ) ?
Freemius_Api_WordPress::Ping() :
$this->_call( 'ping.json?' . http_build_query( array_merge(
array( 'uid' => $unique_anonymous_id ),
$params
) ) );
if ( $this->is_valid_ping( $pong ) ) {
return $pong;
}
if ( self::should_try_with_http( $pong ) ) {
// Fallback to HTTP, since HTTPS fails.
Freemius_Api_WordPress::SetHttp();
self::$_options->set_option( 'api_force_http', true, true );
$pong = is_null( $unique_anonymous_id ) ?
Freemius_Api_WordPress::Ping() :
$this->_call( 'ping.json?' . http_build_query( array_merge(
array( 'uid' => $unique_anonymous_id ),
$params
) ) );
if ( ! $this->is_valid_ping( $pong ) ) {
self::$_options->set_option( 'api_force_http', false, true );
}
}
return $pong;
}
/**
* Check if based on the API result we should try
* to re-run the same request with HTTP instead of HTTPS.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param $result
*
* @return bool
*/
private static function should_try_with_http( $result ) {
if ( ! Freemius_Api_WordPress::IsHttps() ) {
return false;
}
return ( ! is_object( $result ) ||
! isset( $result->error ) ||
! isset( $result->error->code ) ||
! in_array( $result->error->code, array(
'curl_missing',
'cloudflare_ddos_protection',
'maintenance_mode',
'squid_cache_block',
'too_many_requests',
) ) );
}
/**
* Check if valid ping request result.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.1
*
* @param mixed $pong
*
* @return bool
*/
function is_valid_ping( $pong ) {
return Freemius_Api_WordPress::Test( $pong );
}
function get_url( $path = '' ) {
return Freemius_Api_WordPress::GetUrl( $path, $this->_api->IsSandbox() );
}
/**
* Clear API cache.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*/
static function clear_cache() {
self::_init();
self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
self::$_cache->clear();
}
#----------------------------------------------------------------------------------
#region Error Handling
#----------------------------------------------------------------------------------
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param mixed $result
*
* @return bool Is API result contains an error.
*/
static function is_api_error( $result ) {
return ( is_object( $result ) && isset( $result->error ) ) ||
is_string( $result );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param mixed $result
*
* @return bool Is API result contains an error.
*/
static function is_api_error_object( $result ) {
return (
is_object( $result ) &&
isset( $result->error ) &&
isset( $result->error->message )
);
}
/**
* Checks if given API result is a non-empty and not an error object.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param mixed $result
* @param string|null $required_property Optional property we want to verify that is set.
*
* @return bool
*/
static function is_api_result_object( $result, $required_property = null ) {
return (
is_object( $result ) &&
! isset( $result->error ) &&
( empty( $required_property ) || isset( $result->{$required_property} ) )
);
}
/**
* Checks if given API result is a non-empty entity object with non-empty ID.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param mixed $result
*
* @return bool
*/
static function is_api_result_entity( $result ) {
return self::is_api_result_object( $result, 'id' ) &&
FS_Entity::is_valid_id( $result->id );
}
/**
* Get API result error code. If failed to get code, returns an empty string.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param mixed $result
*
* @return string
*/
static function get_error_code( $result ) {
if ( is_object( $result ) &&
isset( $result->error ) &&
is_object( $result->error ) &&
! empty( $result->error->code )
) {
return $result->error->code;
}
return '';
}
#endregion
}

View File

@ -0,0 +1,691 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Logger {
private $_id;
private $_on = false;
private $_echo = false;
private $_file_start = 0;
/**
* @var int PHP Process ID.
*/
private static $_processID;
/**
* @var string PHP Script user name.
*/
private static $_ownerName;
/**
* @var bool Is storage logging turned on.
*/
private static $_isStorageLoggingOn;
/**
* @var int ABSPATH length.
*/
private static $_abspathLength;
private static $LOGGERS = array();
private static $LOG = array();
private static $CNT = 0;
private static $_HOOKED_FOOTER = false;
private function __construct( $id, $on = false, $echo = false ) {
$this->_id = $id;
$bt = debug_backtrace();
$caller = $bt[2];
if ( false !== strpos( $caller['file'], 'plugins' ) ) {
$this->_file_start = strpos( $caller['file'], 'plugins' ) + strlen( 'plugins/' );
} else {
$this->_file_start = strpos( $caller['file'], 'themes' ) + strlen( 'themes/' );
}
if ( $on ) {
$this->on();
}
if ( $echo ) {
$this->echo_on();
}
}
/**
* @param string $id
* @param bool $on
* @param bool $echo
*
* @return FS_Logger
*/
public static function get_logger( $id, $on = false, $echo = false ) {
$id = strtolower( $id );
if ( ! isset( self::$_processID ) ) {
self::init();
}
if ( ! isset( self::$LOGGERS[ $id ] ) ) {
self::$LOGGERS[ $id ] = new FS_Logger( $id, $on, $echo );
}
return self::$LOGGERS[ $id ];
}
/**
* Initialize logging global info.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*/
private static function init() {
self::$_ownerName = function_exists( 'get_current_user' ) ?
get_current_user() :
'unknown';
self::$_isStorageLoggingOn = ( 1 == get_option( 'fs_storage_logger', 0 ) );
self::$_abspathLength = strlen( ABSPATH );
self::$_processID = mt_rand( 0, 32000 );
// Process ID may be `false` on errors.
if ( ! is_numeric( self::$_processID ) ) {
self::$_processID = 0;
}
}
private static function hook_footer() {
if ( self::$_HOOKED_FOOTER ) {
return;
}
if ( is_admin() ) {
add_action( 'admin_footer', 'FS_Logger::dump', 100 );
} else {
add_action( 'wp_footer', 'FS_Logger::dump', 100 );
}
}
function is_on() {
return $this->_on;
}
function on() {
$this->_on = true;
if ( ! function_exists( 'dbDelta' ) ) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
}
self::hook_footer();
}
function echo_on() {
$this->on();
$this->_echo = true;
}
function is_echo_on() {
return $this->_echo;
}
function get_id() {
return $this->_id;
}
function get_file() {
return $this->_file_start;
}
private function _log( &$message, $type, $wrapper = false ) {
if ( ! $this->is_on() ) {
return;
}
$bt = debug_backtrace();
$depth = $wrapper ? 3 : 2;
while ( $depth < count( $bt ) - 1 && 'eval' === $bt[ $depth ]['function'] ) {
$depth ++;
}
$caller = $bt[ $depth ];
/**
* Retrieve the correct call file & line number from backtrace
* when logging from a wrapper method.
*
* @author Vova Feldman
* @since 1.2.1.6
*/
if ( empty( $caller['line'] ) ) {
$depth --;
while ( $depth >= 0 ) {
if ( ! empty( $bt[ $depth ]['line'] ) ) {
$caller['line'] = $bt[ $depth ]['line'];
$caller['file'] = $bt[ $depth ]['file'];
break;
}
}
}
$log = array_merge( $caller, array(
'cnt' => self::$CNT ++,
'logger' => $this,
'timestamp' => microtime( true ),
'log_type' => $type,
'msg' => $message,
) );
if ( self::$_isStorageLoggingOn ) {
$this->db_log( $type, $message, self::$CNT, $caller );
}
self::$LOG[] = $log;
if ( $this->is_echo_on() && ! Freemius::is_ajax() ) {
echo self::format_html( $log ) . "\n";
}
}
function log( $message, $wrapper = false ) {
$this->_log( $message, 'log', $wrapper );
}
function info( $message, $wrapper = false ) {
$this->_log( $message, 'info', $wrapper );
}
function warn( $message, $wrapper = false ) {
$this->_log( $message, 'warn', $wrapper );
}
function error( $message, $wrapper = false ) {
$this->_log( $message, 'error', $wrapper );
}
/**
* Log API error.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.5
*
* @param mixed $api_result
* @param bool $wrapper
*/
function api_error( $api_result, $wrapper = false ) {
$message = '';
if ( is_object( $api_result ) &&
! empty( $api_result->error ) &&
! empty( $api_result->error->message )
) {
$message = $api_result->error->message;
} else if ( is_object( $api_result ) ) {
$message = var_export( $api_result, true );
} else if ( is_string( $api_result ) ) {
$message = $api_result;
} else if ( empty( $api_result ) ) {
$message = 'Empty API result.';
}
$message = 'API Error: ' . $message;
$this->_log( $message, 'error', $wrapper );
}
function entrance( $message = '', $wrapper = false ) {
$msg = 'Entrance' . ( empty( $message ) ? '' : ' > ' ) . $message;
$this->_log( $msg, 'log', $wrapper );
}
function departure( $message = '', $wrapper = false ) {
$msg = 'Departure' . ( empty( $message ) ? '' : ' > ' ) . $message;
$this->_log( $msg, 'log', $wrapper );
}
#--------------------------------------------------------------------------------
#region Log Formatting
#--------------------------------------------------------------------------------
private static function format( $log, $show_type = true ) {
return '[' . str_pad( $log['cnt'], strlen( self::$CNT ), '0', STR_PAD_LEFT ) . '] [' . $log['logger']->_id . '] ' . ( $show_type ? '[' . $log['log_type'] . ']' : '' ) . ( ! empty( $log['class'] ) ? $log['class'] . $log['type'] : '' ) . $log['function'] . ' >> ' . $log['msg'] . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ') ' : '' ) . ' [' . $log['timestamp'] . ']';
}
private static function format_html( $log ) {
return '<div style="font-size: 13px; font-family: monospace; color: #7da767; padding: 8px 3px; background: #000; border-bottom: 1px solid #555;">[' . $log['cnt'] . '] [' . $log['logger']->_id . '] [' . $log['log_type'] . '] <b><code style="color: #c4b1e0;">' . ( ! empty( $log['class'] ) ? $log['class'] . $log['type'] : '' ) . $log['function'] . '</code> >> <b style="color: #f59330;">' . esc_html( $log['msg'] ) . '</b></b>' . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ')' : '' ) . ' [' . $log['timestamp'] . ']</div>';
}
#endregion
static function dump() {
?>
<!-- BEGIN: Freemius PHP Console Log -->
<script type="text/javascript">
<?php
foreach ( self::$LOG as $log ) {
echo 'console.' . $log['log_type'] . '(' . json_encode( self::format( $log, false ) ) . ')' . "\n";
}
?>
</script>
<!-- END: Freemius PHP Console Log -->
<?php
}
static function get_log() {
return self::$LOG;
}
#--------------------------------------------------------------------------------
#region Database Logging
#--------------------------------------------------------------------------------
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @return bool
*/
public static function is_storage_logging_on() {
if ( ! isset( self::$_isStorageLoggingOn ) ) {
self::$_isStorageLoggingOn = ( 1 == get_option( 'fs_storage_logger', 0 ) );
}
return self::$_isStorageLoggingOn;
}
/**
* Turns on/off database persistent debugging to capture
* multi-session logs to debug complex flows like
* plugin auto-deactivate on premium version activation.
*
* @todo Check if Theme Check has issues with DB tables for themes.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param bool $is_on
*
* @return bool
*/
public static function _set_storage_logging( $is_on = true ) {
global $wpdb;
$table = "{$wpdb->prefix}fs_logger";
if ( $is_on ) {
/**
* Create logging table.
*
* NOTE:
* dbDelta must use KEY and not INDEX for indexes.
*
* @link https://core.trac.wordpress.org/ticket/2695
*/
$result = $wpdb->query( "CREATE TABLE {$table} (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`process_id` INT UNSIGNED NOT NULL,
`user_name` VARCHAR(64) NOT NULL,
`logger` VARCHAR(128) NOT NULL,
`log_order` INT UNSIGNED NOT NULL,
`type` ENUM('log','info','warn','error') NOT NULL DEFAULT 'log',
`message` TEXT NOT NULL,
`file` VARCHAR(256) NOT NULL,
`line` INT UNSIGNED NOT NULL,
`function` VARCHAR(256) NOT NULL,
`request_type` ENUM('call','ajax','cron') NOT NULL DEFAULT 'call',
`request_url` VARCHAR(1024) NOT NULL,
`created` DECIMAL(16, 6) NOT NULL,
PRIMARY KEY (`id`),
KEY `process_id` (`process_id` ASC),
KEY `process_logger` (`process_id` ASC, `logger` ASC),
KEY `function` (`function` ASC),
KEY `type` (`type` ASC))" );
} else {
/**
* Drop logging table.
*/
$result = $wpdb->query( "DROP TABLE IF EXISTS $table;" );
}
if ( false !== $result ) {
update_option( 'fs_storage_logger', ( $is_on ? 1 : 0 ) );
}
return ( false !== $result );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param string $type
* @param string $message
* @param int $log_order
* @param array $caller
*
* @return false|int
*/
private function db_log(
&$type,
&$message,
&$log_order,
&$caller
) {
global $wpdb;
$request_type = 'call';
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
$request_type = 'cron';
} else if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
$request_type = 'ajax';
}
$request_url = WP_FS__IS_HTTP_REQUEST ?
$_SERVER['REQUEST_URI'] :
'';
return $wpdb->insert(
"{$wpdb->prefix}fs_logger",
array(
'process_id' => self::$_processID,
'user_name' => self::$_ownerName,
'logger' => $this->_id,
'log_order' => $log_order,
'type' => $type,
'request_type' => $request_type,
'request_url' => $request_url,
'message' => $message,
'file' => isset( $caller['file'] ) ?
substr( $caller['file'], self::$_abspathLength ) :
'',
'line' => $caller['line'],
'function' => ( ! empty( $caller['class'] ) ? $caller['class'] . $caller['type'] : '' ) . $caller['function'],
'created' => microtime( true ),
)
);
}
/**
* Persistent DB logger columns.
*
* @var array
*/
private static $_log_columns = array(
'id',
'process_id',
'user_name',
'logger',
'log_order',
'type',
'message',
'file',
'line',
'function',
'request_type',
'request_url',
'created',
);
/**
* Create DB logs query.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param bool $filters
* @param int $limit
* @param int $offset
* @param bool $order
* @param bool $escape_eol
*
* @return string
*/
private static function build_db_logs_query(
$filters = false,
$limit = 200,
$offset = 0,
$order = false,
$escape_eol = false
) {
global $wpdb;
$select = '*';
if ( $escape_eol ) {
$select = '';
for ( $i = 0, $len = count( self::$_log_columns ); $i < $len; $i ++ ) {
if ( $i > 0 ) {
$select .= ', ';
}
if ( 'message' !== self::$_log_columns[ $i ] ) {
$select .= self::$_log_columns[ $i ];
} else {
$select .= 'REPLACE(message , \'\n\', \' \') AS message';
}
}
}
$query = "SELECT {$select} FROM {$wpdb->prefix}fs_logger";
if ( is_array( $filters ) ) {
$criteria = array();
if ( ! empty( $filters['type'] ) && 'all' !== $filters['type'] ) {
$filters['type'] = strtolower( $filters['type'] );
switch ( $filters['type'] ) {
case 'warn_error':
$criteria[] = array( 'col' => 'type', 'val' => array( 'warn', 'error' ) );
break;
case 'error':
case 'warn':
$criteria[] = array( 'col' => 'type', 'val' => $filters['type'] );
break;
case 'info':
default:
$criteria[] = array( 'col' => 'type', 'val' => array( 'info', 'log' ) );
break;
}
}
if ( ! empty( $filters['request_type'] ) ) {
$filters['request_type'] = strtolower( $filters['request_type'] );
if ( in_array( $filters['request_type'], array( 'call', 'ajax', 'cron' ) ) ) {
$criteria[] = array( 'col' => 'request_type', 'val' => $filters['request_type'] );
}
}
if ( ! empty( $filters['file'] ) ) {
$criteria[] = array(
'col' => 'file',
'op' => 'LIKE',
'val' => '%' . esc_sql( $filters['file'] ),
);
}
if ( ! empty( $filters['function'] ) ) {
$criteria[] = array(
'col' => 'function',
'op' => 'LIKE',
'val' => '%' . esc_sql( $filters['function'] ),
);
}
if ( ! empty( $filters['process_id'] ) && is_numeric( $filters['process_id'] ) ) {
$criteria[] = array( 'col' => 'process_id', 'val' => $filters['process_id'] );
}
if ( ! empty( $filters['logger'] ) ) {
$criteria[] = array(
'col' => 'logger',
'op' => 'LIKE',
'val' => '%' . esc_sql( $filters['logger'] ) . '%',
);
}
if ( ! empty( $filters['message'] ) ) {
$criteria[] = array(
'col' => 'message',
'op' => 'LIKE',
'val' => '%' . esc_sql( $filters['message'] ) . '%',
);
}
if ( 0 < count( $criteria ) ) {
$query .= "\nWHERE\n";
$first = true;
foreach ( $criteria as $c ) {
if ( ! $first ) {
$query .= "AND\n";
}
if ( is_array( $c['val'] ) ) {
$operator = 'IN';
for ( $i = 0, $len = count( $c['val'] ); $i < $len; $i ++ ) {
$c['val'][ $i ] = "'" . esc_sql( $c['val'][ $i ] ) . "'";
}
$val = '(' . implode( ',', $c['val'] ) . ')';
} else {
$operator = ! empty( $c['op'] ) ? $c['op'] : '=';
$val = "'" . esc_sql( $c['val'] ) . "'";
}
$query .= "`{$c['col']}` {$operator} {$val}\n";
$first = false;
}
}
}
if ( ! is_array( $order ) ) {
$order = array(
'col' => 'id',
'order' => 'desc'
);
}
$query .= " ORDER BY {$order['col']} {$order['order']} LIMIT {$offset},{$limit}";
return $query;
}
/**
* Load logs from DB.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param bool $filters
* @param int $limit
* @param int $offset
* @param bool $order
*
* @return object[]|null
*/
public static function load_db_logs(
$filters = false,
$limit = 200,
$offset = 0,
$order = false
) {
global $wpdb;
$query = self::build_db_logs_query(
$filters,
$limit,
$offset,
$order
);
return $wpdb->get_results( $query );
}
/**
* Load logs from DB.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param bool $filters
* @param string $filename
* @param int $limit
* @param int $offset
* @param bool $order
*
* @return false|string File download URL or false on failure.
*/
public static function download_db_logs(
$filters = false,
$filename = '',
$limit = 10000,
$offset = 0,
$order = false
) {
global $wpdb;
$query = self::build_db_logs_query(
$filters,
$limit,
$offset,
$order,
true
);
$upload_dir = wp_upload_dir();
if ( empty( $filename ) ) {
$filename = 'fs-logs-' . date( 'Y-m-d_H-i-s', WP_FS__SCRIPT_START_TIME ) . '.csv';
}
$filepath = rtrim( $upload_dir['path'], '/' ) . "/{$filename}";
$query .= " INTO OUTFILE '{$filepath}' FIELDS TERMINATED BY '\t' ESCAPED BY '\\\\' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n'";
$columns = '';
for ( $i = 0, $len = count( self::$_log_columns ); $i < $len; $i ++ ) {
if ( $i > 0 ) {
$columns .= ', ';
}
$columns .= "'" . self::$_log_columns[ $i ] . "'";
}
$query = "SELECT {$columns} UNION ALL " . $query;
$result = $wpdb->query( $query );
if ( false === $result ) {
return false;
}
return rtrim( $upload_dir['url'], '/' ) . '/' . $filename;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1.6
*
* @param string $filename
*
* @return string
*/
public static function get_logs_download_url( $filename = '' ) {
$upload_dir = wp_upload_dir();
if ( empty( $filename ) ) {
$filename = 'fs-logs-' . date( 'Y-m-d_H-i-s', WP_FS__SCRIPT_START_TIME ) . '.csv';
}
return rtrim( $upload_dir['url'], '/' ) . $filename;
}
#endregion
}

View File

@ -0,0 +1,431 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Options
*
* A wrapper class for handling network level and single site level options.
*/
class FS_Options {
/**
* @var string
*/
private $_id;
/**
* @var array[string]FS_Options {
* @key string
* @value FS_Options
* }
*/
private static $_instances;
/**
* @var FS_Option_Manager Site level options.
*/
private $_options;
/**
* @var FS_Option_Manager Network level options.
*/
private $_network_options;
/**
* @var int The ID of the blog that is associated with the current site level options.
*/
private $_blog_id = 0;
/**
* @var bool
*/
private $_is_multisite;
/**
* @var string[] Lazy collection of params on the site level.
*/
private static $_SITE_OPTIONS_MAP;
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param string $id
* @param bool $load
*
* @return FS_Options
*/
static function instance( $id, $load = false ) {
if ( ! isset( self::$_instances[ $id ] ) ) {
self::$_instances[ $id ] = new FS_Options( $id, $load );
}
return self::$_instances[ $id ];
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param string $id
* @param bool $load
*/
private function __construct( $id, $load = false ) {
$this->_id = $id;
$this->_is_multisite = is_multisite();
if ( $this->_is_multisite ) {
$this->_blog_id = get_current_blog_id();
$this->_network_options = FS_Option_Manager::get_manager( $id, $load, true );
}
$this->_options = FS_Option_Manager::get_manager( $id, $load, $this->_blog_id );
}
/**
* Switch the context of the site level options manager.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param $blog_id
*/
function set_site_blog_context( $blog_id ) {
$this->_blog_id = $blog_id;
$this->_options = FS_Option_Manager::get_manager( $this->_id, false, $this->_blog_id );
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $option
* @param mixed $default
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_SITE_LEVEL_PARAMS).
*
* @return mixed
*/
function get_option( $option, $default = null, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_storage( $option, $network_level_or_blog_id ) ) {
return $this->_network_options->get_option( $option, $default );
}
$site_options = $this->get_site_options( $network_level_or_blog_id );
return $site_options->get_option( $option, $default );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param string $option
* @param mixed $value
* @param bool $flush
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_SITE_LEVEL_PARAMS).
*/
function set_option( $option, $value, $flush = false, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_storage( $option, $network_level_or_blog_id ) ) {
$this->_network_options->set_option( $option, $value, $flush );
} else {
$site_options = $this->get_site_options( $network_level_or_blog_id );
$site_options->set_option( $option, $value, $flush );
}
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $option
* @param bool $flush
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_SITE_LEVEL_PARAMS).
*/
function unset_option( $option, $flush = false, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_storage( $option, $network_level_or_blog_id ) ) {
$this->_network_options->unset_option( $option, $flush );
} else {
$site_options = $this->get_site_options( $network_level_or_blog_id );
$site_options->unset_option( $option, $flush );
}
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param bool $flush
* @param bool $network_level
*/
function load( $flush = false, $network_level = true ) {
if ( $this->_is_multisite && $network_level ) {
$this->_network_options->load( $flush );
} else {
$this->_options->load( $flush );
}
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.0.0
*
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, store both network storage and the current context blog storage.
*/
function store( $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ||
false === $network_level_or_blog_id ||
0 == $network_level_or_blog_id ||
is_null( $network_level_or_blog_id )
) {
$site_options = $this->get_site_options( $network_level_or_blog_id );
$site_options->store();
}
if ( $this->_is_multisite &&
( is_null( $network_level_or_blog_id ) || true === $network_level_or_blog_id )
) {
$this->_network_options->store();
}
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int|null|bool $network_level_or_blog_id
* @param bool $flush
*/
function clear( $network_level_or_blog_id = null, $flush = false ) {
if ( ! $this->_is_multisite ||
false === $network_level_or_blog_id ||
is_null( $network_level_or_blog_id ) ||
is_numeric( $network_level_or_blog_id )
) {
$site_options = $this->get_site_options( $network_level_or_blog_id );
$site_options->clear( $flush );
}
if ( $this->_is_multisite &&
( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
) {
$this->_network_options->clear( $flush );
}
}
/**
* Migration script to the new storage data structure that is network compatible.
*
* IMPORTANT:
* This method should be executed only after it is determined if this is a network
* level compatible product activation.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*/
function migrate_to_network( $blog_id = 0 ) {
if ( ! $this->_is_multisite ) {
return;
}
$updated = false;
$site_options = $this->get_site_options( $blog_id );
$keys = $site_options->get_options_keys();
foreach ( $keys as $option ) {
if ( $this->is_site_option( $option ) ||
// Don't move admin notices to the network storage.
in_array($option, array(
// Don't move admin notices to the network storage.
'admin_notices',
// Don't migrate the module specific data, it will be migrated by the FS_Storage.
'plugin_data',
'theme_data',
))
) {
continue;
}
$option_updated = false;
// Migrate option to the network storage.
$site_option = $site_options->get_option( $option );
if ( ! $this->_network_options->has_option( $option ) ) {
// Option not set on the network level, so just set it.
$this->_network_options->set_option( $option, $site_option, false );
$option_updated = true;
} else {
// Option already set on the network level, so we need to merge it inelegantly.
$network_option = $this->_network_options->get_option( $option );
if ( is_array( $network_option ) && is_array( $site_option ) ) {
// Option is an array.
foreach ( $site_option as $key => $value ) {
if ( ! isset( $network_option[ $key ] ) ) {
$network_option[ $key ] = $value;
$option_updated = true;
} else if ( is_array( $network_option[ $key ] ) && is_array( $value ) ) {
if ( empty( $network_option[ $key ] ) ) {
$network_option[ $key ] = $value;
$option_updated = true;
} else if ( empty( $value ) ) {
// Do nothing.
} else {
reset($value);
$first_key = key($value);
if ( $value[$first_key] instanceof FS_Entity ) {
// Merge entities by IDs.
$network_entities_ids = array();
foreach ( $network_option[ $key ] as $entity ) {
$network_entities_ids[ $entity->id ] = true;
}
foreach ( $value as $entity ) {
if ( ! isset( $network_entities_ids[ $entity->id ] ) ) {
$network_option[ $key ][] = $entity;
$option_updated = true;
}
}
}
}
}
}
}
if ( $option_updated ) {
$this->_network_options->set_option( $option, $network_option, false );
}
}
/**
* Remove the option from site level storage.
*
* IMPORTANT:
* The line below is intentionally commented since we want to preserve the option
* on the site storage level for "downgrade compatibility". Basically, if the user
* will downgrade to an older version of the plugin with the prev storage structure,
* it will continue working.
*
* @todo After a few releases we can remove this.
*/
// $site_options->unset_option($option, false);
if ( $option_updated ) {
$updated = true;
}
}
if ( ! $updated ) {
return;
}
// Update network level storage.
$this->_network_options->store();
// $site_options->store();
}
#--------------------------------------------------------------------------------
#region Helper Methods
#--------------------------------------------------------------------------------
/**
* We don't want to load the map right away since it's not even needed in a non-MS environment.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*/
private static function load_site_options_map() {
self::$_SITE_OPTIONS_MAP = array(
'sites' => true,
'theme_sites' => true,
'unique_id' => true,
'active_plugins' => true,
);
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $option
*
* @return bool
*/
private function is_site_option( $option ) {
if ( WP_FS__ACCOUNTS_OPTION_NAME != $this->_id ) {
return false;
}
if ( ! isset( self::$_SITE_OPTIONS_MAP ) ) {
self::load_site_options_map();
}
return isset( self::$_SITE_OPTIONS_MAP[ $option ] );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*
* @return FS_Option_Manager
*/
private function get_site_options( $blog_id = 0 ) {
if ( 0 == $blog_id || $blog_id == $this->_blog_id ) {
return $this->_options;
}
return FS_Option_Manager::get_manager( $this->_id, true, $blog_id );
}
/**
* Check if an option should be stored on the MS network storage.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $option
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_SITE_LEVEL_PARAMS).
*
* @return bool
*/
private function should_use_network_storage( $option, $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ) {
// Not a multisite environment.
return false;
}
if ( is_numeric( $network_level_or_blog_id ) ) {
// Explicitly asked to use a specified blog storage.
return false;
}
if ( is_bool( $network_level_or_blog_id ) ) {
// Explicitly specified whether should use the network or blog level storage.
return $network_level_or_blog_id;
}
// Determine which storage to use based on the option.
return ! $this->is_site_option( $option );
}
#endregion
}

View File

@ -0,0 +1,85 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
define( 'WP_FS__SECURITY_PARAMS_PREFIX', 's_' );
/**
* Class FS_Security
*/
class FS_Security {
/**
* @var FS_Security
* @since 1.0.3
*/
private static $_instance;
/**
* @var FS_Logger
* @since 1.0.3
*/
private static $_logger;
/**
* @return \FS_Security
*/
public static function instance() {
if ( ! isset( self::$_instance ) ) {
self::$_instance = new FS_Security();
self::$_logger = FS_Logger::get_logger(
WP_FS__SLUG,
WP_FS__DEBUG_SDK,
WP_FS__ECHO_DEBUG_SDK
);
}
return self::$_instance;
}
private function __construct() {
}
/**
* @param \FS_Scope_Entity $entity
* @param int $timestamp
* @param string $action
*
* @return string
*/
function get_secure_token( FS_Scope_Entity $entity, $timestamp, $action = '' ) {
return md5(
$timestamp .
$entity->id .
$entity->secret_key .
$entity->public_key .
$action
);
}
/**
* @param \FS_Scope_Entity $entity
* @param int|bool $timestamp
* @param string $action
*
* @return array
*/
function get_context_params( FS_Scope_Entity $entity, $timestamp = false, $action = '' ) {
if ( false === $timestamp ) {
$timestamp = time();
}
return array(
's_ctx_type' => $entity->get_type(),
's_ctx_id' => $entity->id,
's_ctx_ts' => $timestamp,
's_ctx_secure' => $this->get_secure_token( $entity, $timestamp, $action ),
);
}
}

View File

@ -0,0 +1,532 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Storage
*
* A wrapper class for handling network level and single site level storage.
*
* @property bool $is_network_activation
* @property int $network_install_blog_id
* @property object $sync_cron
*/
class FS_Storage {
/**
* @var FS_Storage[]
*/
private static $_instances = array();
/**
* @var FS_Key_Value_Storage Site level storage.
*/
private $_storage;
/**
* @var FS_Key_Value_Storage Network level storage.
*/
private $_network_storage;
/**
* @var string
*/
private $_module_type;
/**
* @var string
*/
private $_module_slug;
/**
* @var int The ID of the blog that is associated with the current site level options.
*/
private $_blog_id = 0;
/**
* @var bool
*/
private $_is_multisite;
/**
* @var bool
*/
private $_is_network_active = false;
/**
* @var bool
*/
private $_is_delegated_connection = false;
/**
* @var array {
* @key string Option name.
* @value int If 0 store on the network level. If 1, store on the network level only if module was network level activated. If 2, store on the network level only if network activated and NOT delegated the connection.
* }
*/
private static $_NETWORK_OPTIONS_MAP;
/**
* @author Leo Fajardo (@leorw)
*
* @param string $module_type
* @param string $slug
*
* @return FS_Storage
*/
static function instance( $module_type, $slug ) {
$key = $module_type . ':' . $slug;
if ( ! isset( self::$_instances[ $key ] ) ) {
self::$_instances[ $key ] = new FS_Storage( $module_type, $slug );
}
return self::$_instances[ $key ];
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $module_type
* @param string $slug
*/
private function __construct( $module_type, $slug ) {
$this->_module_type = $module_type;
$this->_module_slug = $slug;
$this->_is_multisite = is_multisite();
if ( $this->_is_multisite ) {
$this->_blog_id = get_current_blog_id();
$this->_network_storage = FS_Key_Value_Storage::instance( $module_type . '_data', $slug, true );
}
$this->_storage = FS_Key_Value_Storage::instance( $module_type . '_data', $slug, $this->_blog_id );
}
/**
* Tells this storage wrapper class that the context plugin is network active. This flag will affect how values
* are retrieved/stored from/into the storage.
*
* @author Leo Fajardo (@leorw)
*
* @param bool $is_network_active
* @param bool $is_delegated_connection
*/
function set_network_active( $is_network_active = true, $is_delegated_connection = false ) {
$this->_is_network_active = $is_network_active;
$this->_is_delegated_connection = $is_delegated_connection;
}
/**
* Switch the context of the site level storage manager.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*/
function set_site_blog_context( $blog_id ) {
$this->_storage = $this->get_site_storage( $blog_id );
$this->_blog_id = $blog_id;
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $key
* @param mixed $value
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_BINARY_MAP).
* @param bool $flush
*/
function store( $key, $value, $network_level_or_blog_id = null, $flush = true ) {
if ( $this->should_use_network_storage( $key, $network_level_or_blog_id ) ) {
$this->_network_storage->store( $key, $value, $flush );
} else {
$storage = $this->get_site_storage( $network_level_or_blog_id );
$storage->store( $key, $value, $flush );
}
}
/**
* @author Leo Fajardo (@leorw)
*
* @param bool $store
* @param string[] $exceptions Set of keys to keep and not clear.
* @param int|null|bool $network_level_or_blog_id
*/
function clear_all( $store = true, $exceptions = array(), $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ||
false === $network_level_or_blog_id ||
is_null( $network_level_or_blog_id ) ||
is_numeric( $network_level_or_blog_id )
) {
$storage = $this->get_site_storage( $network_level_or_blog_id );
$storage->clear_all( $store, $exceptions );
}
if ( $this->_is_multisite &&
( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
) {
$this->_network_storage->clear_all( $store, $exceptions );
}
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $key
* @param bool $store
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_BINARY_MAP).
*/
function remove( $key, $store = true, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_storage( $key, $network_level_or_blog_id ) ) {
$this->_network_storage->remove( $key, $store );
} else {
$storage = $this->get_site_storage( $network_level_or_blog_id );
$storage->remove( $key, $store );
}
}
/**
* @author Leo Fajardo (@leorw)
*
* @param string $key
* @param mixed $default
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_BINARY_MAP).
*
* @return mixed
*/
function get( $key, $default = false, $network_level_or_blog_id = null ) {
if ( $this->should_use_network_storage( $key, $network_level_or_blog_id ) ) {
return $this->_network_storage->get( $key, $default );
} else {
$storage = $this->get_site_storage( $network_level_or_blog_id );
return $storage->get( $key, $default );
}
}
/**
* Multisite activated:
* true: Save network storage.
* int: Save site specific storage.
* false|0: Save current site storage.
* null: Save network and current site storage.
* Site level activated:
* Save site storage.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param bool|int|null $network_level_or_blog_id
*/
function save( $network_level_or_blog_id = null ) {
if ( $this->_is_network_active &&
( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) )
) {
$this->_network_storage->save();
}
if ( ! $this->_is_network_active || true !== $network_level_or_blog_id ) {
$storage = $this->get_site_storage( $network_level_or_blog_id );
$storage->save();
}
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @return string
*/
function get_module_slug() {
return $this->_module_slug;
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @return string
*/
function get_module_type() {
return $this->_module_type;
}
/**
* Migration script to the new storage data structure that is network compatible.
*
* IMPORTANT:
* This method should be executed only after it is determined if this is a network
* level compatible product activation.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*/
function migrate_to_network() {
if ( ! $this->_is_multisite ) {
return;
}
$updated = false;
if ( ! isset( self::$_NETWORK_OPTIONS_MAP ) ) {
self::load_network_options_map();
}
foreach ( self::$_NETWORK_OPTIONS_MAP as $option => $storage_level ) {
if ( ! $this->is_multisite_option( $option ) ) {
continue;
}
if ( isset( $this->_storage->{$option} ) && ! isset( $this->_network_storage->{$option} ) ) {
// Migrate option to the network storage.
$this->_network_storage->store( $option, $this->_storage->{$option}, false );
/**
* Remove the option from site level storage.
*
* IMPORTANT:
* The line below is intentionally commented since we want to preserve the option
* on the site storage level for "downgrade compatibility". Basically, if the user
* will downgrade to an older version of the plugin with the prev storage structure,
* it will continue working.
*
* @todo After a few releases we can remove this.
*/
// $this->_storage->remove($option, false);
$updated = true;
}
}
if ( ! $updated ) {
return;
}
// Update network level storage.
$this->_network_storage->save();
// $this->_storage->save();
}
#--------------------------------------------------------------------------------
#region Helper Methods
#--------------------------------------------------------------------------------
/**
* We don't want to load the map right away since it's not even needed in a non-MS environment.
*
* Example:
* array(
* 'option1' => 0, // Means that the option should always be stored on the network level.
* 'option2' => 1, // Means that the option should be stored on the network level only when the module was network level activated.
* 'option2' => 2, // Means that the option should be stored on the network level only when the module was network level activated AND the connection was NOT delegated.
* 'option3' => 3, // Means that the option should always be stored on the site level.
* )
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*/
private static function load_network_options_map() {
self::$_NETWORK_OPTIONS_MAP = array(
// Network level options.
'affiliate_application_data' => 0,
'beta_data' => 0,
'connectivity_test' => 0,
'handle_gdpr_admin_notice' => 0,
'has_trial_plan' => 0,
'install_sync_timestamp' => 0,
'install_sync_cron' => 0,
'is_anonymous_ms' => 0,
'is_network_activated' => 0,
'is_on' => 0,
'is_plugin_new_install' => 0,
'network_install_blog_id' => 0,
'pending_sites_info' => 0,
'plugin_last_version' => 0,
'plugin_main_file' => 0,
'plugin_version' => 0,
'sdk_downgrade_mode' => 0,
'sdk_last_version' => 0,
'sdk_upgrade_mode' => 0,
'sdk_version' => 0,
'sticky_optin_added_ms' => 0,
'subscriptions' => 0,
'sync_timestamp' => 0,
'sync_cron' => 0,
'was_plugin_loaded' => 0,
'network_user_id' => 0,
'plugin_upgrade_mode' => 0,
'plugin_downgrade_mode' => 0,
'is_network_connected' => 0,
/**
* Special flag that is used when a super-admin upgrades to the new version of the SDK that
* supports network level integration, when the connection decision wasn't made for all of the
* sites in the network.
*/
'is_network_activation' => 0,
'license_migration' => 0,
// When network activated, then network level.
'install_timestamp' => 1,
'prev_is_premium' => 1,
'require_license_activation' => 1,
// If not network activated OR delegated, then site level.
'activation_timestamp' => 2,
'expired_license_notice_shown' => 2,
'is_whitelabeled' => 2,
'last_license_key' => 2,
'last_license_user_id' => 2,
'prev_user_id' => 2,
'sticky_optin_added' => 2,
'uninstall_reason' => 2,
'is_pending_activation' => 2,
'pending_license_key' => 2,
'is_extensions_tracking_allowed' => 2,
// Site level options.
'is_anonymous' => 3,
);
}
/**
* This method will and should only be executed when is_multisite() is true.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $key
*
* @return bool|mixed
*/
private function is_multisite_option( $key ) {
if ( ! isset( self::$_NETWORK_OPTIONS_MAP ) ) {
self::load_network_options_map();
}
if ( ! isset( self::$_NETWORK_OPTIONS_MAP[ $key ] ) ) {
// Option not found -> use site level storage.
return false;
}
if ( 0 === self::$_NETWORK_OPTIONS_MAP[ $key ] ) {
// Option found and set to always use the network level storage on a multisite.
return true;
}
if ( 3 === self::$_NETWORK_OPTIONS_MAP[ $key ] ) {
// Option found and set to always use the site level storage on a multisite.
return false;
}
if ( ! $this->_is_network_active ) {
return false;
}
if ( 1 === self::$_NETWORK_OPTIONS_MAP[ $key ] ) {
// Network activated.
return true;
}
if ( 2 === self::$_NETWORK_OPTIONS_MAP[ $key ] && ! $this->_is_delegated_connection ) {
// Network activated and not delegated.
return true;
}
return false;
}
/**
* @author Leo Fajardo
*
* @param string $key
* @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_BINARY_MAP).
*
* @return bool
*/
private function should_use_network_storage( $key, $network_level_or_blog_id = null ) {
if ( ! $this->_is_multisite ) {
// Not a multisite environment.
return false;
}
if ( is_numeric( $network_level_or_blog_id ) ) {
// Explicitly asked to use a specified blog storage.
return false;
}
if ( is_bool( $network_level_or_blog_id ) ) {
// Explicitly specified whether should use the network or blog level storage.
return $network_level_or_blog_id;
}
// Determine which storage to use based on the option.
return $this->is_multisite_option( $key );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $blog_id
*
* @return \FS_Key_Value_Storage
*/
private function get_site_storage( $blog_id = 0 ) {
if ( ! is_numeric( $blog_id ) ||
$blog_id == $this->_blog_id ||
0 == $blog_id
) {
return $this->_storage;
}
return FS_Key_Value_Storage::instance(
$this->_module_type . '_data',
$this->_storage->get_secondary_id(),
$blog_id
);
}
#endregion
#--------------------------------------------------------------------------------
#region Magic methods
#--------------------------------------------------------------------------------
function __set( $k, $v ) {
if ( $this->should_use_network_storage( $k ) ) {
$this->_network_storage->{$k} = $v;
} else {
$this->_storage->{$k} = $v;
}
}
function __isset( $k ) {
return $this->should_use_network_storage( $k ) ?
isset( $this->_network_storage->{$k} ) :
isset( $this->_storage->{$k} );
}
function __unset( $k ) {
if ( $this->should_use_network_storage( $k ) ) {
unset( $this->_network_storage->{$k} );
} else {
unset( $this->_storage->{$k} );
}
}
function __get( $k ) {
return $this->should_use_network_storage( $k ) ?
$this->_network_storage->{$k} :
$this->_storage->{$k};
}
#endregion
}

View File

@ -0,0 +1,126 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_User_Lock
*/
class FS_User_Lock {
/**
* @var int
*/
private $_wp_user_id;
/**
* @var int
*/
private $_thread_id;
#--------------------------------------------------------------------------------
#region Singleton
#--------------------------------------------------------------------------------
/**
* @var FS_User_Lock
*/
private static $_instance;
/**
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return FS_User_Lock
*/
static function instance() {
if ( ! isset( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
#endregion
private function __construct() {
$this->_wp_user_id = Freemius::get_current_wp_user_id();
$this->_thread_id = mt_rand( 0, 32000 );
}
/**
* Try to acquire lock. If the lock is already set or is being acquired by another locker, don't do anything.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @param int $expiration
*
* @return bool TRUE if successfully acquired lock.
*/
function try_lock( $expiration = 0 ) {
if ( $this->is_locked() ) {
// Already locked.
return false;
}
set_site_transient( "locked_{$this->_wp_user_id}", $this->_thread_id, $expiration );
if ( $this->has_lock() ) {
set_site_transient( "locked_{$this->_wp_user_id}", true, $expiration );
return true;
}
return false;
}
/**
* Acquire lock regardless if it's already acquired by another locker or not.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @param int $expiration
*/
function lock( $expiration = 0 ) {
set_site_transient( "locked_{$this->_wp_user_id}", true, $expiration );
}
/**
* Checks if lock is currently acquired.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return bool
*/
function is_locked() {
return ( false !== get_site_transient( "locked_{$this->_wp_user_id}" ) );
}
/**
* Unlock the lock.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
function unlock() {
delete_site_transient( "locked_{$this->_wp_user_id}" );
}
/**
* Checks if lock is currently acquired by the current locker.
*
* @return bool
*/
private function has_lock() {
return ( $this->_thread_id == get_site_transient( "locked_{$this->_wp_user_id}" ) );
}
}

View File

@ -0,0 +1,102 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.2.7
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Zerif_Customizer_Theme_Info_Main
*
* @since 1.0.0
* @access public
*/
class FS_Customizer_Support_Section extends WP_Customize_Section {
function __construct( $manager, $id, $args = array() ) {
$manager->register_section_type( 'FS_Customizer_Support_Section' );
parent::__construct( $manager, $id, $args );
}
/**
* The type of customize section being rendered.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'freemius-support-section';
/**
* @var Freemius
*/
public $fs = null;
/**
* Add custom parameters to pass to the JS via JSON.
*
* @since 1.0.0
*/
public function json() {
$json = parent::json();
$is_contact_visible = $this->fs->is_page_visible( 'contact' );
$is_support_visible = $this->fs->is_page_visible( 'support' );
$json['theme_title'] = $this->fs->get_plugin_name();
if ( $is_contact_visible && $is_support_visible ) {
$json['theme_title'] .= ' ' . $this->fs->get_text_inline( 'Support', 'support' );
}
if ( $is_contact_visible ) {
$json['contact'] = array(
'label' => $this->fs->get_text_inline( 'Contact Us', 'contact-us' ),
'url' => $this->fs->contact_url(),
);
}
if ( $is_support_visible ) {
$json['support'] = array(
'label' => $this->fs->get_text_inline( 'Support Forum', 'support-forum' ),
'url' => $this->fs->get_support_forum_url()
);
}
return $json;
}
/**
* Outputs the Underscore.js template.
*
* @since 1.0.0
*/
protected function render_template() {
?>
<li id="fs_customizer_support"
class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
<h3 class="accordion-section-title">
<span>{{ data.theme_title }}</span>
<# if ( data.contact && data.support ) { #>
<div class="button-group">
<# } #>
<# if ( data.contact ) { #>
<a class="button" href="{{ data.contact.url }}" target="_blank" rel="noopener noreferrer">{{ data.contact.label }} </a>
<# } #>
<# if ( data.support ) { #>
<a class="button" href="{{ data.support.url }}" target="_blank" rel="noopener noreferrer">{{ data.support.label }} </a>
<# } #>
<# if ( data.contact && data.support ) { #>
</div>
<# } #>
</h3>
</li>
<?php
}
}

View File

@ -0,0 +1,161 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.2.7
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Customizer_Upsell_Control
*/
class FS_Customizer_Upsell_Control extends WP_Customize_Control {
/**
* Control type
*
* @var string control type
*/
public $type = 'freemius-upsell-control';
/**
* @var Freemius
*/
public $fs = null;
/**
* @param WP_Customize_Manager $manager the customize manager class.
* @param string $id id.
* @param array $args customizer manager parameters.
*/
public function __construct( WP_Customize_Manager $manager, $id, array $args ) {
$manager->register_control_type( 'FS_Customizer_Upsell_Control' );
parent::__construct( $manager, $id, $args );
}
/**
* Enqueue resources for the control.
*/
public function enqueue() {
fs_enqueue_local_style( 'fs_customizer', 'customizer.css' );
}
/**
* Json conversion
*/
public function to_json() {
$pricing_cta = esc_html( $this->fs->get_pricing_cta_label() ) . '&nbsp;&nbsp;' . ( is_rtl() ? '&#x2190;' : '&#x27a4;' );
parent::to_json();
$this->json['button_text'] = $pricing_cta;
$this->json['button_url'] = $this->fs->is_in_trial_promotion() ?
$this->fs->get_trial_url() :
$this->fs->get_upgrade_url();
$api = FS_Plugin::is_valid_id( $this->fs->get_bundle_id() ) ?
$this->fs->get_api_bundle_scope() :
$this->fs->get_api_plugin_scope();
// Load features.
$pricing = $api->get( $this->fs->add_show_pending( "pricing.json" ) );
if ( $this->fs->is_api_result_object( $pricing, 'plans' ) ) {
// Add support features.
if ( is_array( $pricing->plans ) && 0 < count( $pricing->plans ) ) {
$support_features = array(
'kb' => 'Help Center',
'forum' => 'Support Forum',
'email' => 'Priority Email Support',
'phone' => 'Phone Support',
'skype' => 'Skype Support',
'is_success_manager' => 'Personal Success Manager',
);
for ( $i = 0, $len = count( $pricing->plans ); $i < $len; $i ++ ) {
if ( 'free' == $pricing->plans[$i]->name ) {
continue;
}
if ( ! isset( $pricing->plans[ $i ]->features ) ||
! is_array( $pricing->plans[ $i ]->features ) ) {
$pricing->plans[$i]->features = array();
}
foreach ( $support_features as $key => $label ) {
$key = ( 'is_success_manager' !== $key ) ?
"support_{$key}" :
$key;
if ( ! empty( $pricing->plans[ $i ]->{$key} ) ) {
$support_feature = new stdClass();
$support_feature->title = $label;
$pricing->plans[ $i ]->features[] = $support_feature;
}
}
}
}
}
$this->json['plans'] = $pricing->plans;
$this->json['strings'] = array(
'plan' => $this->fs->get_text_x_inline( 'Plan', 'as product pricing plan', 'plan' ),
);
}
/**
* Control content
*/
public function content_template() {
?>
<div id="fs_customizer_upsell">
<# if ( data.plans ) { #>
<ul class="fs-customizer-plans">
<# for (i in data.plans) { #>
<# if ( 'free' != data.plans[i].name && (null != data.plans[i].features && 0 < data.plans[i].features.length) ) { #>
<li class="fs-customizer-plan">
<div class="fs-accordion-section-open">
<h2 class="fs-accordion-section-title menu-item">
<span>{{ data.plans[i].title }}</span>
<button type="button" class="button-link item-edit" aria-expanded="true">
<span class="screen-reader-text">Toggle section: {{ data.plans[i].title }} {{ data.strings.plan }}</span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
</h2>
<div class="fs-accordion-section-content">
<# if ( data.plans[i].description ) { #>
<h3>{{ data.plans[i].description }}</h3>
<# } #>
<# if ( data.plans[i].features ) { #>
<ul>
<# for ( j in data.plans[i].features ) { #>
<li><div class="fs-feature">
<span class="dashicons dashicons-yes"></span><span><# if ( data.plans[i].features[j].value ) { #>{{ data.plans[i].features[j].value }} <# } #>{{ data.plans[i].features[j].title }}</span>
<# if ( data.plans[i].features[j].description ) { #>
<span class="dashicons dashicons-editor-help"><span class="fs-feature-desc">{{ data.plans[i].features[j].description }}</span></span>
<# } #>
</div></li>
<# } #>
</ul>
<# } #>
<# if ( 'free' != data.plans[i].name ) { #>
<a href="{{ data.button_url }}" class="button button-primary" target="_blank">{{{ data.button_text }}}</a>
<# } #>
</div>
</div>
</li>
<# } #>
<# } #>
</ul>
<# } #>
</div>
<?php }
}

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

View File

@ -0,0 +1,64 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.1.7.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Extends Debug Bar plugin by adding a panel to show all Freemius API requests.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.7.3
*
* Class Freemius_Debug_Bar_Panel
*/
class Freemius_Debug_Bar_Panel extends Debug_Bar_Panel {
function init() {
$this->title( 'Freemius' );
}
static function requests_count() {
if ( class_exists( 'Freemius_Api_WordPress' ) ) {
$logger = Freemius_Api_WordPress::GetLogger();
} else {
$logger = array();
}
return number_format( count( $logger ) );
}
static function total_time() {
if ( class_exists( 'Freemius_Api_WordPress' ) ) {
$logger = Freemius_Api_WordPress::GetLogger();
} else {
$logger = array();
}
$total_time = .0;
foreach ( $logger as $l ) {
$total_time += $l['total'];
}
return number_format( 100 * $total_time, 2 ) . ' ' . fs_text_x_inline( 'ms', 'milliseconds' );
}
function render() {
?>
<div id='debug-bar-php'>
<?php fs_require_template( '/debug/api-calls.php' ) ?>
<br>
<?php fs_require_template( '/debug/scheduled-crons.php' ) ?>
<br>
<?php fs_require_template( '/debug/plugins-themes-sync.php' ) ?>
<br>
<?php fs_require_template( '/debug/logger.php' ) ?>
</div>
<?php
}
}

View File

@ -0,0 +1,52 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.1.7.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! WP_FS__DEBUG_SDK ) {
return;
}
/**
* Initialize Freemius custom debug panels.
*
* @param array $panels Debug bar panels objects
*
* @return array Debug bar panels with your custom panels
*/
function fs_custom_panels_init( $panels ) {
if ( class_exists( 'Debug_Bar_Panel' ) ) {
if ( FS_API__LOGGER_ON ) {
require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
$panels[] = new Freemius_Debug_Bar_Panel();
}
}
return $panels;
}
function fs_custom_status_init( $statuses ) {
if ( class_exists( 'Debug_Bar_Panel' ) ) {
if ( FS_API__LOGGER_ON ) {
require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
$statuses[] = array(
'fs_api_requests',
fs_text_inline( 'Freemius API' ),
Freemius_Debug_Bar_Panel::requests_count() . ' ' . fs_text_inline( 'Requests' ) .
' (' . Freemius_Debug_Bar_Panel::total_time() . ')'
);
}
}
return $statuses;
}
add_filter( 'debug_bar_panels', 'fs_custom_panels_init' );
add_filter( 'debug_bar_statuses', 'fs_custom_status_init' );

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

View File

@ -0,0 +1,128 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_AffiliateTerms extends FS_Scope_Entity {
#region Properties
/**
* @var bool
*/
public $is_active;
/**
* @var string Enum: `affiliation` or `rewards`. Defaults to `affiliation`.
*/
public $type;
/**
* @var string Enum: `payout` or `credit`. Defaults to `payout`.
*/
public $reward_type;
/**
* If `first`, the referral will be attributed to the first visited source containing the affiliation link that
* was clicked.
*
* @var string Enum: `first` or `last`. Defaults to `first`.
*/
public $referral_attribution;
/**
* @var int Defaults to `30`, `0` for session cookie, and `null` for endless cookie (until cookies are cleaned).
*/
public $cookie_days;
/**
* @var int
*/
public $commission;
/**
* @var string Enum: `percentage` or `dollar`. Defaults to `percentage`.
*/
public $commission_type;
/**
* @var null|int Defaults to `0` (affiliate only on first payment). `null` for commission for all renewals. If
* greater than `0`, affiliate will get paid for all renewals for `commission_renewals_days` days after
* the initial upgrade/purchase.
*/
public $commission_renewals_days;
/**
* @var int Only cents and no percentage. In US cents, e.g.: 100 = $1.00. Defaults to `null`.
*/
public $install_commission;
/**
* @var string Required default target link, e.g.: pricing page.
*/
public $default_url;
/**
* @var string One of the following: 'all', 'new_customer', 'new_user'.
* If 'all' - reward for any user type.
* If 'new_customer' - reward only for new customers.
* If 'new_user' - reward only for new users.
*/
public $reward_customer_type;
/**
* @var int Defaults to `0` (affiliate only on directly affiliated links). `null` if an affiliate will get
* paid for all customers' lifetime payments. If greater than `0`, an affiliate will get paid for all
* customer payments for `future_payments_days` days after the initial payment.
*/
public $future_payments_days;
/**
* @var bool If `true`, allow referrals from social sites.
*/
public $is_social_allowed;
/**
* @var bool If `true`, allow conversions without HTTP referrer header at all.
*/
public $is_app_allowed;
/**
* @var bool If `true`, allow referrals from any site.
*/
public $is_any_site_allowed;
#endregion Properties
/**
* @author Leo Fajardo (@leorw)
*
* @return string
*/
function get_formatted_commission()
{
return ( 'dollar' === $this->commission_type ) ?
( '$' . $this->commission ) :
( $this->commission . '%' );
}
/**
* @author Leo Fajardo (@leorw)
*
* @return bool
*/
function has_lifetime_commission() {
return ( 0 !== $this->future_payments_days );
}
/**
* @author Leo Fajardo (@leorw)
*
* @return bool
*/
function is_session_cookie() {
return ( 0 == $this->cookie_days );
}
/**
* @author Leo Fajardo (@leorw)
*
* @return bool
*/
function has_renewals_commission() {
return ( is_null( $this->commission_renewals_days ) || $this->commission_renewals_days > 0 );
}
}

View File

@ -0,0 +1,84 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Affiliate extends FS_Scope_Entity {
#region Properties
/**
* @var string
*/
public $paypal_email;
/**
* @var number
*/
public $custom_affiliate_terms_id;
/**
* @var boolean
*/
public $is_using_custom_terms;
/**
* @var string status Enum: `pending`, `rejected`, `suspended`, or `active`. Defaults to `pending`.
*/
public $status;
/**
* @var string
*/
public $domain;
#endregion Properties
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_active() {
return ( 'active' === $this->status );
}
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_pending() {
return ( 'pending' === $this->status );
}
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_suspended() {
return ( 'suspended' === $this->status );
}
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_rejected() {
return ( 'rejected' === $this->status );
}
/**
* @author Leo Fajardo
*
* @return bool
*/
function is_blocked() {
return ( 'blocked' === $this->status );
}
}

View File

@ -0,0 +1,95 @@
<?php
/**
* @package Freemius for EDD Add-On
* @copyright Copyright (c) 2016, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Billing extends FS_Entity {
#region Properties
/**
* @var int
*/
public $entity_id;
/**
* @var string (Enum) Linked entity type. One of: developer, plugin, user, install
*/
public $entity_type;
/**
* @var string
*/
public $business_name;
/**
* @var string
*/
public $first;
/**
* @var string
*/
public $last;
/**
* @var string
*/
public $email;
/**
* @var string
*/
public $phone;
/**
* @var string
*/
public $website;
/**
* @var string Tax or VAT ID.
*/
public $tax_id;
/**
* @var string
*/
public $address_street;
/**
* @var string
*/
public $address_apt;
/**
* @var string
*/
public $address_city;
/**
* @var string
*/
public $address_country;
/**
* @var string Two chars country code.
*/
public $address_country_code;
/**
* @var string
*/
public $address_state;
/**
* @var number Numeric ZIP code (cab be with leading zeros).
*/
public $address_zip;
#endregion Properties
/**
* @param object|bool $event
*/
function __construct( $event = false ) {
parent::__construct( $event );
}
static function get_type() {
return 'billing';
}
}

View File

@ -0,0 +1,159 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Get object's public variables.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.0
*
* @param object $object
*
* @return array
*/
function fs_get_object_public_vars( $object ) {
return get_object_vars( $object );
}
class FS_Entity {
/**
* @var number
*/
public $id;
/**
* @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
*/
public $updated;
/**
* @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
*/
public $created;
/**
* @param bool|object $entity
*/
function __construct( $entity = false ) {
if ( ! ( $entity instanceof stdClass ) && ! ( $entity instanceof FS_Entity ) ) {
return;
}
$props = fs_get_object_public_vars( $this );
foreach ( $props as $key => $def_value ) {
$this->{$key} = isset( $entity->{$key} ) ?
$entity->{$key} :
$def_value;
}
}
static function get_type() {
return 'type';
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @param FS_Entity $entity1
* @param FS_Entity $entity2
*
* @return bool
*/
static function equals( $entity1, $entity2 ) {
if ( is_null( $entity1 ) && is_null( $entity2 ) ) {
return true;
} else if ( is_object( $entity1 ) && is_object( $entity2 ) ) {
return ( $entity1->id == $entity2->id );
} else if ( is_object( $entity1 ) ) {
return is_null( $entity1->id );
} else {
return is_null( $entity2->id );
}
}
private $_is_updated = false;
/**
* Update object property.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @param string|array[string]mixed $key
* @param string|bool $val
*
* @return bool
*/
function update( $key, $val = false ) {
if ( ! is_array( $key ) ) {
$key = array( $key => $val );
}
$is_updated = false;
foreach ( $key as $k => $v ) {
if ( $this->{$k} === $v ) {
continue;
}
if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
$this->{$k} == $v
) {
continue;
}
// Update value.
$this->{$k} = $v;
$is_updated = true;
}
$this->_is_updated = $is_updated;
return $is_updated;
}
/**
* Checks if entity was updated.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_updated() {
return $this->_is_updated;
}
/**
* @param $id
*
* @author Vova Feldman (@svovaf)
* @since 1.1.2
*
* @return bool
*/
static function is_valid_id($id){
return is_numeric($id);
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.1
*
* @return string
*/
public static function get_class_name() {
return get_called_class();
}
}

View File

@ -0,0 +1,168 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2016, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Payment extends FS_Entity {
#region Properties
/**
* @var number
*/
public $plugin_id;
/**
* @var number
*/
public $user_id;
/**
* @var number
*/
public $install_id;
/**
* @var number
*/
public $subscription_id;
/**
* @var number
*/
public $plan_id;
/**
* @var number
*/
public $license_id;
/**
* @var float
*/
public $gross;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var string One of the following: `usd`, `gbp`, `eur`.
*/
public $currency;
/**
* @var number
*/
public $bound_payment_id;
/**
* @var string
*/
public $external_id;
/**
* @var string
*/
public $gateway;
/**
* @var string ISO 3166-1 alpha-2 - two-letter country code.
*
* @link http://www.wikiwand.com/en/ISO_3166-1_alpha-2
*/
public $country_code;
/**
* @var string
*/
public $vat_id;
/**
* @var float Actual Tax / VAT in $$$
*/
public $vat;
/**
* @var int Payment source.
*/
public $source = 0;
#endregion Properties
const CURRENCY_USD = 'usd';
const CURRENCY_GBP = 'gbp';
const CURRENCY_EUR = 'eur';
/**
* @param object|bool $payment
*/
function __construct( $payment = false ) {
parent::__construct( $payment );
}
static function get_type() {
return 'payment';
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.0
*
* @return bool
*/
function is_refund() {
return ( parent::is_valid_id( $this->bound_payment_id ) && 0 > $this->gross );
}
/**
* Checks if the payment was migrated from another platform.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.2
*
* @return bool
*/
function is_migrated() {
return ( 0 != $this->source );
}
/**
* Returns the gross in this format:
* `{symbol}{amount | 2 decimal digits} {currency | uppercase}`
*
* Examples: £9.99 GBP, -£9.99 GBP.
*
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @return string
*/
function formatted_gross()
{
return (
( $this->gross < 0 ? '-' : '' ) .
$this->get_symbol() .
number_format( abs( $this->gross ), 2, '.', ',' ) . ' ' .
strtoupper( $this->currency )
);
}
/**
* A map between supported currencies with their symbols.
*
* @var array<string,string>
*/
static $CURRENCY_2_SYMBOL;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @return string
*/
private function get_symbol() {
if ( ! isset( self::$CURRENCY_2_SYMBOL ) ) {
// Lazy load.
self::$CURRENCY_2_SYMBOL = array(
self::CURRENCY_USD => '$',
self::CURRENCY_GBP => '&pound;',
self::CURRENCY_EUR => '&euro;',
);
}
return self::$CURRENCY_2_SYMBOL[ $this->currency ];
}
}

View File

@ -0,0 +1,34 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Plugin_Info extends FS_Entity {
public $plugin_id;
public $description;
public $short_description;
public $banner_url;
public $card_banner_url;
public $selling_point_0;
public $selling_point_1;
public $selling_point_2;
public $screenshots;
/**
* @param stdClass|bool $plugin_info
*/
function __construct( $plugin_info = false ) {
parent::__construct( $plugin_info );
}
static function get_type() {
return 'plugin';
}
}

View File

@ -0,0 +1,330 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.5
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Plugin_License
*/
class FS_Plugin_License extends FS_Entity {
#region Properties
/**
* @var number
*/
public $plugin_id;
/**
* @var number
*/
public $user_id;
/**
* @var number
*/
public $plan_id;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var string
*/
public $parent_plan_name;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var string
*/
public $parent_plan_title;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @var number
*/
public $parent_license_id;
/**
* @author Leo Fajardo (@leorw)
* @since 2.4.0
*
* @var array
*/
public $products;
/**
* @var number
*/
public $pricing_id;
/**
* @var int|null
*/
public $quota;
/**
* @var int
*/
public $activated;
/**
* @var int
*/
public $activated_local;
/**
* @var string
*/
public $expiration;
/**
* @var string
*/
public $secret_key;
/**
* @var bool
*/
public $is_whitelabeled;
/**
* @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same
* license.
*/
public $is_free_localhost;
/**
* @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only
* block updates and support.
*/
public $is_block_features;
/**
* @var bool
*/
public $is_cancelled;
#endregion Properties
/**
* @param stdClass|bool $license
*/
function __construct( $license = false ) {
parent::__construct( $license );
}
/**
* Get entity type.
*
* @return string
*/
static function get_type() {
return 'license';
}
/**
* Check how many site activations left.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.5
*
* @return int
*/
function left() {
if ( ! $this->is_features_enabled() ) {
return 0;
}
if ( $this->is_unlimited() ) {
return 999;
}
return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) );
}
/**
* Check if single site license.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8.1
*
* @return bool
*/
function is_single_site() {
return ( is_numeric( $this->quota ) && 1 == $this->quota );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.5
*
* @return bool
*/
function is_expired() {
return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME );
}
/**
* Check if license is not expired.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.1
*
* @return bool
*/
function is_valid() {
return ! $this->is_expired();
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @return bool
*/
function is_lifetime() {
return is_null( $this->expiration );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.0
*
* @return bool
*/
function is_unlimited() {
return is_null( $this->quota );
}
/**
* Check if license is fully utilized.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @param bool|null $is_localhost
*
* @return bool
*/
function is_utilized( $is_localhost = null ) {
if ( is_null( $is_localhost ) ) {
$is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER;
}
if ( $this->is_unlimited() ) {
return false;
}
return ! ( $this->is_free_localhost && $is_localhost ) &&
( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) );
}
/**
* Check if license can be activated.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param bool|null $is_localhost
*
* @return bool
*/
function can_activate( $is_localhost = null ) {
return ! $this->is_utilized( $is_localhost ) && $this->is_features_enabled();
}
/**
* Check if license can be activated on a given number of production and localhost sites.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param int $production_count
* @param int $localhost_count
*
* @return bool
*/
function can_activate_bulk( $production_count, $localhost_count ) {
if ( $this->is_unlimited() ) {
return true;
}
/**
* For simplicity, the logic will work as following: when given X sites to activate the license on, if it's
* possible to activate on ALL of them, do the activation. If it's not possible to activate on ALL of them,
* do NOT activate on any of them.
*/
return ( $this->quota >= $this->activated + $production_count + ( $this->is_free_localhost ? 0 : $this->activated_local + $localhost_count ) );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.2.1
*
* @return bool
*/
function is_active() {
return ( ! $this->is_cancelled );
}
/**
* Check if license's plan features are enabled.
*
* - Either if plan not expired
* - If expired, based on the configuration to block features or not.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @return bool
*/
function is_features_enabled() {
return $this->is_active() && ( ! $this->is_block_features || ! $this->is_expired() );
}
/**
* Subscription considered to be new without any payments
* if the license expires in less than 24 hours
* from the license creation.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_first_payment_pending() {
return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) );
}
/**
* @return int
*/
function total_activations() {
return ( $this->activated + $this->activated_local );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.3.1
*
* @return string
*/
function get_html_escaped_masked_secret_key() {
return self::mask_secret_key_for_html( $this->secret_key );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.3.1
*
* @param string $secret_key
*
* @return string
*/
static function mask_secret_key_for_html( $secret_key ) {
return (
// Initial 6 chars - sk_ABC
htmlspecialchars( substr( $secret_key, 0, 6 ) ) .
// Masking
str_pad( '', ( strlen( $secret_key ) - 9 ) * 6, '&bull;' ) .
// Last 3 chars.
htmlspecialchars( substr( $secret_key, - 3 ) )
);
}
}

View File

@ -0,0 +1,145 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.5
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class FS_Plugin_Plan
*
* @property FS_Pricing[] $pricing
*/
class FS_Plugin_Plan extends FS_Entity {
#region Properties
/**
* @var number
*/
public $plugin_id;
/**
* @var string
*/
public $name;
/**
* @var string
*/
public $title;
/**
* @var string
*/
public $description;
/**
* @var bool Defaults to true. If true, allow unlimited localhost installs with the same license.
*/
public $is_free_localhost;
/**
* @var bool Defaults to true. If false, don't block features after license expiry - only block updates and
* support.
*/
public $is_block_features;
/**
* @var int
*/
public $license_type;
/**
* @var bool
*/
public $is_https_support;
/**
* @var int Trial days.
*/
public $trial_period;
/**
* @var string If true, require payment for trial.
*/
public $is_require_subscription;
/**
* @var string Knowledge Base URL.
*/
public $support_kb;
/**
* @var string Support Forum URL.
*/
public $support_forum;
/**
* @var string Support email address.
*/
public $support_email;
/**
* @var string Support phone.
*/
public $support_phone;
/**
* @var string Support skype username.
*/
public $support_skype;
/**
* @var bool Is personal success manager supported with the plan.
*/
public $is_success_manager;
/**
* @var bool Is featured plan.
*/
public $is_featured;
#endregion Properties
/**
* @param object|bool $plan
*/
function __construct( $plan = false ) {
parent::__construct( $plan );
if ( is_object( $plan ) ) {
$this->name = strtolower( $plan->name );
}
}
static function get_type() {
return 'plan';
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_free() {
return ( 'free' === $this->name );
}
/**
* Checks if this plan supports "Technical Support".
*
* @author Leo Fajardo (leorw)
* @since 1.2.0
*
* @return bool
*/
function has_technical_support() {
return ( ! empty( $this->support_email ) ||
! empty( $this->support_skype ) ||
! empty( $this->support_phone ) ||
! empty( $this->is_success_manager )
);
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function has_trial() {
return ! $this->is_free() &&
is_numeric( $this->trial_period ) && ( $this->trial_period > 0 );
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2018, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 2.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Plugin_Tag extends FS_Entity {
/**
* @var string
*/
public $version;
/**
* @var string
*/
public $url;
/**
* @var string
*/
public $requires_platform_version;
/**
* @var string
*/
public $tested_up_to_version;
/**
* @var bool
*/
public $has_free;
/**
* @var bool
*/
public $has_premium;
/**
* @var string One of the following: `pending`, `beta`, `unreleased`.
*/
public $release_mode;
function __construct( $tag = false ) {
parent::__construct( $tag );
}
static function get_type() {
return 'tag';
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.0
*
* @return bool
*/
function is_beta() {
return ( 'beta' === $this->release_mode );
}
}

View File

@ -0,0 +1,159 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Plugin extends FS_Scope_Entity {
/**
* @since 1.0.6
* @var null|number
*/
public $parent_plugin_id;
/**
* @var string
*/
public $title;
/**
* @var string
*/
public $slug;
/**
* @author Leo Fajardo (@leorw)
* @since 2.2.1
*
* @var string
*/
public $premium_slug;
/**
* @since 1.2.2
*
* @var string 'plugin' or 'theme'
*/
public $type;
/**
* @author Leo Fajardo (@leorw)
*
* @since 1.2.3
*
* @var string|false false if the module doesn't have an affiliate program or one of the following: 'selected', 'customers', or 'all'.
*/
public $affiliate_moderation;
/**
* @var bool Set to true if the free version of the module is hosted on WordPress.org. Defaults to true.
*/
public $is_wp_org_compliant = true;
/**
* @author Leo Fajardo (@leorw)
* @since 2.2.5
*
* @var int
*/
public $premium_releases_count;
#region Install Specific Properties
/**
* @var string
*/
public $file;
/**
* @var string
*/
public $version;
/**
* @var bool
*/
public $auto_update;
/**
* @var FS_Plugin_Info
*/
public $info;
/**
* @since 1.0.9
*
* @var bool
*/
public $is_premium;
/**
* @author Leo Fajardo (@leorw)
* @since 2.2.1
*
* @var string
*/
public $premium_suffix;
/**
* @since 1.0.9
*
* @var bool
*/
public $is_live;
/**
* @since 2.2.3
* @var null|number
*/
public $bundle_id;
/**
* @since 2.3.1
* @var null|string
*/
public $bundle_public_key;
const AFFILIATE_MODERATION_CUSTOMERS = 'customers';
#endregion Install Specific Properties
/**
* @param stdClass|bool $plugin
*/
function __construct( $plugin = false ) {
parent::__construct( $plugin );
$this->is_premium = false;
$this->is_live = true;
if ( empty( $this->premium_slug ) && ! empty( $plugin->slug ) ) {
$this->premium_slug = "{$this->slug}-premium";
}
if ( empty( $this->premium_suffix ) ) {
$this->premium_suffix = '(Premium)';
}
if ( isset( $plugin->info ) && is_object( $plugin->info ) ) {
$this->info = new FS_Plugin_Info( $plugin->info );
}
}
/**
* Check if plugin is an add-on (has parent).
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @return bool
*/
function is_addon() {
return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id );
}
/**
* @author Leo Fajardo (@leorw)
* @since 1.2.3
*
* @return bool
*/
function has_affiliate_program() {
return ( ! empty( $this->affiliate_moderation ) );
}
static function get_type() {
return 'plugin';
}
}

View File

@ -0,0 +1,157 @@
<?php
/**
* @package Freemius for EDD Add-On
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Pricing extends FS_Entity {
#region Properties
/**
* @var number
*/
public $plan_id;
/**
* @var int
*/
public $licenses;
/**
* @var null|float
*/
public $monthly_price;
/**
* @var null|float
*/
public $annual_price;
/**
* @var null|float
*/
public $lifetime_price;
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.1
*
* @var string One of the following: `usd`, `gbp`, `eur`.
*/
public $currency;
#endregion Properties
/**
* @param object|bool $pricing
*/
function __construct( $pricing = false ) {
parent::__construct( $pricing );
}
static function get_type() {
return 'pricing';
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function has_monthly() {
return ( is_numeric( $this->monthly_price ) && $this->monthly_price > 0 );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function has_annual() {
return ( is_numeric( $this->annual_price ) && $this->annual_price > 0 );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function has_lifetime() {
return ( is_numeric( $this->lifetime_price ) && $this->lifetime_price > 0 );
}
/**
* Check if unlimited licenses pricing.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function is_unlimited() {
return is_null( $this->licenses );
}
/**
* Check if pricing has more than one billing cycle.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return bool
*/
function is_multi_cycle() {
$cycles = 0;
if ( $this->has_monthly() ) {
$cycles ++;
}
if ( $this->has_annual() ) {
$cycles ++;
}
if ( $this->has_lifetime() ) {
$cycles ++;
}
return $cycles > 1;
}
/**
* Get annual over monthly discount.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return int
*/
function annual_discount_percentage() {
return floor( $this->annual_savings() / ( $this->monthly_price * 12 * ( $this->is_unlimited() ? 1 : $this->licenses ) ) * 100 );
}
/**
* Get annual over monthly savings.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.8
*
* @return float
*/
function annual_savings() {
return ( $this->monthly_price * 12 - $this->annual_price ) * ( $this->is_unlimited() ? 1 : $this->licenses );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.3.1
*
* @return bool
*/
function is_usd() {
return ( 'usd' === $this->currency );
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.4
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Scope_Entity extends FS_Entity {
/**
* @var string
*/
public $public_key;
/**
* @var string
*/
public $secret_key;
/**
* @param bool|stdClass $scope_entity
*/
function __construct( $scope_entity = false ) {
parent::__construct( $scope_entity );
}
}

View File

@ -0,0 +1,253 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Site extends FS_Scope_Entity {
/**
* @var number
*/
public $site_id;
/**
* @var number
*/
public $plugin_id;
/**
* @var number
*/
public $user_id;
/**
* @var string
*/
public $title;
/**
* @var string
*/
public $url;
/**
* @var string
*/
public $version;
/**
* @var string E.g. en-GB
*/
public $language;
/**
* @var string E.g. UTF-8
*/
public $charset;
/**
* @var string Platform version (e.g WordPress version).
*/
public $platform_version;
/**
* Freemius SDK version
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*
* @var string SDK version (e.g.: 1.2.2)
*/
public $sdk_version;
/**
* @var string Programming language version (e.g PHP version).
*/
public $programming_language_version;
/**
* @var number|null
*/
public $plan_id;
/**
* @var number|null
*/
public $license_id;
/**
* @var number|null
*/
public $trial_plan_id;
/**
* @var string|null
*/
public $trial_ends;
/**
* @since 1.0.9
*
* @var bool
*/
public $is_premium = false;
/**
* @author Leo Fajardo (@leorw)
*
* @since 1.2.1.5
*
* @var bool
*/
public $is_disconnected = false;
/**
* @since 2.0.0
*
* @var bool
*/
public $is_active = true;
/**
* @since 2.0.0
*
* @var bool
*/
public $is_uninstalled = false;
/**
* @author Edgar Melkonyan
*
* @since 2.4.2
*
* @var bool
*/
public $is_beta;
/**
* @param stdClass|bool $site
*/
function __construct( $site = false ) {
parent::__construct( $site );
if ( is_object( $site ) ) {
$this->plan_id = $site->plan_id;
}
if ( ! is_bool( $this->is_disconnected ) ) {
$this->is_disconnected = false;
}
}
static function get_type() {
return 'install';
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $url
*
* @return bool
*/
static function is_localhost_by_address( $url ) {
if ( false !== strpos( $url, '127.0.0.1' ) ||
false !== strpos( $url, 'localhost' )
) {
return true;
}
if ( ! fs_starts_with( $url, 'http' ) ) {
$url = 'http://' . $url;
}
$url_parts = parse_url( $url );
$subdomain = $url_parts['host'];
return (
// Starts with.
fs_starts_with( $subdomain, 'local.' ) ||
fs_starts_with( $subdomain, 'dev.' ) ||
fs_starts_with( $subdomain, 'test.' ) ||
fs_starts_with( $subdomain, 'stage.' ) ||
fs_starts_with( $subdomain, 'staging.' ) ||
// Ends with.
fs_ends_with( $subdomain, '.dev' ) ||
fs_ends_with( $subdomain, '.test' ) ||
fs_ends_with( $subdomain, '.staging' ) ||
fs_ends_with( $subdomain, '.local' ) ||
fs_ends_with( $subdomain, '.example' ) ||
fs_ends_with( $subdomain, '.invalid' ) ||
// GoDaddy test/dev.
fs_ends_with( $subdomain, '.myftpupload.com' ) ||
// ngrok tunneling.
fs_ends_with( $subdomain, '.ngrok.io' ) ||
// wpsandbox.
fs_ends_with( $subdomain, '.wpsandbox.pro' ) ||
// SiteGround staging.
fs_starts_with( $subdomain, 'staging' ) ||
// WPEngine staging.
fs_ends_with( $subdomain, '.staging.wpengine.com' ) ||
fs_ends_with( $subdomain, '.dev.wpengine.com' ) ||
fs_ends_with( $subdomain, '.wpengine.com' ) ||
// Pantheon
( fs_ends_with( $subdomain, 'pantheonsite.io' ) &&
( fs_starts_with( $subdomain, 'test-' ) || fs_starts_with( $subdomain, 'dev-' ) ) ) ||
// Cloudways
fs_ends_with( $subdomain, '.cloudwaysapps.com' ) ||
// Kinsta
( fs_starts_with( $subdomain, 'staging-' ) && ( fs_ends_with( $subdomain, '.kinsta.com' ) || fs_ends_with( $subdomain, '.kinsta.cloud' ) ) ) ||
// DesktopServer
fs_ends_with( $subdomain, '.dev.cc' ) ||
// Pressable
fs_ends_with( $subdomain, '.mystagingwebsite.com' )
);
}
function is_localhost() {
return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
}
/**
* Check if site in trial.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_trial() {
return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
}
/**
* Check if user already utilized the trial with the current install.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_trial_utilized() {
return is_numeric( $this->trial_plan_id );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @return bool
*/
function is_tracking_allowed() {
return ( true !== $this->is_disconnected );
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @return bool
*/
function is_tracking_prohibited() {
return ! $this->is_tracking_allowed();
}
/**
* @author Edgar Melkonyan
*
* @return bool
*/
function is_beta() {
return ( isset( $this->is_beta ) && true === $this->is_beta );
}
}

View File

@ -0,0 +1,147 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.9
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Subscription extends FS_Entity {
#region Properties
/**
* @var number
*/
public $user_id;
/**
* @var number
*/
public $install_id;
/**
* @var number
*/
public $plan_id;
/**
* @var number
*/
public $license_id;
/**
* @var float
*/
public $total_gross;
/**
* @var float
*/
public $amount_per_cycle;
/**
* @var int # of months
*/
public $billing_cycle;
/**
* @var float
*/
public $outstanding_balance;
/**
* @var int
*/
public $failed_payments;
/**
* @var string
*/
public $gateway;
/**
* @var string
*/
public $external_id;
/**
* @var string|null
*/
public $trial_ends;
/**
* @var string|null Datetime of the next payment, or null if cancelled.
*/
public $next_payment;
/**
* @since 2.3.1
*
* @var string|null Datetime of the cancellation.
*/
public $canceled_at;
/**
* @var string|null
*/
public $vat_id;
/**
* @var string Two characters country code
*/
public $country_code;
#endregion Properties
/**
* @param object|bool $subscription
*/
function __construct( $subscription = false ) {
parent::__construct( $subscription );
}
static function get_type() {
return 'subscription';
}
/**
* Check if subscription is active.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_active() {
if ( $this->is_canceled() ) {
return false;
}
return (
! empty( $this->next_payment ) &&
strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME
);
}
/**
* @author Vova Feldman (@svovaf)
* @since 2.3.1
*
* @return bool
*/
function is_canceled() {
return ! is_null( $this->canceled_at );
}
/**
* Subscription considered to be new without any payments
* if the next payment should be made within less than 24 hours
* from the subscription creation.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @return bool
*/
function is_first_payment_pending() {
return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.7
*/
function has_trial() {
return ! is_null( $this->trial_ends );
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_User extends FS_Scope_Entity {
#region Properties
/**
* @var string
*/
public $email;
/**
* @var string
*/
public $first;
/**
* @var string
*/
public $last;
/**
* @var bool
*/
public $is_verified;
/**
* @var string|null
*/
public $customer_id;
/**
* @var float
*/
public $gross;
#endregion Properties
/**
* @param object|bool $user
*/
function __construct( $user = false ) {
parent::__construct( $user );
}
function get_name() {
return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) );
}
function is_verified() {
return ( isset( $this->is_verified ) && true === $this->is_verified );
}
static function get_type() {
return 'user';
}
}

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,500 @@
<?php
/**
* IMPORTANT:
* This file will be loaded based on the order of the plugins/themes load.
* If there's a theme and a plugin using Freemius, the plugin's essential
* file will always load first.
*
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.1.5
*/
if ( ! function_exists( 'fs_normalize_path' ) ) {
if ( function_exists( 'wp_normalize_path' ) ) {
/**
* Normalize a filesystem path.
*
* Replaces backslashes with forward slashes for Windows systems, and ensures
* no duplicate slashes exist.
*
* @param string $path Path to normalize.
*
* @return string Normalized path.
*/
function fs_normalize_path( $path ) {
return wp_normalize_path( $path );
}
} else {
function fs_normalize_path( $path ) {
$path = str_replace( '\\', '/', $path );
$path = preg_replace( '|/+|', '/', $path );
return $path;
}
}
}
require_once dirname( __FILE__ ) . '/supplements/fs-essential-functions-2.2.1.php';
#region Core Redirect (copied from BuddyPress) -----------------------------------------
if ( ! function_exists( 'fs_redirect' ) ) {
/**
* Redirects to another page, with a workaround for the IIS Set-Cookie bug.
*
* @link http://support.microsoft.com/kb/q176113/
* @since 1.5.1
* @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
*
* @param string $location The path to redirect to.
* @param bool $exit If true, exit after redirect (Since 1.2.1.5).
* @param int $status Status code to use.
*
* @return bool False if $location is not set
*/
function fs_redirect( $location, $exit = true, $status = 302 ) {
global $is_IIS;
$file = '';
$line = '';
if ( headers_sent($file, $line) ) {
if ( WP_FS__DEBUG_SDK && class_exists( 'FS_Admin_Notices' ) ) {
$notices = FS_Admin_Notices::instance( 'global' );
$notices->add( "Freemius failed to redirect the page because the headers have been already sent from line <b><code>{$line}</code></b> in file <b><code>{$file}</code></b>. If it's unexpected, it usually happens due to invalid space and/or EOL character(s).", 'Oops...', 'error' );
}
return false;
}
if ( defined( 'DOING_AJAX' ) ) {
// Don't redirect on AJAX calls.
return false;
}
if ( ! $location ) // allows the wp_redirect filter to cancel a redirect
{
return false;
}
$location = fs_sanitize_redirect( $location );
if ( $is_IIS ) {
header( "Refresh: 0;url=$location" );
} else {
if ( php_sapi_name() != 'cgi-fcgi' ) {
status_header( $status );
} // This causes problems on IIS and some FastCGI setups
header( "Location: $location" );
}
if ( $exit ) {
exit();
}
return true;
}
if ( ! function_exists( 'fs_sanitize_redirect' ) ) {
/**
* Sanitizes a URL for use in a redirect.
*
* @since 2.3
*
* @param string $location
*
* @return string redirect-sanitized URL
*/
function fs_sanitize_redirect( $location ) {
$location = preg_replace( '|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location );
$location = fs_kses_no_null( $location );
// remove %0d and %0a from location
$strip = array( '%0d', '%0a' );
$found = true;
while ( $found ) {
$found = false;
foreach ( (array) $strip as $val ) {
while ( strpos( $location, $val ) !== false ) {
$found = true;
$location = str_replace( $val, '', $location );
}
}
}
return $location;
}
}
if ( ! function_exists( 'fs_kses_no_null' ) ) {
/**
* Removes any NULL characters in $string.
*
* @since 1.0.0
*
* @param string $string
*
* @return string
*/
function fs_kses_no_null( $string ) {
$string = preg_replace( '/\0+/', '', $string );
$string = preg_replace( '/(\\\\0)+/', '', $string );
return $string;
}
}
}
#endregion Core Redirect (copied from BuddyPress) -----------------------------------------
if ( ! function_exists( '__fs' ) ) {
global $fs_text_overrides;
if ( ! isset( $fs_text_overrides ) ) {
$fs_text_overrides = array();
}
/**
* Retrieve a translated text by key.
*
* @deprecated Use `fs_text()` instead since methods starting with `__` trigger warnings in Php 7.
* @todo Remove this method in the future.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.4
*
* @param string $key
* @param string $slug
*
* @return string
*
* @global $fs_text, $fs_text_overrides
*/
function __fs( $key, $slug = 'freemius' ) {
_deprecated_function( __FUNCTION__, '2.0.0', 'fs_text()' );
global $fs_text,
$fs_module_info_text,
$fs_text_overrides;
if ( isset( $fs_text_overrides[ $slug ] ) ) {
if ( isset( $fs_text_overrides[ $slug ][ $key ] ) ) {
return $fs_text_overrides[ $slug ][ $key ];
}
$lower_key = strtolower( $key );
if ( isset( $fs_text_overrides[ $slug ][ $lower_key ] ) ) {
return $fs_text_overrides[ $slug ][ $lower_key ];
}
}
if ( ! isset( $fs_text ) ) {
$dir = defined( 'WP_FS__DIR_INCLUDES' ) ?
WP_FS__DIR_INCLUDES :
dirname( __FILE__ );
require_once $dir . '/i18n.php';
}
if ( isset( $fs_text[ $key ] ) ) {
return $fs_text[ $key ];
}
if ( isset( $fs_module_info_text[ $key ] ) ) {
return $fs_module_info_text[ $key ];
}
return $key;
}
/**
* Output a translated text by key.
*
* @deprecated Use `fs_echo()` instead for consistency with `fs_text()`.
*
* @todo Remove this method in the future.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.4
*
* @param string $key
* @param string $slug
*/
function _efs( $key, $slug = 'freemius' ) {
fs_echo( $key, $slug );
}
}
if ( ! function_exists( 'fs_get_ip' ) ) {
/**
* Get client IP.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.2
*
* @return string|null
*/
function fs_get_ip() {
$fields = array(
'HTTP_CF_CONNECTING_IP',
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_FORWARDED_FOR',
'HTTP_FORWARDED',
'REMOTE_ADDR',
);
foreach ( $fields as $ip_field ) {
if ( ! empty( $_SERVER[ $ip_field ] ) ) {
return $_SERVER[ $ip_field ];
}
}
return null;
}
}
/**
* Leverage backtrace to find caller plugin main file path.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.6
*
* @return string
*/
function fs_find_caller_plugin_file() {
/**
* All the code below will be executed once on activation.
* If the user changes the main plugin's file name, the file_exists()
* will catch it.
*/
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$all_plugins = fs_get_plugins( true );
$all_plugins_paths = array();
// Get active plugin's main files real full names (might be symlinks).
foreach ( $all_plugins as $relative_path => $data ) {
$all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
}
$plugin_file = null;
for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
if ( empty( $bt[ $i ]['file'] ) ) {
continue;
}
if ( in_array( fs_normalize_path( $bt[ $i ]['file'] ), $all_plugins_paths ) ) {
$plugin_file = $bt[ $i ]['file'];
break;
}
}
if ( is_null( $plugin_file ) ) {
// Throw an error to the developer in case of some edge case dev environment.
wp_die(
'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.',
'Error',
array( 'back_link' => true )
);
}
return $plugin_file;
}
require_once dirname( __FILE__ ) . '/supplements/fs-essential-functions-1.1.7.1.php';
/**
* Update SDK newest version reference.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $sdk_relative_path
* @param string|bool $plugin_file
*
* @global $fs_active_plugins
*/
function fs_update_sdk_newest_version( $sdk_relative_path, $plugin_file = false ) {
/**
* If there is a plugin running an older version of FS (1.2.1 or below), the `fs_update_sdk_newest_version()`
* function in the older version will be used instead of this one. But since the older version is using
* the `is_plugin_active` function to check if a plugin is active, passing the theme's `plugin_path` to the
* `is_plugin_active` function will return false since the path is not a plugin path, so `in_activation` will be
* `true` for theme modules and the upgrading of the SDK version to 1.2.2 or newer version will work fine.
*
* Future versions that will call this function will use the proper logic here instead of just relying on the
* `is_plugin_active` function to fail for themes.
*
* @author Leo Fajardo (@leorw)
* @since 1.2.2
*/
global $fs_active_plugins;
$newest_sdk = $fs_active_plugins->plugins[ $sdk_relative_path ];
if ( ! is_string( $plugin_file ) ) {
$plugin_file = plugin_basename( fs_find_caller_plugin_file() );
}
if ( ! isset( $newest_sdk->type ) || 'theme' !== $newest_sdk->type ) {
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$in_activation = ( ! is_plugin_active( $plugin_file ) );
} else {
$theme = wp_get_theme();
$in_activation = ( $newest_sdk->plugin_path == $theme->stylesheet );
}
$fs_active_plugins->newest = (object) array(
'plugin_path' => $plugin_file,
'sdk_path' => $sdk_relative_path,
'version' => $newest_sdk->version,
'in_activation' => $in_activation,
'timestamp' => time(),
);
// Update DB with latest SDK version and path.
update_option( 'fs_active_plugins', $fs_active_plugins );
}
/**
* Reorder the plugins load order so the plugin with the newest Freemius SDK is loaded first.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @return bool Was plugin order changed. Return false if plugin was loaded first anyways.
*
* @global $fs_active_plugins
*/
function fs_newest_sdk_plugin_first() {
global $fs_active_plugins;
/**
* @todo Multi-site network activated plugin are always loaded prior to site plugins so if there's a plugin activated in the network mode that has an older version of the SDK of another plugin which is site activated that has new SDK version, the fs-essential-functions.php will be loaded from the older SDK. Same thing about MU plugins (loaded even before network activated plugins).
*
* @link https://github.com/Freemius/wordpress-sdk/issues/26
*/
$newest_sdk_plugin_path = $fs_active_plugins->newest->plugin_path;
$active_plugins = get_option( 'active_plugins', array() );
$updated_active_plugins = array( $newest_sdk_plugin_path );
$plugin_found = false;
$is_first_path = true;
foreach ( $active_plugins as $key => $plugin_path ) {
if ( $plugin_path === $newest_sdk_plugin_path ) {
if ( $is_first_path ) {
// if it's the first plugin already, no need to continue
return false;
}
$plugin_found = true;
// Skip the plugin (it is already added as the 1st item of $updated_active_plugins).
continue;
}
$updated_active_plugins[] = $plugin_path;
if ( $is_first_path ) {
$is_first_path = false;
}
}
if ( $plugin_found ) {
update_option( 'active_plugins', $updated_active_plugins );
return true;
}
if ( is_multisite() ) {
// Plugin is network active.
$network_active_plugins = get_site_option( 'active_sitewide_plugins', array() );
if ( isset( $network_active_plugins[ $newest_sdk_plugin_path ] ) ) {
reset( $network_active_plugins );
if ( $newest_sdk_plugin_path === key( $network_active_plugins ) ) {
// Plugin is already activated first on the network level.
return false;
} else {
$time = $network_active_plugins[ $newest_sdk_plugin_path ];
// Remove plugin from its current position.
unset( $network_active_plugins[ $newest_sdk_plugin_path ] );
// Set it to be included first.
$network_active_plugins = array( $newest_sdk_plugin_path => $time ) + $network_active_plugins;
update_site_option( 'active_sitewide_plugins', $network_active_plugins );
return true;
}
}
}
return false;
}
/**
* Go over all Freemius SDKs in the system and find and "remember"
* the newest SDK which is associated with an active plugin.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @global $fs_active_plugins
*/
function fs_fallback_to_newest_active_sdk() {
global $fs_active_plugins;
/**
* @var object $newest_sdk_data
*/
$newest_sdk_data = null;
$newest_sdk_path = null;
foreach ( $fs_active_plugins->plugins as $sdk_relative_path => $data ) {
if ( is_null( $newest_sdk_data ) || version_compare( $data->version, $newest_sdk_data->version, '>' )
) {
// If plugin inactive or SDK starter file doesn't exist, remove SDK reference.
if ( 'plugin' === $data->type ) {
$is_module_active = is_plugin_active( $data->plugin_path );
} else {
$active_theme = wp_get_theme();
$is_module_active = ( $data->plugin_path === $active_theme->get_template() );
}
$is_sdk_exists = file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $sdk_relative_path . '/start.php' ) );
if ( ! $is_module_active || ! $is_sdk_exists ) {
unset( $fs_active_plugins->plugins[ $sdk_relative_path ] );
// No need to store the data since it will be stored in fs_update_sdk_newest_version()
// or explicitly with update_option().
} else {
$newest_sdk_data = $data;
$newest_sdk_path = $sdk_relative_path;
}
}
}
if ( is_null( $newest_sdk_data ) ) {
// Couldn't find any SDK reference.
$fs_active_plugins = new stdClass();
update_option( 'fs_active_plugins', $fs_active_plugins );
} else {
fs_update_sdk_newest_version( $newest_sdk_path, $newest_sdk_data->plugin_path );
}
}

View File

@ -0,0 +1,605 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.1.4
*
* @deprecated This file is no longer in use. It's still in the project for backward compatibility.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once dirname( __FILE__ ) . '/l10n.php';
/**
* All strings can now be overridden.
*
* For example, if we want to override:
* 'you-are-step-away' => 'You are just one step away - %s',
*
* We can use the filter:
* fs_override_i18n( array(
* 'opt-in-connect' => __( "Yes - I'm in!", '{your-text_domain}' ),
* 'skip' => __( 'Not today', '{your-text_domain}' ),
* ), '{plugin_slug}' );
*
* Or with the Freemius instance:
*
* my_freemius->override_i18n( array(
* 'opt-in-connect' => __( "Yes - I'm in!", '{your-text_domain}' ),
* 'skip' => __( 'Not today', '{your-text_domain}' ),
* ) );
*/
global $fs_text;
$fs_text = array(
'account' => _fs_text( 'Account' ),
'addon' => _fs_text( 'Add-On' ),
'contact-us' => _fs_text( 'Contact Us' ),
'contact-support' => _fs_text( 'Contact Support' ),
'change-ownership' => _fs_text( 'Change Ownership' ),
'support' => _fs_text( 'Support' ),
'support-forum' => _fs_text( 'Support Forum' ),
'add-ons' => _fs_text( 'Add-Ons' ),
'upgrade' => _fs_x( 'Upgrade', 'verb' ),
'awesome' => _fs_text( 'Awesome' ),
'pricing' => _fs_x( 'Pricing', 'noun' ),
'price' => _fs_x( 'Price', 'noun' ),
'unlimited-updates' => _fs_text( 'Unlimited Updates' ),
'downgrade' => _fs_x( 'Downgrade', 'verb' ),
'cancel-subscription' => _fs_x( 'Cancel Subscription', 'verb' ),
'cancel-trial' => _fs_text( 'Cancel Trial' ),
'free-trial' => _fs_text( 'Free Trial' ),
'start-free-x' => _fs_text( 'Start my free %s' ),
'no-commitment-x' => _fs_text( 'No commitment for %s - cancel anytime' ),
'after-x-pay-as-little-y' => _fs_text( 'After your free %s, pay as little as %s' ),
'details' => _fs_text( 'Details' ),
'account-details' => _fs_text( 'Account Details' ),
'delete' => _fs_x( 'Delete', 'verb' ),
'show' => _fs_x( 'Show', 'verb' ),
'hide' => _fs_x( 'Hide', 'verb' ),
'edit' => _fs_x( 'Edit', 'verb' ),
'update' => _fs_x( 'Update', 'verb' ),
'date' => _fs_text( 'Date' ),
'amount' => _fs_text( 'Amount' ),
'invoice' => _fs_text( 'Invoice' ),
'billing' => _fs_text( 'Billing' ),
'payments' => _fs_text( 'Payments' ),
'delete-account' => _fs_text( 'Delete Account' ),
'dismiss' => _fs_x( 'Dismiss', 'as close a window' ),
'plan' => _fs_x( 'Plan', 'as product pricing plan' ),
'change-plan' => _fs_text( 'Change Plan' ),
'download-x-version' => _fs_x( 'Download %s Version', 'as download professional version' ),
'download-x-version-now' => _fs_x( 'Download %s version now', 'as download professional version now' ),
'download-latest' => _fs_x( 'Download Latest', 'as download latest version' ),
'you-have-x-license' => _fs_x( 'You have a %s license.', 'E.g. you have a professional license.' ),
'new' => _fs_text( 'New' ),
'free' => _fs_text( 'Free' ),
'trial' => _fs_x( 'Trial', 'as trial plan' ),
'start-trial' => _fs_x( 'Start Trial', 'as starting a trial plan' ),
'purchase' => _fs_x( 'Purchase', 'verb' ),
'purchase-license' => _fs_text( 'Purchase License' ),
'buy' => _fs_x( 'Buy', 'verb' ),
'buy-license' => _fs_text( 'Buy License' ),
'license-single-site' => _fs_text( 'Single Site License' ),
'license-unlimited' => _fs_text( 'Unlimited Licenses' ),
'license-x-sites' => _fs_text( 'Up to %s Sites' ),
'renew-license-now' => _fs_text( '%sRenew your license now%s to access version %s security & feature updates, and support.' ),
'ask-for-upgrade-email-address' => _fs_text( "Enter the email address you've used for the upgrade below and we will resend you the license key." ),
'x-plan' => _fs_x( '%s Plan', 'e.g. Professional Plan' ),
'you-are-step-away' => _fs_text( 'You are just one step away - %s' ),
'activate-x-now' => _fs_x( 'Complete "%s" Activation Now',
'%s - plugin name. As complete "Jetpack" activation now' ),
'few-plugin-tweaks' => _fs_text( 'We made a few tweaks to the %s, %s' ),
'optin-x-now' => _fs_text( 'Opt in to make "%s" better!' ),
'error' => _fs_text( 'Error' ),
'failed-finding-main-path' => _fs_text( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.' ),
'learn-more' => _fs_text( 'Learn more' ),
'license_not_whitelabeled' => _fs_text( "Is this your client's site? %s if you wish to hide sensitive info like your billing address and invoices from the WP Admin."),
'license_whitelabeled' => _fs_text( 'Your %s license was flagged as white-labeled to hide sensitive information from the WP Admin (e.g. your billing address and invoices). If you ever wish to revert it back, you can easily do it through your %s. If this was a mistake you can also %s.'),
#region Affiliation
'affiliation' => _fs_text( 'Affiliation' ),
'affiliate' => _fs_text( 'Affiliate' ),
'affiliate-tracking' => _fs_text( '%s tracking cookie after the first visit to maximize earnings potential.' ),
'renewals-commission' => _fs_text( 'Get commission for automated subscription renewals.' ),
'affiliate-application-accepted' => _fs_text( "Your affiliate application for %s has been accepted! Log in to your affiliate area at: %s." ),
'affiliate-application-thank-you' => _fs_text( "Thank you for applying for our affiliate program, we'll review your details during the next 14 days and will get back to you with further information." ),
'affiliate-application-rejected' => _fs_text( "Thank you for applying for our affiliate program, unfortunately, we've decided at this point to reject your application. Please try again in 30 days." ),
'affiliate-account-suspended' => _fs_text( 'Your affiliation account was temporarily suspended.' ),
'affiliate-account-blocked' => _fs_text( 'Due to violation of our affiliation terms, we decided to temporarily block your affiliation account. If you have any questions, please contact support.' ),
'become-an-ambassador' => _fs_text( 'Like the %s? Become our ambassador and earn cash ;-)' ),
'become-an-ambassador-admin-notice' => _fs_text( 'Hey there, did you know that %s has an affiliate program? If you like the %s you can become our ambassador and earn some cash!' ),
'refer-new-customers' => _fs_text( 'Refer new customers to our %s and earn %s commission on each successful sale you refer!' ),
'program-summary' => _fs_text( 'Program Summary' ),
'commission-on-new-license-purchase' => _fs_text( '%s commission when a customer purchases a new license.' ),
'unlimited-commissions' => _fs_text( 'Unlimited commissions.' ),
'minimum-payout-amount' => _fs_text( '%s minimum payout amount.' ),
'payouts-unit-and-processing' => _fs_text( 'Payouts are in USD and processed monthly via PayPal.' ),
'commission-payment' => _fs_text( 'As we reserve 30 days for potential refunds, we only pay commissions that are older than 30 days.' ),
'become-an-affiliate' => _fs_text( 'Become an affiliate' ),
'apply-to-become-an-affiliate' => _fs_text( 'Apply to become an affiliate' ),
'full-name' => _fs_text( 'Full name' ),
'paypal-account-email-address' => _fs_text( 'PayPal account email address' ),
'promotion-methods' => _fs_text( 'Promotion methods' ),
'social-media' => _fs_text( 'Social media (Facebook, Twitter, etc.)' ),
'mobile-apps' => _fs_text( 'Mobile apps' ),
'statistics-information-field-label' => _fs_text( 'Website, email, and social media statistics (optional)' ),
'statistics-information-field-desc' => _fs_text( 'Please feel free to provide any relevant website or social media statistics, e.g. monthly unique site visits, number of email subscribers, followers, etc. (we will keep this information confidential).' ),
'promotion-method-desc-field-label' => _fs_text( 'How will you promote us?' ),
'promotion-method-desc-field-desc' => _fs_text( 'Please provide details on how you intend to promote %s (please be as specific as possible).' ),
'domain-field-label' => _fs_text( 'Where are you going to promote the %s?' ),
'domain-field-desc' => _fs_text( 'Enter the domain of your website or other websites from where you plan to promote the %s.' ),
'extra-domain-fields-label' => _fs_text( 'Extra Domains' ),
'extra-domain-fields-desc' => _fs_text( 'Extra domains where you will be marketing the product from.' ),
'add-another-domain' => _fs_text( 'Add another domain' ),
'remove' => _fs_x( 'Remove', 'Remove domain' ),
'email-address-is-required' => _fs_text( 'Email address is required.' ),
'domain-is-required' => _fs_text( 'Domain is required.' ),
'invalid-domain' => _fs_text( 'Invalid domain' ),
'paypal-email-address-is-required' => _fs_text( 'PayPal email address is required.' ),
'processing' => _fs_text( 'Processing...' ),
'non-expiring' => _fs_text( 'Non-expiring' ),
'account-is-pending-activation' => _fs_text( 'Account is pending activation.' ),
#endregion Affiliation
#region Account
'expiration' => _fs_x( 'Expiration', 'as expiration date' ),
'license' => _fs_x( 'License', 'as software license' ),
'not-verified' => _fs_text( 'not verified' ),
'verify-email' => _fs_text( 'Verify Email' ),
'expires-in' => _fs_x( 'Expires in %s', 'e.g. expires in 2 months' ),
'renews-in' => _fs_x( 'Auto renews in %s', 'e.g. auto renews in 2 months' ),
'no-expiration' => _fs_text( 'No expiration' ),
'expired' => _fs_text( 'Expired' ),
'cancelled' => _fs_text( 'Cancelled' ),
'in-x' => _fs_x( 'In %s', 'e.g. In 2 hours' ),
'x-ago' => _fs_x( '%s ago', 'e.g. 2 min ago' ),
/* translators: %s: Version number (e.g. 4.6 or higher) */
'x-or-higher' => _fs_text( '%s or higher' ),
'version' => _fs_x( 'Version', 'as plugin version' ),
'name' => _fs_text( 'Name' ),
'email' => _fs_text( 'Email' ),
'email-address' => _fs_text( 'Email address' ),
'verified' => _fs_text( 'Verified' ),
'module' => _fs_text( 'Module' ),
'module-type' => _fs_text( 'Module Type' ),
'plugin' => _fs_text( 'Plugin' ),
'plugins' => _fs_text( 'Plugins' ),
'theme' => _fs_text( 'Theme' ),
'themes' => _fs_text( 'Themes' ),
'path' => _fs_x( 'Path', 'as file/folder path' ),
'title' => _fs_text( 'Title' ),
'free-version' => _fs_text( 'Free version' ),
'premium-version' => _fs_text( 'Premium version' ),
'slug' => _fs_x( 'Slug', 'as WP plugin slug' ),
'id' => _fs_text( 'ID' ),
'users' => _fs_text( 'Users' ),
'module-installs' => _fs_text( '%s Installs' ),
'sites' => _fs_x( 'Sites', 'like websites' ),
'user-id' => _fs_text( 'User ID' ),
'site-id' => _fs_text( 'Site ID' ),
'public-key' => _fs_text( 'Public Key' ),
'secret-key' => _fs_text( 'Secret Key' ),
'no-secret' => _fs_x( 'No Secret', 'as secret encryption key missing' ),
'no-id' => _fs_text( 'No ID' ),
'sync-license' => _fs_x( 'Sync License', 'as synchronize license' ),
'sync' => _fs_x( 'Sync', 'as synchronize' ),
'activate-license' => _fs_text( 'Activate License' ),
'activate-free-version' => _fs_text( 'Activate Free Version' ),
'activate-license-message' => _fs_text( 'Please enter the license key that you received in the email right after the purchase:' ),
'activating-license' => _fs_text( 'Activating license...' ),
'change-license' => _fs_text( 'Change License' ),
'update-license' => _fs_text( 'Update License' ),
'deactivate-license' => _fs_text( 'Deactivate License' ),
'activate' => _fs_text( 'Activate' ),
'deactivate' => _fs_text( 'Deactivate' ),
'skip-deactivate' => _fs_text( 'Skip & Deactivate' ),
'skip-and-x' => _fs_text( 'Skip & %s' ),
'no-deactivate' => _fs_text( 'No - just deactivate' ),
'yes-do-your-thing' => _fs_text( 'Yes - do your thing' ),
'active' => _fs_x( 'Active', 'active mode' ),
'is-active' => _fs_x( 'Is Active', 'is active mode?' ),
'install-now' => _fs_text( 'Install Now' ),
'install-update-now' => _fs_text( 'Install Update Now' ),
'more-information-about-x' => _fs_text( 'More information about %s' ),
'localhost' => _fs_text( 'Localhost' ),
'activate-x-plan' => _fs_x( 'Activate %s Plan', 'as activate Professional plan' ),
'x-left' => _fs_x( '%s left', 'as 5 licenses left' ),
'last-license' => _fs_text( 'Last license' ),
'what-is-your-x' => _fs_text( 'What is your %s?' ),
'activate-this-addon' => _fs_text( 'Activate this add-on' ),
'deactivate-license-confirm' => _fs_text( 'Deactivating your license will block all premium features, but will enable you to activate the license on another site. Are you sure you want to proceed?' ),
'delete-account-x-confirm' => _fs_text( 'Deleting the account will automatically deactivate your %s plan license so you can use it on other sites. If you want to terminate the recurring payments as well, click the "Cancel" button, and first "Downgrade" your account. Are you sure you would like to continue with the deletion?' ),
'delete-account-confirm' => _fs_text( 'Deletion is not temporary. Only delete if you no longer want to use this %s anymore. Are you sure you would like to continue with the deletion?' ),
'downgrade-x-confirm' => _fs_text( 'Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s.' ),
'cancel-trial-confirm' => _fs_text( 'Cancelling the trial will immediately block access to all premium features. Are you sure?' ),
'after-downgrade-non-blocking' => _fs_text( 'You can still enjoy all %s features but you will not have access to %s security & feature updates, nor support.' ),
'after-downgrade-blocking' => _fs_text( 'Once your license expires you can still use the Free version but you will NOT have access to the %s features.' ),
'proceed-confirmation' => _fs_text( 'Are you sure you want to proceed?' ),
#endregion Account
'add-ons-for-x' => _fs_text( 'Add Ons for %s' ),
'add-ons-missing' => _fs_text( 'We could\'nt load the add-ons list. It\'s probably an issue on our side, please try to come back in few minutes.' ),
#region Plugin Deactivation
'anonymous-feedback' => _fs_text( 'Anonymous feedback' ),
'quick-feedback' => _fs_text( 'Quick feedback' ),
'deactivation-share-reason' => _fs_text( 'If you have a moment, please let us know why you are %s' ),
'deactivating' => _fs_text( 'deactivating' ),
'deactivation' => _fs_text( 'Deactivation' ),
'theme-switch' => _fs_text( 'Theme Switch' ),
'switching' => _fs_text( 'switching' ),
'switch' => _fs_text( 'Switch' ),
'activate-x' => _fs_text( 'Activate %s' ),
'deactivation-modal-button-confirm' => _fs_text( 'Yes - %s' ),
'deactivation-modal-button-submit' => _fs_text( 'Submit & %s' ),
'cancel' => _fs_text( 'Cancel' ),
'reason-no-longer-needed' => _fs_text( 'I no longer need the %s' ),
'reason-found-a-better-plugin' => _fs_text( 'I found a better %s' ),
'reason-needed-for-a-short-period' => _fs_text( 'I only needed the %s for a short period' ),
'reason-broke-my-site' => _fs_text( 'The %s broke my site' ),
'reason-suddenly-stopped-working' => _fs_text( 'The %s suddenly stopped working' ),
'reason-cant-pay-anymore' => _fs_text( "I can't pay for it anymore" ),
'reason-temporary-deactivation' => _fs_text( "It's a temporary deactivation. I'm just debugging an issue." ),
'reason-temporary-x' => _fs_text( "It's a temporary %s. I'm just debugging an issue." ),
'reason-other' => _fs_x( 'Other',
'the text of the "other" reason for deactivating the module that is shown in the modal box.' ),
'ask-for-reason-message' => _fs_text( 'Kindly tell us the reason so we can improve.' ),
'placeholder-plugin-name' => _fs_text( "What's the %s's name?" ),
'placeholder-comfortable-price' => _fs_text( 'What price would you feel comfortable paying?' ),
'reason-couldnt-make-it-work' => _fs_text( "I couldn't understand how to make it work" ),
'reason-great-but-need-specific-feature' => _fs_text( "The %s is great, but I need specific feature that you don't support" ),
'reason-not-working' => _fs_text( 'The %s is not working' ),
'reason-not-what-i-was-looking-for' => _fs_text( "It's not what I was looking for" ),
'reason-didnt-work-as-expected' => _fs_text( "The %s didn't work as expected" ),
'placeholder-feature' => _fs_text( 'What feature?' ),
'placeholder-share-what-didnt-work' => _fs_text( "Kindly share what didn't work so we can fix it for future users..." ),
'placeholder-what-youve-been-looking-for' => _fs_text( "What you've been looking for?" ),
'placeholder-what-did-you-expect' => _fs_text( "What did you expect?" ),
'reason-didnt-work' => _fs_text( "The %s didn't work" ),
'reason-dont-like-to-share-my-information' => _fs_text( "I don't like to share my information with you" ),
'dont-have-to-share-any-data' => _fs_text( "You might have missed it, but you don't have to share any data and can just %s the opt-in." ),
#endregion Plugin Deactivation
#region Connect
'hey-x' => _fs_x( 'Hey %s,', 'greeting' ),
'thanks-x' => _fs_x( 'Thanks %s!', 'a greeting. E.g. Thanks John!' ),
'connect-message' => _fs_text( 'Never miss an important update - opt in to our security and feature updates notifications, and non-sensitive diagnostic tracking with %4$s.' ),
'connect-message_on-update' => _fs_text( 'Please help us improve %1$s! If you opt in, some data about your usage of %1$s will be sent to %4$s. If you skip this, that\'s okay! %1$s will still work just fine.' ),
'pending-activation-message' => _fs_text( 'You should receive an activation email for %s to your mailbox at %s. Please make sure you click the activation button in that email to %s.' ),
'complete-the-install' => _fs_text( 'complete the install' ),
'start-the-trial' => _fs_text( 'start the trial' ),
'thanks-for-purchasing' => _fs_text( 'Thanks for purchasing %s! To get started, please enter your license key:' ),
'license-sync-disclaimer' => _fs_text( 'The %1$s will be periodically sending data to %2$s to check for security and feature updates, and verify the validity of your license.' ),
'what-permissions' => _fs_text( 'What permissions are being granted?' ),
'permissions-profile' => _fs_text( 'Your Profile Overview' ),
'permissions-profile_desc' => _fs_text( 'Name and email address' ),
'permissions-site' => _fs_text( 'Your Site Overview' ),
'permissions-site_desc' => _fs_text( 'Site URL, WP version, PHP info, plugins & themes' ),
'permissions-events' => _fs_text( 'Current %s Events' ),
'permissions-events_desc' => _fs_text( 'Activation, deactivation and uninstall' ),
'permissions-plugins_themes' => _fs_text( 'Plugins & Themes' ),
'permissions-plugins_themes_desc' => _fs_text( 'Titles, versions and state.' ),
'permissions-admin-notices' => _fs_text( 'Admin Notices' ),
'permissions-newsletter' => _fs_text( 'Newsletter' ),
'permissions-newsletter_desc' => _fs_text( 'Updates, announcements, marketing, no spam' ),
'privacy-policy' => _fs_text( 'Privacy Policy' ),
'tos' => _fs_text( 'Terms of Service' ),
'activating' => _fs_x( 'Activating', 'as activating plugin' ),
'sending-email' => _fs_x( 'Sending email', 'as in the process of sending an email' ),
'opt-in-connect' => _fs_x( 'Allow & Continue', 'button label' ),
'agree-activate-license' => _fs_x( 'Agree & Activate License', 'button label' ),
'skip' => _fs_x( 'Skip', 'verb' ),
'click-here-to-use-plugin-anonymously' => _fs_text( 'Click here to use the plugin anonymously' ),
'resend-activation-email' => _fs_text( 'Re-send activation email' ),
'license-key' => _fs_text( 'License key' ),
'send-license-key' => _fs_text( 'Send License Key' ),
'sending-license-key' => _fs_text( 'Sending license key' ),
'have-license-key' => _fs_text( 'Have a license key?' ),
'dont-have-license-key' => _fs_text( 'Don\'t have a license key?' ),
'cant-find-license-key' => _fs_text( "Can't find your license key?" ),
'email-not-found' => _fs_text( "We couldn't find your email address in the system, are you sure it's the right address?" ),
'no-active-licenses' => _fs_text( "We can't see any active licenses associated with that email address, are you sure it's the right address?" ),
'opt-in' => _fs_text( 'Opt In' ),
'opt-out' => _fs_text( 'Opt Out' ),
'opt-out-cancel' => _fs_text( 'On second thought - I want to continue helping' ),
'opting-out' => _fs_text( 'Opting out...' ),
'opting-in' => _fs_text( 'Opting in...' ),
'opt-out-message-appreciation' => _fs_text( 'We appreciate your help in making the %s better by letting us track some usage data.' ),
'opt-out-message-usage-tracking' => _fs_text( "Usage tracking is done in the name of making %s better. Making a better user experience, prioritizing new features, and more good things. We'd really appreciate if you'll reconsider letting us continue with the tracking." ),
'opt-out-message-clicking-opt-out' => _fs_text( 'By clicking "Opt Out", we will no longer be sending any data from %s to %s.' ),
'apply-on-all-sites-in-the-network' => _fs_text( 'Apply on all sites in the network.' ),
'delegate-to-site-admins' => _fs_text( 'Delegate to Site Admins' ),
'delegate-to-site-admins-and-continue' => _fs_text( 'Delegate to Site Admins & Continue' ),
'continue' => _fs_text( 'Continue' ),
'allow' => _fs_text( 'allow' ),
'delegate' => _fs_text( 'delegate' ),
#endregion Connect
#region Screenshots
'screenshots' => _fs_text( 'Screenshots' ),
'view-full-size-x' => _fs_text( 'Click to view full-size screenshot %d' ),
#endregion Screenshots
#region Debug
'freemius-debug' => _fs_text( 'Freemius Debug' ),
'on' => _fs_x( 'On', 'as turned on' ),
'off' => _fs_x( 'Off', 'as turned off' ),
'debugging' => _fs_x( 'Debugging', 'as code debugging' ),
'freemius-state' => _fs_text( 'Freemius State' ),
'connected' => _fs_x( 'Connected', 'as connection was successful' ),
'blocked' => _fs_x( 'Blocked', 'as connection blocked' ),
'api' => _fs_x( 'API', 'as application program interface' ),
'sdk' => _fs_x( 'SDK', 'as software development kit versions' ),
'sdk-versions' => _fs_x( 'SDK Versions', 'as software development kit versions' ),
'plugin-path' => _fs_x( 'Plugin Path', 'as plugin folder path' ),
'sdk-path' => _fs_x( 'SDK Path', 'as sdk path' ),
'addons-of-x' => _fs_text( 'Add Ons of Plugin %s' ),
'delete-all-confirm' => _fs_text( 'Are you sure you want to delete all Freemius data?' ),
'actions' => _fs_text( 'Actions' ),
'delete-all-accounts' => _fs_text( 'Delete All Accounts' ),
'start-fresh' => _fs_text( 'Start Fresh' ),
'clear-api-cache' => _fs_text( 'Clear API Cache' ),
'sync-data-from-server' => _fs_text( 'Sync Data From Server' ),
'scheduled-crons' => _fs_text( 'Scheduled Crons' ),
'cron-type' => _fs_text( 'Cron Type' ),
'plugins-themes-sync' => _fs_text( 'Plugins & Themes Sync' ),
'module-licenses' => _fs_text( '%s Licenses' ),
'debug-log' => _fs_text( 'Debug Log' ),
'all' => _fs_text( 'All' ),
'file' => _fs_text( 'File' ),
'function' => _fs_text( 'Function' ),
'process-id' => _fs_text( 'Process ID' ),
'logger' => _fs_text( 'Logger' ),
'message' => _fs_text( 'Message' ),
'download' => _fs_text( 'Download' ),
'filter' => _fs_text( 'Filter' ),
'type' => _fs_text( 'Type' ),
'all-types' => _fs_text( 'All Types' ),
'all-requests' => _fs_text( 'All Requests' ),
#endregion Debug
#region Expressions
'congrats' => _fs_x( 'Congrats', 'as congratulations' ),
'oops' => _fs_x( 'Oops', 'exclamation' ),
'yee-haw' => _fs_x( 'Yee-haw', 'interjection expressing joy or exuberance' ),
'woot' => _fs_x( 'W00t',
'(especially in electronic communication) used to express elation, enthusiasm, or triumph.' ),
'right-on' => _fs_x( 'Right on', 'a positive response' ),
'hmm' => _fs_x( 'Hmm',
'something somebody says when they are thinking about what you have just said. ' ),
'ok' => _fs_text( 'O.K' ),
'hey' => _fs_x( 'Hey', 'exclamation' ),
'heads-up' => _fs_x( 'Heads up',
'advance notice of something that will need attention.' ),
#endregion Expressions
#region Admin Notices
'you-have-latest' => _fs_text( 'Seems like you got the latest release.' ),
'you-are-good' => _fs_text( 'You are all good!' ),
'user-exist-message' => _fs_text( 'Sorry, we could not complete the email update. Another user with the same email is already registered.' ),
'user-exist-message_ownership' => _fs_text( 'If you would like to give up the ownership of the %s\'s account to %s click the Change Ownership button.' ),
'email-updated-message' => _fs_text( 'Your email was successfully updated. You should receive an email with confirmation instructions in few moments.' ),
'name-updated-message' => _fs_text( 'Your name was successfully updated.' ),
'x-updated' => _fs_text( 'You have successfully updated your %s.' ),
'name-update-failed-message' => _fs_text( 'Please provide your full name.' ),
'verification-email-sent-message' => _fs_text( 'Verification mail was just sent to %s. If you can\'t find it after 5 min, please check your spam box.' ),
'addons-info-external-message' => _fs_text( 'Just letting you know that the add-ons information of %s is being pulled from an external server.' ),
'no-cc-required' => _fs_text( 'No credit card required' ),
'premium-activated-message' => _fs_text( 'Premium %s version was successfully activated.' ),
'successful-version-upgrade-message' => _fs_text( 'The upgrade of %s was successfully completed.' ),
'activation-with-plan-x-message' => _fs_text( 'Your account was successfully activated with the %s plan.' ),
'download-latest-x-version-now' => _fs_text( 'Download the latest %s version now' ),
'follow-steps-to-complete-upgrade' => _fs_text( 'Please follow these steps to complete the upgrade' ),
'download-latest-x-version' => _fs_text( 'Download the latest %s version' ),
'download-latest-version' => _fs_text( 'Download the latest version' ),
'deactivate-free-version' => _fs_text( 'Deactivate the free version' ),
'upload-and-activate' => _fs_text( 'Upload and activate the downloaded version' ),
'howto-upload-activate' => _fs_text( 'How to upload and activate?' ),
'addon-successfully-purchased-message' => _fs_x( '%s Add-on was successfully purchased.',
'%s - product name, e.g. Facebook add-on was successfully...' ),
'addon-successfully-upgraded-message' => _fs_text( 'Your %s Add-on plan was successfully upgraded.' ),
'email-verified-message' => _fs_text( 'Your email has been successfully verified - you are AWESOME!' ),
'plan-upgraded-message' => _fs_text( 'Your plan was successfully upgraded.' ),
'plan-changed-to-x-message' => _fs_text( 'Your plan was successfully changed to %s.' ),
'license-expired-blocking-message' => _fs_text( 'Your license has expired. You can still continue using the free %s forever.' ),
'license-cancelled' => _fs_text( 'Your license has been cancelled. If you think it\'s a mistake, please contact support.' ),
'trial-started-message' => _fs_text( 'Your trial has been successfully started.' ),
'license-activated-message' => _fs_text( 'Your license was successfully activated.' ),
'no-active-license-message' => _fs_text( 'It looks like your site currently doesn\'t have an active license.' ),
'license-deactivation-message' => _fs_text( 'Your license was successfully deactivated, you are back to the %s plan.' ),
'license-deactivation-failed-message' => _fs_text( 'It looks like the license deactivation failed.' ),
'license-activation-failed-message' => _fs_text( 'It looks like the license could not be activated.' ),
'server-error-message' => _fs_text( 'Error received from the server:' ),
'trial-expired-message' => _fs_text( 'Your trial has expired. You can still continue using all our free features.' ),
'plan-x-downgraded-message' => _fs_text( 'Your plan was successfully downgraded. Your %s plan license will expire in %s.' ),
'plan-downgraded-failure-message' => _fs_text( 'Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes.' ),
'trial-cancel-no-trial-message' => _fs_text( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)' ),
'trial-cancel-message' => _fs_text( 'Your %s free trial was successfully cancelled.' ),
'version-x-released' => _fs_x( 'Version %s was released.', '%s - numeric version number' ),
'please-download-x' => _fs_text( 'Please download %s.' ),
'latest-x-version' => _fs_x( 'the latest %s version here',
'%s - plan name, as the latest professional version here' ),
'trial-x-promotion-message' => _fs_text( 'How do you like %s so far? Test all our %s premium features with a %d-day free trial.' ),
'start-free-trial' => _fs_x( 'Start free trial', 'call to action' ),
'starting-trial' => _fs_text( 'Starting trial' ),
'please-wait' => _fs_text( 'Please wait' ),
'trial-cancel-failure-message' => _fs_text( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.' ),
'trial-utilized' => _fs_text( 'You already utilized a trial before.' ),
'in-trial-mode' => _fs_text( 'You are already running the %s in a trial mode.' ),
'trial-plan-x-not-exist' => _fs_text( 'Plan %s do not exist, therefore, can\'t start a trial.' ),
'plan-x-no-trial' => _fs_text( 'Plan %s does not support a trial period.' ),
'no-trials' => _fs_text( 'None of the %s\'s plans supports a trial period.' ),
'unexpected-api-error' => _fs_text( 'Unexpected API error. Please contact the %s\'s author with the following error.' ),
'no-commitment-for-x-days' => _fs_text( 'No commitment for %s days - cancel anytime!' ),
'license-expired-non-blocking-message' => _fs_text( 'Your license has expired. You can still continue using all the %s features, but you\'ll need to renew your license to continue getting updates and support.' ),
'could-not-activate-x' => _fs_text( 'Couldn\'t activate %s.' ),
'contact-us-with-error-message' => _fs_text( 'Please contact us with the following message:' ),
'plan-did-not-change-message' => _fs_text( 'It looks like you are still on the %s plan. If you did upgrade or change your plan, it\'s probably an issue on our side - sorry.' ),
'contact-us-here' => _fs_text( 'Please contact us here' ),
'plan-did-not-change-email-message' => _fs_text( 'I have upgraded my account but when I try to Sync the License, the plan remains %s.' ),
#endregion Admin Notices
#region Connectivity Issues
'connectivity-test-fails-message' => _fs_text( 'From unknown reason, the API connectivity test failed.' ),
'connectivity-test-maybe-temporary' => _fs_text( 'It\'s probably a temporary issue on our end. Just to be sure, with your permission, would it be o.k to run another connectivity test?' ),
'curl-missing-message' => _fs_text( 'We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server.' ),
'curl-disabled-methods' => _fs_text( 'Disabled method(s):' ),
'cloudflare-blocks-connection-message' => _fs_text( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.' ),
'x-requires-access-to-api' => _fs_x( '%s requires an access to our API.',
'as pluginX requires an access to our API' ),
'squid-blocks-connection-message' => _fs_text( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.' ),
'squid-no-clue-title' => _fs_text( 'I don\'t know what is Squid or ACL, help me!' ),
'squid-no-clue-desc' => _fs_text( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.' ),
'sysadmin-title' => _fs_text( 'I\'m a system administrator' ),
'squid-sysadmin-desc' => _fs_text( 'Great, please whitelist the following domains: %s. Once you are done, deactivate the %s and activate it again.' ),
'curl-missing-no-clue-title' => _fs_text( 'I don\'t know what is cURL or how to install it, help me!' ),
'curl-missing-no-clue-desc' => _fs_text( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.' ),
'curl-missing-sysadmin-desc' => _fs_text( 'Great, please install cURL and enable it in your php.ini file. In addition, search for the \'disable_functions\' directive in your php.ini file and remove any disabled methods starting with \'curl_\'. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the %s and reactivate it back again.' ),
'happy-to-resolve-issue-asap' => _fs_text( 'We are sure it\'s an issue on our side and more than happy to resolve it for you ASAP if you give us a chance.' ),
'contact-support-before-deactivation' => _fs_text( 'Sorry for the inconvenience and we are here to help if you give us a chance.' ),
'fix-issue-title' => _fs_text( 'Yes - I\'m giving you a chance to fix it' ),
'fix-issue-desc' => _fs_text( 'We will do our best to whitelist your server and resolve this issue ASAP. You will get a follow-up email to %s once we have an update.' ),
'install-previous-title' => _fs_text( 'Let\'s try your previous version' ),
'install-previous-desc' => _fs_text( 'Uninstall this version and install the previous one.' ),
'deactivate-plugin-title' => _fs_text( 'That\'s exhausting, please deactivate' ),
'deactivate-plugin-desc' => _fs_text( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.' ),
'fix-request-sent-message' => _fs_text( 'Thank for giving us the chance to fix it! A message was just sent to our technical staff. We will get back to you as soon as we have an update to %s. Appreciate your patience.' ),
'server-blocking-access' => _fs_x( 'Your server is blocking the access to Freemius\' API, which is crucial for %1$s synchronization. Please contact your host to whitelist %2$s',
'%1$s - plugin title, %2$s - API domain' ),
'wrong-authentication-param-message' => _fs_text( 'It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again.' ),
#endregion Connectivity Issues
#region Change Owner
'change-owner-request-sent-x' => _fs_text( 'Please check your mailbox, you should receive an email via %s to confirm the ownership change. From security reasons, you must confirm the change within the next 15 min. If you cannot find the email, please check your spam folder.' ),
'change-owner-request_owner-confirmed' => _fs_text( 'Thanks for confirming the ownership change. An email was just sent to %s for final approval.' ),
'change-owner-request_candidate-confirmed' => _fs_text( '%s is the new owner of the account.' ),
#endregion Change Owner
'addon-x-cannot-run-without-y' => _fs_x( '%s cannot run without %s.',
'addonX cannot run without pluginY' ),
'addon-x-cannot-run-without-parent' => _fs_x( '%s cannot run without the plugin.', 'addonX cannot run...' ),
'plugin-x-activation-message' => _fs_x( '%s activation was successfully completed.',
'pluginX activation was successfully...' ),
'features-and-pricing' => _fs_x( 'Features & Pricing', 'Plugin installer section title' ),
'free-addon-not-deployed' => _fs_text( 'Add-on must be deployed to WordPress.org or Freemius.' ),
'paid-addon-not-deployed' => _fs_text( 'Paid add-on must be deployed to Freemius.' ),
#--------------------------------------------------------------------------------
#region Add-On Licensing
#--------------------------------------------------------------------------------
'addon-no-license-message' => _fs_text( '%s is a premium only add-on. You have to purchase a license first before activating the plugin.' ),
'addon-trial-cancelled-message' => _fs_text( '%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.' ),
#endregion
#--------------------------------------------------------------------------------
#region Billing Cycles
#--------------------------------------------------------------------------------
'monthly' => _fs_x( 'Monthly', 'as every month' ),
'mo' => _fs_x( 'mo', 'as monthly period' ),
'annual' => _fs_x( 'Annual', 'as once a year' ),
'annually' => _fs_x( 'Annually', 'as once a year' ),
'once' => _fs_x( 'Once', 'as once a year' ),
'year' => _fs_x( 'year', 'as annual period' ),
'lifetime' => _fs_text( 'Lifetime' ),
'best' => _fs_x( 'Best', 'e.g. the best product' ),
'billed-x' => _fs_x( 'Billed %s', 'e.g. billed monthly' ),
'save-x' => _fs_x( 'Save %s', 'as a discount of $5 or 10%' ),
#endregion Billing Cycles
'view-details' => _fs_text( 'View details' ),
#--------------------------------------------------------------------------------
#region Trial
#--------------------------------------------------------------------------------
'approve-start-trial' => _fs_x( 'Approve & Start Trial', 'button label' ),
/* translators: %1$s: Number of trial days; %2$s: Plan name; */
'start-trial-prompt-header' => _fs_text( 'You are 1-click away from starting your %1$s-day free trial of the %2$s plan.' ),
/* translators: %s: Link to freemius.com */
'start-trial-prompt-message' => _fs_text( 'For compliance with the WordPress.org guidelines, before we start the trial we ask that you opt in with your user and non-sensitive site information, allowing the %s to periodically send data to %s to check for version updates and to validate your trial.' ),
#endregion
#--------------------------------------------------------------------------------
#region Billing Details
#--------------------------------------------------------------------------------
'business-name' => _fs_text( 'Business name' ),
'tax-vat-id' => _fs_text( 'Tax / VAT ID' ),
'address-line-n' => _fs_text( 'Address Line %d' ),
'country' => _fs_text( 'Country' ),
'select-country' => _fs_text( 'Select Country' ),
'city' => _fs_text( 'City' ),
'town' => _fs_text( 'Town' ),
'state' => _fs_text( 'State' ),
'province' => _fs_text( 'Province' ),
'zip-postal-code' => _fs_text( 'ZIP / Postal Code' ),
#endregion
#--------------------------------------------------------------------------------
#region Module Installation
#--------------------------------------------------------------------------------
'installing-plugin-x' => _fs_text( 'Installing plugin: %s' ),
'auto-installation' => _fs_text( 'Automatic Installation' ),
/* translators: %s: Number of seconds */
'x-sec' => _fs_text( '%s sec' ),
'installing-in-n' => _fs_text( 'An automated download and installation of %s (paid version) from %s will start in %s. If you would like to do it manually - click the cancellation button now.' ),
'installing-module-x' => _fs_text( 'The installation process has started and may take a few minutes to complete. Please wait until it is done - do not refresh this page.' ),
'cancel-installation' => _fs_text( 'Cancel Installation' ),
'module-package-rename-failure' => _fs_text( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.' ),
'auto-install-error-invalid-id' => _fs_text( 'Invalid module ID.' ),
'auto-install-error-not-opted-in' => _fs_text( 'Auto installation only works for opted-in users.' ),
'auto-install-error-premium-activated' => _fs_text( 'Premium version already active.' ),
'auto-install-error-premium-addon-activated' => _fs_text( 'Premium add-on version already installed.' ),
'auto-install-error-invalid-license' => _fs_text( 'You do not have a valid license to access the premium version.' ),
'auto-install-error-serviceware' => _fs_text( 'Plugin is a "Serviceware" which means it does not have a premium code version.' ),
#endregion
/* translators: %s: Page name */
'secure-x-page-header' => _fs_text( 'Secure HTTPS %s page, running from an external domain' ),
'pci-compliant' => _fs_text( 'PCI compliant' ),
'view-paid-features' => _fs_text( 'View paid features' ),
);
/**
* Localization of the strings in the plugin/theme info dialog box.
*
* $fs_module_info_text should ONLY include strings that are not located in $fs_text.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.2
*/
global $fs_module_info_text;
$fs_module_info_text = array(
'description' => _fs_x( 'Description', 'Plugin installer section title' ),
'installation' => _fs_x( 'Installation', 'Plugin installer section title' ),
'faq' => _fs_x( 'FAQ', 'Plugin installer section title' ),
'changelog' => _fs_x( 'Changelog', 'Plugin installer section title' ),
'reviews' => _fs_x( 'Reviews', 'Plugin installer section title' ),
'other_notes' => _fs_x( 'Other Notes', 'Plugin installer section title' ),
/* translators: %s: 1 or One */
'x-star' => _fs_text( '%s star' ),
/* translators: %s: Number larger than 1 */
'x-stars' => _fs_text( '%s stars' ),
/* translators: %s: 1 or One */
'x-rating' => _fs_text( '%s rating' ),
/* translators: %s: Number larger than 1 */
'x-ratings' => _fs_text( '%s ratings' ),
/* translators: %s: 1 or One (Number of times downloaded) */
'x-time' => _fs_text( '%s time' ),
/* translators: %s: Number of times downloaded */
'x-times' => _fs_text( '%s times' ),
/* translators: %s: # of stars (e.g. 5 stars) */
'click-to-reviews' => _fs_text( 'Click to see reviews that provided a rating of %s' ),
'last-updated:' => _fs_text( 'Last Updated' ),
'requires-wordpress-version:' => _fs_text( 'Requires WordPress Version:' ),
'author:' => _fs_x( 'Author:', 'as the plugin author' ),
'compatible-up-to:' => _fs_text( 'Compatible up to:' ),
'downloaded:' => _fs_text( 'Downloaded:' ),
'wp-org-plugin-page' => _fs_text( 'WordPress.org Plugin Page' ),
'plugin-homepage' => _fs_text( 'Plugin Homepage' ),
'donate-to-plugin' => _fs_text( 'Donate to this plugin' ),
'average-rating' => _fs_text( 'Average Rating' ),
'based-on-x' => _fs_text( 'based on %s' ),
'warning:' => _fs_text( 'Warning:' ),
'contributors' => _fs_text( 'Contributors' ),
'plugin-install' => _fs_text( 'Plugin Install' ),
'not-tested-warning' => _fs_text( 'This plugin has not been tested with your current version of WordPress.' ),
'not-compatible-warning' => _fs_text( 'This plugin has not been marked as compatible with your version of WordPress.' ),
'newer-installed' => _fs_text( 'Newer Version (%s) Installed' ),
'latest-installed' => _fs_text( 'Latest Version Installed' ),
);

View File

@ -0,0 +1,3 @@
<?php
// Silence is golden.
// Hide file structure from users on unprotected servers.

View File

@ -0,0 +1,48 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.2.1.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Retrieve the translation of $text.
*
* @since 1.2.1.6
*
* @param string $text
*
* @return string
*/
function _fs_text( $text ) {
// Avoid misleading Theme Check warning.
$fn = 'translate';
return $fn( $text, 'freemius' );
}
/**
* Retrieve translated string with gettext context.
*
* Quite a few times, there will be collisions with similar translatable text
* found in more than two places, but with different translated context.
*
* By including the context in the pot file, translators can translate the two
* strings differently.
*
* @since 1.2.1.6
*
* @param string $text
* @param string $context
*
* @return string
*/
function _fs_x( $text, $context ) {
// Avoid misleading Theme Check warning.
$fn = 'translate_with_gettext_context';
return $fn( $text, $context, 'freemius' );
}

View File

@ -0,0 +1,477 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.0.7
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Admin_Notice_Manager {
/**
* @since 1.2.2
*
* @var string
*/
protected $_module_unique_affix;
/**
* @var string
*/
protected $_id;
/**
* @var string
*/
protected $_title;
/**
* @var array[string]array
*/
private $_notices = array();
/**
* @var FS_Key_Value_Storage
*/
private $_sticky_storage;
/**
* @var FS_Logger
*/
protected $_logger;
/**
* @since 2.0.0
* @var int The ID of the blog that is associated with the current site level admin notices.
*/
private $_blog_id = 0;
/**
* @since 2.0.0
* @var bool
*/
private $_is_network_notices;
/**
* @var FS_Admin_Notice_Manager[]
*/
private static $_instances = array();
/**
* @param string $id
* @param string $title
* @param string $module_unique_affix
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on
* network and blog admin pages.
* @param bool $network_level_or_blog_id Since 2.0.0
*
* @return \FS_Admin_Notice_Manager
*/
static function instance(
$id,
$title = '',
$module_unique_affix = '',
$is_network_and_blog_admins = false,
$network_level_or_blog_id = false
) {
if ( $is_network_and_blog_admins ) {
$network_level_or_blog_id = true;
}
$key = strtolower( $id );
if ( is_multisite() ) {
if ( true === $network_level_or_blog_id ) {
$key .= ':ms';
} else if ( is_numeric( $network_level_or_blog_id ) && $network_level_or_blog_id > 0 ) {
$key .= ":{$network_level_or_blog_id}";
} else {
$network_level_or_blog_id = get_current_blog_id();
$key .= ":{$network_level_or_blog_id}";
}
}
if ( ! isset( self::$_instances[ $key ] ) ) {
self::$_instances[ $key ] = new FS_Admin_Notice_Manager(
$id,
$title,
$module_unique_affix,
$is_network_and_blog_admins,
$network_level_or_blog_id
);
}
return self::$_instances[ $key ];
}
/**
* @param string $id
* @param string $title
* @param string $module_unique_affix
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and
* blog admin pages.
* @param bool|int $network_level_or_blog_id
*/
protected function __construct(
$id,
$title = '',
$module_unique_affix = '',
$is_network_and_blog_admins = false,
$network_level_or_blog_id = false
) {
$this->_id = $id;
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $this->_id . '_data', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
$this->_title = ! empty( $title ) ? $title : '';
$this->_module_unique_affix = $module_unique_affix;
$this->_sticky_storage = FS_Key_Value_Storage::instance( 'admin_notices', $this->_id, $network_level_or_blog_id );
if ( is_multisite() ) {
$this->_is_network_notices = ( true === $network_level_or_blog_id );
if ( is_numeric( $network_level_or_blog_id ) ) {
$this->_blog_id = $network_level_or_blog_id;
}
} else {
$this->_is_network_notices = false;
}
$is_network_admin = fs_is_network_admin();
$is_blog_admin = fs_is_blog_admin();
if ( ( $this->_is_network_notices && $is_network_admin ) ||
( ! $this->_is_network_notices && $is_blog_admin ) ||
( $is_network_and_blog_admins && ( $is_network_admin || $is_blog_admin ) )
) {
if ( 0 < count( $this->_sticky_storage ) ) {
$ajax_action_suffix = str_replace( ':', '-', $this->_id );
// If there are sticky notices for the current slug, add a callback
// to the AJAX action that handles message dismiss.
add_action( "wp_ajax_fs_dismiss_notice_action_{$ajax_action_suffix}", array(
&$this,
'dismiss_notice_ajax_callback'
) );
foreach ( $this->_sticky_storage as $msg ) {
// Add admin notice.
$this->add(
$msg['message'],
$msg['title'],
$msg['type'],
true,
$msg['id'],
false,
isset( $msg['wp_user_id'] ) ? $msg['wp_user_id'] : null,
! empty( $msg['plugin'] ) ? $msg['plugin'] : null,
$is_network_and_blog_admins
);
}
}
}
}
/**
* Remove sticky message by ID.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
*/
function dismiss_notice_ajax_callback() {
check_admin_referer( 'fs_dismiss_notice_action' );
if ( ! is_numeric( $_POST['message_id'] ) ) {
$this->_sticky_storage->remove( $_POST['message_id'] );
}
wp_die();
}
/**
* Rendered sticky message dismiss JavaScript.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*/
static function _add_sticky_dismiss_javascript() {
$params = array();
fs_require_once_template( 'sticky-admin-notice-js.php', $params );
}
private static $_added_sticky_javascript = false;
/**
* Hook to the admin_footer to add sticky message dismiss JavaScript handler.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*/
private static function has_sticky_messages() {
if ( ! self::$_added_sticky_javascript ) {
add_action( 'admin_footer', array( 'FS_Admin_Notice_Manager', '_add_sticky_dismiss_javascript' ) );
}
}
/**
* Handle admin_notices by printing the admin messages stacked in the queue.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.4
*
*/
function _admin_notices_hook() {
if ( function_exists( 'current_user_can' ) &&
! current_user_can( 'manage_options' )
) {
// Only show messages to admins.
return;
}
$show_admin_notices = ( ! $this->is_gutenberg_page() );
foreach ( $this->_notices as $id => $msg ) {
if ( isset( $msg['wp_user_id'] ) && is_numeric( $msg['wp_user_id'] ) ) {
if ( get_current_user_id() != $msg['wp_user_id'] ) {
continue;
}
}
/**
* Added a filter to control the visibility of admin notices.
*
* Usage example:
*
* /**
* * @param bool $show
* * @param array $msg {
* * @var string $message The actual message.
* * @var string $title An optional message title.
* * @var string $type The type of the message ('success', 'update', 'warning', 'promotion').
* * @var string $id The unique identifier of the message.
* * @var string $manager_id The unique identifier of the notices manager. For plugins it would be the plugin's slug, for themes - `<slug>-theme`.
* * @var string $plugin The product's title.
* * @var string $wp_user_id An optional WP user ID that this admin notice is for.
* * }
* *
* * @return bool
* *\/
* function my_custom_show_admin_notice( $show, $msg ) {
* if ('trial_promotion' != $msg['id']) {
* return false;
* }
*
* return $show;
* }
*
* my_fs()->add_filter( 'show_admin_notice', 'my_custom_show_admin_notice', 10, 2 );
*
* @author Vova Feldman
* @since 2.2.0
*/
$show_notice = call_user_func_array( 'fs_apply_filter', array(
$this->_module_unique_affix,
'show_admin_notice',
$show_admin_notices,
$msg
) );
if ( true !== $show_notice ) {
continue;
}
fs_require_template( 'admin-notice.php', $msg );
if ( $msg['sticky'] ) {
self::has_sticky_messages();
}
}
}
/**
* Enqueue common stylesheet to style admin notice.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*/
function _enqueue_styles() {
fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
}
/**
* Check if the current page is the Gutenberg block editor.
*
* @author Vova Feldman (@svovaf)
* @since 2.2.3
*
* @return bool
*/
function is_gutenberg_page() {
if ( function_exists( 'is_gutenberg_page' ) &&
is_gutenberg_page()
) {
// The Gutenberg plugin is on.
return true;
}
$current_screen = get_current_screen();
if ( method_exists( $current_screen, 'is_block_editor' ) &&
$current_screen->is_block_editor()
) {
// Gutenberg page on 5+.
return true;
}
return false;
}
/**
* Add admin message to admin messages queue, and hook to admin_notices / all_admin_notices if not yet hooked.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.4
*
* @param string $message
* @param string $title
* @param string $type
* @param bool $is_sticky
* @param string $id Message ID
* @param bool $store_if_sticky
* @param number|null $wp_user_id
* @param string|null $plugin_title
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network
* and blog admin pages.
*
* @uses add_action()
*/
function add(
$message,
$title = '',
$type = 'success',
$is_sticky = false,
$id = '',
$store_if_sticky = true,
$wp_user_id = null,
$plugin_title = null,
$is_network_and_blog_admins = false
) {
$notices_type = $this->get_notices_type();
if ( empty( $this->_notices ) ) {
if ( ! $is_network_and_blog_admins ) {
add_action( $notices_type, array( &$this, "_admin_notices_hook" ) );
} else {
add_action( 'network_admin_notices', array( &$this, "_admin_notices_hook" ) );
add_action( 'admin_notices', array( &$this, "_admin_notices_hook" ) );
}
add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_styles' ) );
}
if ( '' === $id ) {
$id = md5( $title . ' ' . $message . ' ' . $type );
}
$message_object = array(
'message' => $message,
'title' => $title,
'type' => $type,
'sticky' => $is_sticky,
'id' => $id,
'manager_id' => $this->_id,
'plugin' => ( ! is_null( $plugin_title ) ? $plugin_title : $this->_title ),
'wp_user_id' => $wp_user_id,
);
if ( $is_sticky && $store_if_sticky ) {
$this->_sticky_storage->{$id} = $message_object;
}
$this->_notices[ $id ] = $message_object;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @param string|string[] $ids
*/
function remove_sticky( $ids ) {
if ( ! is_array( $ids ) ) {
$ids = array( $ids );
}
foreach ( $ids as $id ) {
// Remove from sticky storage.
$this->_sticky_storage->remove( $id );
if ( isset( $this->_notices[ $id ] ) ) {
unset( $this->_notices[ $id ] );
}
}
}
/**
* Check if sticky message exists by id.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*
* @param $id
*
* @return bool
*/
function has_sticky( $id ) {
return isset( $this->_sticky_storage[ $id ] );
}
/**
* Adds sticky admin notification.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.7
*
* @param string $message
* @param string $id Message ID
* @param string $title
* @param string $type
* @param number|null $wp_user_id
* @param string|null $plugin_title
* @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network
* and blog admin pages.
*/
function add_sticky( $message, $id, $title = '', $type = 'success', $wp_user_id = null, $plugin_title = null, $is_network_and_blog_admins = false ) {
if ( ! empty( $this->_module_unique_affix ) ) {
$message = fs_apply_filter( $this->_module_unique_affix, "sticky_message_{$id}", $message );
$title = fs_apply_filter( $this->_module_unique_affix, "sticky_title_{$id}", $title );
}
$this->add( $message, $title, $type, true, $id, true, $wp_user_id, $plugin_title, $is_network_and_blog_admins );
}
/**
* Clear all sticky messages.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.8
*/
function clear_all_sticky() {
$this->_sticky_storage->clear_all();
}
#--------------------------------------------------------------------------------
#region Helper Method
#--------------------------------------------------------------------------------
/**
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @return string
*/
private function get_notices_type() {
return $this->_is_network_notices ?
'network_admin_notices' :
'admin_notices';
}
#endregion
}

View File

@ -0,0 +1,326 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 1.1.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_Cache_Manager {
/**
* @var FS_Option_Manager
*/
private $_options;
/**
* @var FS_Logger
*/
private $_logger;
/**
* @var FS_Cache_Manager[]
*/
private static $_MANAGERS = array();
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.3
*
* @param string $id
*/
private function __construct( $id ) {
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_cach_mngr_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
$this->_logger->entrance();
$this->_logger->log( 'id = ' . $id );
$this->_options = FS_Option_Manager::get_manager( $id, true, true, false );
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param $id
*
* @return FS_Cache_Manager
*/
static function get_manager( $id ) {
$id = strtolower( $id );
if ( ! isset( self::$_MANAGERS[ $id ] ) ) {
self::$_MANAGERS[ $id ] = new FS_Cache_Manager( $id );
}
return self::$_MANAGERS[ $id ];
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @return bool
*/
function is_empty() {
$this->_logger->entrance();
return $this->_options->is_empty();
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*/
function clear() {
$this->_logger->entrance();
$this->_options->clear( true );
}
/**
* Delete cache manager from DB.
*
* @author Vova Feldman (@svovaf)
* @since 1.0.9
*/
function delete() {
$this->_options->delete();
}
/**
* Check if there's a cached item.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
*
* @return bool
*/
function has( $key ) {
$cache_entry = $this->_options->get_option( $key, false );
return ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp )
);
}
/**
* Check if there's a valid cached item.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
* @param null|int $expiration Since 1.2.2.7
*
* @return bool
*/
function has_valid( $key, $expiration = null ) {
$cache_entry = $this->_options->get_option( $key, false );
$is_valid = ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp ) &&
$cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
);
if ( $is_valid &&
is_numeric( $expiration ) &&
isset( $cache_entry->created ) &&
is_numeric( $cache_entry->created ) &&
$cache_entry->created + $expiration < WP_FS__SCRIPT_START_TIME
) {
/**
* Even if the cache is still valid, since we are checking for validity
* with an explicit expiration period, if the period has past, return
* `false` as if the cache is invalid.
*
* @since 1.2.2.7
*/
$is_valid = false;
}
return $is_valid;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
function get( $key, $default = null ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp )
) {
return $cache_entry->result;
}
return is_object( $default ) ? clone $default : $default;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
function get_valid( $key, $default = null ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp ) &&
$cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
) {
return $cache_entry->result;
}
return is_object( $default ) ? clone $default : $default;
}
/**
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
* @param mixed $value
* @param int $expiration
* @param int $created Since 2.0.0 Cache creation date.
*/
function set( $key, $value, $expiration = WP_FS__TIME_24_HOURS_IN_SEC, $created = WP_FS__SCRIPT_START_TIME ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = new stdClass();
$cache_entry->result = $value;
$cache_entry->created = $created;
$cache_entry->timestamp = $created + $expiration;
$this->_options->set_option( $key, $cache_entry, true );
}
/**
* Get cached record expiration, or false if not cached or expired.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.7.3
*
* @param string $key
*
* @return bool|int
*/
function get_record_expiration( $key ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp ) &&
$cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
) {
return $cache_entry->timestamp;
}
return false;
}
/**
* Purge cached item.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.6
*
* @param string $key
*/
function purge( $key ) {
$this->_logger->entrance( 'key = ' . $key );
$this->_options->unset_option( $key, true );
}
/**
* Extend cached item caching period.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*
* @param string $key
* @param int $expiration
*
* @return bool
*/
function update_expiration( $key, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( ! is_object( $cache_entry ) ||
! isset( $cache_entry->timestamp ) ||
! is_numeric( $cache_entry->timestamp )
) {
return false;
}
$this->set( $key, $cache_entry->result, $expiration, $cache_entry->created );
return true;
}
/**
* Set cached item as expired.
*
* @author Vova Feldman (@svovaf)
* @since 1.2.2.7
*
* @param string $key
*/
function expire( $key ) {
$this->_logger->entrance( 'key = ' . $key );
$cache_entry = $this->_options->get_option( $key, false );
if ( is_object( $cache_entry ) &&
isset( $cache_entry->timestamp ) &&
is_numeric( $cache_entry->timestamp )
) {
// Set to expired.
$cache_entry->timestamp = WP_FS__SCRIPT_START_TIME;
$this->_options->set_option( $key, $cache_entry, true );
}
}
#--------------------------------------------------------------------------------
#region Migration
#--------------------------------------------------------------------------------
/**
* Migrate options from site level.
*
* @author Vova Feldman (@svovaf)
* @since 2.0.0
*/
function migrate_to_network() {
$this->_options->migrate_to_network();
}
#endregion
}

View File

@ -0,0 +1,202 @@
<?php
/**
* @package Freemius
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
* @since 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class FS_GDPR_Manager {
/**
* @var FS_Option_Manager
*/
private $_storage;
/**
* @var array {
* @type bool $required Are GDPR rules apply on the current context admin.
* @type bool $show_opt_in_notice Should the marketing and offers opt-in message be shown to the admin or not. If not set, defaults to `true`.
* @type int $notice_shown_at Last time the special GDPR opt-in message was shown to the current admin.
* }
*/
private $_data;
/**
* @var int
*/
private $_wp_user_id;
/**
* @var string
*/
private $_option_name;
/**
* @var FS_Admin_Notices
*/
private $_notices;
#--------------------------------------------------------------------------------
#region Singleton
#--------------------------------------------------------------------------------
/**
* @var FS_GDPR_Manager
*/
private static $_instance;
/**
* @return FS_GDPR_Manager
*/
public static function instance() {
if ( ! isset( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
#endregion
private function __construct() {
$this->_storage = FS_Option_Manager::get_manager( WP_FS__GDPR_OPTION_NAME, true, true );
$this->_wp_user_id = Freemius::get_current_wp_user_id();
$this->_option_name = "u{$this->_wp_user_id}";
$this->_data = $this->_storage->get_option( $this->_option_name, array() );
$this->_notices = FS_Admin_Notices::instance( 'all_admins', '', '', true );
if ( ! is_array( $this->_data ) ) {
$this->_data = array();
}
}
/**
* Update a GDPR option for the current admin and store it.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @param string $name
* @param mixed $value
*/
private function update_option( $name, $value ) {
$this->_data[ $name ] = $value;
$this->_storage->set_option( $this->_option_name, $this->_data, true );
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.1.0
*
* @return bool|null
*/
public function is_required() {
return isset( $this->_data['required'] ) ?
$this->_data['required'] :
null;
}
/**
* @author Leo Fajardo (@leorw)
* @since 2.1.0
*
* @param bool $is_required
*/
public function store_is_required( $is_required ) {
$this->update_option( 'required', $is_required );
}
/**
* Checks if the GDPR opt-in sticky notice is currently shown.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return bool
*/
public function is_opt_in_notice_shown() {
return $this->_notices->has_sticky( "gdpr_optin_actions_{$this->_wp_user_id}", true );
}
/**
* Remove the GDPR opt-in sticky notice.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
public function remove_opt_in_notice() {
$this->_notices->remove_sticky( "gdpr_optin_actions_{$this->_wp_user_id}", true );
$this->disable_opt_in_notice();
}
/**
* Prevents the opt-in message from being added/shown.
*
* @author Leo Fajardo (@leorw)
* @since 2.1.0
*/
public function disable_opt_in_notice() {
$this->update_option( 'show_opt_in_notice', false );
}
/**
* Checks if a GDPR opt-in message needs to be shown to the current admin.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return bool
*/
public function should_show_opt_in_notice() {
return (
! isset( $this->_data['show_opt_in_notice'] ) ||
true === $this->_data['show_opt_in_notice']
);
}
/**
* Get the last time the GDPR opt-in notice was shown.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*
* @return false|int
*/
public function last_time_notice_was_shown() {
return isset( $this->_data['notice_shown_at'] ) ?
$this->_data['notice_shown_at'] :
false;
}
/**
* Update the timestamp of the last time the GDPR opt-in message was shown to now.
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
public function notice_was_just_shown() {
$this->update_option( 'notice_shown_at', WP_FS__SCRIPT_START_TIME );
}
/**
* @param string $message
* @param string|null $plugin_title
*
* @author Vova Feldman (@svovaf)
* @since 2.1.0
*/
public function add_opt_in_sticky_notice( $message, $plugin_title = null ) {
$this->_notices->add_sticky(
$message,
"gdpr_optin_actions_{$this->_wp_user_id}",
'',
'promotion',
true,
$this->_wp_user_id,
$plugin_title,
true
);
}
}

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