v1.0.0
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
vendor/
|
||||
.phpunit.result.cache
|
||||
674
LICENSE
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
334
admin/class-fontdelbosc-admin.php
Normal file
|
|
@ -0,0 +1,334 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin settings page (Settings → Font del Bosc Temps) and its AJAX
|
||||
* endpoints for API key tests and nearest-station detection.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* See the file header block for the class documentation.
|
||||
*/
|
||||
final class Fontdelbosc_Admin {
|
||||
|
||||
/**
|
||||
* Registers the admin hooks.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function init(): void {
|
||||
add_action( 'admin_menu', array( __CLASS__, 'add_settings_page' ) );
|
||||
add_action( 'admin_init', array( __CLASS__, 'register_settings' ) );
|
||||
add_action( 'admin_notices', array( __CLASS__, 'maybe_show_notice' ) );
|
||||
add_action( 'wp_ajax_fontdelbosc_test_api', array( __CLASS__, 'ajax_test_api' ) );
|
||||
add_action( 'wp_ajax_fontdelbosc_find_station', array( __CLASS__, 'ajax_find_station' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the settings page under Settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function add_settings_page(): void {
|
||||
add_options_page(
|
||||
'Font del Bosc — El Temps',
|
||||
'Font del Bosc Temps',
|
||||
'manage_options',
|
||||
'fontdelbosc-eltemps',
|
||||
array( __CLASS__, 'render_settings_page' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the settings page view.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function render_settings_page(): void {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
require FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'admin/views/settings-page.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the option group, sections and fields via the Settings API.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register_settings(): void {
|
||||
register_setting(
|
||||
'fdb_settings',
|
||||
'fontdelbosc_options',
|
||||
array(
|
||||
'sanitize_callback' => array( __CLASS__, 'sanitize' ),
|
||||
'show_in_rest' => false,
|
||||
)
|
||||
);
|
||||
|
||||
add_settings_section( 'fdb_section_keys', __( 'API Keys', 'fontdelbosc-eltemps' ), '__return_false', 'fontdelbosc-eltemps' );
|
||||
add_settings_section( 'fdb_section_cache', __( 'Cache Settings', 'fontdelbosc-eltemps' ), '__return_false', 'fontdelbosc-eltemps' );
|
||||
add_settings_section( 'fdb_section_display', __( 'Display Options', 'fontdelbosc-eltemps' ), '__return_false', 'fontdelbosc-eltemps' );
|
||||
|
||||
add_settings_field( 'fdb_field_aemet_key', __( 'AEMET API key', 'fontdelbosc-eltemps' ), array( __CLASS__, 'field_aemet_key' ), 'fontdelbosc-eltemps', 'fdb_section_keys' );
|
||||
add_settings_field( 'fdb_field_meteocat_key', __( 'Meteocat API key', 'fontdelbosc-eltemps' ), array( __CLASS__, 'field_meteocat_key' ), 'fontdelbosc-eltemps', 'fdb_section_keys' );
|
||||
add_settings_field( 'fdb_field_ttl_current', __( 'Current conditions cache (seconds)', 'fontdelbosc-eltemps' ), array( __CLASS__, 'field_ttl_current' ), 'fontdelbosc-eltemps', 'fdb_section_cache' );
|
||||
add_settings_field( 'fdb_field_ttl_forecast', __( 'Forecast cache (seconds)', 'fontdelbosc-eltemps' ), array( __CLASS__, 'field_ttl_forecast' ), 'fontdelbosc-eltemps', 'fdb_section_cache' );
|
||||
add_settings_field( 'fdb_field_ttl_historical', __( 'Historical data cache (seconds)', 'fontdelbosc-eltemps' ), array( __CLASS__, 'field_ttl_historical' ), 'fontdelbosc-eltemps', 'fdb_section_cache' );
|
||||
add_settings_field( 'fdb_field_attribution', __( 'Display Options', 'fontdelbosc-eltemps' ), array( __CLASS__, 'field_attribution' ), 'fontdelbosc-eltemps', 'fdb_section_display' );
|
||||
add_settings_field( 'fdb_field_delete', __( 'Uninstall', 'fontdelbosc-eltemps' ), array( __CLASS__, 'field_delete' ), 'fontdelbosc-eltemps', 'fdb_section_display' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes the option array on save.
|
||||
*
|
||||
* @param mixed $input Raw input.
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public static function sanitize( mixed $input ): array {
|
||||
$input = is_array( $input ) ? $input : array();
|
||||
$old = (array) get_option( 'fontdelbosc_options', array() );
|
||||
|
||||
$aemet_key = sanitize_text_field( Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $input, 'aemet_api_key' ) ) ?? '' );
|
||||
$meteo_key = sanitize_text_field( Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $input, 'meteocat_api_key' ) ) ?? '' );
|
||||
|
||||
return array(
|
||||
'aemet_api_key' => '' === $aemet_key ? Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $old, 'aemet_api_key' ) ) ?? '' : $aemet_key,
|
||||
'meteocat_api_key' => '' === $meteo_key ? Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $old, 'meteocat_api_key' ) ) ?? '' : $meteo_key,
|
||||
'meteocat_station_code' => sanitize_text_field( Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $old, 'meteocat_station_code' ) ) ?? '' ),
|
||||
'cache_ttl_current' => max( 60, min( 86400, Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $input, 'cache_ttl_current' ) ) ?? 600 ) ),
|
||||
'cache_ttl_forecast' => max( 60, min( 86400, Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $input, 'cache_ttl_forecast' ) ) ?? 3600 ) ),
|
||||
'cache_ttl_historical' => max( 60, min( 604800, Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $input, 'cache_ttl_historical' ) ) ?? 86400 ) ),
|
||||
'display_attribution' => ! empty( Fontdelbosc_Payload::get( $input, 'display_attribution' ) ),
|
||||
'delete_data_on_uninstall' => ! empty( Fontdelbosc_Payload::get( $input, 'delete_data_on_uninstall' ) ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the AEMET API key field. The stored key is never rendered;
|
||||
* only its last 4 characters are shown as a hint.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function field_aemet_key(): void {
|
||||
$key = Fontdelbosc_Plugin::get_options()['aemet_api_key'];
|
||||
|
||||
printf(
|
||||
'<input type="password" autocomplete="new-password" class="regular-text" name="fontdelbosc_options[aemet_api_key]" value="" />'
|
||||
);
|
||||
|
||||
self::key_hint( $key );
|
||||
|
||||
echo '<p class="description"><a href="https://opendata.aemet.es/centrodedescargas/altaUsuario" target="_blank" rel="noopener noreferrer">opendata.aemet.es</a></p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the Meteocat API key field. The stored key is never rendered;
|
||||
* only its last 4 characters are shown as a hint.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function field_meteocat_key(): void {
|
||||
$key = Fontdelbosc_Plugin::get_options()['meteocat_api_key'];
|
||||
|
||||
printf(
|
||||
'<input type="password" autocomplete="new-password" class="regular-text" name="fontdelbosc_options[meteocat_api_key]" value="" />'
|
||||
);
|
||||
|
||||
self::key_hint( $key );
|
||||
|
||||
echo '<p class="description"><a href="https://apidocs.meteocat.gencat.cat/" target="_blank" rel="noopener noreferrer">apidocs.meteocat.gencat.cat</a></p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the "current key" hint when a key is stored, leaving the field
|
||||
* itself empty so submitting the form without retyping keeps the key.
|
||||
*
|
||||
* @param string $key Stored API key.
|
||||
* @return void
|
||||
*/
|
||||
private static function key_hint( string $key ): void {
|
||||
if ( '' === $key ) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
'<p class="description">%s</p>',
|
||||
sprintf(
|
||||
/* translators: %s: last 4 characters of the stored API key. */
|
||||
esc_html__( 'Current key ends in …%s', 'fontdelbosc-eltemps' ),
|
||||
esc_html( substr( $key, -4 ) )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the current conditions TTL field.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function field_ttl_current(): void {
|
||||
$value = Fontdelbosc_Plugin::get_options()['cache_ttl_current'];
|
||||
|
||||
printf(
|
||||
'<input type="number" min="60" max="86400" step="10" class="small-text" name="fontdelbosc_options[cache_ttl_current]" value="%d" />',
|
||||
esc_attr( (string) $value )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the forecast TTL field.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function field_ttl_forecast(): void {
|
||||
$value = Fontdelbosc_Plugin::get_options()['cache_ttl_forecast'];
|
||||
|
||||
printf(
|
||||
'<input type="number" min="60" max="86400" step="10" class="small-text" name="fontdelbosc_options[cache_ttl_forecast]" value="%d" />',
|
||||
esc_attr( (string) $value )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the historical data TTL field.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function field_ttl_historical(): void {
|
||||
$value = Fontdelbosc_Plugin::get_options()['cache_ttl_historical'];
|
||||
|
||||
printf(
|
||||
'<input type="number" min="60" max="604800" step="10" class="small-text" name="fontdelbosc_options[cache_ttl_historical]" value="%d" />',
|
||||
esc_attr( (string) $value )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the attribution toggle.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function field_attribution(): void {
|
||||
$options = Fontdelbosc_Plugin::get_options();
|
||||
|
||||
printf(
|
||||
'<label><input type="checkbox" name="fontdelbosc_options[display_attribution]" value="1" %s /> %s</label>',
|
||||
checked( ! empty( $options['display_attribution'] ), true, false ),
|
||||
esc_html__( 'Show data source attribution', 'fontdelbosc-eltemps' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the uninstall data-deletion toggle.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function field_delete(): void {
|
||||
$options = Fontdelbosc_Plugin::get_options();
|
||||
|
||||
printf(
|
||||
'<label><input type="checkbox" name="fontdelbosc_options[delete_data_on_uninstall]" value="1" %s /> %s</label>',
|
||||
checked( ! empty( $options['delete_data_on_uninstall'] ), true, false ),
|
||||
esc_html__( 'Delete all plugin data on uninstall', 'fontdelbosc-eltemps' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows an informational notice when no API key is configured and the
|
||||
* plugin is running on the Open-Meteo fallback.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function maybe_show_notice(): void {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$options = Fontdelbosc_Plugin::get_options();
|
||||
|
||||
if ( '' !== $options['aemet_api_key'] || '' !== $options['meteocat_api_key'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( null === $screen || ! in_array( $screen->base, array( 'plugins', 'dashboard', 'options-general' ), true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div class="notice notice-info is-dismissible"><p>%s</p></div>',
|
||||
esc_html__( 'No weather API keys are configured. Data is served by Open-Meteo (no key required).', 'fontdelbosc-eltemps' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler: tests an API source connectivity.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function ajax_test_api(): void {
|
||||
check_ajax_referer( 'fontdelbosc_admin', 'nonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( array( 'message' => 'forbidden' ) );
|
||||
}
|
||||
|
||||
$raw = isset( $_POST['source'] ) && is_string( $_POST['source'] ) ? wp_unslash( $_POST['source'] ) : '';
|
||||
$source = sanitize_key( $raw );
|
||||
$options = Fontdelbosc_Plugin::get_options();
|
||||
$ok = false;
|
||||
|
||||
switch ( $source ) {
|
||||
case 'aemet':
|
||||
$ok = '' !== $options['aemet_api_key'] && null !== Fontdelbosc_Api_Aemet::get_daily( $options['aemet_api_key'] );
|
||||
break;
|
||||
case 'meteocat':
|
||||
$ok = '' !== $options['meteocat_api_key'] && null !== Fontdelbosc_Api_Meteocat::get_hourly( $options['meteocat_api_key'] );
|
||||
break;
|
||||
case 'open-meteo':
|
||||
$ok = null !== Fontdelbosc_Api_OpenMeteo::get_current();
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $ok ) {
|
||||
wp_send_json_success( array( 'message' => 'ok' ) );
|
||||
}
|
||||
|
||||
wp_send_json_error( array( 'message' => 'failed' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX handler: finds and stores the XEMA station closest to Font del Bosc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function ajax_find_station(): void {
|
||||
check_ajax_referer( 'fontdelbosc_admin', 'nonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( array( 'message' => 'forbidden' ) );
|
||||
}
|
||||
|
||||
$options = Fontdelbosc_Plugin::get_options();
|
||||
|
||||
if ( '' === $options['meteocat_api_key'] ) {
|
||||
wp_send_json_error( array( 'message' => 'no-key' ) );
|
||||
}
|
||||
|
||||
$station = Fontdelbosc_Api_Meteocat::find_nearest_station( $options['meteocat_api_key'] );
|
||||
|
||||
if ( null === $station ) {
|
||||
wp_send_json_error( array( 'message' => 'failed' ) );
|
||||
}
|
||||
|
||||
$options['meteocat_station_code'] = $station['codi'];
|
||||
update_option( 'fontdelbosc_options', $options );
|
||||
|
||||
wp_send_json_success( $station );
|
||||
}
|
||||
}
|
||||
156
admin/views/settings-page.php
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
/**
|
||||
* Settings page view: Settings → Font del Bosc Temps.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$fontdelbosc_options = Fontdelbosc_Plugin::get_options();
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
||||
|
||||
<form method="post" action="options.php">
|
||||
<?php
|
||||
settings_fields( 'fdb_settings' );
|
||||
do_settings_sections( 'fontdelbosc-eltemps' );
|
||||
submit_button();
|
||||
?>
|
||||
</form>
|
||||
|
||||
<section>
|
||||
<h2><?php esc_html_e( 'Usage', 'fontdelbosc-eltemps' ); ?></h2>
|
||||
<ul class="fdb-usage">
|
||||
<li><code>[fontdelbosc_eltemps]</code> — <?php esc_html_e( 'Current conditions (default view).', 'fontdelbosc-eltemps' ); ?></li>
|
||||
<li><code>[fontdelbosc_eltemps view="hourly" hours="24"]</code> — <?php esc_html_e( 'Hourly forecast for the following hours. Attribute hours: 1-48 (24 by default).', 'fontdelbosc-eltemps' ); ?></li>
|
||||
<li><code>[fontdelbosc_eltemps view="daily" days="7"]</code> — <?php esc_html_e( 'Daily forecast. Attribute days: 1-7 (7 by default).', 'fontdelbosc-eltemps' ); ?></li>
|
||||
<li><code>[fontdelbosc_eltemps view="historical" year="2024" month="6"]</code> — <?php esc_html_e( 'Historical data for one month. Attributes year and month; by default the last completed month.', 'fontdelbosc-eltemps' ); ?></li>
|
||||
</ul>
|
||||
<p class="description"><?php esc_html_e( 'In the block editor, add a Shortcode block and paste the code. This version ships no dedicated blocks; the shortcode works anywhere shortcodes are supported, including the Shortcode block and text widgets.', 'fontdelbosc-eltemps' ); ?></p>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2><?php esc_html_e( 'Status', 'fontdelbosc-eltemps' ); ?></h2>
|
||||
<table class="form-table" role="presentation">
|
||||
<tr>
|
||||
<th scope="row">AEMET</th>
|
||||
<td>
|
||||
<button type="button" class="button" data-fdb-test="aemet"><?php esc_html_e( 'Test connection', 'fontdelbosc-eltemps' ); ?></button>
|
||||
<span id="fdb-test-aemet"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Meteocat</th>
|
||||
<td>
|
||||
<button type="button" class="button" data-fdb-test="meteocat"><?php esc_html_e( 'Test connection', 'fontdelbosc-eltemps' ); ?></button>
|
||||
<span id="fdb-test-meteocat"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Open-Meteo</th>
|
||||
<td>
|
||||
<button type="button" class="button" data-fdb-test="open-meteo"><?php esc_html_e( 'Test connection', 'fontdelbosc-eltemps' ); ?></button>
|
||||
<span id="fdb-test-open-meteo"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( '' !== $fontdelbosc_options['meteocat_api_key'] ) : ?>
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Nearest station', 'fontdelbosc-eltemps' ); ?></th>
|
||||
<td>
|
||||
<?php if ( '' !== $fontdelbosc_options['meteocat_station_code'] ) : ?>
|
||||
<?php
|
||||
/* translators: %s: XEMA station code. */
|
||||
printf( esc_html__( 'Nearest station: %s', 'fontdelbosc-eltemps' ), esc_html( $fontdelbosc_options['meteocat_station_code'] ) );
|
||||
?>
|
||||
<?php endif; ?>
|
||||
<button type="button" class="button" id="fdb-find-station"><?php esc_html_e( 'Find nearest station', 'fontdelbosc-eltemps' ); ?></button>
|
||||
<span id="fdb-station-result"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.fontdelboscAdmin =
|
||||
<?php
|
||||
echo wp_json_encode(
|
||||
array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'fontdelbosc_admin' ),
|
||||
'ok' => __( 'Connection successful.', 'fontdelbosc-eltemps' ),
|
||||
'fail' => __( 'Connection failed.', 'fontdelbosc-eltemps' ),
|
||||
)
|
||||
);
|
||||
?>
|
||||
;
|
||||
( function () {
|
||||
'use strict';
|
||||
|
||||
var cfg = window.fontdelboscAdmin || {};
|
||||
|
||||
function post( action, data ) {
|
||||
var body = new URLSearchParams();
|
||||
body.set( 'action', action );
|
||||
body.set( 'nonce', cfg.nonce || '' );
|
||||
Object.keys( data || {} ).forEach( function ( key ) {
|
||||
body.set( key, data[ key ] );
|
||||
} );
|
||||
|
||||
return fetch( cfg.ajaxurl, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
|
||||
body: body.toString()
|
||||
} ).then( function ( response ) {
|
||||
return response.json();
|
||||
} );
|
||||
}
|
||||
|
||||
document.querySelectorAll( '[data-fdb-test]' ).forEach( function ( button ) {
|
||||
button.addEventListener( 'click', function () {
|
||||
var source = button.getAttribute( 'data-fdb-test' );
|
||||
var output = document.getElementById( 'fdb-test-' + source );
|
||||
|
||||
if ( output ) {
|
||||
output.textContent = '…';
|
||||
}
|
||||
|
||||
post( 'fontdelbosc_test_api', { source: source } ).then( function ( result ) {
|
||||
if ( output ) {
|
||||
output.textContent = result && result.success ? cfg.ok : cfg.fail;
|
||||
}
|
||||
} ).catch( function () {
|
||||
if ( output ) {
|
||||
output.textContent = cfg.fail;
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
var find = document.getElementById( 'fdb-find-station' );
|
||||
|
||||
if ( find ) {
|
||||
find.addEventListener( 'click', function () {
|
||||
var output = document.getElementById( 'fdb-station-result' );
|
||||
|
||||
if ( output ) {
|
||||
output.textContent = '…';
|
||||
}
|
||||
|
||||
post( 'fontdelbosc_find_station', {} ).then( function ( result ) {
|
||||
if ( output ) {
|
||||
output.textContent = result && result.success && result.data ? result.data.codi : cfg.fail;
|
||||
}
|
||||
} ).catch( function () {
|
||||
if ( output ) {
|
||||
output.textContent = cfg.fail;
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}
|
||||
} )();
|
||||
</script>
|
||||
43
changelog.txt
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
== Changelog ==
|
||||
|
||||
= 1.0.0 =
|
||||
|
||||
_Release date: 2026-10-12_
|
||||
|
||||
**Highlights**
|
||||
|
||||
* Weather display for Font del Bosc (Mediona, Alt Penedès) with current conditions, hourly forecast, daily forecast and historical data.
|
||||
|
||||
**Added**
|
||||
|
||||
* Shortcode `[fontdelbosc_eltemps]` with `view` (current, hourly, daily, historical), `hours`, `days`, `year` and `month` attributes.
|
||||
* Sidebar widget with current conditions or today's forecast.
|
||||
* Meteocat (municipal forecast, XEMA stations), AEMET OpenData (daily and hourly municipal forecast) and Open-Meteo (current, forecast, ERA5 archive) integrations with automatic fallback chains.
|
||||
* Transients caching with stale-while-error policy and configurable TTLs.
|
||||
* Hourly WP-Cron event (fontdelbosc_refresh_weather) that keeps the caches warm; scheduled on activation, cleared on deactivation.
|
||||
* Settings page (Settings → Font del Bosc Temps) with API keys, cache, attribution, uninstall options, connection tests and nearest XEMA station detection.
|
||||
* Spanish (es_ES) and Catalan (ca) translations.
|
||||
* Meteocons icons (MIT), bundled locally.
|
||||
|
||||
**Changed**
|
||||
|
||||
* Nothing; initial release.
|
||||
|
||||
**Fixed**
|
||||
|
||||
* Nothing; initial release.
|
||||
|
||||
**Security**
|
||||
|
||||
* Nonces and capability checks on all admin and AJAX endpoints; sanitization and escaping on all input and output.
|
||||
|
||||
**Compatibility**
|
||||
|
||||
* WordPress: 6.4 - 7.1
|
||||
* PHP: 8.2 - 8.5
|
||||
|
||||
**Tests**
|
||||
|
||||
* PHP Coding Standards: 3.13.6 (WPCS 3.4.1, zero errors)
|
||||
* PHPStan level max: 2.3.1 (zero errors)
|
||||
* Plugin Check (PCP): pending (requires WP-CLI)
|
||||
43
fontdelbosc-eltemps.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* Plugin Name: Font del Bosc — El Temps
|
||||
* Plugin URI: https://github.com/robotstxt/fontdelbosc-eltemps
|
||||
* Description: Weather display for Font del Bosc (Mediona, Alt Penedès).
|
||||
* Version: 1.0.0
|
||||
* Requires at least: 6.4
|
||||
* Requires PHP: 8.2
|
||||
* Author: ROBOTSTXT
|
||||
* Author URI: https://www.robotstxt.es
|
||||
* License: GPL-3.0-or-later
|
||||
* Text Domain: fontdelbosc-eltemps
|
||||
* Domain Path: /languages
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
define( 'FONTDELBOSC_ELTEMPS_VERSION', '1.0.0' );
|
||||
define( 'FONTDELBOSC_ELTEMPS_PLUGIN_FILE', __FILE__ );
|
||||
define( 'FONTDELBOSC_ELTEMPS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'FONTDELBOSC_ELTEMPS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
||||
|
||||
// Font del Bosc spring (OSM node 12091829069), next to road C-244.
|
||||
define( 'FONTDELBOSC_ELTEMPS_LAT', 41.48772 );
|
||||
define( 'FONTDELBOSC_ELTEMPS_LON', 1.65947 );
|
||||
define( 'FONTDELBOSC_ELTEMPS_TIMEZONE', 'Europe/Madrid' );
|
||||
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'includes/class-fontdelbosc-conditions.php';
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'includes/class-fontdelbosc-payload.php';
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'includes/class-fontdelbosc-api-openmeteo.php';
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'includes/class-fontdelbosc-api-meteocat.php';
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'includes/class-fontdelbosc-api-aemet.php';
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'includes/class-fontdelbosc-data-manager.php';
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'includes/class-fontdelbosc-shortcode.php';
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'includes/class-fontdelbosc-widget.php';
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'includes/class-fontdelbosc-plugin.php';
|
||||
|
||||
Fontdelbosc_Plugin::instance();
|
||||
|
||||
register_activation_hook( __FILE__, array( 'Fontdelbosc_Plugin', 'activate' ) );
|
||||
register_deactivation_hook( __FILE__, array( 'Fontdelbosc_Plugin', 'deactivate' ) );
|
||||
440
includes/class-fontdelbosc-api-aemet.php
Normal file
|
|
@ -0,0 +1,440 @@
|
|||
<?php
|
||||
/**
|
||||
* AEMET OpenData API handler.
|
||||
*
|
||||
* Endpoints used:
|
||||
* - Daily municipal forecast: GET /prediccion/especifica/municipio/diaria/08122
|
||||
* - Hourly municipal forecast: GET /prediccion/especifica/municipio/horaria/08122
|
||||
*
|
||||
* AEMET uses a double-call pattern: the first request returns a JSON with a
|
||||
* temporary "datos" URL; the second request returns the actual data. Data
|
||||
* responses are encoded as ISO-8859-15, so a UTF-8 re-decode fallback is
|
||||
* applied.
|
||||
*
|
||||
* Response shape (both endpoints): the payload is an array whose first
|
||||
* element carries "origen" metadata and a "prediccion" object holding the
|
||||
* "dia" array. Period formats: "00-24" (daily), "08" (single hour) and
|
||||
* "0814" (hour range). Sky-state codes may carry a trailing "n" for the
|
||||
* night variant.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Handles AEMET municipal forecast requests.
|
||||
*/
|
||||
final class Fontdelbosc_Api_Aemet {
|
||||
|
||||
/**
|
||||
* API base URL.
|
||||
*/
|
||||
private const BASE_URL = 'https://opendata.aemet.es/opendata/api';
|
||||
|
||||
/**
|
||||
* INE municipal code for Mediona.
|
||||
*/
|
||||
private const MUNICIPAL_CODE = '08122';
|
||||
|
||||
/**
|
||||
* Returns the normalized daily forecast.
|
||||
*
|
||||
* @param string $api_key AEMET API key.
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_daily( string $api_key ): ?array {
|
||||
$payload = self::fetch_data( '/prediccion/especifica/municipio/diaria/' . self::MUNICIPAL_CODE, $api_key );
|
||||
$dias = Fontdelbosc_Payload::arr( Fontdelbosc_Payload::path( $payload, 0, 'prediccion', 'dia' ) );
|
||||
$days = array();
|
||||
|
||||
foreach ( $dias as $day ) {
|
||||
$date = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $day, 'fecha' ) );
|
||||
|
||||
if ( null === $date ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$date = substr( $date, 0, 10 );
|
||||
$pop = self::period_value( Fontdelbosc_Payload::get( $day, 'probPrecipitacion' ) );
|
||||
$velocity = self::period_value( Fontdelbosc_Payload::get( $day, 'viento' ), 'velocidad' );
|
||||
|
||||
$days[ $date ] = array(
|
||||
'date' => $date,
|
||||
'condition' => self::sky_condition( Fontdelbosc_Payload::get( $day, 'estadoCielo' ) ),
|
||||
'temp_max' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $day, 'temperatura', 'maxima' ) ),
|
||||
'temp_min' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $day, 'temperatura', 'minima' ) ),
|
||||
'precipitation' => null,
|
||||
'pop' => Fontdelbosc_Payload::int( $pop ),
|
||||
'wind_max' => Fontdelbosc_Payload::float( $velocity ),
|
||||
);
|
||||
}
|
||||
|
||||
if ( array() === $days ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ksort( $days );
|
||||
|
||||
return array(
|
||||
'source' => 'aemet',
|
||||
'days' => array_values( $days ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the normalized hourly forecast, from the current hour onwards.
|
||||
*
|
||||
* @param string $api_key AEMET API key.
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_hourly( string $api_key ): ?array {
|
||||
$payload = self::fetch_data( '/prediccion/especifica/municipio/horaria/' . self::MUNICIPAL_CODE, $api_key );
|
||||
$dias = Fontdelbosc_Payload::arr( Fontdelbosc_Payload::path( $payload, 0, 'prediccion', 'dia' ) );
|
||||
|
||||
$temperatures = array();
|
||||
$pops = array();
|
||||
$cielos = array();
|
||||
$winds = array();
|
||||
|
||||
foreach ( $dias as $day ) {
|
||||
$date = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $day, 'fecha' ) );
|
||||
|
||||
if ( null === $date ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$date = substr( $date, 0, 10 );
|
||||
|
||||
self::collect_entries( Fontdelbosc_Payload::get( $day, 'temperatura' ), $date, 'value', $temperatures );
|
||||
self::collect_entries( Fontdelbosc_Payload::get( $day, 'estadoCielo' ), $date, 'value', $cielos );
|
||||
self::collect_entries( Fontdelbosc_Payload::get( $day, 'probPrecipitacion' ), $date, 'value', $pops );
|
||||
self::collect_entries( Fontdelbosc_Payload::get( $day, 'vientoAndRachaMax' ), $date, 'velocidad', $winds );
|
||||
}
|
||||
|
||||
$keys = array_unique( array_merge( array_keys( $temperatures ), array_keys( $cielos ) ) );
|
||||
sort( $keys );
|
||||
|
||||
$now = ( new DateTimeImmutable( 'now', new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) ) )->format( 'Y-m-d H:00' );
|
||||
$hours = array();
|
||||
|
||||
foreach ( $keys as $key ) {
|
||||
if ( $key < $now ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hours[] = array(
|
||||
'time' => self::key_timestamp( $key ),
|
||||
'hour' => (int) substr( $key, 11, 2 ),
|
||||
'temperature' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::get( $temperatures, $key ) ),
|
||||
'pop' => Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $pops, $key ) ),
|
||||
'condition' => self::condition( Fontdelbosc_Payload::get( $cielos, $key ) ),
|
||||
'wind' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::get( $winds, $key ) ),
|
||||
);
|
||||
}
|
||||
|
||||
if ( array() === $hours ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'source' => 'aemet',
|
||||
'hours' => $hours,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects period-based values into an hour-keyed map. Handles the
|
||||
* single-hour ("08"), hour-range ("0814") and dashed ("00-24") period
|
||||
* formats; ranges are applied end-exclusive.
|
||||
*
|
||||
* @param mixed $entries Raw element entries.
|
||||
* @param string $date Day prefix (Y-m-d).
|
||||
* @param string $value_key Key holding the value.
|
||||
* @param array<string,mixed> $map Output map, modified by reference.
|
||||
* @return void
|
||||
*/
|
||||
private static function collect_entries( mixed $entries, string $date, string $value_key, array &$map ): void {
|
||||
foreach ( Fontdelbosc_Payload::arr( $entries ) as $entry ) {
|
||||
$period = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $entry, 'periodo' ) );
|
||||
$range = null === $period ? null : self::expand_period( $period );
|
||||
|
||||
if ( null === $range ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for ( $hour = $range[0]; $hour < $range[1]; $hour++ ) {
|
||||
if ( $hour < 0 || $hour > 23 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$map[ sprintf( '%s %02d:00', $date, $hour ) ] = Fontdelbosc_Payload::get( $entry, $value_key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expands an AEMET period string to an end-exclusive hour range.
|
||||
*
|
||||
* @param string $period Period ("08", "0814" or "00-24").
|
||||
* @return array{0:int,1:int}|null
|
||||
*/
|
||||
private static function expand_period( string $period ): ?array {
|
||||
$period = str_replace( '-', '', $period );
|
||||
|
||||
if ( 2 === strlen( $period ) ) {
|
||||
return array( (int) $period, (int) $period + 1 );
|
||||
}
|
||||
|
||||
if ( 4 === strlen( $period ) ) {
|
||||
return array( (int) substr( $period, 0, 2 ), (int) substr( $period, 2, 2 ) );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the "00-24" value of a daily element, falling back to the first entry.
|
||||
*
|
||||
* @param mixed $entries Raw element entries.
|
||||
* @param string $value_key Key holding the value.
|
||||
* @return mixed
|
||||
*/
|
||||
private static function period_value( mixed $entries, string $value_key = 'value' ): mixed {
|
||||
foreach ( Fontdelbosc_Payload::arr( $entries ) as $entry ) {
|
||||
$period = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $entry, 'periodo' ) );
|
||||
|
||||
if ( '00-24' === $period ) {
|
||||
return Fontdelbosc_Payload::get( $entry, $value_key );
|
||||
}
|
||||
}
|
||||
|
||||
return Fontdelbosc_Payload::path( $entries, 0, $value_key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Picks the best sky-state code from daily estadoCielo entries: the
|
||||
* "00-24" period when present, otherwise the first non-empty value.
|
||||
* Empty values (distant days, night-only periods) are skipped.
|
||||
*
|
||||
* @param mixed $entries estadoCielo entries.
|
||||
* @return string|null
|
||||
*/
|
||||
private static function sky_condition( mixed $entries ): ?string {
|
||||
$fallback = null;
|
||||
|
||||
foreach ( Fontdelbosc_Payload::arr( $entries ) as $entry ) {
|
||||
$value = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $entry, 'value' ) ) ?? '';
|
||||
$period = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $entry, 'periodo' ) );
|
||||
|
||||
if ( '' === $value ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( null === $fallback ) {
|
||||
$fallback = $value;
|
||||
}
|
||||
|
||||
if ( '00-24' === $period ) {
|
||||
return self::condition( $value );
|
||||
}
|
||||
}
|
||||
|
||||
return null === $fallback ? null : self::condition( $fallback );
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps an AEMET sky-state code to a condition key. Codes may carry a
|
||||
* trailing "n" (night variant), which is stripped first.
|
||||
*
|
||||
* @param mixed $value AEMET sky-state code.
|
||||
* @return string|null
|
||||
*/
|
||||
private static function condition( mixed $value ): ?string {
|
||||
$code_str = is_string( $value ) || is_numeric( $value ) ? rtrim( (string) $value, 'n' ) : '';
|
||||
|
||||
if ( ! is_numeric( $code_str ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$code = (int) $code_str;
|
||||
|
||||
if ( 11 === $code ) {
|
||||
return 'clear';
|
||||
}
|
||||
|
||||
if ( 12 === $code ) {
|
||||
return 'mainly_clear';
|
||||
}
|
||||
|
||||
if ( 13 === $code ) {
|
||||
return 'partly_cloudy';
|
||||
}
|
||||
|
||||
if ( 14 === $code || 15 === $code ) {
|
||||
return 'cloudy';
|
||||
}
|
||||
|
||||
if ( 16 === $code || 17 === $code ) {
|
||||
return 'overcast';
|
||||
}
|
||||
|
||||
if ( 18 === $code || 19 === $code ) {
|
||||
return 'fog';
|
||||
}
|
||||
|
||||
if ( $code >= 20 && $code <= 27 ) {
|
||||
return 'rain_light';
|
||||
}
|
||||
|
||||
if ( ( $code >= 28 && $code <= 37 ) || ( $code >= 61 && $code <= 66 ) ) {
|
||||
return 'thunderstorm';
|
||||
}
|
||||
|
||||
if ( $code >= 38 && $code <= 44 ) {
|
||||
return 'rain';
|
||||
}
|
||||
|
||||
if ( ( $code >= 45 && $code <= 47 ) || ( $code >= 70 && $code <= 77 ) ) {
|
||||
return 'snow';
|
||||
}
|
||||
|
||||
if ( $code >= 51 && $code <= 56 ) {
|
||||
return 'drizzle';
|
||||
}
|
||||
|
||||
if ( 81 === $code || 82 === $code ) {
|
||||
return 'fog';
|
||||
}
|
||||
|
||||
return 'cloudy';
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the AEMET double call and returns the decoded data payload.
|
||||
*
|
||||
* @param string $path API path.
|
||||
* @param string $api_key AEMET API key.
|
||||
* @return array<mixed>|null
|
||||
*/
|
||||
private static function fetch_data( string $path, string $api_key ): ?array {
|
||||
if ( '' === $api_key ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$meta = self::request_json( self::BASE_URL . $path . '?api_key=' . rawurlencode( $api_key ), false );
|
||||
$data_url = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $meta, 'datos' ) ) ?? '';
|
||||
|
||||
if ( '' === $data_url ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::request_json( $data_url, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a GET request and decodes the JSON response, with an
|
||||
* ISO-8859-1 to UTF-8 fallback for AEMET data payloads. Transient
|
||||
* gateway 5xx errors are retried once.
|
||||
*
|
||||
* @param string $url Request URL.
|
||||
* @param bool $latin1_fallback Whether to retry with converted encoding.
|
||||
* @return array<mixed>|null
|
||||
*/
|
||||
private static function request_json( string $url, bool $latin1_fallback ): ?array {
|
||||
$response = self::http_get( $url );
|
||||
$code = wp_remote_retrieve_response_code( $response );
|
||||
|
||||
if ( $code >= 500 && wp_doing_cron() ) {
|
||||
sleep( 1 );
|
||||
|
||||
$response = self::http_get( $url );
|
||||
$code = wp_remote_retrieve_response_code( $response );
|
||||
}
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
self::log( 'AEMET request failed: ' . $response->get_error_message() );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( 200 !== $code ) {
|
||||
self::log( 'AEMET returned HTTP ' . $code );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$body = (string) wp_remote_retrieve_body( $response );
|
||||
$data = json_decode( $body, true );
|
||||
|
||||
if ( null === $data && $latin1_fallback ) {
|
||||
$converted = self::to_utf8( $body );
|
||||
$data = null === $converted ? null : json_decode( $converted, true );
|
||||
}
|
||||
|
||||
return is_array( $data ) ? $data : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the HTTP GET request.
|
||||
*
|
||||
* @param string $url Request URL.
|
||||
* @return array<string,mixed>|WP_Error
|
||||
*/
|
||||
private static function http_get( string $url ): array|WP_Error {
|
||||
return wp_remote_get(
|
||||
$url,
|
||||
array(
|
||||
'timeout' => 5,
|
||||
'headers' => array(
|
||||
'Accept' => 'application/json',
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an ISO-8859-1 payload to UTF-8 using the first available
|
||||
* extension (mbstring, then iconv).
|
||||
*
|
||||
* @param string $body Raw body.
|
||||
* @return string|null
|
||||
*/
|
||||
private static function to_utf8( string $body ): ?string {
|
||||
if ( function_exists( 'mb_convert_encoding' ) ) {
|
||||
return mb_convert_encoding( $body, 'UTF-8', 'ISO-8859-1' );
|
||||
}
|
||||
|
||||
if ( function_exists( 'iconv' ) ) {
|
||||
$converted = iconv( 'ISO-8859-1', 'UTF-8//IGNORE', $body );
|
||||
|
||||
return false === $converted ? null : $converted;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an hour key to a Unix timestamp.
|
||||
*
|
||||
* @param string $key Hour key (Y-m-d H:00).
|
||||
* @return int
|
||||
*/
|
||||
private static function key_timestamp( string $key ): int {
|
||||
try {
|
||||
return ( new DateTimeImmutable( $key, new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) ) )->getTimestamp();
|
||||
} catch ( Exception ) {
|
||||
return time();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a message to the error log with the plugin prefix.
|
||||
*
|
||||
* @param string $message Message.
|
||||
* @return void
|
||||
*/
|
||||
private static function log( string $message ): void {
|
||||
error_log( '[fontdelbosc-eltemps] ' . $message );
|
||||
}
|
||||
}
|
||||
398
includes/class-fontdelbosc-api-meteocat.php
Normal file
|
|
@ -0,0 +1,398 @@
|
|||
<?php
|
||||
/**
|
||||
* Meteocat API handler (Servei Meteorològic de Catalunya).
|
||||
*
|
||||
* Endpoints used:
|
||||
* - Predicció municipal: GET /prediccio/v1/municipi/081228/prediccio
|
||||
* - XEMA station data: GET /xema/v1/estacions/{codi}/dades/{variable}
|
||||
* - XEMA station catalog: GET /xema/v1/estacions/metadades
|
||||
*
|
||||
* Requires an API key passed as the X-Api-Key header.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Handles Meteocat municipal forecast and XEMA station requests.
|
||||
*/
|
||||
final class Fontdelbosc_Api_Meteocat {
|
||||
|
||||
/**
|
||||
* API base URL.
|
||||
*/
|
||||
private const BASE_URL = 'https://api.meteo.cat';
|
||||
|
||||
/**
|
||||
* IDESCAT municipal code for Mediona.
|
||||
*/
|
||||
private const MUNICIPAL_CODE = '081228';
|
||||
|
||||
/**
|
||||
* Returns the normalized hourly forecast from the municipal prediction,
|
||||
* from the current hour onwards.
|
||||
*
|
||||
* @param string $api_key Meteocat API key.
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_hourly( string $api_key ): ?array {
|
||||
$payload = self::request( '/prediccio/v1/municipi/' . self::MUNICIPAL_CODE . '/prediccio', $api_key );
|
||||
$series = array();
|
||||
|
||||
foreach ( Fontdelbosc_Payload::arr( Fontdelbosc_Payload::path( $payload, 0, 'prediccions' ) ) as $prediction ) {
|
||||
foreach ( Fontdelbosc_Payload::arr( Fontdelbosc_Payload::get( $prediction, 'variables' ) ) as $name => $points ) {
|
||||
foreach ( Fontdelbosc_Payload::arr( $points ) as $point ) {
|
||||
$iso = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $point, 'data' ) );
|
||||
$key = null === $iso ? null : self::hour_key( $iso );
|
||||
|
||||
if ( null !== $key ) {
|
||||
$series[ (string) $name ][ $key ] = $point;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$keys = array();
|
||||
|
||||
foreach ( $series as $points ) {
|
||||
$keys = array_merge( $keys, array_keys( $points ) );
|
||||
}
|
||||
|
||||
$keys = array_values( array_unique( $keys ) );
|
||||
sort( $keys );
|
||||
|
||||
$now = self::now_key();
|
||||
$hours = array();
|
||||
|
||||
foreach ( $keys as $key ) {
|
||||
if ( $key < $now ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hours[] = array(
|
||||
'time' => self::key_timestamp( $key ),
|
||||
'hour' => (int) substr( $key, 11, 2 ),
|
||||
'temperature' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $series, 'temperatura', $key, 'valor' ) ),
|
||||
'pop' => Fontdelbosc_Payload::int( self::coalesce( Fontdelbosc_Payload::path( $series, 'probabilitatPrecipitacio', $key, 'valor' ), Fontdelbosc_Payload::path( $series, 'probabilitatDePrecipitacio', $key, 'valor' ) ) ),
|
||||
'condition' => self::condition( Fontdelbosc_Payload::path( $series, 'cel', $key ) ),
|
||||
'wind' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $series, 'vent', $key, 'valor' ) ),
|
||||
);
|
||||
}
|
||||
|
||||
if ( array() === $hours ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'source' => 'meteocat',
|
||||
'hours' => $hours,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns normalized current conditions from the configured XEMA station.
|
||||
*
|
||||
* @param string $api_key Meteocat API key.
|
||||
* @param string $station_code XEMA station code.
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_current( string $api_key, string $station_code ): ?array {
|
||||
if ( '' === $station_code ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$temperature = self::station_variable( $api_key, $station_code, 't' );
|
||||
$humidity = self::station_variable( $api_key, $station_code, 'hr' );
|
||||
$wind = self::station_variable( $api_key, $station_code, 'v' );
|
||||
|
||||
if ( null === $temperature && null === $humidity && null === $wind ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'temperature' => $temperature,
|
||||
'apparent' => null,
|
||||
'humidity' => $humidity,
|
||||
'precipitation' => null,
|
||||
'wind_speed' => null === $wind ? null : round( $wind * 3.6, 1 ),
|
||||
'wind_direction' => null,
|
||||
'condition' => null,
|
||||
'source' => 'meteocat',
|
||||
'time' => time(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the XEMA station closest to Font del Bosc.
|
||||
*
|
||||
* @param string $api_key Meteocat API key.
|
||||
* @return array{codi:string,nom:string,distance_km:float}|null
|
||||
*/
|
||||
public static function find_nearest_station( string $api_key ): ?array {
|
||||
$stations = self::request( '/xema/v1/estacions/metadades', $api_key );
|
||||
|
||||
if ( null === $stations ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$best = null;
|
||||
$distance = INF;
|
||||
|
||||
foreach ( Fontdelbosc_Payload::arr( $stations ) as $station ) {
|
||||
$codi = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $station, 'codi' ) );
|
||||
$lat = self::to_float( Fontdelbosc_Payload::path( $station, 'coordenades', 'latitud' ) );
|
||||
$lon = self::to_float( Fontdelbosc_Payload::path( $station, 'coordenades', 'longitud' ) );
|
||||
|
||||
if ( null === $codi || '' === $codi || null === $lat || null === $lon ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$current = self::haversine( FONTDELBOSC_ELTEMPS_LAT, FONTDELBOSC_ELTEMPS_LON, $lat, $lon );
|
||||
|
||||
if ( $current < $distance ) {
|
||||
$distance = $current;
|
||||
$best = array(
|
||||
'codi' => $codi,
|
||||
'nom' => Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $station, 'nom' ) ) ?? '',
|
||||
'distance_km' => round( $current, 1 ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $best;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the latest numeric value of a XEMA station variable.
|
||||
*
|
||||
* @param string $api_key Meteocat API key.
|
||||
* @param string $station Station code.
|
||||
* @param string $variable Variable code (t, hr, v).
|
||||
* @return float|null
|
||||
*/
|
||||
private static function station_variable( string $api_key, string $station, string $variable ): ?float {
|
||||
$data = self::request( '/xema/v1/estacions/' . rawurlencode( $station ) . '/dades/' . rawurlencode( $variable ), $api_key );
|
||||
$measures = Fontdelbosc_Payload::arr( Fontdelbosc_Payload::path( $data, 'variables', 0, 'mesures' ) );
|
||||
|
||||
foreach ( array_reverse( $measures ) as $measure ) {
|
||||
$value = Fontdelbosc_Payload::float( Fontdelbosc_Payload::get( $measure, 'valor' ) );
|
||||
|
||||
if ( null !== $value ) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a Meteocat "cel" data point to a condition key, preferring the
|
||||
* descriptive Catalan "estat" text over the numeric symbol.
|
||||
*
|
||||
* @param mixed $point Cel data point.
|
||||
* @return string|null
|
||||
*/
|
||||
private static function condition( mixed $point ): ?string {
|
||||
if ( ! is_array( $point ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$estat = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $point, 'estat' ) ) ?? '';
|
||||
|
||||
if ( '' !== $estat ) {
|
||||
$estat = mb_strtolower( $estat );
|
||||
$keywords = array(
|
||||
'tempesta' => 'thunderstorm',
|
||||
'calabruix' => 'thunderstorm_hail',
|
||||
'aiguaneu' => 'snow',
|
||||
'neu' => 'snow',
|
||||
'plugim' => 'drizzle',
|
||||
'ruixat' => 'rain_showers',
|
||||
'pluja' => 'rain',
|
||||
'boira' => 'fog',
|
||||
'parcialment' => 'partly_cloudy',
|
||||
'molt ennuvolat' => 'overcast',
|
||||
'cobert' => 'overcast',
|
||||
'ennuvolat' => 'cloudy',
|
||||
'núvol' => 'cloudy',
|
||||
'sol' => 'clear',
|
||||
'clar' => 'clear',
|
||||
);
|
||||
|
||||
foreach ( $keywords as $needle => $condition ) {
|
||||
if ( str_contains( $estat, $needle ) ) {
|
||||
return $condition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$symbol = Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $point, 'simbol' ) );
|
||||
|
||||
if ( null === $symbol ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$map = array(
|
||||
1 => 'clear',
|
||||
2 => 'partly_cloudy',
|
||||
3 => 'partly_cloudy',
|
||||
4 => 'cloudy',
|
||||
5 => 'drizzle',
|
||||
6 => 'drizzle',
|
||||
7 => 'drizzle',
|
||||
8 => 'overcast',
|
||||
9 => 'rain_light',
|
||||
10 => 'rain',
|
||||
11 => 'thunderstorm',
|
||||
12 => 'thunderstorm',
|
||||
13 => 'rain_showers',
|
||||
14 => 'rain_showers',
|
||||
15 => 'rain_showers',
|
||||
16 => 'rain',
|
||||
);
|
||||
|
||||
return $map[ $symbol ] ?? 'cloudy';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first non-null value of a pair.
|
||||
*
|
||||
* @param mixed $first First value.
|
||||
* @param mixed $second Second value.
|
||||
* @return mixed
|
||||
*/
|
||||
private static function coalesce( mixed $first, mixed $second ): mixed {
|
||||
return null !== $first ? $first : $second;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Meteocat ISO date-time to an hour key in local time.
|
||||
*
|
||||
* @param string $iso ISO date-time string.
|
||||
* @return string|null Format: Y-m-d H:00.
|
||||
*/
|
||||
private static function hour_key( string $iso ): ?string {
|
||||
try {
|
||||
return ( new DateTimeImmutable( $iso ) )->setTimezone( new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) )->format( 'Y-m-d H:00' );
|
||||
} catch ( Exception ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an hour key to a Unix timestamp.
|
||||
*
|
||||
* @param string $key Hour key (Y-m-d H:00).
|
||||
* @return int
|
||||
*/
|
||||
private static function key_timestamp( string $key ): int {
|
||||
try {
|
||||
return ( new DateTimeImmutable( $key, new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) ) )->getTimestamp();
|
||||
} catch ( Exception ) {
|
||||
return time();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current hour key used to filter hourly series.
|
||||
*
|
||||
* @return string Format: Y-m-d H:00.
|
||||
*/
|
||||
private static function now_key(): string {
|
||||
return ( new DateTimeImmutable( 'now', new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) ) )->format( 'Y-m-d H:00' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a coordinate value to float, handling decimal commas.
|
||||
*
|
||||
* @param mixed $value Raw value.
|
||||
* @return float|null
|
||||
*/
|
||||
private static function to_float( mixed $value ): ?float {
|
||||
if ( is_int( $value ) || is_float( $value ) ) {
|
||||
return (float) $value;
|
||||
}
|
||||
|
||||
if ( is_string( $value ) ) {
|
||||
$normalized = str_replace( ',', '.', trim( $value ) );
|
||||
|
||||
return is_numeric( $normalized ) ? (float) $normalized : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Haversine distance in kilometers between two coordinates.
|
||||
*
|
||||
* @param float $lat1 Latitude A.
|
||||
* @param float $lon1 Longitude A.
|
||||
* @param float $lat2 Latitude B.
|
||||
* @param float $lon2 Longitude B.
|
||||
* @return float
|
||||
*/
|
||||
private static function haversine( float $lat1, float $lon1, float $lat2, float $lon2 ): float {
|
||||
$radians = M_PI / 180;
|
||||
$radius = 6371;
|
||||
|
||||
$dlat = ( $lat2 - $lat1 ) * $radians;
|
||||
$dlon = ( $lon2 - $lon1 ) * $radians;
|
||||
|
||||
$a = ( sin( $dlat / 2 ) ** 2 ) + ( cos( $lat1 * $radians ) * cos( $lat2 * $radians ) * ( sin( $dlon / 2 ) ** 2 ) );
|
||||
|
||||
return 2 * $radius * asin( sqrt( $a ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an authenticated GET request and decodes the JSON response.
|
||||
*
|
||||
* @param string $path API path.
|
||||
* @param string $api_key Meteocat API key.
|
||||
* @return array<mixed>|null
|
||||
*/
|
||||
private static function request( string $path, string $api_key ): ?array {
|
||||
if ( '' === $api_key ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$response = wp_remote_get(
|
||||
self::BASE_URL . $path,
|
||||
array(
|
||||
'timeout' => 5,
|
||||
'headers' => array(
|
||||
'X-Api-Key' => $api_key,
|
||||
'Accept' => 'application/json',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
self::log( 'Meteocat request failed: ' . $response->get_error_message() );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$code = wp_remote_retrieve_response_code( $response );
|
||||
|
||||
if ( 200 !== $code ) {
|
||||
self::log( 'Meteocat returned HTTP ' . $code . ' for ' . $path );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode( (string) wp_remote_retrieve_body( $response ), true );
|
||||
|
||||
return is_array( $data ) ? $data : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a message to the error log with the plugin prefix.
|
||||
*
|
||||
* @param string $message Message.
|
||||
* @return void
|
||||
*/
|
||||
private static function log( string $message ): void {
|
||||
error_log( '[fontdelbosc-eltemps] ' . $message );
|
||||
}
|
||||
}
|
||||
379
includes/class-fontdelbosc-api-openmeteo.php
Normal file
|
|
@ -0,0 +1,379 @@
|
|||
<?php
|
||||
/**
|
||||
* Open-Meteo API handler. No API key required; used as universal fallback
|
||||
* and as the only source for historical (ERA5) data.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Handles Open-Meteo forecast and ERA5 archive requests.
|
||||
*/
|
||||
final class Fontdelbosc_Api_OpenMeteo {
|
||||
|
||||
/**
|
||||
* Forecast endpoint.
|
||||
*/
|
||||
private const FORECAST_URL = 'https://api.open-meteo.com/v1/forecast';
|
||||
|
||||
/**
|
||||
* ERA5 archive endpoint.
|
||||
*/
|
||||
private const ARCHIVE_URL = 'https://archive-api.open-meteo.com/v1/archive';
|
||||
|
||||
/**
|
||||
* WMO weather interpretation code to condition key.
|
||||
*
|
||||
* @var array<int,string>
|
||||
*/
|
||||
private const WMO_MAP = array(
|
||||
0 => 'clear',
|
||||
1 => 'mainly_clear',
|
||||
2 => 'partly_cloudy',
|
||||
3 => 'overcast',
|
||||
45 => 'fog',
|
||||
48 => 'fog',
|
||||
51 => 'drizzle_light',
|
||||
53 => 'drizzle',
|
||||
55 => 'drizzle_heavy',
|
||||
61 => 'rain_light',
|
||||
63 => 'rain',
|
||||
65 => 'rain_heavy',
|
||||
71 => 'snow_light',
|
||||
73 => 'snow',
|
||||
75 => 'snow_heavy',
|
||||
80 => 'rain_showers_light',
|
||||
81 => 'rain_showers',
|
||||
82 => 'rain_showers_heavy',
|
||||
95 => 'thunderstorm',
|
||||
96 => 'thunderstorm_hail',
|
||||
99 => 'thunderstorm_hail',
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns normalized current conditions.
|
||||
*
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_current(): ?array {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'latitude' => FONTDELBOSC_ELTEMPS_LAT,
|
||||
'longitude' => FONTDELBOSC_ELTEMPS_LON,
|
||||
'current' => 'temperature_2m,relative_humidity_2m,apparent_temperature,precipitation,weather_code,wind_speed_10m,wind_direction_10m',
|
||||
'timezone' => FONTDELBOSC_ELTEMPS_TIMEZONE,
|
||||
'forecast_days' => 1,
|
||||
),
|
||||
self::FORECAST_URL
|
||||
);
|
||||
$data = self::request( $url );
|
||||
$time = Fontdelbosc_Payload::str( Fontdelbosc_Payload::path( $data, 'current', 'time' ) );
|
||||
|
||||
if ( null === $time ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'temperature' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'current', 'temperature_2m' ) ),
|
||||
'apparent' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'current', 'apparent_temperature' ) ),
|
||||
'humidity' => Fontdelbosc_Payload::int( Fontdelbosc_Payload::path( $data, 'current', 'relative_humidity_2m' ) ),
|
||||
'precipitation' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'current', 'precipitation' ) ),
|
||||
'wind_speed' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'current', 'wind_speed_10m' ) ),
|
||||
'wind_direction' => Fontdelbosc_Payload::int( Fontdelbosc_Payload::path( $data, 'current', 'wind_direction_10m' ) ),
|
||||
'condition' => self::condition( Fontdelbosc_Payload::path( $data, 'current', 'weather_code' ) ),
|
||||
'source' => 'open-meteo',
|
||||
'time' => self::timestamp( $time ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the normalized hourly forecast, from the current hour onwards.
|
||||
*
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_hourly(): ?array {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'latitude' => FONTDELBOSC_ELTEMPS_LAT,
|
||||
'longitude' => FONTDELBOSC_ELTEMPS_LON,
|
||||
'hourly' => 'temperature_2m,precipitation_probability,weather_code,wind_speed_10m',
|
||||
'timezone' => FONTDELBOSC_ELTEMPS_TIMEZONE,
|
||||
'forecast_days' => 3,
|
||||
),
|
||||
self::FORECAST_URL
|
||||
);
|
||||
$data = self::request( $url );
|
||||
$times = Fontdelbosc_Payload::arr( Fontdelbosc_Payload::path( $data, 'hourly', 'time' ) );
|
||||
$now = self::now_key();
|
||||
$hours = array();
|
||||
|
||||
foreach ( $times as $index => $iso_time ) {
|
||||
$raw = Fontdelbosc_Payload::str( $iso_time );
|
||||
|
||||
if ( null === $raw ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$time = str_replace( 'T', ' ', $raw );
|
||||
|
||||
if ( $time < $now ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hours[] = array(
|
||||
'time' => self::timestamp( $time ),
|
||||
'hour' => (int) substr( $time, 11, 2 ),
|
||||
'temperature' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'hourly', 'temperature_2m', $index ) ),
|
||||
'pop' => Fontdelbosc_Payload::int( Fontdelbosc_Payload::path( $data, 'hourly', 'precipitation_probability', $index ) ),
|
||||
'condition' => self::condition( Fontdelbosc_Payload::path( $data, 'hourly', 'weather_code', $index ) ),
|
||||
'wind' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'hourly', 'wind_speed_10m', $index ) ),
|
||||
);
|
||||
}
|
||||
|
||||
if ( array() === $hours ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'source' => 'open-meteo',
|
||||
'hours' => $hours,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the normalized daily forecast.
|
||||
*
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_daily(): ?array {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'latitude' => FONTDELBOSC_ELTEMPS_LAT,
|
||||
'longitude' => FONTDELBOSC_ELTEMPS_LON,
|
||||
'daily' => 'weather_code,temperature_2m_max,temperature_2m_min,precipitation_sum,precipitation_probability_max,wind_speed_10m_max',
|
||||
'timezone' => FONTDELBOSC_ELTEMPS_TIMEZONE,
|
||||
'forecast_days' => 7,
|
||||
),
|
||||
self::FORECAST_URL
|
||||
);
|
||||
$data = self::request( $url );
|
||||
$times = Fontdelbosc_Payload::arr( Fontdelbosc_Payload::path( $data, 'daily', 'time' ) );
|
||||
$days = array();
|
||||
|
||||
foreach ( $times as $index => $date ) {
|
||||
$date = Fontdelbosc_Payload::str( $date );
|
||||
|
||||
if ( null === $date ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$days[] = array(
|
||||
'date' => $date,
|
||||
'condition' => self::condition( Fontdelbosc_Payload::path( $data, 'daily', 'weather_code', $index ) ),
|
||||
'temp_max' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'daily', 'temperature_2m_max', $index ) ),
|
||||
'temp_min' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'daily', 'temperature_2m_min', $index ) ),
|
||||
'precipitation' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'daily', 'precipitation_sum', $index ) ),
|
||||
'pop' => Fontdelbosc_Payload::int( Fontdelbosc_Payload::path( $data, 'daily', 'precipitation_probability_max', $index ) ),
|
||||
'wind_max' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'daily', 'wind_speed_10m_max', $index ) ),
|
||||
);
|
||||
}
|
||||
|
||||
if ( array() === $days ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'source' => 'open-meteo',
|
||||
'days' => $days,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the normalized daily history for a given month (ERA5).
|
||||
*
|
||||
* @param int $year Year (1940 or later).
|
||||
* @param int $month Month (1-12).
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_historical( int $year, int $month ): ?array {
|
||||
try {
|
||||
$start = new DateTimeImmutable( sprintf( '%04d-%02d-01', $year, $month ), new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) );
|
||||
} catch ( Exception ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'latitude' => FONTDELBOSC_ELTEMPS_LAT,
|
||||
'longitude' => FONTDELBOSC_ELTEMPS_LON,
|
||||
'start_date' => $start->format( 'Y-m-d' ),
|
||||
'end_date' => $start->modify( 'last day of this month' )->format( 'Y-m-d' ),
|
||||
'daily' => 'temperature_2m_max,temperature_2m_min,precipitation_sum,wind_speed_10m_max',
|
||||
'timezone' => FONTDELBOSC_ELTEMPS_TIMEZONE,
|
||||
),
|
||||
self::ARCHIVE_URL
|
||||
);
|
||||
$data = self::request( $url );
|
||||
|
||||
$times = Fontdelbosc_Payload::arr( Fontdelbosc_Payload::path( $data, 'daily', 'time' ) );
|
||||
$days = array();
|
||||
|
||||
foreach ( $times as $index => $date ) {
|
||||
$date = Fontdelbosc_Payload::str( $date );
|
||||
$max = Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'daily', 'temperature_2m_max', $index ) );
|
||||
$min = Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'daily', 'temperature_2m_min', $index ) );
|
||||
|
||||
if ( null === $date || ( null === $max && null === $min ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$days[] = array(
|
||||
'date' => $date,
|
||||
'temp_max' => $max,
|
||||
'temp_min' => $min,
|
||||
'precipitation' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'daily', 'precipitation_sum', $index ) ),
|
||||
'wind_max' => Fontdelbosc_Payload::float( Fontdelbosc_Payload::path( $data, 'daily', 'wind_speed_10m_max', $index ) ),
|
||||
);
|
||||
}
|
||||
|
||||
if ( array() === $days ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'source' => 'open-meteo',
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
'days' => $days,
|
||||
'stats' => self::stats( $days ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes monthly statistics for a set of normalized history days.
|
||||
*
|
||||
* @param array<int,array<string,mixed>> $days Normalized days.
|
||||
* @return array<string,float|null>
|
||||
*/
|
||||
private static function stats( array $days ): array {
|
||||
$maxes = array();
|
||||
$mins = array();
|
||||
$precip_sum = 0.0;
|
||||
$wind_max = null;
|
||||
|
||||
foreach ( $days as $day ) {
|
||||
$max = Fontdelbosc_Payload::float( Fontdelbosc_Payload::get( $day, 'temp_max' ) );
|
||||
$min = Fontdelbosc_Payload::float( Fontdelbosc_Payload::get( $day, 'temp_min' ) );
|
||||
$pre = Fontdelbosc_Payload::float( Fontdelbosc_Payload::get( $day, 'precipitation' ) );
|
||||
$win = Fontdelbosc_Payload::float( Fontdelbosc_Payload::get( $day, 'wind_max' ) );
|
||||
|
||||
if ( null !== $max ) {
|
||||
$maxes[] = $max;
|
||||
}
|
||||
|
||||
if ( null !== $min ) {
|
||||
$mins[] = $min;
|
||||
}
|
||||
|
||||
if ( null !== $pre ) {
|
||||
$precip_sum += $pre;
|
||||
}
|
||||
|
||||
if ( null !== $win ) {
|
||||
$wind_max = max( (float) $wind_max, $win );
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'avg_max' => array() === $maxes ? null : round( array_sum( $maxes ) / count( $maxes ), 1 ),
|
||||
'avg_min' => array() === $mins ? null : round( array_sum( $mins ) / count( $mins ), 1 ),
|
||||
'total_precip' => round( $precip_sum, 1 ),
|
||||
'max_wind' => $wind_max,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a WMO code to a condition key.
|
||||
*
|
||||
* @param mixed $code WMO weather code.
|
||||
* @return string|null
|
||||
*/
|
||||
private static function condition( mixed $code ): ?string {
|
||||
if ( ! is_numeric( $code ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return self::WMO_MAP[ (int) $code ] ?? 'cloudy';
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a local (Europe/Madrid) ISO string to a Unix timestamp.
|
||||
*
|
||||
* @param string $iso ISO date-time string.
|
||||
* @return int
|
||||
*/
|
||||
private static function timestamp( string $iso ): int {
|
||||
try {
|
||||
return ( new DateTimeImmutable( $iso, new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) ) )->getTimestamp();
|
||||
} catch ( Exception ) {
|
||||
return time();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current hour key used to filter hourly series.
|
||||
*
|
||||
* @return string Format: Y-m-d H:00.
|
||||
*/
|
||||
private static function now_key(): string {
|
||||
return ( new DateTimeImmutable( 'now', new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) ) )->format( 'Y-m-d H:00' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a GET request and decodes the JSON response.
|
||||
*
|
||||
* @param string $url Request URL.
|
||||
* @return array<mixed>|null
|
||||
*/
|
||||
private static function request( string $url ): ?array {
|
||||
$response = wp_remote_get(
|
||||
$url,
|
||||
array(
|
||||
'timeout' => 5,
|
||||
'headers' => array(
|
||||
'Accept' => 'application/json',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
self::log( 'Open-Meteo request failed: ' . $response->get_error_message() );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$code = wp_remote_retrieve_response_code( $response );
|
||||
|
||||
if ( 200 !== $code ) {
|
||||
self::log( 'Open-Meteo returned HTTP ' . $code );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode( (string) wp_remote_retrieve_body( $response ), true );
|
||||
|
||||
return is_array( $data ) ? $data : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a message to the error log with the plugin prefix.
|
||||
*
|
||||
* @param string $message Message.
|
||||
* @return void
|
||||
*/
|
||||
private static function log( string $message ): void {
|
||||
error_log( '[fontdelbosc-eltemps] ' . $message );
|
||||
}
|
||||
}
|
||||
148
includes/class-fontdelbosc-conditions.php
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
/**
|
||||
* Shared weather condition keys: labels (translated), Meteocons icons,
|
||||
* day/night detection and localized calendar names.
|
||||
*
|
||||
* Icons are Meteocons (https://github.com/basmilius/meteocons), MIT license,
|
||||
* bundled under public/icons/flat/.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Maps condition keys to translated labels, Meteocons icons and
|
||||
* localized calendar names.
|
||||
*/
|
||||
final class Fontdelbosc_Conditions {
|
||||
|
||||
/**
|
||||
* Condition key to Meteocons file names, indexed [ day, night ].
|
||||
*
|
||||
* @var array<string,array{0:string,1:string}>
|
||||
*/
|
||||
private const ICONS = array(
|
||||
'clear' => array( 'clear-day.svg', 'clear-night.svg' ),
|
||||
'mainly_clear' => array( 'clear-day.svg', 'clear-night.svg' ),
|
||||
'partly_cloudy' => array( 'partly-cloudy-day.svg', 'partly-cloudy-night.svg' ),
|
||||
'cloudy' => array( 'cloudy.svg', 'cloudy.svg' ),
|
||||
'overcast' => array( 'overcast.svg', 'overcast.svg' ),
|
||||
'fog' => array( 'fog-day.svg', 'fog-night.svg' ),
|
||||
'drizzle_light' => array( 'drizzle.svg', 'drizzle.svg' ),
|
||||
'drizzle' => array( 'drizzle.svg', 'drizzle.svg' ),
|
||||
'drizzle_heavy' => array( 'drizzle.svg', 'drizzle.svg' ),
|
||||
'rain_light' => array( 'overcast-rain.svg', 'overcast-rain.svg' ),
|
||||
'rain' => array( 'rain.svg', 'rain.svg' ),
|
||||
'rain_heavy' => array( 'extreme-rain.svg', 'extreme-rain.svg' ),
|
||||
'rain_showers_light' => array( 'partly-cloudy-day-rain.svg', 'partly-cloudy-night-rain.svg' ),
|
||||
'rain_showers' => array( 'partly-cloudy-day-rain.svg', 'partly-cloudy-night-rain.svg' ),
|
||||
'rain_showers_heavy' => array( 'rain.svg', 'rain.svg' ),
|
||||
'snow_light' => array( 'snow.svg', 'snow.svg' ),
|
||||
'snow' => array( 'snow.svg', 'snow.svg' ),
|
||||
'snow_heavy' => array( 'extreme-snow.svg', 'extreme-snow.svg' ),
|
||||
'thunderstorm' => array( 'thunderstorms-day-rain.svg', 'thunderstorms-night-rain.svg' ),
|
||||
'thunderstorm_hail' => array( 'thunderstorms-day-hail.svg', 'thunderstorms-night-hail.svg' ),
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns the translated label for a condition key.
|
||||
*
|
||||
* @param string $key Condition key.
|
||||
* @return string
|
||||
*/
|
||||
public static function label( string $key ): string {
|
||||
$labels = array(
|
||||
'clear' => __( 'Clear sky', 'fontdelbosc-eltemps' ),
|
||||
'mainly_clear' => __( 'Clear sky', 'fontdelbosc-eltemps' ),
|
||||
'partly_cloudy' => __( 'Partly cloudy', 'fontdelbosc-eltemps' ),
|
||||
'cloudy' => __( 'Cloudy', 'fontdelbosc-eltemps' ),
|
||||
'overcast' => __( 'Overcast', 'fontdelbosc-eltemps' ),
|
||||
'fog' => __( 'Fog', 'fontdelbosc-eltemps' ),
|
||||
'drizzle_light' => __( 'Drizzle', 'fontdelbosc-eltemps' ),
|
||||
'drizzle' => __( 'Drizzle', 'fontdelbosc-eltemps' ),
|
||||
'drizzle_heavy' => __( 'Drizzle', 'fontdelbosc-eltemps' ),
|
||||
'rain_light' => __( 'Rain', 'fontdelbosc-eltemps' ),
|
||||
'rain' => __( 'Rain', 'fontdelbosc-eltemps' ),
|
||||
'rain_heavy' => __( 'Rain', 'fontdelbosc-eltemps' ),
|
||||
'rain_showers_light' => __( 'Rain', 'fontdelbosc-eltemps' ),
|
||||
'rain_showers' => __( 'Rain', 'fontdelbosc-eltemps' ),
|
||||
'rain_showers_heavy' => __( 'Rain', 'fontdelbosc-eltemps' ),
|
||||
'snow_light' => __( 'Snow', 'fontdelbosc-eltemps' ),
|
||||
'snow' => __( 'Snow', 'fontdelbosc-eltemps' ),
|
||||
'snow_heavy' => __( 'Snow', 'fontdelbosc-eltemps' ),
|
||||
'thunderstorm' => __( 'Thunderstorm', 'fontdelbosc-eltemps' ),
|
||||
'thunderstorm_hail' => __( 'Thunderstorm', 'fontdelbosc-eltemps' ),
|
||||
);
|
||||
|
||||
return $labels[ $key ] ?? $labels['cloudy'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bundled Meteocons icon URL for a condition key.
|
||||
*
|
||||
* @param string $key Condition key.
|
||||
* @param bool $night Whether the night variant should be used.
|
||||
* @return string
|
||||
*/
|
||||
public static function icon( string $key, bool $night = false ): string {
|
||||
$files = self::ICONS[ $key ] ?? self::ICONS['cloudy'];
|
||||
|
||||
return FONTDELBOSC_ELTEMPS_PLUGIN_URL . 'public/icons/flat/' . $files[ $night ? 1 : 0 ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Rough day/night detection for icon selection.
|
||||
*
|
||||
* @param int $hour Local hour (0-23).
|
||||
* @return bool True when night.
|
||||
*/
|
||||
public static function is_night( int $hour ): bool {
|
||||
return $hour < 7 || $hour >= 21;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translated weekday name for an ISO-8601 weekday number.
|
||||
*
|
||||
* @param int $number Weekday number (1 = Monday, 7 = Sunday).
|
||||
* @return string
|
||||
*/
|
||||
public static function weekday( int $number ): string {
|
||||
$weekdays = array(
|
||||
1 => __( 'Monday', 'fontdelbosc-eltemps' ),
|
||||
2 => __( 'Tuesday', 'fontdelbosc-eltemps' ),
|
||||
3 => __( 'Wednesday', 'fontdelbosc-eltemps' ),
|
||||
4 => __( 'Thursday', 'fontdelbosc-eltemps' ),
|
||||
5 => __( 'Friday', 'fontdelbosc-eltemps' ),
|
||||
6 => __( 'Saturday', 'fontdelbosc-eltemps' ),
|
||||
7 => __( 'Sunday', 'fontdelbosc-eltemps' ),
|
||||
);
|
||||
|
||||
return $weekdays[ $number ] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translated month name for a month number.
|
||||
*
|
||||
* @param int $number Month number (1-12).
|
||||
* @return string
|
||||
*/
|
||||
public static function month( int $number ): string {
|
||||
$months = array(
|
||||
1 => __( 'January', 'fontdelbosc-eltemps' ),
|
||||
2 => __( 'February', 'fontdelbosc-eltemps' ),
|
||||
3 => __( 'March', 'fontdelbosc-eltemps' ),
|
||||
4 => __( 'April', 'fontdelbosc-eltemps' ),
|
||||
5 => __( 'May', 'fontdelbosc-eltemps' ),
|
||||
6 => __( 'June', 'fontdelbosc-eltemps' ),
|
||||
7 => __( 'July', 'fontdelbosc-eltemps' ),
|
||||
8 => __( 'August', 'fontdelbosc-eltemps' ),
|
||||
9 => __( 'September', 'fontdelbosc-eltemps' ),
|
||||
10 => __( 'October', 'fontdelbosc-eltemps' ),
|
||||
11 => __( 'November', 'fontdelbosc-eltemps' ),
|
||||
12 => __( 'December', 'fontdelbosc-eltemps' ),
|
||||
);
|
||||
|
||||
return $months[ $number ] ?? '';
|
||||
}
|
||||
}
|
||||
260
includes/class-fontdelbosc-data-manager.php
Normal file
|
|
@ -0,0 +1,260 @@
|
|||
<?php
|
||||
/**
|
||||
* Data manager. Orchestrates the API sources with per-view fallback chains
|
||||
* and Transients API caching (stale-while-error pattern).
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Orchestrates API sources, caching and fallback chains.
|
||||
*/
|
||||
final class Fontdelbosc_Data_Manager {
|
||||
|
||||
/**
|
||||
* Warms or refreshes every cache, regardless of who triggers it.
|
||||
* Hooked to the hourly fontdelbosc_refresh_weather WP-Cron event so
|
||||
* visitors are never served by a cold cache.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function refresh(): void {
|
||||
self::get_current();
|
||||
self::get_hourly( 24 );
|
||||
self::get_daily();
|
||||
|
||||
$now = new DateTimeImmutable( 'now', new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) );
|
||||
$previous = $now->modify( 'first day of previous month' );
|
||||
|
||||
self::get_historical( (int) $previous->format( 'Y' ), (int) $previous->format( 'n' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns normalized current conditions.
|
||||
*
|
||||
* Chain: Meteocat XEMA station (when key and station are configured)
|
||||
* → Open-Meteo current.
|
||||
*
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_current(): ?array {
|
||||
$options = Fontdelbosc_Plugin::get_options();
|
||||
$data = self::cached(
|
||||
'fontdelbosc_current',
|
||||
$options['cache_ttl_current'],
|
||||
static function () use ( $options ): ?array {
|
||||
if ( '' !== $options['meteocat_api_key'] && '' !== $options['meteocat_station_code'] ) {
|
||||
$current = Fontdelbosc_Api_Meteocat::get_current( $options['meteocat_api_key'], $options['meteocat_station_code'] );
|
||||
|
||||
if ( null !== $current ) {
|
||||
$hourly = Fontdelbosc_Data_Manager::get_hourly( 1 );
|
||||
$firsthour = Fontdelbosc_Payload::path( $hourly, 'hours', 0 );
|
||||
|
||||
if ( is_array( $firsthour ) && null !== Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $firsthour, 'condition' ) ) ) {
|
||||
$current['condition'] = Fontdelbosc_Payload::get( $firsthour, 'condition' );
|
||||
}
|
||||
|
||||
return $current;
|
||||
}
|
||||
}
|
||||
|
||||
return Fontdelbosc_Api_OpenMeteo::get_current();
|
||||
}
|
||||
);
|
||||
|
||||
if ( ! is_array( $data ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'temperature' => Fontdelbosc_Payload::get( $data, 'temperature' ),
|
||||
'apparent' => Fontdelbosc_Payload::get( $data, 'apparent' ),
|
||||
'humidity' => Fontdelbosc_Payload::get( $data, 'humidity' ),
|
||||
'precipitation' => Fontdelbosc_Payload::get( $data, 'precipitation' ),
|
||||
'wind_speed' => Fontdelbosc_Payload::get( $data, 'wind_speed' ),
|
||||
'wind_direction' => Fontdelbosc_Payload::get( $data, 'wind_direction' ),
|
||||
'condition' => Fontdelbosc_Payload::get( $data, 'condition' ),
|
||||
'source' => Fontdelbosc_Payload::get( $data, 'source' ),
|
||||
'time' => Fontdelbosc_Payload::get( $data, 'time' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hourly forecast sliced to the requested number of hours.
|
||||
*
|
||||
* Chain: Meteocat municipal → AEMET hourly → Open-Meteo hourly.
|
||||
*
|
||||
* @param int $hours Number of hours (1-48).
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_hourly( int $hours = 24 ): ?array {
|
||||
$options = Fontdelbosc_Plugin::get_options();
|
||||
$data = self::cached(
|
||||
'fontdelbosc_forecast_hourly',
|
||||
$options['cache_ttl_forecast'],
|
||||
static function () use ( $options ): ?array {
|
||||
if ( '' !== $options['meteocat_api_key'] ) {
|
||||
$data = Fontdelbosc_Api_Meteocat::get_hourly( $options['meteocat_api_key'] );
|
||||
|
||||
if ( null !== $data ) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
if ( '' !== $options['aemet_api_key'] ) {
|
||||
$data = Fontdelbosc_Api_Aemet::get_hourly( $options['aemet_api_key'] );
|
||||
|
||||
if ( null !== $data ) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
return Fontdelbosc_Api_OpenMeteo::get_hourly();
|
||||
}
|
||||
);
|
||||
|
||||
$entries = array_values( array_filter( Fontdelbosc_Payload::arr( Fontdelbosc_Payload::get( $data, 'hours' ) ), 'is_array' ) );
|
||||
$source = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $data, 'source' ) );
|
||||
|
||||
if ( '' === $source || array() === $entries ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'source' => $source,
|
||||
'hours' => array_slice( $entries, 0, max( 1, min( 48, $hours ) ) ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the daily forecast sliced to the requested number of days.
|
||||
*
|
||||
* Chain: AEMET daily → Open-Meteo daily.
|
||||
*
|
||||
* @param int $days Number of days (1-7).
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_daily( int $days = 7 ): ?array {
|
||||
$options = Fontdelbosc_Plugin::get_options();
|
||||
$data = self::cached(
|
||||
'fontdelbosc_forecast_daily',
|
||||
$options['cache_ttl_forecast'],
|
||||
static function () use ( $options ): ?array {
|
||||
if ( '' !== $options['aemet_api_key'] ) {
|
||||
$data = Fontdelbosc_Api_Aemet::get_daily( $options['aemet_api_key'] );
|
||||
|
||||
if ( null !== $data ) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
return Fontdelbosc_Api_OpenMeteo::get_daily();
|
||||
}
|
||||
);
|
||||
|
||||
$entries = array_values( array_filter( Fontdelbosc_Payload::arr( Fontdelbosc_Payload::get( $data, 'days' ) ), 'is_array' ) );
|
||||
$source = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $data, 'source' ) );
|
||||
|
||||
if ( '' === $source || array() === $entries ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'source' => $source,
|
||||
'days' => array_slice( $entries, 0, max( 1, min( 7, $days ) ) ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the daily history for a month (Open-Meteo ERA5 archive).
|
||||
*
|
||||
* @param int $year Year (1940 onwards).
|
||||
* @param int $month Month (1-12).
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function get_historical( int $year, int $month ): ?array {
|
||||
$year = max( 1940, min( (int) gmdate( 'Y' ), $year ) );
|
||||
$month = max( 1, min( 12, $month ) );
|
||||
|
||||
$options = Fontdelbosc_Plugin::get_options();
|
||||
$data = self::cached(
|
||||
'fontdelbosc_historical_' . $year . '_' . $month,
|
||||
$options['cache_ttl_historical'],
|
||||
static function () use ( $year, $month ): ?array {
|
||||
return Fontdelbosc_Api_OpenMeteo::get_historical( $year, $month );
|
||||
}
|
||||
);
|
||||
|
||||
$entries = array_values( array_filter( Fontdelbosc_Payload::arr( Fontdelbosc_Payload::get( $data, 'days' ) ), 'is_array' ) );
|
||||
$source = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $data, 'source' ) );
|
||||
|
||||
if ( '' === $source || array() === $entries ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'source' => $source,
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
'days' => $entries,
|
||||
'stats' => Fontdelbosc_Payload::arr( Fontdelbosc_Payload::get( $data, 'stats' ) ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the license attribution line for a data source slug.
|
||||
*
|
||||
* @param string $source Source slug (meteocat, aemet, open-meteo).
|
||||
* @return string
|
||||
*/
|
||||
public static function attribution( string $source ): string {
|
||||
$map = array(
|
||||
'meteocat' => '© Servei Meteorològic de Catalunya. Generalitat de Catalunya',
|
||||
'aemet' => '© AEMET. Gobierno de España',
|
||||
'open-meteo' => 'Weather data by Open-Meteo.com (CC BY 4.0)',
|
||||
);
|
||||
|
||||
return $map[ $source ] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache helper implementing stale-while-error. Fresh data is served
|
||||
* until its TTL expires; on fetch failure the last cached payload is
|
||||
* served for up to one extra day.
|
||||
*
|
||||
* @param string $key Transient key.
|
||||
* @param int $ttl Time-to-live in seconds.
|
||||
* @param callable $fetch Fetch callback returning array|null.
|
||||
* @return mixed
|
||||
*/
|
||||
private static function cached( string $key, int $ttl, callable $fetch ): mixed {
|
||||
$cache = get_transient( $key );
|
||||
|
||||
if ( is_array( $cache ) && (int) Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $cache, 'expires' ) ?? 0 ) > time() ) {
|
||||
return Fontdelbosc_Payload::get( $cache, 'data' );
|
||||
}
|
||||
|
||||
$data = $fetch();
|
||||
|
||||
if ( null !== $data ) {
|
||||
set_transient(
|
||||
$key,
|
||||
array(
|
||||
'expires' => time() + $ttl,
|
||||
'data' => $data,
|
||||
),
|
||||
$ttl + DAY_IN_SECONDS
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
if ( is_array( $cache ) ) {
|
||||
return Fontdelbosc_Payload::get( $cache, 'data' );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
88
includes/class-fontdelbosc-payload.php
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
/**
|
||||
* Typed helpers to navigate decoded JSON payloads without casting mixed values.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Narrowing helpers for mixed JSON values.
|
||||
*/
|
||||
final class Fontdelbosc_Payload {
|
||||
|
||||
/**
|
||||
* Walks a nested array path and returns the value at the end, or null.
|
||||
*
|
||||
* @param mixed $value Starting value.
|
||||
* @param int|string|null ...$keys Path keys.
|
||||
* @return mixed
|
||||
*/
|
||||
public static function path( mixed $value, int|string|null ...$keys ): mixed {
|
||||
foreach ( $keys as $key ) {
|
||||
if ( null === $key || ! is_array( $value ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = $value[ $key ] ?? null;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value at a key, or null when the holder is not an array.
|
||||
*
|
||||
* @param mixed $value Holder.
|
||||
* @param int|string $key Key.
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get( mixed $value, int|string $key ): mixed {
|
||||
if ( ! is_array( $value ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value[ $key ] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value as an array, or an empty array.
|
||||
*
|
||||
* @param mixed $value Raw value.
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public static function arr( mixed $value ): array {
|
||||
return is_array( $value ) ? $value : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value as a string, or null.
|
||||
*
|
||||
* @param mixed $value Raw value.
|
||||
* @return string|null
|
||||
*/
|
||||
public static function str( mixed $value ): ?string {
|
||||
return is_string( $value ) ? $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value as an integer, or null.
|
||||
*
|
||||
* @param mixed $value Raw value.
|
||||
* @return int|null
|
||||
*/
|
||||
public static function int( mixed $value ): ?int {
|
||||
return is_numeric( $value ) ? (int) round( (float) $value ) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value as a float, or null.
|
||||
*
|
||||
* @param mixed $value Raw value.
|
||||
* @return float|null
|
||||
*/
|
||||
public static function float( mixed $value ): ?float {
|
||||
return is_numeric( $value ) ? (float) $value : null;
|
||||
}
|
||||
}
|
||||
168
includes/class-fontdelbosc-plugin.php
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
/**
|
||||
* Bootstrap class. Single entry point that wires every component.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Wires every plugin component and holds the typed options accessor.
|
||||
*/
|
||||
final class Fontdelbosc_Plugin {
|
||||
|
||||
/**
|
||||
* Options shape.
|
||||
*
|
||||
* @var array{
|
||||
* aemet_api_key: string,
|
||||
* meteocat_api_key: string,
|
||||
* meteocat_station_code: string,
|
||||
* cache_ttl_current: int,
|
||||
* cache_ttl_forecast: int,
|
||||
* cache_ttl_historical: int,
|
||||
* display_attribution: bool,
|
||||
* delete_data_on_uninstall: bool
|
||||
* }|null
|
||||
*/
|
||||
private static ?array $options = null;
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @var Fontdelbosc_Plugin|null
|
||||
*/
|
||||
private static ?Fontdelbosc_Plugin $instance = null;
|
||||
|
||||
/**
|
||||
* Returns the singleton instance.
|
||||
*
|
||||
* @return Fontdelbosc_Plugin
|
||||
*/
|
||||
public static function instance(): Fontdelbosc_Plugin {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers every hook. Private constructor: use instance().
|
||||
*/
|
||||
private function __construct() {
|
||||
add_action( 'init', array( $this, 'load_textdomain' ) );
|
||||
add_action( 'init', array( $this, 'init_components' ) );
|
||||
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) );
|
||||
add_action( 'fontdelbosc_refresh_weather', array( 'Fontdelbosc_Data_Manager', 'refresh' ) );
|
||||
|
||||
if ( is_admin() ) {
|
||||
require_once FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'admin/class-fontdelbosc-admin.php';
|
||||
Fontdelbosc_Admin::init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the plugin text domain. Hooked on init to avoid the
|
||||
* just-in-time loading notice on WordPress 6.7+.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function load_textdomain(): void {
|
||||
load_plugin_textdomain(
|
||||
'fontdelbosc-eltemps',
|
||||
false,
|
||||
dirname( plugin_basename( FONTDELBOSC_ELTEMPS_PLUGIN_FILE ) ) . '/languages/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the frontend components.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init_components(): void {
|
||||
Fontdelbosc_Shortcode::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the sidebar widget.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets(): void {
|
||||
register_widget( 'Fontdelbosc_Widget' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers (not enqueues) the public stylesheet, so it is only
|
||||
* printed on pages that actually render weather output.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_assets(): void {
|
||||
wp_register_style(
|
||||
'fdb-weather',
|
||||
FONTDELBOSC_ELTEMPS_PLUGIN_URL . 'public/css/fdb-weather.css',
|
||||
array(),
|
||||
FONTDELBOSC_ELTEMPS_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules the hourly cache-refresh event on activation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function activate(): void {
|
||||
if ( ! wp_next_scheduled( 'fontdelbosc_refresh_weather' ) ) {
|
||||
wp_schedule_event( time(), 'hourly', 'fontdelbosc_refresh_weather' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the scheduled cache-refresh event on deactivation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function deactivate(): void {
|
||||
wp_clear_scheduled_hook( 'fontdelbosc_refresh_weather' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin options merged with their defaults, with every
|
||||
* value narrowed to its documented type.
|
||||
*
|
||||
* @return array{
|
||||
* aemet_api_key: string,
|
||||
* meteocat_api_key: string,
|
||||
* meteocat_station_code: string,
|
||||
* cache_ttl_current: int,
|
||||
* cache_ttl_forecast: int,
|
||||
* cache_ttl_historical: int,
|
||||
* display_attribution: bool,
|
||||
* delete_data_on_uninstall: bool
|
||||
* }
|
||||
*/
|
||||
public static function get_options(): array {
|
||||
if ( null === self::$options ) {
|
||||
$stored = get_option( 'fontdelbosc_options', array() );
|
||||
$stored = is_array( $stored ) ? $stored : array();
|
||||
|
||||
self::$options = array(
|
||||
'aemet_api_key' => Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $stored, 'aemet_api_key' ) ) ?? '',
|
||||
'meteocat_api_key' => Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $stored, 'meteocat_api_key' ) ) ?? '',
|
||||
'meteocat_station_code' => Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $stored, 'meteocat_station_code' ) ) ?? '',
|
||||
'cache_ttl_current' => Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $stored, 'cache_ttl_current' ) ) ?? 600,
|
||||
'cache_ttl_forecast' => Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $stored, 'cache_ttl_forecast' ) ) ?? 3600,
|
||||
'cache_ttl_historical' => Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $stored, 'cache_ttl_historical' ) ) ?? 86400,
|
||||
'display_attribution' => array_key_exists( 'display_attribution', $stored ) ? ! empty( $stored['display_attribution'] ) : true,
|
||||
'delete_data_on_uninstall' => ! empty( $stored['delete_data_on_uninstall'] ),
|
||||
);
|
||||
}
|
||||
|
||||
return self::$options;
|
||||
}
|
||||
}
|
||||
145
includes/class-fontdelbosc-shortcode.php
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
/**
|
||||
* Shortcode [fontdelbosc_eltemps] and the shared view renderer used by
|
||||
* both the shortcode and the widget.
|
||||
*
|
||||
* Attributes:
|
||||
* - view: current (default), hourly, daily, historical
|
||||
* - hours: 1-48, hours to show in the hourly view (default 24)
|
||||
* - days: 1-7, days to show in the daily view (default 7)
|
||||
* - year/month: month shown in the historical view (default: current)
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Renders the weather views for the shortcode and the widget.
|
||||
*/
|
||||
final class Fontdelbosc_Shortcode {
|
||||
|
||||
/**
|
||||
* Registers the shortcode hook.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function init(): void {
|
||||
add_shortcode( 'fontdelbosc_eltemps', array( self::class, 'render' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the shortcode.
|
||||
*
|
||||
* @param array<string> $atts Shortcode attributes.
|
||||
* @param string|null $content Enclosed content (unused).
|
||||
* @param string $tag Shortcode tag (unused).
|
||||
* @return string
|
||||
*/
|
||||
public static function render( $atts = array(), ?string $content = null, string $tag = '' ): string {
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
'view' => 'current',
|
||||
'hours' => 24,
|
||||
'days' => 7,
|
||||
'year' => 0,
|
||||
'month' => 0,
|
||||
),
|
||||
$atts,
|
||||
'fontdelbosc_eltemps'
|
||||
);
|
||||
|
||||
$view = sanitize_key( Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $atts, 'view' ) ) ?? 'current' );
|
||||
|
||||
if ( ! in_array( $view, array( 'current', 'hourly', 'daily', 'historical' ), true ) ) {
|
||||
$view = 'current';
|
||||
}
|
||||
|
||||
return self::render_view(
|
||||
$view,
|
||||
array(
|
||||
'hours' => max( 1, min( 48, Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $atts, 'hours' ) ) ?? 24 ) ),
|
||||
'days' => max( 1, min( 7, Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $atts, 'days' ) ) ?? 7 ) ),
|
||||
'year' => Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $atts, 'year' ) ) ?? 0,
|
||||
'month' => max( 0, min( 12, Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $atts, 'month' ) ) ?? 0 ) ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a weather view. Shared by shortcode and widget.
|
||||
*
|
||||
* @param string $view View name.
|
||||
* @param array<string,mixed> $args Optional view arguments.
|
||||
* @return string
|
||||
*/
|
||||
public static function render_view( string $view, array $args = array() ): string {
|
||||
$args = wp_parse_args(
|
||||
$args,
|
||||
array(
|
||||
'hours' => 24,
|
||||
'days' => 7,
|
||||
'year' => 0,
|
||||
'month' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
$template = 'current.php';
|
||||
$data = null;
|
||||
$now = new DateTimeImmutable( 'now', new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) );
|
||||
|
||||
switch ( $view ) {
|
||||
case 'hourly':
|
||||
$template = 'forecast-hourly.php';
|
||||
$data = Fontdelbosc_Data_Manager::get_hourly( Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $args, 'hours' ) ) ?? 24 );
|
||||
break;
|
||||
case 'daily':
|
||||
$template = 'forecast-daily.php';
|
||||
$data = Fontdelbosc_Data_Manager::get_daily( Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $args, 'days' ) ) ?? 7 );
|
||||
break;
|
||||
case 'historical':
|
||||
$template = 'historical.php';
|
||||
$year = Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $args, 'year' ) ) ?? 0;
|
||||
$month = Fontdelbosc_Payload::int( Fontdelbosc_Payload::get( $args, 'month' ) ) ?? 0;
|
||||
|
||||
if ( $year > 0 || $month > 0 ) {
|
||||
$data = Fontdelbosc_Data_Manager::get_historical(
|
||||
$year > 0 ? $year : (int) $now->format( 'Y' ),
|
||||
$month > 0 ? $month : (int) $now->format( 'n' )
|
||||
);
|
||||
} else {
|
||||
$previous = $now->modify( 'first day of previous month' );
|
||||
|
||||
$data = Fontdelbosc_Data_Manager::get_historical(
|
||||
(int) $previous->format( 'Y' ),
|
||||
(int) $previous->format( 'n' )
|
||||
);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$data = Fontdelbosc_Data_Manager::get_current();
|
||||
}
|
||||
|
||||
if ( null === $data ) {
|
||||
return '<p class="fdb-weather fdb-unavailable">' . esc_html__( 'Weather data unavailable.', 'fontdelbosc-eltemps' ) . '</p>';
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'fdb-weather' );
|
||||
|
||||
return self::load_template( $template, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Buffers and returns a template.
|
||||
*
|
||||
* @param string $template Template file name.
|
||||
* @param array<string,mixed> $data Normalized view data.
|
||||
* @return string
|
||||
*/
|
||||
private static function load_template( string $template, array $data ): string {
|
||||
ob_start();
|
||||
include FONTDELBOSC_ELTEMPS_PLUGIN_DIR . 'templates/' . $template;
|
||||
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
}
|
||||
99
includes/class-fontdelbosc-widget.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
/**
|
||||
* Sidebar widget wrapping the shared view renderer.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Sidebar widget for current conditions or today's forecast.
|
||||
*/
|
||||
final class Fontdelbosc_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Registers the widget with WordPress.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct(
|
||||
'fontdelbosc_weather',
|
||||
'Font del Bosc — El Temps',
|
||||
array(
|
||||
'description' => __( 'Current weather and forecast for Font del Bosc (Mediona).', 'fontdelbosc-eltemps' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the widget output.
|
||||
*
|
||||
* @param array<string,mixed> $args Widget arguments.
|
||||
* @param array<string,mixed> $instance Saved widget values.
|
||||
* @return void
|
||||
*/
|
||||
public function widget( $args, $instance ): void {
|
||||
$title = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $instance, 'title' ) ) ?? '';
|
||||
$title = '' !== $title ? Fontdelbosc_Payload::str( apply_filters( 'widget_title', $title, $instance, $this->id_base ) ) ?? $title : '';
|
||||
$view = 'today' === Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $instance, 'view' ) ) ? 'today' : 'current';
|
||||
|
||||
$before_widget = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $args, 'before_widget' ) ) ?? '';
|
||||
$after_widget = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $args, 'after_widget' ) ) ?? '';
|
||||
$before_title = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $args, 'before_title' ) ) ?? '';
|
||||
$after_title = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $args, 'after_title' ) ) ?? '';
|
||||
|
||||
echo wp_kses_post( $before_widget );
|
||||
|
||||
if ( $title ) {
|
||||
echo wp_kses_post( $before_title . esc_html( $title ) . $after_title );
|
||||
}
|
||||
|
||||
if ( 'today' === $view ) {
|
||||
echo wp_kses_post( Fontdelbosc_Shortcode::render_view( 'daily', array( 'days' => 1 ) ) );
|
||||
} else {
|
||||
echo wp_kses_post( Fontdelbosc_Shortcode::render_view( 'current' ) );
|
||||
}
|
||||
|
||||
echo wp_kses_post( $after_widget );
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the widget settings form.
|
||||
*
|
||||
* @param array<string,mixed> $instance Saved widget values.
|
||||
* @return string|null
|
||||
*/
|
||||
public function form( $instance ): ?string {
|
||||
$title = Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $instance, 'title' ) ) ?? '';
|
||||
$view = 'today' === Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $instance, 'view' ) ) ? 'today' : 'current';
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'fontdelbosc-eltemps' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'view' ) ); ?>"><?php esc_html_e( 'View', 'fontdelbosc-eltemps' ); ?></label>
|
||||
<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'view' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'view' ) ); ?>">
|
||||
<option value="current" <?php selected( $view, 'current' ); ?>><?php esc_html_e( 'Current conditions', 'fontdelbosc-eltemps' ); ?></option>
|
||||
<option value="today" <?php selected( $view, 'today' ); ?>><?php esc_html_e( "Today's forecast", 'fontdelbosc-eltemps' ); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes the widget settings on save.
|
||||
*
|
||||
* @param array<string,mixed> $new_instance New values.
|
||||
* @param array<string,mixed> $old_instance Old values.
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ): array {
|
||||
return array(
|
||||
'title' => sanitize_text_field( Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $new_instance, 'title' ) ) ?? '' ),
|
||||
'view' => 'today' === Fontdelbosc_Payload::str( Fontdelbosc_Payload::get( $new_instance, 'view' ) ) ? 'today' : 'current',
|
||||
);
|
||||
}
|
||||
}
|
||||
BIN
languages/fontdelbosc-eltemps-ca.mo
Normal file
243
languages/fontdelbosc-eltemps-ca.po
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
# Catalan (ca) translation for Font del Bosc — El Temps.
|
||||
# Copyright (C) 2026 ROBOTSTXT
|
||||
# This file is distributed under the GPL-3.0-or-later license.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Font del Bosc — El Temps 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/robotstxt/fontdelbosc-eltemps/issues\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: ca\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"PO-Revision-Date: 2026-10-12 12:00+0200\n"
|
||||
"Last-Translator: ROBOTSTXT\n"
|
||||
"Language-Team: ROBOTSTXT\n"
|
||||
|
||||
msgid "Clear sky"
|
||||
msgstr "Cel clar"
|
||||
|
||||
msgid "Partly cloudy"
|
||||
msgstr "Parcialment ennuvolat"
|
||||
|
||||
msgid "Cloudy"
|
||||
msgstr "Ennuvolat"
|
||||
|
||||
msgid "Overcast"
|
||||
msgstr "Molt ennuvolat"
|
||||
|
||||
msgid "Drizzle"
|
||||
msgstr "Plugim"
|
||||
|
||||
msgid "Rain"
|
||||
msgstr "Pluja"
|
||||
|
||||
msgid "Snow"
|
||||
msgstr "Neu"
|
||||
|
||||
msgid "Thunderstorm"
|
||||
msgstr "Tempesta"
|
||||
|
||||
msgid "Fog"
|
||||
msgstr "Boira"
|
||||
|
||||
msgid "Wind"
|
||||
msgstr "Vent"
|
||||
|
||||
msgid "Humidity"
|
||||
msgstr "Humitat"
|
||||
|
||||
msgid "Precipitation"
|
||||
msgstr "Precipitació"
|
||||
|
||||
msgid "Temperature"
|
||||
msgstr "Temperatura"
|
||||
|
||||
msgid "Feels like"
|
||||
msgstr "Sensació tèrmica"
|
||||
|
||||
msgid "Max"
|
||||
msgstr "Màx."
|
||||
|
||||
msgid "Min"
|
||||
msgstr "Mín."
|
||||
|
||||
msgid "UV Index"
|
||||
msgstr "Índex UV"
|
||||
|
||||
msgid "Today"
|
||||
msgstr "Avui"
|
||||
|
||||
msgid "Tomorrow"
|
||||
msgstr "Demà"
|
||||
|
||||
msgid "Forecast"
|
||||
msgstr "Predicció"
|
||||
|
||||
msgid "Current conditions"
|
||||
msgstr "Condicions actuals"
|
||||
|
||||
msgid "Historical data"
|
||||
msgstr "Dades històriques"
|
||||
|
||||
msgid "Loading weather data…"
|
||||
msgstr "Carregant dades del temps…"
|
||||
|
||||
msgid "Weather data unavailable."
|
||||
msgstr "Dades del temps no disponibles."
|
||||
|
||||
msgid "Source: %s"
|
||||
msgstr "Font: %s"
|
||||
|
||||
msgid "Monday"
|
||||
msgstr "Dilluns"
|
||||
|
||||
msgid "Tuesday"
|
||||
msgstr "Dimarts"
|
||||
|
||||
msgid "Wednesday"
|
||||
msgstr "Dimecres"
|
||||
|
||||
msgid "Thursday"
|
||||
msgstr "Dijous"
|
||||
|
||||
msgid "Friday"
|
||||
msgstr "Divendres"
|
||||
|
||||
msgid "Saturday"
|
||||
msgstr "Dissabte"
|
||||
|
||||
msgid "Sunday"
|
||||
msgstr "Diumenge"
|
||||
|
||||
msgid "January"
|
||||
msgstr "Gener"
|
||||
|
||||
msgid "February"
|
||||
msgstr "Febrer"
|
||||
|
||||
msgid "March"
|
||||
msgstr "Març"
|
||||
|
||||
msgid "April"
|
||||
msgstr "Abril"
|
||||
|
||||
msgid "May"
|
||||
msgstr "Maig"
|
||||
|
||||
msgid "June"
|
||||
msgstr "Juny"
|
||||
|
||||
msgid "July"
|
||||
msgstr "Juliol"
|
||||
|
||||
msgid "August"
|
||||
msgstr "Agost"
|
||||
|
||||
msgid "September"
|
||||
msgstr "Setembre"
|
||||
|
||||
msgid "October"
|
||||
msgstr "Octubre"
|
||||
|
||||
msgid "November"
|
||||
msgstr "Novembre"
|
||||
|
||||
msgid "December"
|
||||
msgstr "Desembre"
|
||||
|
||||
msgid "Average max."
|
||||
msgstr "Màx. mitjana"
|
||||
|
||||
msgid "Average min."
|
||||
msgstr "Mín. mitjana"
|
||||
|
||||
msgid "Total precipitation"
|
||||
msgstr "Precipitació total"
|
||||
|
||||
msgid "Current weather and forecast for Font del Bosc (Mediona)."
|
||||
msgstr "El temps actual i la predicció per a Font del Bosc (Mediona)."
|
||||
|
||||
msgid "Title"
|
||||
msgstr "Títol"
|
||||
|
||||
msgid "View"
|
||||
msgstr "Vista"
|
||||
|
||||
msgid "Today's forecast"
|
||||
msgstr "Predicció d'avui"
|
||||
|
||||
msgid "API Keys"
|
||||
msgstr "Claus de l'API"
|
||||
|
||||
msgid "Cache Settings"
|
||||
msgstr "Ajustos de la memòria cau"
|
||||
|
||||
msgid "Display Options"
|
||||
msgstr "Opcions de visualització"
|
||||
|
||||
msgid "Status"
|
||||
msgstr "Estat"
|
||||
|
||||
msgid "AEMET API key"
|
||||
msgstr "Clau de l'API de l'AEMET"
|
||||
|
||||
msgid "Meteocat API key"
|
||||
msgstr "Clau de l'API de Meteocat"
|
||||
|
||||
msgid "Current conditions cache (seconds)"
|
||||
msgstr "Memòria cau de les condicions actuals (segons)"
|
||||
|
||||
msgid "Forecast cache (seconds)"
|
||||
msgstr "Memòria cau de la predicció (segons)"
|
||||
|
||||
msgid "Historical data cache (seconds)"
|
||||
msgstr "Memòria cau de les dades històriques (segons)"
|
||||
|
||||
msgid "Show data source attribution"
|
||||
msgstr "Mostra l'atribució de la font de dades"
|
||||
|
||||
msgid "Uninstall"
|
||||
msgstr "Desinstal·lació"
|
||||
|
||||
msgid "Delete all plugin data on uninstall"
|
||||
msgstr "Suprimeix totes les dades del complement en desinstal·lar-lo"
|
||||
|
||||
msgid "Test connection"
|
||||
msgstr "Prova la connexió"
|
||||
|
||||
msgid "Connection successful."
|
||||
msgstr "La connexió és correcta."
|
||||
|
||||
msgid "Connection failed."
|
||||
msgstr "No s'ha pogut establir la connexió."
|
||||
|
||||
msgid "Find nearest station"
|
||||
msgstr "Cerca l'estació més propera"
|
||||
|
||||
msgid "Nearest station: %s"
|
||||
msgstr "Estació més propera: %s"
|
||||
|
||||
msgid "No weather API keys are configured. Data is served by Open-Meteo (no key required)."
|
||||
msgstr "No hi ha cap clau d'API meteorològica configurada. Les dades les serveix Open-Meteo (no en necessita cap)."
|
||||
|
||||
msgid "Usage"
|
||||
msgstr "Ús"
|
||||
|
||||
msgid "Current conditions (default view)."
|
||||
msgstr "Condicions actuals (vista per defecte)."
|
||||
|
||||
msgid "Hourly forecast for the following hours. Attribute hours: 1-48 (24 by default)."
|
||||
msgstr "Predicció horària de les properes hores. Atribut hours: 1-48 (24 per defecte)."
|
||||
|
||||
msgid "Daily forecast. Attribute days: 1-7 (7 by default)."
|
||||
msgstr "Predicció diària. Atribut days: 1-7 (7 per defecte)."
|
||||
|
||||
msgid "Historical data for one month. Attributes year and month; by default the last completed month."
|
||||
msgstr "Dades històriques d'un mes. Atributs year i month; per defecte, l'últim mes completat."
|
||||
|
||||
msgid "In the block editor, add a Shortcode block and paste the code. This version ships no dedicated blocks; the shortcode works anywhere shortcodes are supported, including the Shortcode block and text widgets."
|
||||
msgstr "En l'editor de blocs, afegiu un bloc de codi curt i enganxeu-hi el codi. Aquesta versió no inclou blocs propis; el shortcode funciona a qualsevol lloc que admeti codis curts, incloent-hi el bloc de codi curt i els ginys de text."
|
||||
|
||||
msgid "Current key ends in …%s"
|
||||
msgstr "La clau actual acaba en …%s"
|
||||
BIN
languages/fontdelbosc-eltemps-es_ES.mo
Normal file
243
languages/fontdelbosc-eltemps-es_ES.po
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
# Spanish (es_ES) translation for Font del Bosc — El Temps.
|
||||
# Copyright (C) 2026 ROBOTSTXT
|
||||
# This file is distributed under the GPL-3.0-or-later license.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Font del Bosc — El Temps 1.0.0\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/robotstxt/fontdelbosc-eltemps/issues\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: es_ES\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"PO-Revision-Date: 2026-10-12 12:00+0200\n"
|
||||
"Last-Translator: ROBOTSTXT\n"
|
||||
"Language-Team: ROBOTSTXT\n"
|
||||
|
||||
msgid "Clear sky"
|
||||
msgstr "Cielo despejado"
|
||||
|
||||
msgid "Partly cloudy"
|
||||
msgstr "Parcialmente nublado"
|
||||
|
||||
msgid "Cloudy"
|
||||
msgstr "Nublado"
|
||||
|
||||
msgid "Overcast"
|
||||
msgstr "Cubierto"
|
||||
|
||||
msgid "Drizzle"
|
||||
msgstr "Llovizna"
|
||||
|
||||
msgid "Rain"
|
||||
msgstr "Lluvia"
|
||||
|
||||
msgid "Snow"
|
||||
msgstr "Nieve"
|
||||
|
||||
msgid "Thunderstorm"
|
||||
msgstr "Tormenta"
|
||||
|
||||
msgid "Fog"
|
||||
msgstr "Niebla"
|
||||
|
||||
msgid "Wind"
|
||||
msgstr "Viento"
|
||||
|
||||
msgid "Humidity"
|
||||
msgstr "Humedad"
|
||||
|
||||
msgid "Precipitation"
|
||||
msgstr "Precipitación"
|
||||
|
||||
msgid "Temperature"
|
||||
msgstr "Temperatura"
|
||||
|
||||
msgid "Feels like"
|
||||
msgstr "Sensación térmica"
|
||||
|
||||
msgid "Max"
|
||||
msgstr "Máx."
|
||||
|
||||
msgid "Min"
|
||||
msgstr "Mín."
|
||||
|
||||
msgid "UV Index"
|
||||
msgstr "Índice UV"
|
||||
|
||||
msgid "Today"
|
||||
msgstr "Hoy"
|
||||
|
||||
msgid "Tomorrow"
|
||||
msgstr "Mañana"
|
||||
|
||||
msgid "Forecast"
|
||||
msgstr "Previsión"
|
||||
|
||||
msgid "Current conditions"
|
||||
msgstr "Condiciones actuales"
|
||||
|
||||
msgid "Historical data"
|
||||
msgstr "Datos históricos"
|
||||
|
||||
msgid "Loading weather data…"
|
||||
msgstr "Cargando datos del tiempo…"
|
||||
|
||||
msgid "Weather data unavailable."
|
||||
msgstr "Datos del tiempo no disponibles."
|
||||
|
||||
msgid "Source: %s"
|
||||
msgstr "Fuente: %s"
|
||||
|
||||
msgid "Monday"
|
||||
msgstr "Lunes"
|
||||
|
||||
msgid "Tuesday"
|
||||
msgstr "Martes"
|
||||
|
||||
msgid "Wednesday"
|
||||
msgstr "Miércoles"
|
||||
|
||||
msgid "Thursday"
|
||||
msgstr "Jueves"
|
||||
|
||||
msgid "Friday"
|
||||
msgstr "Viernes"
|
||||
|
||||
msgid "Saturday"
|
||||
msgstr "Sábado"
|
||||
|
||||
msgid "Sunday"
|
||||
msgstr "Domingo"
|
||||
|
||||
msgid "January"
|
||||
msgstr "Enero"
|
||||
|
||||
msgid "February"
|
||||
msgstr "Febrero"
|
||||
|
||||
msgid "March"
|
||||
msgstr "Marzo"
|
||||
|
||||
msgid "April"
|
||||
msgstr "Abril"
|
||||
|
||||
msgid "May"
|
||||
msgstr "Mayo"
|
||||
|
||||
msgid "June"
|
||||
msgstr "Junio"
|
||||
|
||||
msgid "July"
|
||||
msgstr "Julio"
|
||||
|
||||
msgid "August"
|
||||
msgstr "Agosto"
|
||||
|
||||
msgid "September"
|
||||
msgstr "Septiembre"
|
||||
|
||||
msgid "October"
|
||||
msgstr "Octubre"
|
||||
|
||||
msgid "November"
|
||||
msgstr "Noviembre"
|
||||
|
||||
msgid "December"
|
||||
msgstr "Diciembre"
|
||||
|
||||
msgid "Average max."
|
||||
msgstr "Máx. media"
|
||||
|
||||
msgid "Average min."
|
||||
msgstr "Mín. media"
|
||||
|
||||
msgid "Total precipitation"
|
||||
msgstr "Precipitación total"
|
||||
|
||||
msgid "Current weather and forecast for Font del Bosc (Mediona)."
|
||||
msgstr "El tiempo actual y la previsión para Font del Bosc (Mediona)."
|
||||
|
||||
msgid "Title"
|
||||
msgstr "Título"
|
||||
|
||||
msgid "View"
|
||||
msgstr "Vista"
|
||||
|
||||
msgid "Today's forecast"
|
||||
msgstr "Previsión de hoy"
|
||||
|
||||
msgid "API Keys"
|
||||
msgstr "Claves de API"
|
||||
|
||||
msgid "Cache Settings"
|
||||
msgstr "Ajustes de caché"
|
||||
|
||||
msgid "Display Options"
|
||||
msgstr "Opciones de visualización"
|
||||
|
||||
msgid "Status"
|
||||
msgstr "Estado"
|
||||
|
||||
msgid "AEMET API key"
|
||||
msgstr "Clave de API de AEMET"
|
||||
|
||||
msgid "Meteocat API key"
|
||||
msgstr "Clave de API de Meteocat"
|
||||
|
||||
msgid "Current conditions cache (seconds)"
|
||||
msgstr "Caché de condiciones actuales (segundos)"
|
||||
|
||||
msgid "Forecast cache (seconds)"
|
||||
msgstr "Caché de previsión (segundos)"
|
||||
|
||||
msgid "Historical data cache (seconds)"
|
||||
msgstr "Caché de datos históricos (segundos)"
|
||||
|
||||
msgid "Show data source attribution"
|
||||
msgstr "Mostrar la atribución de la fuente de datos"
|
||||
|
||||
msgid "Uninstall"
|
||||
msgstr "Desinstalación"
|
||||
|
||||
msgid "Delete all plugin data on uninstall"
|
||||
msgstr "Eliminar todos los datos del plugin al desinstalarlo"
|
||||
|
||||
msgid "Test connection"
|
||||
msgstr "Probar conexión"
|
||||
|
||||
msgid "Connection successful."
|
||||
msgstr "Conexión correcta."
|
||||
|
||||
msgid "Connection failed."
|
||||
msgstr "No se ha podido establecer la conexión."
|
||||
|
||||
msgid "Find nearest station"
|
||||
msgstr "Buscar la estación más cercana"
|
||||
|
||||
msgid "Nearest station: %s"
|
||||
msgstr "Estación más cercana: %s"
|
||||
|
||||
msgid "No weather API keys are configured. Data is served by Open-Meteo (no key required)."
|
||||
msgstr "No hay claves de API meteorológicas configuradas. Los datos los sirve Open-Meteo (no requiere clave)."
|
||||
|
||||
msgid "Usage"
|
||||
msgstr "Uso"
|
||||
|
||||
msgid "Current conditions (default view)."
|
||||
msgstr "Condiciones actuales (vista predeterminada)."
|
||||
|
||||
msgid "Hourly forecast for the following hours. Attribute hours: 1-48 (24 by default)."
|
||||
msgstr "Previsión horaria de las próximas horas. Atributo hours: 1-48 (24 por defecto)."
|
||||
|
||||
msgid "Daily forecast. Attribute days: 1-7 (7 by default)."
|
||||
msgstr "Previsión diaria. Atributo days: 1-7 (7 por defecto)."
|
||||
|
||||
msgid "Historical data for one month. Attributes year and month; by default the last completed month."
|
||||
msgstr "Datos históricos de un mes. Atributos year y month; por defecto, el último mes completado."
|
||||
|
||||
msgid "In the block editor, add a Shortcode block and paste the code. This version ships no dedicated blocks; the shortcode works anywhere shortcodes are supported, including the Shortcode block and text widgets."
|
||||
msgstr "En el editor de bloques, añade un bloque de Código corto y pega el código. Esta versión no incluye bloques propios; el shortcode funciona en cualquier lugar que admita códigos cortos, incluidos el bloque de Código corto y los widgets de texto."
|
||||
|
||||
msgid "Current key ends in …%s"
|
||||
msgstr "La clave actual termina en …%s"
|
||||
256
public/css/fdb-weather.css
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
/**
|
||||
* Font del Bosc — El Temps
|
||||
* Stylesheet for the weather views. BEM naming, prefixed .fdb-.
|
||||
*/
|
||||
|
||||
.fdb-weather {
|
||||
--fdb-bg: #ffffff;
|
||||
--fdb-fg: #1c2430;
|
||||
--fdb-muted: #5a6572;
|
||||
--fdb-accent: #0b6bcb;
|
||||
--fdb-warm: #d97706;
|
||||
--fdb-cold: #0284c7;
|
||||
--fdb-border: #e2e8f0;
|
||||
--fdb-bar-max: #f59e0b;
|
||||
--fdb-bar-min: #38bdf8;
|
||||
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--fdb-border);
|
||||
border-radius: 12px;
|
||||
background: var(--fdb-bg);
|
||||
color: var(--fdb-fg);
|
||||
font-size: 0.95rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.fdb-weather *,
|
||||
.fdb-weather *::before,
|
||||
.fdb-weather *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.fdb-weather {
|
||||
--fdb-bg: #141a22;
|
||||
--fdb-fg: #e5eaf0;
|
||||
--fdb-muted: #97a3b0;
|
||||
--fdb-border: #2a3440;
|
||||
}
|
||||
}
|
||||
|
||||
.fdb-weather__title {
|
||||
margin: 0 0 0.75rem;
|
||||
font-size: 1.05rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.fdb-icon {
|
||||
display: block;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
.fdb-icon--lg {
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
}
|
||||
|
||||
.fdb-attribution {
|
||||
margin: 0.75rem 0 0;
|
||||
font-size: 0.7rem;
|
||||
color: var(--fdb-muted);
|
||||
}
|
||||
|
||||
.fdb-unavailable {
|
||||
margin: 0;
|
||||
color: var(--fdb-muted);
|
||||
}
|
||||
|
||||
/* Current conditions */
|
||||
|
||||
.fdb-current__main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.fdb-current__temp {
|
||||
font-size: 2.6rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.fdb-current__label {
|
||||
margin: 0.25rem 0 0.5rem;
|
||||
color: var(--fdb-muted);
|
||||
}
|
||||
|
||||
.fdb-current__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.25rem 1rem;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
color: var(--fdb-muted);
|
||||
}
|
||||
|
||||
/* Hourly forecast */
|
||||
|
||||
.fdb-hourly__scroll {
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 0.5rem;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.fdb-hourly__item {
|
||||
display: flex;
|
||||
flex: 0 0 auto;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
min-width: 64px;
|
||||
padding: 0.5rem 0.25rem;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fdb-hourly__time {
|
||||
font-size: 0.75rem;
|
||||
color: var(--fdb-muted);
|
||||
}
|
||||
|
||||
.fdb-hourly__temp {
|
||||
font-size: 1.05rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.fdb-hourly__pop {
|
||||
font-size: 0.75rem;
|
||||
color: var(--fdb-cold);
|
||||
}
|
||||
|
||||
.fdb-hourly__wind {
|
||||
font-size: 0.7rem;
|
||||
color: var(--fdb-muted);
|
||||
}
|
||||
|
||||
.fdb-hourly__icon-placeholder {
|
||||
display: block;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
/* Daily forecast */
|
||||
|
||||
.fdb-daily__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.fdb-daily__day {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding: 0.5rem 0.25rem;
|
||||
border: 1px solid var(--fdb-border);
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fdb-daily__name {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.fdb-daily__date {
|
||||
font-size: 0.7rem;
|
||||
color: var(--fdb-muted);
|
||||
}
|
||||
|
||||
.fdb-daily__temps {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.fdb-daily__max {
|
||||
color: var(--fdb-warm);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.fdb-daily__min {
|
||||
color: var(--fdb-cold);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.fdb-daily__pop,
|
||||
.fdb-daily__wind {
|
||||
margin: 0;
|
||||
font-size: 0.75rem;
|
||||
color: var(--fdb-muted);
|
||||
}
|
||||
|
||||
/* Historical chart */
|
||||
|
||||
.fdb-historical__stats {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.25rem 1.25rem;
|
||||
margin: 0 0 1rem;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
color: var(--fdb-muted);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.fdb-historical__chart {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
height: 180px;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.fdb-historical__col {
|
||||
display: flex;
|
||||
flex: 1 1 0;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.fdb-historical__bars {
|
||||
display: flex;
|
||||
gap: 1px;
|
||||
align-items: flex-end;
|
||||
height: calc(100% - 1.25rem);
|
||||
}
|
||||
|
||||
.fdb-historical__bar {
|
||||
flex: 1 1 0;
|
||||
min-height: 2px;
|
||||
border-radius: 2px 2px 0 0;
|
||||
}
|
||||
|
||||
.fdb-historical__bar--max {
|
||||
background: var(--fdb-bar-max);
|
||||
}
|
||||
|
||||
.fdb-historical__bar--min {
|
||||
background: var(--fdb-bar-min);
|
||||
}
|
||||
|
||||
.fdb-historical__day {
|
||||
height: 1.25rem;
|
||||
font-size: 0.65rem;
|
||||
color: var(--fdb-muted);
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
21
public/icons/LICENSE-meteocons.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020-present Bas Milius
|
||||
|
||||
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.
|
||||
17
public/icons/flat/clear-day.svg
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="clear-day">
|
||||
<g id="Sun">
|
||||
<circle id="Core" cx="64" cy="63.9999" r="20" fill="#F8AF18"/>
|
||||
<g id="Rays">
|
||||
<path d="M61 19C61 17.3431 62.3431 16 64 16C65.6568 16 67 17.3431 67 19V33C67 34.6569 65.6568 36 64 36C62.3431 36 61 34.6569 61 33V19Z" fill="#F8AF18"/>
|
||||
<path d="M93.6985 30.0589C94.87 28.8873 96.7696 28.8873 97.9411 30.0589C99.1127 31.2304 99.1127 33.1299 97.9411 34.3015L88.0416 44.201C86.8701 45.3726 84.9706 45.3726 83.799 44.201C82.6274 43.0294 82.6274 41.1299 83.799 39.9584L93.6985 30.0589Z" fill="#F8AF18"/>
|
||||
<path d="M109 61C110.657 61 112 62.3432 112 64C112 65.6569 110.657 67 109 67H95C93.3431 67 92 65.6569 92 64C92 62.3432 93.3431 61 95 61H109Z" fill="#F8AF18"/>
|
||||
<path d="M97.9411 93.6985C99.1127 94.8701 99.1127 96.7696 97.9411 97.9411C96.7696 99.1127 94.8701 99.1127 93.6985 97.9411L83.799 88.0416C82.6274 86.8701 82.6274 84.9706 83.799 83.799C84.9706 82.6274 86.8701 82.6274 88.0416 83.799L97.9411 93.6985Z" fill="#F8AF18"/>
|
||||
<path d="M61 95C61 93.3431 62.3431 92 64 92C65.6568 92 67 93.3431 67 95V109C67 110.657 65.6568 112 64 112C62.3431 112 61 110.657 61 109V95Z" fill="#F8AF18"/>
|
||||
<path d="M39.9584 83.799C41.1299 82.6274 43.0294 82.6274 44.201 83.799C45.3726 84.9706 45.3726 86.8701 44.201 88.0416L34.3015 97.9411C33.1299 99.1127 31.2304 99.1127 30.0589 97.9411C28.8873 96.7696 28.8873 94.87 30.0589 93.6985L39.9584 83.799Z" fill="#F8AF18"/>
|
||||
<path d="M33 61C34.6569 61 36 62.3431 36 64C36 65.6568 34.6569 67 33 67H19C17.3431 67 16 65.6568 16 64C16 62.3431 17.3431 61 19 61H33Z" fill="#F8AF18"/>
|
||||
<path d="M44.201 39.9584C45.3726 41.1299 45.3726 43.0294 44.201 44.201C43.0294 45.3726 41.1299 45.3726 39.9584 44.201L30.0589 34.3015C28.8873 33.1299 28.8873 31.2305 30.0589 30.0589C31.2305 28.8873 33.1299 28.8873 34.3015 30.0589L44.201 39.9584Z" fill="#F8AF18"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
7
public/icons/flat/clear-night.svg
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="clear-night">
|
||||
<g id="Moon">
|
||||
<path id="Moon_2" d="M60.9624 32C44.6764 33.7576 32 47.3624 32 63.8982C32 81.6267 46.5673 96 64.5358 96C79.6824 96 92.3733 85.7745 96 71.9491C74.381 74.267 55.3288 53.4643 60.9624 32Z" fill="#72B9D5"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 328 B |
16
public/icons/flat/cloudy.svg
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="cloudy" clip-path="url(#clip0_2045_39565)">
|
||||
<g id="Sky">
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39565">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 753 B |
23
public/icons/flat/drizzle.svg
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="drizzle" clip-path="url(#clip0_2045_39620)">
|
||||
<g id="Sky">
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Raindrops">
|
||||
<path id="Raindrop 1" d="M52 87V90" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
<path id="Raindrop 2" d="M64 87V90" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 0)"/>
|
||||
<path id="Raindrop 3" d="M76 87V90" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39620">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
38
public/icons/flat/extreme-rain.svg
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="extreme-rain" clip-path="url(#clip0_2045_39605)">
|
||||
<g id="Sky">
|
||||
<g id="Clouds" clip-path="url(#clip1_2045_39605)">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39605" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39605)">
|
||||
<g id="Secondary Cloud">
|
||||
<path id="Cloud" d="M101.194 55.5621C102.367 51.05 99.7602 46.4225 95.5043 44.7133C91.1919 42.9813 85.9612 44.4743 83.4186 48.423C81.2648 47.1797 78.496 47.2496 76.4119 48.609C74.3808 49.934 73.2434 52.372 73.675 54.7789C70.2998 55.3911 67.6874 58.4688 68.0307 61.9561C68.3748 65.4511 71.5394 68.0008 74.9767 68C83.8126 68 92.6514 67.9925 101.488 68C104.911 68 108 65.2849 108 61.774C108 58.1428 104.721 55.4142 101.194 55.5621Z" fill="#B0BCCD"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Cloud_2">
|
||||
<path id="Cloud_3" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#7C8CA2"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Raindrops">
|
||||
<path id="Raindrop 1" d="M52 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
<path id="Raindrop 2" d="M64 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 0)"/>
|
||||
<path id="Raindrop 3" d="M76 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39605">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
<clipPath id="clip1_2045_39605">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
38
public/icons/flat/extreme-snow.svg
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="extreme-snow" clip-path="url(#clip0_2045_39704)">
|
||||
<g id="Sky">
|
||||
<g id="Clouds" clip-path="url(#clip1_2045_39704)">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39704" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39704)">
|
||||
<g id="Secondary Cloud">
|
||||
<path id="Cloud" d="M101.194 55.5621C102.367 51.05 99.7602 46.4225 95.5043 44.7133C91.1919 42.9813 85.9612 44.4743 83.4186 48.423C81.2648 47.1797 78.496 47.2496 76.4119 48.609C74.3808 49.934 73.2434 52.372 73.675 54.7789C70.2998 55.3911 67.6874 58.4688 68.0307 61.9561C68.3748 65.4511 71.5394 68.0008 74.9767 68C83.8126 68 92.6514 67.9925 101.488 68C104.911 68 108 65.2849 108 61.774C108 58.1428 104.721 55.4142 101.194 55.5621Z" fill="#B0BCCD"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Cloud_2">
|
||||
<path id="Cloud_3" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#7C8CA2"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Snowflakes">
|
||||
<path id="Snowflake 1" d="M52.5781 90.366L51.3735 89.6775C51.4794 89.2326 51.4786 88.7687 51.3708 88.3241L52.5781 87.6345C52.6738 87.5805 52.7577 87.5079 52.8252 87.421C52.8926 87.3342 52.9423 87.2347 52.9711 87.1284C52.9998 87.0221 53.0071 86.9112 52.9926 86.802C52.9782 86.6928 52.9422 86.5876 52.8868 86.4926C52.7732 86.2998 52.5886 86.1597 52.3728 86.1025C52.157 86.0452 51.9276 86.0754 51.7339 86.1866L50.5278 86.8763C50.1931 86.5586 49.7868 86.3264 49.3437 86.1995V84.8202C49.3368 84.6003 49.245 84.3918 49.0875 84.2387C48.93 84.0856 48.7192 84 48.4998 84C48.2805 84 48.0699 84.0856 47.9124 84.2387C47.7548 84.3918 47.6628 84.6003 47.656 84.8202V86.1995C47.214 86.3289 46.8081 86.5598 46.4706 86.874L45.2662 86.1853C45.0724 86.0742 44.8428 86.044 44.627 86.1013C44.4113 86.1585 44.2267 86.2986 44.113 86.4913C44.0576 86.5864 44.0217 86.6916 44.0072 86.8007C43.9928 86.9099 44 87.0209 44.0288 87.1271C44.0575 87.2334 44.1072 87.3329 44.1747 87.4198C44.2421 87.5067 44.326 87.5792 44.4217 87.6332L45.6264 88.3216C45.5204 88.7666 45.5213 89.2305 45.629 89.675L44.4217 90.3647C44.326 90.4187 44.2421 90.4912 44.1747 90.5781C44.1072 90.665 44.0575 90.7645 44.0288 90.8708C44 90.9771 43.9928 91.088 44.0072 91.1972C44.0217 91.3063 44.0576 91.4115 44.113 91.5066C44.2267 91.6992 44.4113 91.8392 44.627 91.8965C44.8428 91.9537 45.0724 91.9236 45.2662 91.8126L46.4721 91.1229C46.8063 91.4409 47.2128 91.6726 47.6562 91.7979V93.1798C47.6631 93.3997 47.755 93.6082 47.9126 93.7613C48.0701 93.9144 48.2807 94 48.5 94C48.7194 94 48.9302 93.9144 49.0877 93.7613C49.2452 93.6082 49.337 93.3997 49.3439 93.1798V91.7975C49.7853 91.6683 50.1907 91.4378 50.5278 91.1242L51.7341 91.8138C51.9278 91.9248 52.1573 91.955 52.373 91.8977C52.5888 91.8405 52.7733 91.7005 52.887 91.5079C52.9424 91.4128 52.9784 91.3076 52.9928 91.1984C53.0073 91.0892 52.9998 90.9783 52.9711 90.872C52.9423 90.7657 52.8929 90.6662 52.8254 90.5793C52.7579 90.4925 52.6738 90.4199 52.5781 90.366ZM47.8664 90.0861C47.7229 90.005 47.5968 89.8961 47.4956 89.7657C47.3944 89.6353 47.3202 89.486 47.2771 89.3266C47.2339 89.1671 47.2228 89.0007 47.2443 88.8369C47.2658 88.6731 47.3197 88.5152 47.4026 88.3724C47.5735 88.084 47.8503 87.8743 48.1736 87.7883C48.497 87.7023 48.8411 87.747 49.1321 87.9126C49.2756 87.9938 49.4016 88.1027 49.5028 88.2331C49.604 88.3635 49.6782 88.5127 49.7214 88.6722C49.7645 88.8316 49.7757 88.9981 49.7541 89.1619C49.7326 89.3257 49.6787 89.4836 49.5958 89.6263C49.425 89.9149 49.1482 90.1247 48.8248 90.2108C48.5014 90.2969 48.1574 90.2523 47.8664 90.0867V90.0861Z" fill="#86C3DB" transform="translate(0, 8)"/>
|
||||
<path id="Snowflake 2" d="M67.5781 90.366L66.3735 89.6775C66.4794 89.2326 66.4786 88.7687 66.3708 88.3241L67.5781 87.6345C67.6738 87.5805 67.7577 87.5079 67.8252 87.421C67.8926 87.3342 67.9423 87.2347 67.9711 87.1284C67.9998 87.0221 68.0071 86.9112 67.9926 86.802C67.9782 86.6928 67.9422 86.5876 67.8868 86.4926C67.7732 86.2998 67.5886 86.1597 67.3728 86.1025C67.157 86.0452 66.9276 86.0754 66.7339 86.1866L65.5278 86.8763C65.1931 86.5586 64.7868 86.3264 64.3437 86.1995V84.8202C64.3368 84.6003 64.245 84.3918 64.0875 84.2387C63.93 84.0856 63.7192 84 63.4998 84C63.2805 84 63.0699 84.0856 62.9124 84.2387C62.7548 84.3918 62.6628 84.6003 62.656 84.8202V86.1995C62.214 86.3289 61.8081 86.5598 61.4706 86.874L60.2662 86.1853C60.0724 86.0742 59.8428 86.044 59.627 86.1013C59.4113 86.1585 59.2267 86.2986 59.113 86.4913C59.0576 86.5864 59.0217 86.6916 59.0072 86.8007C58.9928 86.9099 59 87.0209 59.0288 87.1271C59.0575 87.2334 59.1072 87.3329 59.1747 87.4198C59.2421 87.5067 59.326 87.5792 59.4217 87.6332L60.6264 88.3216C60.5204 88.7666 60.5213 89.2305 60.629 89.675L59.4217 90.3647C59.326 90.4187 59.2421 90.4912 59.1747 90.5781C59.1072 90.665 59.0575 90.7645 59.0288 90.8708C59 90.9771 58.9928 91.088 59.0072 91.1972C59.0217 91.3063 59.0576 91.4115 59.113 91.5066C59.2267 91.6992 59.4113 91.8392 59.627 91.8965C59.8428 91.9537 60.0724 91.9236 60.2662 91.8126L61.4721 91.1229C61.8063 91.4409 62.2128 91.6726 62.6562 91.7979V93.1798C62.6631 93.3997 62.755 93.6082 62.9126 93.7613C63.0701 93.9144 63.2807 94 63.5 94C63.7194 94 63.9302 93.9144 64.0877 93.7613C64.2452 93.6082 64.337 93.3997 64.3439 93.1798V91.7975C64.7853 91.6683 65.1907 91.4378 65.5278 91.1242L66.7341 91.8138C66.9278 91.9248 67.1573 91.955 67.373 91.8977C67.5888 91.8405 67.7733 91.7005 67.887 91.5079C67.9424 91.4128 67.9784 91.3076 67.9928 91.1984C68.0073 91.0892 67.9998 90.9783 67.9711 90.872C67.9423 90.7657 67.8929 90.6662 67.8254 90.5793C67.7579 90.4925 67.6738 90.4199 67.5781 90.366ZM62.8664 90.0861C62.7229 90.005 62.5968 89.8961 62.4956 89.7657C62.3944 89.6353 62.3202 89.486 62.2771 89.3266C62.2339 89.1671 62.2228 89.0007 62.2443 88.8369C62.2658 88.6731 62.3197 88.5152 62.4026 88.3724C62.5735 88.084 62.8503 87.8743 63.1736 87.7883C63.497 87.7023 63.8411 87.747 64.1321 87.9126C64.2756 87.9938 64.4016 88.1027 64.5028 88.2331C64.604 88.3635 64.6782 88.5127 64.7214 88.6722C64.7645 88.8316 64.7757 88.9981 64.7541 89.1619C64.7326 89.3257 64.6787 89.4836 64.5958 89.6263C64.425 89.9149 64.1482 90.1247 63.8248 90.2108C63.5014 90.2969 63.1574 90.2523 62.8664 90.0867V90.0861Z" fill="#86C3DB" transform="translate(0, 0)"/>
|
||||
<path id="Snowflake 3" d="M82.5781 90.366L81.3735 89.6775C81.4794 89.2326 81.4786 88.7687 81.3708 88.3241L82.5781 87.6345C82.6738 87.5805 82.7577 87.5079 82.8252 87.421C82.8926 87.3342 82.9423 87.2347 82.9711 87.1284C82.9998 87.0221 83.0071 86.9112 82.9926 86.802C82.9782 86.6928 82.9422 86.5876 82.8868 86.4926C82.7732 86.2998 82.5886 86.1597 82.3728 86.1025C82.157 86.0452 81.9276 86.0754 81.7339 86.1866L80.5278 86.8763C80.1931 86.5586 79.7868 86.3264 79.3437 86.1995V84.8202C79.3368 84.6003 79.245 84.3918 79.0875 84.2387C78.93 84.0856 78.7192 84 78.4998 84C78.2805 84 78.0699 84.0856 77.9124 84.2387C77.7548 84.3918 77.6628 84.6003 77.656 84.8202V86.1995C77.214 86.3289 76.8081 86.5598 76.4706 86.874L75.2662 86.1853C75.0724 86.0742 74.8428 86.044 74.627 86.1013C74.4113 86.1585 74.2267 86.2986 74.113 86.4913C74.0576 86.5864 74.0217 86.6916 74.0072 86.8007C73.9928 86.9099 74 87.0209 74.0288 87.1271C74.0575 87.2334 74.1072 87.3329 74.1747 87.4198C74.2421 87.5067 74.326 87.5792 74.4217 87.6332L75.6264 88.3216C75.5204 88.7666 75.5213 89.2305 75.629 89.675L74.4217 90.3647C74.326 90.4187 74.2421 90.4912 74.1747 90.5781C74.1072 90.665 74.0575 90.7645 74.0288 90.8708C74 90.9771 73.9928 91.088 74.0072 91.1972C74.0217 91.3063 74.0576 91.4115 74.113 91.5066C74.2267 91.6992 74.4113 91.8392 74.627 91.8965C74.8428 91.9537 75.0724 91.9236 75.2662 91.8126L76.4721 91.1229C76.8063 91.4409 77.2128 91.6726 77.6562 91.7979V93.1798C77.6631 93.3997 77.755 93.6082 77.9126 93.7613C78.0701 93.9144 78.2807 94 78.5 94C78.7194 94 78.9302 93.9144 79.0877 93.7613C79.2452 93.6082 79.337 93.3997 79.3439 93.1798V91.7975C79.7853 91.6683 80.1907 91.4378 80.5278 91.1242L81.7341 91.8138C81.9278 91.9248 82.1573 91.955 82.373 91.8977C82.5888 91.8405 82.7733 91.7005 82.887 91.5079C82.9424 91.4128 82.9784 91.3076 82.9928 91.1984C83.0073 91.0892 82.9998 90.9783 82.9711 90.872C82.9423 90.7657 82.8929 90.6662 82.8254 90.5793C82.7579 90.4925 82.6738 90.4199 82.5781 90.366ZM77.8664 90.0861C77.7229 90.005 77.5968 89.8961 77.4956 89.7657C77.3944 89.6353 77.3202 89.486 77.2771 89.3266C77.2339 89.1671 77.2228 89.0007 77.2443 88.8369C77.2658 88.6731 77.3197 88.5152 77.4026 88.3724C77.5735 88.084 77.8503 87.8743 78.1736 87.7883C78.497 87.7023 78.8411 87.747 79.1321 87.9126C79.2756 87.9938 79.4016 88.1027 79.5028 88.2331C79.604 88.3635 79.6782 88.5127 79.7214 88.6722C79.7645 88.8316 79.7757 88.9981 79.7541 89.1619C79.7326 89.3257 79.6787 89.4836 79.5958 89.6263C79.425 89.9149 79.1482 90.1247 78.8248 90.2108C78.5014 90.2969 78.1574 90.2523 77.8664 90.0867V90.0861Z" fill="#86C3DB" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39704">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
<clipPath id="clip1_2045_39704">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 9.7 KiB |
28
public/icons/flat/fog-day.svg
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="fog-day">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39539" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="75">
|
||||
<rect id="Mask" width="128" height="75" fill="black"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39539)">
|
||||
<g id="Sun">
|
||||
<circle id="Core" cx="64" cy="72" r="13" fill="#F8AF18"/>
|
||||
<g id="Rays">
|
||||
<path d="M62 42C62 40.8954 62.8954 40 64 40C65.1046 40 66 40.8954 66 42V51.3333C66 52.4379 65.1046 53.3333 64 53.3333C62.8954 53.3333 62 52.4379 62 51.3333V42Z" fill="#F8AF18"/>
|
||||
<path d="M83.799 49.3726C84.58 48.5915 85.8464 48.5915 86.6274 49.3726C87.4085 50.1536 87.4085 51.42 86.6274 52.201L80.0278 58.8007C79.2467 59.5817 77.9804 59.5817 77.1993 58.8007C76.4183 58.0196 76.4183 56.7533 77.1993 55.9722L83.799 49.3726Z" fill="#F8AF18"/>
|
||||
<path d="M94 70C95.1046 70 96 70.8954 96 72C96 73.1046 95.1046 74 94 74H84.6667C83.5621 74 82.6667 73.1046 82.6667 72C82.6667 70.8954 83.5621 70 84.6667 70H94Z" fill="#F8AF18"/>
|
||||
<path d="M86.6274 91.799C87.4085 92.58 87.4085 93.8464 86.6274 94.6274C85.8464 95.4085 84.58 95.4085 83.799 94.6274L77.1993 88.0278C76.4183 87.2467 76.4183 85.9804 77.1993 85.1993C77.9804 84.4183 79.2467 84.4183 80.0278 85.1993L86.6274 91.799Z" fill="#F8AF18"/>
|
||||
<path d="M62 92.6667C62 91.5621 62.8954 90.6667 64 90.6667C65.1046 90.6667 66 91.5621 66 92.6667V102C66 103.105 65.1046 104 64 104C62.8954 104 62 103.105 62 102V92.6667Z" fill="#F8AF18"/>
|
||||
<path d="M47.9722 85.1993C48.7533 84.4183 50.0196 84.4183 50.8007 85.1993C51.5817 85.9804 51.5817 87.2467 50.8007 88.0278L44.201 94.6274C43.42 95.4085 42.1536 95.4085 41.3726 94.6274C40.5915 93.8464 40.5915 92.58 41.3726 91.799L47.9722 85.1993Z" fill="#F8AF18"/>
|
||||
<path d="M43.3333 70C44.4379 70 45.3333 70.8954 45.3333 72C45.3333 73.1046 44.4379 74 43.3333 74H34C32.8954 74 32 73.1046 32 72C32 70.8954 32.8954 70 34 70H43.3333Z" fill="#F8AF18"/>
|
||||
<path d="M50.8007 55.9722C51.5817 56.7533 51.5817 58.0196 50.8007 58.8007C50.0196 59.5817 48.7533 59.5817 47.9722 58.8007L41.3726 52.201C40.5915 51.42 40.5915 50.1536 41.3726 49.3726C42.1536 48.5915 43.42 48.5915 44.201 49.3726L50.8007 55.9722Z" fill="#F8AF18"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<path id="Line 2" d="M40 81H88" stroke="#E2E8F0" stroke-width="3" stroke-miterlimit="10" stroke-linecap="round"/>
|
||||
<path id="Line 1" d="M40 89H88" stroke="#E2E8F0" stroke-width="3" stroke-miterlimit="10" stroke-linecap="round"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
18
public/icons/flat/fog-night.svg
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="fog-night">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39544" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="75">
|
||||
<rect id="Mask" width="128" height="75" fill="black"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39544)">
|
||||
<g id="Moon">
|
||||
<path id="Moon_2" d="M61.9117 40C50.715 41.2083 42 50.5617 42 61.93C42 74.1183 52.015 84 64.3683 84C74.7817 84 83.5067 76.97 86 67.465C71.137 69.0586 58.0386 54.7567 61.9117 40Z" fill="#72B9D5"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<path id="Line 2" d="M40 81H88" stroke="#E2E8F0" stroke-width="3" stroke-miterlimit="10" stroke-linecap="round"/>
|
||||
<path id="Line 1" d="M40 89H88" stroke="#E2E8F0" stroke-width="3" stroke-miterlimit="10" stroke-linecap="round"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 819 B |
38
public/icons/flat/overcast-rain.svg
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="overcast-rain" clip-path="url(#clip0_2045_39596)">
|
||||
<g id="Sky">
|
||||
<g id="Clouds" clip-path="url(#clip1_2045_39596)">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39596" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39596)">
|
||||
<g id="Secondary Cloud">
|
||||
<path id="Cloud" d="M101.194 55.5621C102.367 51.05 99.7602 46.4225 95.5043 44.7133C91.1919 42.9813 85.9612 44.4743 83.4186 48.423C81.2648 47.1797 78.496 47.2496 76.4119 48.609C74.3808 49.934 73.2434 52.372 73.675 54.7789C70.2998 55.3911 67.6874 58.4688 68.0307 61.9561C68.3748 65.4511 71.5394 68.0008 74.9767 68C83.8126 68 92.6514 67.9925 101.488 68C104.911 68 108 65.2849 108 61.774C108 58.1428 104.721 55.4142 101.194 55.5621Z" fill="#B0BCCD"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Cloud_2">
|
||||
<path id="Cloud_3" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Raindrops">
|
||||
<path id="Raindrop 1" d="M52 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
<path id="Raindrop 2" d="M64 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 0)"/>
|
||||
<path id="Raindrop 3" d="M76 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39596">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
<clipPath id="clip1_2045_39596">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
31
public/icons/flat/overcast.svg
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="overcast" clip-path="url(#clip0_2045_39571)">
|
||||
<g id="Sky">
|
||||
<g id="Clouds" clip-path="url(#clip1_2045_39571)">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39571" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39571)">
|
||||
<g id="Secondary Cloud">
|
||||
<path id="Cloud" d="M101.194 55.5621C102.367 51.05 99.7602 46.4225 95.5043 44.7133C91.1919 42.9813 85.9612 44.4743 83.4186 48.423C81.2648 47.1797 78.496 47.2496 76.4119 48.609C74.3808 49.934 73.2434 52.372 73.675 54.7789C70.2998 55.3911 67.6874 58.4688 68.0307 61.9561C68.3748 65.4511 71.5394 68.0008 74.9767 68C83.8126 68 92.6514 67.9925 101.488 68C104.911 68 108 65.2849 108 61.774C108 58.1428 104.721 55.4142 101.194 55.5621Z" fill="#B0BCCD"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Cloud_2">
|
||||
<path id="Cloud_3" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39571">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
<clipPath id="clip1_2045_39571">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2 KiB |
45
public/icons/flat/partly-cloudy-day-rain.svg
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="partly-cloudy-day-rain" clip-path="url(#clip0_2045_39590)">
|
||||
<g id="Sky">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39590" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39590)">
|
||||
<g id="Sun">
|
||||
<circle id="Core" cx="39" cy="51" r="9" fill="#F8AF18"/>
|
||||
<g id="Rays">
|
||||
<path d="M37.6875 31.3125C37.6875 30.5876 38.2751 30 39 30C39.7249 30 40.3125 30.5876 40.3125 31.3125V37.4375C40.3125 38.1624 39.7249 38.75 39 38.75C38.2751 38.75 37.6875 38.1624 37.6875 37.4375V31.3125Z" fill="#F8AF18"/>
|
||||
<path d="M51.9931 36.1508C52.5056 35.6382 53.3367 35.6382 53.8492 36.1508C54.3618 36.6633 54.3618 37.4943 53.8492 38.0069L49.5182 42.3379C49.0056 42.8505 48.1746 42.8505 47.6621 42.3379C47.1495 41.8254 47.1495 40.9944 47.6621 40.4818L51.9931 36.1508Z" fill="#F8AF18"/>
|
||||
<path d="M58.6875 49.6875C59.4124 49.6875 60 50.2751 60 51C60 51.7249 59.4124 52.3125 58.6875 52.3125H52.5625C51.8376 52.3125 51.25 51.7249 51.25 51C51.25 50.2751 51.8376 49.6875 52.5625 49.6875H58.6875Z" fill="#F8AF18"/>
|
||||
<path d="M53.8492 63.9931C54.3618 64.5057 54.3618 65.3367 53.8492 65.8492C53.3367 66.3618 52.5056 66.3618 51.9931 65.8492L47.6621 61.5182C47.1495 61.0057 47.1495 60.1746 47.6621 59.6621C48.1746 59.1495 49.0057 59.1495 49.5182 59.6621L53.8492 63.9931Z" fill="#F8AF18"/>
|
||||
<path d="M37.6875 64.5625C37.6875 63.8376 38.2751 63.25 39 63.25C39.7249 63.25 40.3125 63.8376 40.3125 64.5625V70.6875C40.3125 71.4124 39.7249 72 39 72C38.2751 72 37.6875 71.4124 37.6875 70.6875V64.5625Z" fill="#F8AF18"/>
|
||||
<path d="M28.4818 59.6621C28.9943 59.1495 29.8254 59.1495 30.3379 59.6621C30.8505 60.1746 30.8505 61.0056 30.3379 61.5182L26.0069 65.8492C25.4943 66.3618 24.6633 66.3618 24.1508 65.8492C23.6382 65.3367 23.6382 64.5056 24.1508 63.9931L28.4818 59.6621Z" fill="#F8AF18"/>
|
||||
<path d="M25.4375 49.6875C26.1624 49.6875 26.75 50.2751 26.75 51C26.75 51.7249 26.1624 52.3125 25.4375 52.3125H19.3125C18.5876 52.3125 18 51.7249 18 51C18 50.2751 18.5876 49.6875 19.3125 49.6875H25.4375Z" fill="#F8AF18"/>
|
||||
<path d="M30.3379 40.4818C30.8505 40.9944 30.8505 41.8254 30.3379 42.3379C29.8254 42.8505 28.9944 42.8505 28.4818 42.3379L24.1508 38.0069C23.6382 37.4944 23.6382 36.6633 24.1508 36.1508C24.6633 35.6382 25.4944 35.6382 26.0069 36.1508L30.3379 40.4818Z" fill="#F8AF18"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Raindrops">
|
||||
<path id="Raindrop 1" d="M52 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
<path id="Raindrop 2" d="M64 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 0)"/>
|
||||
<path id="Raindrop 3" d="M76 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39590">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
38
public/icons/flat/partly-cloudy-day.svg
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="partly-cloudy-day" clip-path="url(#clip0_2045_39567)">
|
||||
<g id="Sky">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39567" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39567)">
|
||||
<g id="Sun">
|
||||
<circle id="Core" cx="39" cy="51" r="9" fill="#F8AF18"/>
|
||||
<g id="Rays">
|
||||
<path d="M37.6875 31.3125C37.6875 30.5876 38.2751 30 39 30C39.7249 30 40.3125 30.5876 40.3125 31.3125V37.4375C40.3125 38.1624 39.7249 38.75 39 38.75C38.2751 38.75 37.6875 38.1624 37.6875 37.4375V31.3125Z" fill="#F8AF18"/>
|
||||
<path d="M51.9931 36.1508C52.5056 35.6382 53.3367 35.6382 53.8492 36.1508C54.3618 36.6633 54.3618 37.4943 53.8492 38.0069L49.5182 42.3379C49.0056 42.8505 48.1746 42.8505 47.6621 42.3379C47.1495 41.8254 47.1495 40.9944 47.6621 40.4818L51.9931 36.1508Z" fill="#F8AF18"/>
|
||||
<path d="M58.6875 49.6875C59.4124 49.6875 60 50.2751 60 51C60 51.7249 59.4124 52.3125 58.6875 52.3125H52.5625C51.8376 52.3125 51.25 51.7249 51.25 51C51.25 50.2751 51.8376 49.6875 52.5625 49.6875H58.6875Z" fill="#F8AF18"/>
|
||||
<path d="M53.8492 63.9931C54.3618 64.5057 54.3618 65.3367 53.8492 65.8492C53.3367 66.3618 52.5056 66.3618 51.9931 65.8492L47.6621 61.5182C47.1495 61.0057 47.1495 60.1746 47.6621 59.6621C48.1746 59.1495 49.0057 59.1495 49.5182 59.6621L53.8492 63.9931Z" fill="#F8AF18"/>
|
||||
<path d="M37.6875 64.5625C37.6875 63.8376 38.2751 63.25 39 63.25C39.7249 63.25 40.3125 63.8376 40.3125 64.5625V70.6875C40.3125 71.4124 39.7249 72 39 72C38.2751 72 37.6875 71.4124 37.6875 70.6875V64.5625Z" fill="#F8AF18"/>
|
||||
<path d="M28.4818 59.6621C28.9943 59.1495 29.8254 59.1495 30.3379 59.6621C30.8505 60.1746 30.8505 61.0056 30.3379 61.5182L26.0069 65.8492C25.4943 66.3618 24.6633 66.3618 24.1508 65.8492C23.6382 65.3367 23.6382 64.5056 24.1508 63.9931L28.4818 59.6621Z" fill="#F8AF18"/>
|
||||
<path d="M25.4375 49.6875C26.1624 49.6875 26.75 50.2751 26.75 51C26.75 51.7249 26.1624 52.3125 25.4375 52.3125H19.3125C18.5876 52.3125 18 51.7249 18 51C18 50.2751 18.5876 49.6875 19.3125 49.6875H25.4375Z" fill="#F8AF18"/>
|
||||
<path d="M30.3379 40.4818C30.8505 40.9944 30.8505 41.8254 30.3379 42.3379C29.8254 42.8505 28.9944 42.8505 28.4818 42.3379L24.1508 38.0069C23.6382 37.4944 23.6382 36.6633 24.1508 36.1508C24.6633 35.6382 25.4944 35.6382 26.0069 36.1508L30.3379 40.4818Z" fill="#F8AF18"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39567">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
35
public/icons/flat/partly-cloudy-night-rain.svg
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="partly-cloudy-night-rain" clip-path="url(#clip0_2045_39593)">
|
||||
<g id="Sky">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39593" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39593)">
|
||||
<g id="Moon">
|
||||
<path id="Moon_2" d="M35.766 34C29.1498 34.714 24 40.241 24 46.9586C24 54.1608 29.918 60 37.2177 60C43.371 60 48.5267 55.8459 50 50.2293C41.2173 51.171 33.4773 42.7199 35.766 34Z" fill="#72B9D5"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Raindrops">
|
||||
<path id="Raindrop 1" d="M52 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
<path id="Raindrop 2" d="M64 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 0)"/>
|
||||
<path id="Raindrop 3" d="M76 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39593">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
28
public/icons/flat/partly-cloudy-night.svg
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="partly-cloudy-night" clip-path="url(#clip0_2045_39569)">
|
||||
<g id="Sky">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39569" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39569)">
|
||||
<g id="Moon">
|
||||
<path id="Moon_2" d="M35.766 34C29.1498 34.714 24 40.241 24 46.9586C24 54.1608 29.918 60 37.2177 60C43.371 60 48.5267 55.8459 50 50.2293C41.2173 51.171 33.4773 42.7199 35.766 34Z" fill="#72B9D5"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39569">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
23
public/icons/flat/rain.svg
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="rain" clip-path="url(#clip0_2045_39587)">
|
||||
<g id="Sky">
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Raindrops">
|
||||
<path id="Raindrop 1" d="M52 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
<path id="Raindrop 2" d="M64 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 0)"/>
|
||||
<path id="Raindrop 3" d="M76 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39587">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
23
public/icons/flat/snow.svg
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="snow" clip-path="url(#clip0_2045_39686)">
|
||||
<g id="Sky">
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3886 63.0856C92.6838 53.8819 87.7408 44.1357 79.0085 40.4822C70.2653 36.8242 59.8277 40.1375 54.8372 48.2115C50.5363 45.625 44.9752 45.7781 40.8239 48.5991C36.6832 51.4128 34.4996 56.5143 35.3499 61.4539C28.3926 62.7685 23.3934 69.3393 24.0614 76.4076C24.7297 83.4776 30.8718 89.0018 37.9534 89C55.6066 89 73.306 89 90.9767 89C98.0446 89 104 83.1189 104 76.0281C104 68.7015 97.6775 62.7674 90.3886 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Snowflakes">
|
||||
<path id="Snowflake 1" d="M52.5781 90.366L51.3735 89.6775C51.4794 89.2326 51.4786 88.7687 51.3708 88.3241L52.5781 87.6345C52.6738 87.5805 52.7577 87.5079 52.8252 87.421C52.8926 87.3342 52.9423 87.2347 52.9711 87.1284C52.9998 87.0221 53.0071 86.9112 52.9926 86.802C52.9782 86.6928 52.9422 86.5876 52.8868 86.4926C52.7732 86.2998 52.5886 86.1597 52.3728 86.1025C52.157 86.0452 51.9276 86.0754 51.7339 86.1866L50.5278 86.8763C50.1931 86.5586 49.7868 86.3264 49.3437 86.1995V84.8202C49.3368 84.6003 49.245 84.3918 49.0875 84.2387C48.93 84.0856 48.7192 84 48.4998 84C48.2805 84 48.0699 84.0856 47.9124 84.2387C47.7548 84.3918 47.6628 84.6003 47.656 84.8202V86.1995C47.214 86.3289 46.8081 86.5598 46.4706 86.874L45.2662 86.1853C45.0724 86.0742 44.8428 86.044 44.627 86.1013C44.4113 86.1585 44.2267 86.2986 44.113 86.4913C44.0576 86.5864 44.0217 86.6916 44.0072 86.8007C43.9928 86.9099 44 87.0209 44.0288 87.1271C44.0575 87.2334 44.1072 87.3329 44.1747 87.4198C44.2421 87.5067 44.326 87.5792 44.4217 87.6332L45.6264 88.3216C45.5204 88.7666 45.5213 89.2305 45.629 89.675L44.4217 90.3647C44.326 90.4187 44.2421 90.4912 44.1747 90.5781C44.1072 90.665 44.0575 90.7645 44.0288 90.8708C44 90.9771 43.9928 91.088 44.0072 91.1972C44.0217 91.3063 44.0576 91.4115 44.113 91.5066C44.2267 91.6992 44.4113 91.8392 44.627 91.8965C44.8428 91.9537 45.0724 91.9236 45.2662 91.8126L46.4721 91.1229C46.8063 91.4409 47.2128 91.6726 47.6562 91.7979V93.1798C47.6631 93.3997 47.755 93.6082 47.9126 93.7613C48.0701 93.9144 48.2807 94 48.5 94C48.7194 94 48.9302 93.9144 49.0877 93.7613C49.2452 93.6082 49.337 93.3997 49.3439 93.1798V91.7975C49.7853 91.6683 50.1907 91.4378 50.5278 91.1242L51.7341 91.8138C51.9278 91.9248 52.1573 91.955 52.373 91.8977C52.5888 91.8405 52.7733 91.7005 52.887 91.5079C52.9424 91.4128 52.9784 91.3076 52.9928 91.1984C53.0073 91.0892 52.9998 90.9783 52.9711 90.872C52.9423 90.7657 52.8929 90.6662 52.8254 90.5793C52.7579 90.4925 52.6738 90.4199 52.5781 90.366ZM47.8664 90.0861C47.7229 90.005 47.5968 89.8961 47.4956 89.7657C47.3944 89.6353 47.3202 89.486 47.2771 89.3266C47.2339 89.1671 47.2228 89.0007 47.2443 88.8369C47.2658 88.6731 47.3197 88.5152 47.4026 88.3724C47.5735 88.084 47.8503 87.8743 48.1736 87.7883C48.497 87.7023 48.8411 87.747 49.1321 87.9126C49.2756 87.9938 49.4016 88.1027 49.5028 88.2331C49.604 88.3635 49.6782 88.5127 49.7214 88.6722C49.7645 88.8316 49.7757 88.9981 49.7541 89.1619C49.7326 89.3257 49.6787 89.4836 49.5958 89.6263C49.425 89.9149 49.1482 90.1247 48.8248 90.2108C48.5014 90.2969 48.1574 90.2523 47.8664 90.0867V90.0861Z" fill="#86C3DB" transform="translate(0, 8)"/>
|
||||
<path id="Snowflake 2" d="M67.5781 90.366L66.3735 89.6775C66.4794 89.2326 66.4786 88.7687 66.3708 88.3241L67.5781 87.6345C67.6738 87.5805 67.7577 87.5079 67.8252 87.421C67.8926 87.3342 67.9423 87.2347 67.9711 87.1284C67.9998 87.0221 68.0071 86.9112 67.9926 86.802C67.9782 86.6928 67.9422 86.5876 67.8868 86.4926C67.7732 86.2998 67.5886 86.1597 67.3728 86.1025C67.157 86.0452 66.9276 86.0754 66.7339 86.1866L65.5278 86.8763C65.1931 86.5586 64.7868 86.3264 64.3437 86.1995V84.8202C64.3368 84.6003 64.245 84.3918 64.0875 84.2387C63.93 84.0856 63.7192 84 63.4998 84C63.2805 84 63.0699 84.0856 62.9124 84.2387C62.7548 84.3918 62.6628 84.6003 62.656 84.8202V86.1995C62.214 86.3289 61.8081 86.5598 61.4706 86.874L60.2662 86.1853C60.0724 86.0742 59.8428 86.044 59.627 86.1013C59.4113 86.1585 59.2267 86.2986 59.113 86.4913C59.0576 86.5864 59.0217 86.6916 59.0072 86.8007C58.9928 86.9099 59 87.0209 59.0288 87.1271C59.0575 87.2334 59.1072 87.3329 59.1747 87.4198C59.2421 87.5067 59.326 87.5792 59.4217 87.6332L60.6264 88.3216C60.5204 88.7666 60.5213 89.2305 60.629 89.675L59.4217 90.3647C59.326 90.4187 59.2421 90.4912 59.1747 90.5781C59.1072 90.665 59.0575 90.7645 59.0288 90.8708C59 90.9771 58.9928 91.088 59.0072 91.1972C59.0217 91.3063 59.0576 91.4115 59.113 91.5066C59.2267 91.6992 59.4113 91.8392 59.627 91.8965C59.8428 91.9537 60.0724 91.9236 60.2662 91.8126L61.4721 91.1229C61.8063 91.4409 62.2128 91.6726 62.6562 91.7979V93.1798C62.6631 93.3997 62.755 93.6082 62.9126 93.7613C63.0701 93.9144 63.2807 94 63.5 94C63.7194 94 63.9302 93.9144 64.0877 93.7613C64.2452 93.6082 64.337 93.3997 64.3439 93.1798V91.7975C64.7853 91.6683 65.1907 91.4378 65.5278 91.1242L66.7341 91.8138C66.9278 91.9248 67.1573 91.955 67.373 91.8977C67.5888 91.8405 67.7733 91.7005 67.887 91.5079C67.9424 91.4128 67.9784 91.3076 67.9928 91.1984C68.0073 91.0892 67.9998 90.9783 67.9711 90.872C67.9423 90.7657 67.8929 90.6662 67.8254 90.5793C67.7579 90.4925 67.6738 90.4199 67.5781 90.366ZM62.8664 90.0861C62.7229 90.005 62.5968 89.8961 62.4956 89.7657C62.3944 89.6353 62.3202 89.486 62.2771 89.3266C62.2339 89.1671 62.2228 89.0007 62.2443 88.8369C62.2658 88.6731 62.3197 88.5152 62.4026 88.3724C62.5735 88.084 62.8503 87.8743 63.1736 87.7883C63.497 87.7023 63.8411 87.747 64.1321 87.9126C64.2756 87.9938 64.4016 88.1027 64.5028 88.2331C64.604 88.3635 64.6782 88.5127 64.7214 88.6722C64.7645 88.8316 64.7757 88.9981 64.7541 89.1619C64.7326 89.3257 64.6787 89.4836 64.5958 89.6263C64.425 89.9149 64.1482 90.1247 63.8248 90.2108C63.5014 90.2969 63.1574 90.2523 62.8664 90.0867V90.0861Z" fill="#86C3DB" transform="translate(0, 0)"/>
|
||||
<path id="Snowflake 3" d="M82.5781 90.366L81.3735 89.6775C81.4794 89.2326 81.4786 88.7687 81.3708 88.3241L82.5781 87.6345C82.6738 87.5805 82.7577 87.5079 82.8252 87.421C82.8926 87.3342 82.9423 87.2347 82.9711 87.1284C82.9998 87.0221 83.0071 86.9112 82.9926 86.802C82.9782 86.6928 82.9422 86.5876 82.8868 86.4926C82.7732 86.2998 82.5886 86.1597 82.3728 86.1025C82.157 86.0452 81.9276 86.0754 81.7339 86.1866L80.5278 86.8763C80.1931 86.5586 79.7868 86.3264 79.3437 86.1995V84.8202C79.3368 84.6003 79.245 84.3918 79.0875 84.2387C78.93 84.0856 78.7192 84 78.4998 84C78.2805 84 78.0699 84.0856 77.9124 84.2387C77.7548 84.3918 77.6628 84.6003 77.656 84.8202V86.1995C77.214 86.3289 76.8081 86.5598 76.4706 86.874L75.2662 86.1853C75.0724 86.0742 74.8428 86.044 74.627 86.1013C74.4113 86.1585 74.2267 86.2986 74.113 86.4913C74.0576 86.5864 74.0217 86.6916 74.0072 86.8007C73.9928 86.9099 74 87.0209 74.0288 87.1271C74.0575 87.2334 74.1072 87.3329 74.1747 87.4198C74.2421 87.5067 74.326 87.5792 74.4217 87.6332L75.6264 88.3216C75.5204 88.7666 75.5213 89.2305 75.629 89.675L74.4217 90.3647C74.326 90.4187 74.2421 90.4912 74.1747 90.5781C74.1072 90.665 74.0575 90.7645 74.0288 90.8708C74 90.9771 73.9928 91.088 74.0072 91.1972C74.0217 91.3063 74.0576 91.4115 74.113 91.5066C74.2267 91.6992 74.4113 91.8392 74.627 91.8965C74.8428 91.9537 75.0724 91.9236 75.2662 91.8126L76.4721 91.1229C76.8063 91.4409 77.2128 91.6726 77.6562 91.7979V93.1798C77.6631 93.3997 77.755 93.6082 77.9126 93.7613C78.0701 93.9144 78.2807 94 78.5 94C78.7194 94 78.9302 93.9144 79.0877 93.7613C79.2452 93.6082 79.337 93.3997 79.3439 93.1798V91.7975C79.7853 91.6683 80.1907 91.4378 80.5278 91.1242L81.7341 91.8138C81.9278 91.9248 82.1573 91.955 82.373 91.8977C82.5888 91.8405 82.7733 91.7005 82.887 91.5079C82.9424 91.4128 82.9784 91.3076 82.9928 91.1984C83.0073 91.0892 82.9998 90.9783 82.9711 90.872C82.9423 90.7657 82.8929 90.6662 82.8254 90.5793C82.7579 90.4925 82.6738 90.4199 82.5781 90.366ZM77.8664 90.0861C77.7229 90.005 77.5968 89.8961 77.4956 89.7657C77.3944 89.6353 77.3202 89.486 77.2771 89.3266C77.2339 89.1671 77.2228 89.0007 77.2443 88.8369C77.2658 88.6731 77.3197 88.5152 77.4026 88.3724C77.5735 88.084 77.8503 87.8743 78.1736 87.7883C78.497 87.7023 78.8411 87.747 79.1321 87.9126C79.2756 87.9938 79.4016 88.1027 79.5028 88.2331C79.604 88.3635 79.6782 88.5127 79.7214 88.6722C79.7645 88.8316 79.7757 88.9981 79.7541 89.1619C79.7326 89.3257 79.6787 89.4836 79.5958 89.6263C79.425 89.9149 79.1482 90.1247 78.8248 90.2108C78.5014 90.2969 78.1574 90.2523 77.8664 90.0867V90.0861Z" fill="#86C3DB" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39686">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.4 KiB |
48
public/icons/flat/thunderstorms-day-hail.svg
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="thunderstorms-day-hail" clip-path="url(#clip0_2045_39976)">
|
||||
<g id="Sky">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39976" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39976)">
|
||||
<g id="Sun">
|
||||
<circle id="Core" cx="39" cy="51" r="9" fill="#F8AF18"/>
|
||||
<g id="Rays">
|
||||
<path d="M37.6875 31.3125C37.6875 30.5876 38.2751 30 39 30C39.7249 30 40.3125 30.5876 40.3125 31.3125V37.4375C40.3125 38.1624 39.7249 38.75 39 38.75C38.2751 38.75 37.6875 38.1624 37.6875 37.4375V31.3125Z" fill="#F8AF18"/>
|
||||
<path d="M51.9931 36.1508C52.5056 35.6382 53.3367 35.6382 53.8492 36.1508C54.3618 36.6633 54.3618 37.4943 53.8492 38.0069L49.5182 42.3379C49.0056 42.8505 48.1746 42.8505 47.6621 42.3379C47.1495 41.8254 47.1495 40.9944 47.6621 40.4818L51.9931 36.1508Z" fill="#F8AF18"/>
|
||||
<path d="M58.6875 49.6875C59.4124 49.6875 60 50.2751 60 51C60 51.7249 59.4124 52.3125 58.6875 52.3125H52.5625C51.8376 52.3125 51.25 51.7249 51.25 51C51.25 50.2751 51.8376 49.6875 52.5625 49.6875H58.6875Z" fill="#F8AF18"/>
|
||||
<path d="M53.8492 63.9931C54.3618 64.5057 54.3618 65.3367 53.8492 65.8492C53.3367 66.3618 52.5056 66.3618 51.9931 65.8492L47.6621 61.5182C47.1495 61.0057 47.1495 60.1746 47.6621 59.6621C48.1746 59.1495 49.0057 59.1495 49.5182 59.6621L53.8492 63.9931Z" fill="#F8AF18"/>
|
||||
<path d="M37.6875 64.5625C37.6875 63.8376 38.2751 63.25 39 63.25C39.7249 63.25 40.3125 63.8376 40.3125 64.5625V70.6875C40.3125 71.4124 39.7249 72 39 72C38.2751 72 37.6875 71.4124 37.6875 70.6875V64.5625Z" fill="#F8AF18"/>
|
||||
<path d="M28.4818 59.6621C28.9943 59.1495 29.8254 59.1495 30.3379 59.6621C30.8505 60.1746 30.8505 61.0056 30.3379 61.5182L26.0069 65.8492C25.4943 66.3618 24.6633 66.3618 24.1508 65.8492C23.6382 65.3367 23.6382 64.5056 24.1508 63.9931L28.4818 59.6621Z" fill="#F8AF18"/>
|
||||
<path d="M25.4375 49.6875C26.1624 49.6875 26.75 50.2751 26.75 51C26.75 51.7249 26.1624 52.3125 25.4375 52.3125H19.3125C18.5876 52.3125 18 51.7249 18 51C18 50.2751 18.5876 49.6875 19.3125 49.6875H25.4375Z" fill="#F8AF18"/>
|
||||
<path d="M30.3379 40.4818C30.8505 40.9944 30.8505 41.8254 30.3379 42.3379C29.8254 42.8505 28.9944 42.8505 28.4818 42.3379L24.1508 38.0069C23.6382 37.4944 23.6382 36.6633 24.1508 36.1508C24.6633 35.6382 25.4944 35.6382 26.0069 36.1508L30.3379 40.4818Z" fill="#F8AF18"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3887 63.0856C92.684 53.8819 87.741 44.1357 79.0087 40.4822C70.2654 36.8242 59.8278 40.1375 54.8373 48.2115C50.5364 45.625 44.9753 45.7781 40.824 48.5991C36.6833 51.4128 34.4998 56.5143 35.35 61.4539C28.3927 62.7685 23.3935 69.3393 24.0616 76.4076C24.7298 83.4776 30.872 89.0018 37.9535 89C55.6067 89 73.3061 89 90.9768 89C98.0447 89 104 83.1189 104 76.0281C104 68.7015 97.6776 62.7674 90.3887 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Ice balls">
|
||||
<path id="Ice Ball 1" d="M52 86C51.4067 86 50.8266 86.1759 50.3333 86.5056C49.8399 86.8352 49.4554 87.3038 49.2283 87.852C49.0013 88.4001 48.9419 89.0033 49.0577 89.5853C49.1734 90.1672 49.4591 90.7018 49.8787 91.1213C50.2983 91.5409 50.8329 91.8266 51.4148 91.9424C51.9968 92.0581 52.5998 91.9987 53.148 91.7716C53.6961 91.5446 54.1647 91.1601 54.4944 90.6667C54.824 90.1734 55 89.5933 55 89C55 88.2044 54.6839 87.4413 54.1213 86.8787C53.5587 86.3161 52.7957 86 52 86Z" fill="#86C3DB" transform="translate(0, 8)"/>
|
||||
<path id="Ice Ball 2" d="M64 86C63.4067 86 62.8266 86.1759 62.3333 86.5056C61.8399 86.8352 61.4554 87.3038 61.2283 87.852C61.0013 88.4001 60.9419 89.0033 61.0577 89.5853C61.1734 90.1672 61.4591 90.7018 61.8787 91.1213C62.2983 91.5409 62.8329 91.8266 63.4148 91.9424C63.9968 92.0581 64.5998 91.9987 65.148 91.7716C65.6961 91.5446 66.1647 91.1601 66.4944 90.6667C66.824 90.1734 67 89.5933 67 89C67 88.2044 66.6839 87.4413 66.1213 86.8787C65.5587 86.3161 64.7957 86 64 86Z" fill="#86C3DB" transform="translate(0, 0)"/>
|
||||
<path id="Ice Ball 3" d="M76 86C75.4067 86 74.8266 86.1759 74.3333 86.5056C73.8399 86.8352 73.4554 87.3038 73.2283 87.852C73.0013 88.4001 72.9419 89.0033 73.0577 89.5853C73.1734 90.1672 73.4591 90.7018 73.8787 91.1213C74.2983 91.5409 74.8329 91.8266 75.4148 91.9424C75.9968 92.0581 76.5998 91.9987 77.148 91.7716C77.6961 91.5446 78.1647 91.1601 78.4944 90.6667C78.824 90.1734 79 89.5933 79 89C79 88.2044 78.6839 87.4413 78.1213 86.8787C77.5587 86.3161 76.7957 86 76 86Z" fill="#86C3DB" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Lightning">
|
||||
<path id="Lightning Bolt" d="M60.0003 68L52 90.9092H60.0003L55.9995 110L76 83.2728H63.9996L71.9999 68H60.0003Z" fill="#F6A823"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39976">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
48
public/icons/flat/thunderstorms-day-rain.svg
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="thunderstorms-day-rain" clip-path="url(#clip0_2045_39888)">
|
||||
<g id="Sky">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39888" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39888)">
|
||||
<g id="Sun">
|
||||
<circle id="Core" cx="39" cy="51" r="9" fill="#F8AF18"/>
|
||||
<g id="Rays">
|
||||
<path d="M37.6875 31.3125C37.6875 30.5876 38.2751 30 39 30C39.7249 30 40.3125 30.5876 40.3125 31.3125V37.4375C40.3125 38.1624 39.7249 38.75 39 38.75C38.2751 38.75 37.6875 38.1624 37.6875 37.4375V31.3125Z" fill="#F8AF18"/>
|
||||
<path d="M51.9931 36.1508C52.5056 35.6382 53.3367 35.6382 53.8492 36.1508C54.3618 36.6633 54.3618 37.4943 53.8492 38.0069L49.5182 42.3379C49.0056 42.8505 48.1746 42.8505 47.6621 42.3379C47.1495 41.8254 47.1495 40.9944 47.6621 40.4818L51.9931 36.1508Z" fill="#F8AF18"/>
|
||||
<path d="M58.6875 49.6875C59.4124 49.6875 60 50.2751 60 51C60 51.7249 59.4124 52.3125 58.6875 52.3125H52.5625C51.8376 52.3125 51.25 51.7249 51.25 51C51.25 50.2751 51.8376 49.6875 52.5625 49.6875H58.6875Z" fill="#F8AF18"/>
|
||||
<path d="M53.8492 63.9931C54.3618 64.5057 54.3618 65.3367 53.8492 65.8492C53.3367 66.3618 52.5056 66.3618 51.9931 65.8492L47.6621 61.5182C47.1495 61.0057 47.1495 60.1746 47.6621 59.6621C48.1746 59.1495 49.0057 59.1495 49.5182 59.6621L53.8492 63.9931Z" fill="#F8AF18"/>
|
||||
<path d="M37.6875 64.5625C37.6875 63.8376 38.2751 63.25 39 63.25C39.7249 63.25 40.3125 63.8376 40.3125 64.5625V70.6875C40.3125 71.4124 39.7249 72 39 72C38.2751 72 37.6875 71.4124 37.6875 70.6875V64.5625Z" fill="#F8AF18"/>
|
||||
<path d="M28.4818 59.6621C28.9943 59.1495 29.8254 59.1495 30.3379 59.6621C30.8505 60.1746 30.8505 61.0056 30.3379 61.5182L26.0069 65.8492C25.4943 66.3618 24.6633 66.3618 24.1508 65.8492C23.6382 65.3367 23.6382 64.5056 24.1508 63.9931L28.4818 59.6621Z" fill="#F8AF18"/>
|
||||
<path d="M25.4375 49.6875C26.1624 49.6875 26.75 50.2751 26.75 51C26.75 51.7249 26.1624 52.3125 25.4375 52.3125H19.3125C18.5876 52.3125 18 51.7249 18 51C18 50.2751 18.5876 49.6875 19.3125 49.6875H25.4375Z" fill="#F8AF18"/>
|
||||
<path d="M30.3379 40.4818C30.8505 40.9944 30.8505 41.8254 30.3379 42.3379C29.8254 42.8505 28.9944 42.8505 28.4818 42.3379L24.1508 38.0069C23.6382 37.4944 23.6382 36.6633 24.1508 36.1508C24.6633 35.6382 25.4944 35.6382 26.0069 36.1508L30.3379 40.4818Z" fill="#F8AF18"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3887 63.0856C92.684 53.8819 87.741 44.1357 79.0087 40.4822C70.2654 36.8242 59.8278 40.1375 54.8373 48.2115C50.5364 45.625 44.9753 45.7781 40.824 48.5991C36.6833 51.4128 34.4998 56.5143 35.35 61.4539C28.3927 62.7685 23.3935 69.3393 24.0616 76.4076C24.7298 83.4776 30.872 89.0018 37.9535 89C55.6067 89 73.3061 89 90.9768 89C98.0447 89 104 83.1189 104 76.0281C104 68.7015 97.6776 62.7674 90.3887 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Raindrops">
|
||||
<path id="Raindrop 1" d="M52 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
<path id="Raindrop 2" d="M64 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 0)"/>
|
||||
<path id="Raindrop 3" d="M76 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Lightning">
|
||||
<path id="Lightning Bolt" d="M60.0003 68L52 90.9092H60.0003L55.9995 110L76 83.2728H63.9996L71.9999 68H60.0003Z" fill="#F6A823"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39888">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4 KiB |
38
public/icons/flat/thunderstorms-night-hail.svg
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="thunderstorms-night-hail" clip-path="url(#clip0_2045_39980)">
|
||||
<g id="Sky">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39980" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39980)">
|
||||
<g id="Moon">
|
||||
<path id="Moon_2" d="M35.766 34C29.1498 34.714 24 40.241 24 46.9586C24 54.1608 29.918 60 37.2177 60C43.371 60 48.5267 55.8459 50 50.2293C41.2173 51.171 33.4773 42.7199 35.766 34Z" fill="#72B9D5"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3887 63.0856C92.684 53.8819 87.741 44.1357 79.0087 40.4822C70.2654 36.8242 59.8278 40.1375 54.8373 48.2115C50.5364 45.625 44.9753 45.7781 40.824 48.5991C36.6833 51.4128 34.4998 56.5143 35.35 61.4539C28.3927 62.7685 23.3935 69.3393 24.0616 76.4076C24.7298 83.4776 30.872 89.0018 37.9535 89C55.6067 89 73.3061 89 90.9768 89C98.0447 89 104 83.1189 104 76.0281C104 68.7015 97.6776 62.7674 90.3887 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Ice balls">
|
||||
<path id="Ice Ball 1" d="M52 86C51.4067 86 50.8266 86.1759 50.3333 86.5056C49.8399 86.8352 49.4554 87.3038 49.2283 87.852C49.0013 88.4001 48.9419 89.0033 49.0577 89.5853C49.1734 90.1672 49.4591 90.7018 49.8787 91.1213C50.2983 91.5409 50.8329 91.8266 51.4148 91.9424C51.9968 92.0581 52.5998 91.9987 53.148 91.7716C53.6961 91.5446 54.1647 91.1601 54.4944 90.6667C54.824 90.1734 55 89.5933 55 89C55 88.2044 54.6839 87.4413 54.1213 86.8787C53.5587 86.3161 52.7957 86 52 86Z" fill="#86C3DB" transform="translate(0, 8)"/>
|
||||
<path id="Ice Ball 2" d="M64 86C63.4067 86 62.8266 86.1759 62.3333 86.5056C61.8399 86.8352 61.4554 87.3038 61.2283 87.852C61.0013 88.4001 60.9419 89.0033 61.0577 89.5853C61.1734 90.1672 61.4591 90.7018 61.8787 91.1213C62.2983 91.5409 62.8329 91.8266 63.4148 91.9424C63.9968 92.0581 64.5998 91.9987 65.148 91.7716C65.6961 91.5446 66.1647 91.1601 66.4944 90.6667C66.824 90.1734 67 89.5933 67 89C67 88.2044 66.6839 87.4413 66.1213 86.8787C65.5587 86.3161 64.7957 86 64 86Z" fill="#86C3DB" transform="translate(0, 0)"/>
|
||||
<path id="Ice Ball 3" d="M76 86C75.4067 86 74.8266 86.1759 74.3333 86.5056C73.8399 86.8352 73.4554 87.3038 73.2283 87.852C73.0013 88.4001 72.9419 89.0033 73.0577 89.5853C73.1734 90.1672 73.4591 90.7018 73.8787 91.1213C74.2983 91.5409 74.8329 91.8266 75.4148 91.9424C75.9968 92.0581 76.5998 91.9987 77.148 91.7716C77.6961 91.5446 78.1647 91.1601 78.4944 90.6667C78.824 90.1734 79 89.5933 79 89C79 88.2044 78.6839 87.4413 78.1213 86.8787C77.5587 86.3161 76.7957 86 76 86Z" fill="#86C3DB" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Lightning">
|
||||
<path id="Lightning Bolt" d="M60.0003 68L52 90.9092H60.0003L55.9995 110L76 83.2728H63.9996L71.9999 68H60.0003Z" fill="#F6A823"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39980">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
38
public/icons/flat/thunderstorms-night-rain.svg
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<svg viewBox="0 0 128 128" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="thunderstorms-night-rain" clip-path="url(#clip0_2045_39892)">
|
||||
<g id="Sky">
|
||||
<g id="Mask group">
|
||||
<mask id="mask0_2045_39892" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="128" height="128">
|
||||
<g id="Cloud Mask">
|
||||
<path id="Subtract" fill-rule="evenodd" clip-rule="evenodd" d="M128 0H0V128H128V0ZM37.9519 93H90.9752C100.227 93 107.998 85.353 107.998 76.0281C107.998 68.0217 102.305 61.3501 94.9248 59.5512C95.3619 49.9005 89.6744 40.6093 80.5509 36.7922C71.1071 32.8411 60.0664 35.6119 53.5305 43.2384C48.5702 41.5956 42.9815 42.2957 38.5741 45.2907C34.1459 48.2998 31.4305 53.2809 31.1846 58.5379C24.0633 61.463 19.3278 68.8506 20.0776 76.7839C20.942 85.9295 28.8285 93.0018 37.9519 93Z" fill="black"/>
|
||||
</g>
|
||||
</mask>
|
||||
<g mask="url(#mask0_2045_39892)">
|
||||
<g id="Moon">
|
||||
<path id="Moon_2" d="M35.766 34C29.1498 34.714 24 40.241 24 46.9586C24 54.1608 29.918 60 37.2177 60C43.371 60 48.5267 55.8459 50 50.2293C41.2173 51.171 33.4773 42.7199 35.766 34Z" fill="#72B9D5"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Clouds">
|
||||
<g id="Cloud">
|
||||
<path id="Cloud_2" d="M90.3887 63.0856C92.684 53.8819 87.741 44.1357 79.0087 40.4822C70.2654 36.8242 59.8278 40.1375 54.8373 48.2115C50.5364 45.625 44.9753 45.7781 40.824 48.5991C36.6833 51.4128 34.4998 56.5143 35.35 61.4539C28.3927 62.7685 23.3935 69.3393 24.0616 76.4076C24.7298 83.4776 30.872 89.0018 37.9535 89C55.6067 89 73.3061 89 90.9768 89C98.0447 89 104 83.1189 104 76.0281C104 68.7015 97.6776 62.7674 90.3887 63.0856Z" fill="#E6EFFC"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Precipitation">
|
||||
<g id="Raindrops">
|
||||
<path id="Raindrop 1" d="M52 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
<path id="Raindrop 2" d="M64 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 0)"/>
|
||||
<path id="Raindrop 3" d="M76 83V95" stroke="#0A5AD4" stroke-width="4" stroke-linecap="round" transform="translate(0, 8)"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Lightning">
|
||||
<path id="Lightning Bolt" d="M60.0003 68L52 90.9092H60.0003L55.9995 110L76 83.2728H63.9996L71.9999 68H60.0003Z" fill="#F6A823"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2045_39892">
|
||||
<rect width="128" height="128" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
96
readme.txt
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
=== Font del Bosc — El Temps ===
|
||||
Contributors: robotstxt
|
||||
Tags: weather, forecast, meteocat, aemet, open-meteo
|
||||
Requires at least: 6.4
|
||||
Tested up to: 7.1
|
||||
Stable tag: 1.0.0
|
||||
Requires PHP: 8.2
|
||||
Version: 1.0.0
|
||||
License: GPL-3.0-or-later
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
|
||||
Weather for Font del Bosc (Mediona, Alt Penedès): current conditions, hourly and daily forecast, and historical data.
|
||||
|
||||
== Description ==
|
||||
|
||||
Displays the weather for the Font del Bosc urbanization (Mediona, Sant Joan de Mediona, Alt Penedès, Barcelona). The location is fixed to the Font del Bosc spring coordinates; there is no location picker.
|
||||
|
||||
Data sources, with automatic fallback:
|
||||
|
||||
* Meteocat (Servei Meteorològic de Catalunya): hourly municipal forecast and XEMA station observations. Requires a free API key.
|
||||
* AEMET OpenData: daily municipal forecast. Requires a free API key.
|
||||
* Open-Meteo: current conditions, forecast and historical data (ERA5). No API key required; used automatically when no other key is configured.
|
||||
|
||||
All requests are cached through the WordPress Transients API, with a stale-while-error policy so cached data is served when a source temporarily fails.
|
||||
|
||||
Icons by Meteocons (MIT license), bundled with the plugin.
|
||||
|
||||
== Using the plugin ==
|
||||
|
||||
= Shortcode =
|
||||
|
||||
`[fontdelbosc_eltemps]` renders the current conditions. Attributes:
|
||||
|
||||
* `view`: `current` (default), `hourly`, `daily` or `historical`.
|
||||
* `hours`: hours to show in the hourly view (1-48, default 24).
|
||||
* `days`: days to show in the daily view (1-7, default 7).
|
||||
* `year` / `month`: month shown in the historical view (defaults to the last completed month).
|
||||
|
||||
Examples:
|
||||
|
||||
`[fontdelbosc_eltemps view="hourly" hours="24"]`
|
||||
`[fontdelbosc_eltemps view="daily" days="5"]`
|
||||
`[fontdelbosc_eltemps view="historical" year="2024" month="6"]`
|
||||
|
||||
= Widget =
|
||||
|
||||
A sidebar widget with an editable title offers the current conditions or today's forecast.
|
||||
|
||||
= Settings =
|
||||
|
||||
Settings → Font del Bosc Temps: AEMET and Meteocat API keys, cache TTLs, attribution toggle, data deletion on uninstall, and connection tests. When a Meteocat key is set, the nearest XEMA station to Font del Bosc can be detected automatically.
|
||||
|
||||
== Installation ==
|
||||
|
||||
= Automatic download =
|
||||
|
||||
Visit the plugin section in your WordPress, search for "Font del Bosc — El Temps"; download and install the plugin.
|
||||
|
||||
= Manual download =
|
||||
|
||||
Extract the contents of the ZIP and upload the contents to the `/wp-content/plugins/fontdelbosc-eltemps/` directory. Once uploaded, it will appear in your plugin list.
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Do I need API keys? =
|
||||
|
||||
No. Without keys the plugin uses Open-Meteo for everything. Adding an AEMET key improves the daily forecast, and adding a Meteocat key improves the hourly forecast and enables station observations.
|
||||
|
||||
= Where do the historical data come from? =
|
||||
|
||||
The Open-Meteo ERA5 archive (from 1940), which is available without a key.
|
||||
|
||||
== Compatibility ==
|
||||
|
||||
* WordPress: 6.4 - 7.1
|
||||
* PHP: 8.2 - 8.5
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0.0 =
|
||||
|
||||
* Initial release: current conditions, hourly forecast, daily forecast, historical month view, widget, shortcode, caching and source fallback.
|
||||
|
||||
= Previous versions =
|
||||
|
||||
If you want to see the full changelog, visit the [changelog.txt](https://github.com/robotstxt/fontdelbosc-eltemps/raw/main/changelog.txt) file.
|
||||
|
||||
== Compliance ==
|
||||
|
||||
This plugin adheres to the following security measures and review protocols for each version:
|
||||
|
||||
* [WordPress Plugin Handbook](https://developer.wordpress.org/plugins/)
|
||||
* [WordPress Plugin Security](https://developer.wordpress.org/plugins/wordpress-org/plugin-security/)
|
||||
* [WordPress APIs Security](https://developer.wordpress.org/apis/security/)
|
||||
* [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards)
|
||||
* [Plugin Check (PCP)](https://wordpress.org/plugins/plugin-check/)
|
||||
47
templates/current.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* Current conditions template.
|
||||
*
|
||||
* @var array<string,mixed> $data Normalized current conditions.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$fontdelbosc_night = Fontdelbosc_Conditions::is_night( (int) wp_date( 'G', (int) ( $data['time'] ?? time() ) ) );
|
||||
$fontdelbosc_show_attribution = ! empty( Fontdelbosc_Plugin::get_options()['display_attribution'] );
|
||||
?>
|
||||
<div class="fdb-weather fdb-current">
|
||||
<div class="fdb-current__main">
|
||||
<?php if ( ! empty( $data['condition'] ) ) : ?>
|
||||
<img class="fdb-icon fdb-icon--lg" src="<?php echo esc_url( Fontdelbosc_Conditions::icon( (string) $data['condition'], $fontdelbosc_night ) ); ?>" alt="" width="96" height="96" loading="lazy" />
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $data['temperature'] ) : ?>
|
||||
<span class="fdb-current__temp"><?php echo esc_html( number_format_i18n( round( (float) $data['temperature'] ) ) ); ?>°C</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ( ! empty( $data['condition'] ) ) : ?>
|
||||
<p class="fdb-current__label"><?php echo esc_html( Fontdelbosc_Conditions::label( (string) $data['condition'] ) ); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<ul class="fdb-current__meta">
|
||||
<?php if ( null !== $data['apparent'] ) : ?>
|
||||
<li><?php echo esc_html__( 'Feels like', 'fontdelbosc-eltemps' ); ?>: <?php echo esc_html( number_format_i18n( round( (float) $data['apparent'] ) ) ); ?>°C</li>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $data['humidity'] ) : ?>
|
||||
<li><?php echo esc_html__( 'Humidity', 'fontdelbosc-eltemps' ); ?>: <?php echo esc_html( number_format_i18n( (float) $data['humidity'] ) ); ?>%</li>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $data['wind_speed'] ) : ?>
|
||||
<li><?php echo esc_html__( 'Wind', 'fontdelbosc-eltemps' ); ?>: <?php echo esc_html( number_format_i18n( round( (float) $data['wind_speed'] ) ) ); ?> km/h</li>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $data['precipitation'] ) : ?>
|
||||
<li><?php echo esc_html__( 'Precipitation', 'fontdelbosc-eltemps' ); ?>: <?php echo esc_html( number_format_i18n( (float) $data['precipitation'], 1 ) ); ?> mm</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
|
||||
<?php if ( $fontdelbosc_show_attribution ) : ?>
|
||||
<p class="fdb-attribution"><?php echo esc_html( Fontdelbosc_Data_Manager::attribution( (string) $data['source'] ) ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
68
templates/forecast-daily.php
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Daily forecast template (grid of day cards).
|
||||
*
|
||||
* @var array<string,mixed> $data Normalized daily forecast.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$fontdelbosc_show_attribution = ! empty( Fontdelbosc_Plugin::get_options()['display_attribution'] );
|
||||
?>
|
||||
<div class="fdb-weather fdb-daily">
|
||||
<h3 class="fdb-weather__title"><?php esc_html_e( 'Forecast', 'fontdelbosc-eltemps' ); ?></h3>
|
||||
|
||||
<div class="fdb-daily__grid">
|
||||
<?php foreach ( $data['days'] as $fontdelbosc_index => $fontdelbosc_day ) : ?>
|
||||
<?php
|
||||
try {
|
||||
$fontdelbosc_date = DateTimeImmutable::createFromFormat( 'Y-m-d', (string) $fontdelbosc_day['date'], new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) );
|
||||
} catch ( Exception ) {
|
||||
$fontdelbosc_date = false;
|
||||
}
|
||||
|
||||
$fontdelbosc_timestamp = $fontdelbosc_date instanceof DateTimeImmutable ? $fontdelbosc_date->getTimestamp() : time();
|
||||
$fontdelbosc_weekday = (int) wp_date( 'N', $fontdelbosc_timestamp );
|
||||
|
||||
if ( 0 === $fontdelbosc_index ) {
|
||||
$fontdelbosc_label = __( 'Today', 'fontdelbosc-eltemps' );
|
||||
} elseif ( 1 === $fontdelbosc_index ) {
|
||||
$fontdelbosc_label = __( 'Tomorrow', 'fontdelbosc-eltemps' );
|
||||
} else {
|
||||
$fontdelbosc_label = Fontdelbosc_Conditions::weekday( $fontdelbosc_weekday );
|
||||
}
|
||||
?>
|
||||
<div class="fdb-daily__day">
|
||||
<span class="fdb-daily__name"><?php echo esc_html( $fontdelbosc_label ); ?></span>
|
||||
<span class="fdb-daily__date"><?php echo esc_html( wp_date( 'j/n', $fontdelbosc_timestamp ) ); ?></span>
|
||||
<?php if ( ! empty( $fontdelbosc_day['condition'] ) ) : ?>
|
||||
<img class="fdb-icon" src="<?php echo esc_url( Fontdelbosc_Conditions::icon( (string) $fontdelbosc_day['condition'] ) ); ?>" alt="" width="48" height="48" loading="lazy" />
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $fontdelbosc_day['temp_max'] || null !== $fontdelbosc_day['temp_min'] ) : ?>
|
||||
<p class="fdb-daily__temps">
|
||||
<?php if ( null !== $fontdelbosc_day['temp_max'] ) : ?>
|
||||
<span class="fdb-daily__max"><span class="screen-reader-text"><?php esc_html_e( 'Max', 'fontdelbosc-eltemps' ); ?> </span><?php echo esc_html( number_format_i18n( round( (float) $fontdelbosc_day['temp_max'] ) ) ); ?>°</span>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $fontdelbosc_day['temp_min'] ) : ?>
|
||||
<span class="fdb-daily__min"><span class="screen-reader-text"><?php esc_html_e( 'Min', 'fontdelbosc-eltemps' ); ?> </span><?php echo esc_html( number_format_i18n( round( (float) $fontdelbosc_day['temp_min'] ) ) ); ?>°</span>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $fontdelbosc_day['pop'] ) : ?>
|
||||
<p class="fdb-daily__pop"><?php echo esc_html( number_format_i18n( (float) $fontdelbosc_day['pop'] ) ); ?>%</p>
|
||||
<?php elseif ( null !== $fontdelbosc_day['precipitation'] ) : ?>
|
||||
<p class="fdb-daily__pop"><?php echo esc_html( number_format_i18n( (float) $fontdelbosc_day['precipitation'], 1 ) ); ?> mm</p>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $fontdelbosc_day['wind_max'] ) : ?>
|
||||
<p class="fdb-daily__wind"><?php echo esc_html( number_format_i18n( round( (float) $fontdelbosc_day['wind_max'] ) ) ); ?> km/h</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ( $fontdelbosc_show_attribution ) : ?>
|
||||
<p class="fdb-attribution"><?php echo esc_html( Fontdelbosc_Data_Manager::attribution( (string) $data['source'] ) ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
43
templates/forecast-hourly.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* Hourly forecast template (horizontally scrollable strip).
|
||||
*
|
||||
* @var array<string,mixed> $data Normalized hourly forecast.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$fontdelbosc_show_attribution = ! empty( Fontdelbosc_Plugin::get_options()['display_attribution'] );
|
||||
?>
|
||||
<div class="fdb-weather fdb-hourly">
|
||||
<h3 class="fdb-weather__title"><?php esc_html_e( 'Forecast', 'fontdelbosc-eltemps' ); ?></h3>
|
||||
|
||||
<div class="fdb-hourly__scroll">
|
||||
<?php foreach ( $data['hours'] as $fontdelbosc_hour ) : ?>
|
||||
<?php $fontdelbosc_night = Fontdelbosc_Conditions::is_night( (int) $fontdelbosc_hour['hour'] ); ?>
|
||||
<div class="fdb-hourly__item">
|
||||
<span class="fdb-hourly__time"><?php echo esc_html( sprintf( '%02d:00', (int) $fontdelbosc_hour['hour'] ) ); ?></span>
|
||||
<?php if ( ! empty( $fontdelbosc_hour['condition'] ) ) : ?>
|
||||
<img class="fdb-icon" src="<?php echo esc_url( Fontdelbosc_Conditions::icon( (string) $fontdelbosc_hour['condition'], $fontdelbosc_night ) ); ?>" alt="" width="48" height="48" loading="lazy" />
|
||||
<?php else : ?>
|
||||
<span class="fdb-hourly__icon-placeholder"></span>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $fontdelbosc_hour['temperature'] ) : ?>
|
||||
<span class="fdb-hourly__temp"><?php echo esc_html( number_format_i18n( round( (float) $fontdelbosc_hour['temperature'] ) ) ); ?>°</span>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $fontdelbosc_hour['pop'] ) : ?>
|
||||
<span class="fdb-hourly__pop"><?php echo esc_html( number_format_i18n( (float) $fontdelbosc_hour['pop'] ) ); ?>%</span>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $fontdelbosc_hour['wind'] ) : ?>
|
||||
<span class="fdb-hourly__wind"><?php echo esc_html( number_format_i18n( round( (float) $fontdelbosc_hour['wind'] ) ) ); ?> km/h</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ( $fontdelbosc_show_attribution ) : ?>
|
||||
<p class="fdb-attribution"><?php echo esc_html( Fontdelbosc_Data_Manager::attribution( (string) $data['source'] ) ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
86
templates/historical.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/**
|
||||
* Historical data template: monthly stats plus a pure-CSS bar chart
|
||||
* (daily max/min temperatures, precipitation in tooltips).
|
||||
*
|
||||
* @var array<string,mixed> $data Normalized monthly history.
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$fontdelbosc_show_attribution = ! empty( Fontdelbosc_Plugin::get_options()['display_attribution'] );
|
||||
$fontdelbosc_maxes = array();
|
||||
$fontdelbosc_mins = array();
|
||||
|
||||
foreach ( $data['days'] as $fontdelbosc_day ) {
|
||||
if ( is_numeric( $fontdelbosc_day['temp_max'] ?? null ) ) {
|
||||
$fontdelbosc_maxes[] = (float) $fontdelbosc_day['temp_max'];
|
||||
}
|
||||
|
||||
if ( is_numeric( $fontdelbosc_day['temp_min'] ?? null ) ) {
|
||||
$fontdelbosc_mins[] = (float) $fontdelbosc_day['temp_min'];
|
||||
}
|
||||
}
|
||||
|
||||
$fontdelbosc_scale_min = array() === $fontdelbosc_mins ? 0 : floor( min( $fontdelbosc_mins ) );
|
||||
$fontdelbosc_scale_max = array() === $fontdelbosc_maxes ? 1 : ceil( max( $fontdelbosc_maxes ) );
|
||||
|
||||
if ( $fontdelbosc_scale_max <= $fontdelbosc_scale_min ) {
|
||||
$fontdelbosc_scale_max = $fontdelbosc_scale_min + 1;
|
||||
}
|
||||
|
||||
$fontdelbosc_range = $fontdelbosc_scale_max - $fontdelbosc_scale_min;
|
||||
?>
|
||||
<div class="fdb-weather fdb-historical">
|
||||
<h3 class="fdb-weather__title"><?php echo esc_html__( 'Historical data', 'fontdelbosc-eltemps' ); ?> — <?php echo esc_html( Fontdelbosc_Conditions::month( (int) $data['month'] ) . ' ' . (string) $data['year'] ); ?></h3>
|
||||
|
||||
<ul class="fdb-historical__stats">
|
||||
<?php if ( null !== ( $data['stats']['avg_max'] ?? null ) ) : ?>
|
||||
<li><?php esc_html_e( 'Average max.', 'fontdelbosc-eltemps' ); ?> <?php echo esc_html( number_format_i18n( (float) $data['stats']['avg_max'], 1 ) ); ?>°C</li>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== ( $data['stats']['avg_min'] ?? null ) ) : ?>
|
||||
<li><?php esc_html_e( 'Average min.', 'fontdelbosc-eltemps' ); ?> <?php echo esc_html( number_format_i18n( (float) $data['stats']['avg_min'], 1 ) ); ?>°C</li>
|
||||
<?php endif; ?>
|
||||
<li><?php esc_html_e( 'Total precipitation', 'fontdelbosc-eltemps' ); ?> <?php echo esc_html( number_format_i18n( (float) $data['stats']['total_precip'], 1 ) ); ?> mm</li>
|
||||
</ul>
|
||||
|
||||
<div class="fdb-historical__chart" aria-hidden="true">
|
||||
<?php foreach ( $data['days'] as $fontdelbosc_day ) : ?>
|
||||
<?php
|
||||
try {
|
||||
$fontdelbosc_date = DateTimeImmutable::createFromFormat( 'Y-m-d', (string) $fontdelbosc_day['date'], new DateTimeZone( FONTDELBOSC_ELTEMPS_TIMEZONE ) );
|
||||
} catch ( Exception ) {
|
||||
$fontdelbosc_date = false;
|
||||
}
|
||||
|
||||
$fontdelbosc_timestamp = $fontdelbosc_date instanceof DateTimeImmutable ? $fontdelbosc_date->getTimestamp() : time();
|
||||
|
||||
$fontdelbosc_height_max = is_numeric( $fontdelbosc_day['temp_max'] ?? null ) ? round( ( ( (float) $fontdelbosc_day['temp_max'] - $fontdelbosc_scale_min ) / $fontdelbosc_range ) * 100, 1 ) : 0;
|
||||
$fontdelbosc_height_min = is_numeric( $fontdelbosc_day['temp_min'] ?? null ) ? round( ( ( (float) $fontdelbosc_day['temp_min'] - $fontdelbosc_scale_min ) / $fontdelbosc_range ) * 100, 1 ) : 0;
|
||||
|
||||
$fontdelbosc_title_parts = array( wp_date( 'j/n', $fontdelbosc_timestamp ) );
|
||||
|
||||
if ( is_numeric( $fontdelbosc_day['temp_max'] ?? null ) ) {
|
||||
$fontdelbosc_title_parts[] = number_format_i18n( round( (float) $fontdelbosc_day['temp_max'] ) ) . '° / ' . number_format_i18n( round( (float) $fontdelbosc_day['temp_min'] ) ) . '°';
|
||||
}
|
||||
|
||||
if ( is_numeric( $fontdelbosc_day['precipitation'] ?? null ) ) {
|
||||
$fontdelbosc_title_parts[] = number_format_i18n( (float) $fontdelbosc_day['precipitation'], 1 ) . ' mm';
|
||||
}
|
||||
?>
|
||||
<div class="fdb-historical__col" title="<?php echo esc_attr( implode( ' · ', $fontdelbosc_title_parts ) ); ?>">
|
||||
<div class="fdb-historical__bars">
|
||||
<div class="fdb-historical__bar fdb-historical__bar--max" style="height:<?php echo esc_attr( (string) $fontdelbosc_height_max ); ?>%"></div>
|
||||
<div class="fdb-historical__bar fdb-historical__bar--min" style="height:<?php echo esc_attr( (string) $fontdelbosc_height_min ); ?>%"></div>
|
||||
</div>
|
||||
<span class="fdb-historical__day"><?php echo esc_html( wp_date( 'j', $fontdelbosc_timestamp ) ); ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ( $fontdelbosc_show_attribution ) : ?>
|
||||
<p class="fdb-attribution"><?php echo esc_html( Fontdelbosc_Data_Manager::attribution( (string) $data['source'] ) ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
18
uninstall.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* Uninstall cleanup for Font del Bosc — El Temps.
|
||||
*
|
||||
* Plugin data is preserved by default. It is only removed when the
|
||||
* "Delete all plugin data on uninstall" option was explicitly enabled.
|
||||
* Transients are not purged here: they expire on their own (within ~25 hours).
|
||||
*
|
||||
* @package FontdelboscEltemps
|
||||
*/
|
||||
|
||||
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
|
||||
|
||||
$fontdelbosc_options = get_option( 'fontdelbosc_options' );
|
||||
|
||||
if ( is_array( $fontdelbosc_options ) && ! empty( $fontdelbosc_options['delete_data_on_uninstall'] ) ) {
|
||||
delete_option( 'fontdelbosc_options' );
|
||||
}
|
||||