Refactor SEO automation into unified CLI application
Major refactoring to create a clean, integrated CLI application: ### New Features: - Unified CLI executable (./seo) with simple command structure - All commands accept optional CSV file arguments - Auto-detection of latest files when no arguments provided - Simplified output directory structure (output/ instead of output/reports/) - Cleaner export filename format (all_posts_YYYY-MM-DD.csv) ### Commands: - export: Export all posts from WordPress sites - analyze [csv]: Analyze posts with AI (optional CSV input) - recategorize [csv]: Recategorize posts with AI - seo_check: Check SEO quality - categories: Manage categories across sites - approve [files]: Review and approve recommendations - full_pipeline: Run complete workflow - analytics, gaps, opportunities, report, status ### Changes: - Moved all scripts to scripts/ directory - Created config.yaml for configuration - Updated all scripts to use output/ directory - Deprecated old seo-cli.py in favor of new ./seo - Added AGENTS.md and CHANGELOG.md documentation - Consolidated README.md with updated usage ### Technical: - Added PyYAML dependency - Removed hardcoded configuration values - All scripts now properly integrated - Better error handling and user feedback Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
117
wordpress-plugins/rank-math-api-manager/CHANGELOG.md
Normal file
117
wordpress-plugins/rank-math-api-manager/CHANGELOG.md
Normal file
@@ -0,0 +1,117 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.0.8] - 2025-07-31
|
||||
|
||||
### Added
|
||||
|
||||
- ✅ **Complete WordPress Auto-Update System**: Production-ready auto-update implementation
|
||||
- WordPress native update integration using `pre_set_site_transient_update_plugins` filter
|
||||
- GitHub API integration for checking latest releases with proper caching
|
||||
- Custom ZIP asset support with correct folder structure handling
|
||||
- "View Details" modal support via `plugins_api` filter
|
||||
- Auto-update toggle functionality for users
|
||||
- Enhanced debug logging and error handling
|
||||
- **GitHub Rate Limiting**: 5-minute intervals between API calls to prevent abuse
|
||||
- **Transient Caching**: 1-hour GitHub API response caching for improved performance
|
||||
- **Update URI Header**: Prevents conflicts with WordPress.org update system
|
||||
|
||||
### Changed
|
||||
|
||||
- Enhanced class structure with proper singleton pattern implementation
|
||||
- Improved error handling with comprehensive debug logging
|
||||
- Updated plugin version to 1.0.8
|
||||
- Optimized GitHub API communication with fallback mechanisms
|
||||
|
||||
### Security
|
||||
|
||||
- Enhanced input validation and sanitization for all API endpoints
|
||||
- Proper capability checks (`edit_posts`) for all update operations
|
||||
- Secure GitHub API communication with proper error handling
|
||||
- Rate limiting to prevent API abuse
|
||||
|
||||
### Fixed
|
||||
|
||||
- Proper ZIP file structure handling for WordPress plugin updates
|
||||
- Version comparison logic for accurate update detection
|
||||
- Plugin folder naming consistency during updates
|
||||
|
||||
## [1.0.7] - 2025-07-29
|
||||
|
||||
### Added
|
||||
|
||||
- Enhanced plugin dependency checking
|
||||
- Comprehensive documentation in /docs folder
|
||||
- WordPress Plugin Check (PCP) compatibility improvements
|
||||
|
||||
### Removed
|
||||
|
||||
- **Auto-Update System**: Removed previous auto-update implementation to prepare for fresh implementation
|
||||
- Removed GitHub API integration
|
||||
- Removed update manager class
|
||||
- Removed auto-update related hooks and filters
|
||||
- Cleaned up update-related options and transients
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved code structure with singleton pattern
|
||||
- Enhanced security measures with proper nonce verification
|
||||
- Better error handling and logging throughout the plugin
|
||||
- Updated plugin version to 1.0.7
|
||||
|
||||
### Security
|
||||
|
||||
- Implemented proper input validation and sanitization
|
||||
- Added capability checks for all admin functions
|
||||
- Secure API communication with GitHub
|
||||
- Rate limiting for update checks
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved error handling and validation
|
||||
- Enhanced security measures
|
||||
- Better integration with n8n workflows
|
||||
|
||||
### Fixed
|
||||
|
||||
- Various bug fixes and performance improvements
|
||||
|
||||
## [1.0.6] -
|
||||
|
||||
### Removed
|
||||
|
||||
- Schema markup-related code (moved to roadmap for future development)
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved code quality and WordPress standards compliance
|
||||
- Updated plugin description
|
||||
|
||||
## [1.0.5] -
|
||||
|
||||
### Added
|
||||
|
||||
- Support for WooCommerce products
|
||||
- Enhanced error handling
|
||||
|
||||
### Changed
|
||||
|
||||
- Improved validation mechanisms
|
||||
|
||||
## [1.0.0] -
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release
|
||||
- Basic SEO field support (SEO Title, SEO Description, Canonical URL, Focus Keyword)
|
||||
- REST API endpoints for metadata updates
|
||||
- Integration with n8n workflows
|
||||
- Support for WordPress posts and WooCommerce products
|
||||
- Authentication and permission validation
|
||||
- Input sanitization and validation
|
||||
674
wordpress-plugins/rank-math-api-manager/LICENSE.md
Normal file
674
wordpress-plugins/rank-math-api-manager/LICENSE.md
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 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>.
|
||||
480
wordpress-plugins/rank-math-api-manager/README.md
Normal file
480
wordpress-plugins/rank-math-api-manager/README.md
Normal file
@@ -0,0 +1,480 @@
|
||||
# Rank Math API Manager
|
||||
|
||||

|
||||
|
||||
[](https://www.gnu.org/licenses/gpl-3.0)
|
||||
[](https://wordpress.org/)
|
||||
[](https://php.net/)
|
||||
[](https://wordpress.org/)
|
||||
|
||||
## 📋 Overview
|
||||
|
||||
**Plugin Name**: Rank Math API Manager
|
||||
**Version**: 1.0.7
|
||||
**Author**: [Devora AS](https://devora.no/)
|
||||
**Description**: WordPress extension that exposes REST API endpoints to update [Rank Math](https://rankmath.com/) SEO metadata programmatically.
|
||||
|
||||
## 🎯 Purpose
|
||||
|
||||
This extension enhances the WordPress REST API with custom endpoints that allow external systems (such as n8n workflows) to update Rank Math SEO fields directly via API calls. This eliminates the need for manual SEO configuration and integrates seamlessly with automation.
|
||||
|
||||
## ✨ Features
|
||||
|
||||
### 🔧 Supported SEO Fields
|
||||
|
||||
- **SEO Title** (`rank_math_title`) - Meta title for search engines
|
||||
- **SEO Description** (`rank_math_description`) - Meta description for search engines
|
||||
- **Canonical URL** (`rank_math_canonical_url`) - Canonical URL for duplicate content
|
||||
- **Focus Keyword** (`rank_math_focus_keyword`) - Primary keyword for the article
|
||||
|
||||
### 🌐 REST API Endpoints
|
||||
|
||||
#### POST `/wp-json/rank-math-api/v1/update-meta`
|
||||
|
||||
Updates Rank Math SEO metadata for a specific post or product.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `post_id` (required) - ID of the post/product
|
||||
- `rank_math_title` (optional) - SEO title
|
||||
- `rank_math_description` (optional) - SEO description
|
||||
- `rank_math_canonical_url` (optional) - Canonical URL
|
||||
- `rank_math_focus_keyword` (optional) - Focus keyword
|
||||
|
||||
**Request Example:**
|
||||
|
||||
```bash
|
||||
curl -X POST "https://example.com/wp-json/rank-math-api/v1/update-meta" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-H "Authorization: Basic [base64-encoded-credentials]" \
|
||||
-d "post_id=123&rank_math_title=Optimized title&rank_math_description=SEO description&rank_math_focus_keyword=keyword"
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"rank_math_title": "updated",
|
||||
"rank_math_description": "updated",
|
||||
"rank_math_focus_keyword": "updated"
|
||||
}
|
||||
```
|
||||
|
||||
## 🚀 Installation
|
||||
|
||||
### 1. Plugin Installation
|
||||
|
||||
1. Upload `rank-math-api-manager.php` to `/wp-content/plugins/rank-math-api-manager/`
|
||||
2. Activate the plugin in WordPress admin panel
|
||||
3. Verify that the plugin is active
|
||||
|
||||
### 2. Permissions
|
||||
|
||||
The plugin requires users to have `edit_posts` permissions to update metadata.
|
||||
|
||||
### 3. REST API Access
|
||||
|
||||
Ensure that the WordPress REST API is available and not blocked by security layers.
|
||||
|
||||
## 🔗 Integration with n8n Workflow
|
||||
|
||||
This plugin is specifically designed to work with Devora's n8n workflow "Write wordpress post with AI".
|
||||
|
||||
### Workflow Integration
|
||||
|
||||
1. **Automatic SEO Generation**: AI generates SEO metadata based on content
|
||||
2. **Programmatic Update**: n8n sends API calls to the plugin
|
||||
3. **Seamless Integration**: No manual intervention required
|
||||
|
||||
### n8n Node Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"method": "POST",
|
||||
"url": "https://example.com/wp-json/rank-math-api/v1/update-meta",
|
||||
"contentType": "form-urlencoded",
|
||||
"bodyParameters": {
|
||||
"post_id": "={{ $('Post on Wordpress').first().json.id }}",
|
||||
"rank_math_title": "={{ $('Generate metatitle e metadescription').first().json.output.metatitle }}",
|
||||
"rank_math_description": "={{ $('Generate metatitle e metadescription').first().json.output.metadescription }}",
|
||||
"rank_math_focus_keyword": "={{ $('Generate metatitle e metadescription').first().json.output.metakeywords }}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 🛡️ Security
|
||||
|
||||
### Authentication
|
||||
|
||||
- Requires WordPress Application Password or Basic Auth
|
||||
- Validates user permissions (`edit_posts`)
|
||||
- Sanitizes all input parameters
|
||||
|
||||
### Validation
|
||||
|
||||
- Validates that `post_id` exists
|
||||
- Sanitizes text fields with `sanitize_text_field()`
|
||||
- Validates URLs with `esc_url_raw()`
|
||||
|
||||
## 🔧 Technical Details
|
||||
|
||||
### Post Types
|
||||
|
||||
The plugin automatically supports:
|
||||
|
||||
- **Posts** (standard WordPress posts)
|
||||
- **Products** (WooCommerce products, if WooCommerce is active)
|
||||
|
||||
### Meta Fields
|
||||
|
||||
All SEO fields are registered as post meta with:
|
||||
|
||||
- `show_in_rest: true` - Available via REST API
|
||||
- `single: true` - Single values
|
||||
- `type: string` - String data type
|
||||
- `auth_callback` - Permission control
|
||||
|
||||
## 🗺️ Development Roadmap
|
||||
|
||||
### 🎯 Phase 1: Extended Field Support (High Priority)
|
||||
|
||||
#### 1.1 Social Media Meta Tags
|
||||
|
||||
- **Facebook Title** (`rank_math_facebook_title`)
|
||||
- **Facebook Description** (`rank_math_facebook_description`)
|
||||
- **Facebook Image** (`rank_math_facebook_image`)
|
||||
- **Twitter Title** (`rank_math_twitter_title`)
|
||||
- **Twitter Description** (`rank_math_twitter_description`)
|
||||
- **Twitter Image** (`rank_math_twitter_image`)
|
||||
|
||||
#### 1.2 Advanced SEO Fields
|
||||
|
||||
- **Robots Meta** (`rank_math_robots`)
|
||||
- **Advanced Robots** (`rank_math_advanced_robots`)
|
||||
- **Primary Category** (`rank_math_primary_category`)
|
||||
- **Secondary Focus Keyword** (`rank_math_secondary_focus_keyword`)
|
||||
- **Tertiary Focus Keyword** (`rank_math_tertiary_focus_keyword`)
|
||||
|
||||
#### 1.3 Schema Markup
|
||||
|
||||
- **Schema Type** (`rank_math_schema_type`)
|
||||
- **Article Schema Type** (`rank_math_schema_article_type`)
|
||||
|
||||
### 🚀 Phase 2: Bulk Operations and Read Functions
|
||||
|
||||
#### 2.1 Bulk Updates
|
||||
|
||||
```php
|
||||
POST /wp-json/rank-math-api/v1/bulk-update
|
||||
```
|
||||
|
||||
- Update multiple posts/products in one API request
|
||||
- Support for batch processing
|
||||
- Error handling for individual updates
|
||||
|
||||
#### 2.2 Read Functions
|
||||
|
||||
```php
|
||||
GET /wp-json/rank-math-api/v1/get-meta/{post_id}
|
||||
GET /wp-json/rank-math-api/v1/posts
|
||||
```
|
||||
|
||||
- Retrieve existing SEO metadata
|
||||
- List of posts with SEO information
|
||||
- Filtering and sorting
|
||||
|
||||
#### 2.3 SEO Status Endpoint
|
||||
|
||||
```php
|
||||
GET /wp-json/rank-math-api/v1/seo-status/{post_id}
|
||||
```
|
||||
|
||||
- SEO score for posts
|
||||
- Missing fields
|
||||
- Improvement recommendations
|
||||
- Schema status
|
||||
|
||||
### 🔄 Phase 3: Automation and Integration
|
||||
|
||||
#### 3.1 Conditional Updates
|
||||
|
||||
```php
|
||||
POST /wp-json/rank-math-api/v1/smart-update
|
||||
```
|
||||
|
||||
- Update only if fields are empty
|
||||
- Update only if values are different
|
||||
- Minimum/maximum length validation
|
||||
- Duplicate checking
|
||||
|
||||
#### 3.2 Webhook Support
|
||||
|
||||
```php
|
||||
POST /wp-json/rank-math-api/v1/webhooks
|
||||
```
|
||||
|
||||
- Register webhooks for SEO updates
|
||||
- Real-time notifications for changes
|
||||
- Configurable webhook endpoints
|
||||
|
||||
#### 3.3 SEO Template System
|
||||
|
||||
```php
|
||||
POST /wp-json/rank-math-api/v1/apply-template
|
||||
```
|
||||
|
||||
- Predefined SEO templates
|
||||
- Variable substitution
|
||||
- Content-based templates (blog, product, page)
|
||||
|
||||
### 📊 Phase 4: Advanced Features
|
||||
|
||||
#### 4.1 SEO Validation
|
||||
|
||||
```php
|
||||
POST /wp-json/rank-math-api/v1/validate
|
||||
```
|
||||
|
||||
- Validation of SEO metadata before saving
|
||||
- Length controls
|
||||
- Keyword density
|
||||
- Duplicate checking
|
||||
|
||||
#### 4.2 Analytics and Reporting
|
||||
|
||||
```php
|
||||
GET /wp-json/rank-math-api/v1/analytics
|
||||
```
|
||||
|
||||
- SEO statistics for the website
|
||||
- Average SEO score
|
||||
- Schema implementation rate
|
||||
- Missing metadata overview
|
||||
|
||||
#### 4.3 Rate Limiting and Security
|
||||
|
||||
- Rate limiting per user/IP
|
||||
- API key support
|
||||
- Audit logging
|
||||
- Advanced error handling
|
||||
|
||||
### 🌐 Phase 5: Enterprise Features
|
||||
|
||||
#### 5.1 Multi-site Support
|
||||
|
||||
```php
|
||||
POST /wp-json/rank-math-api/v1/multisite-update
|
||||
```
|
||||
|
||||
- Support for WordPress multisite
|
||||
- Cross-site SEO synchronization
|
||||
- Centralized SEO administration
|
||||
|
||||
#### 5.2 Advanced Integrations
|
||||
|
||||
- Google Search Console API integration
|
||||
- Google Analytics 4 integration
|
||||
- External SEO tool integration
|
||||
|
||||
## 📈 Expected Timeline
|
||||
|
||||
| Phase | Features | Estimated Delivery | Status |
|
||||
| ----- | ---------------------- | ------------------ | ---------- |
|
||||
| 1 | Extended Field Support | Q3 2025 | 🔄 Planned |
|
||||
| 2 | Bulk Operations | Q3 2025 | 🔄 Planned |
|
||||
| 3 | Automation | Q3 2025 | 🔄 Planned |
|
||||
| 4 | Advanced Features | Q4 2025 | 🔄 Planned |
|
||||
| 5 | Enterprise | Q1 2026 | 🔄 Planned |
|
||||
|
||||
## 🎯 Use Cases
|
||||
|
||||
### 1. **Content Syndication**
|
||||
|
||||
- Update SEO metadata when content is syndicated
|
||||
- Cross-site SEO synchronization
|
||||
- Automatic SEO optimization
|
||||
|
||||
### 2. **AI-driven SEO Optimization**
|
||||
|
||||
- Integration with AI tools
|
||||
- Automatic keyword generation
|
||||
- Content-based SEO suggestions
|
||||
|
||||
### 3. **E-commerce SEO Automation**
|
||||
|
||||
- Product catalog optimization
|
||||
- Seasonal campaigns
|
||||
- Inventory-based SEO updates
|
||||
|
||||
### 4. **Bulk SEO Administration**
|
||||
|
||||
- Mass reporting of posts
|
||||
- SEO audit automation
|
||||
- Competitor analysis integration
|
||||
|
||||
## ❓ FAQ (Frequently Asked Questions)
|
||||
|
||||
### 🤔 General Questions
|
||||
|
||||
**Q: What is Rank Math API Manager?**
|
||||
A: Rank Math API Manager is a WordPress plugin that allows you to update Rank Math SEO metadata programmatically via REST API endpoints. It's specifically designed to integrate with automation like n8n workflows.
|
||||
|
||||
**Q: Which WordPress versions are supported?**
|
||||
A: The plugin requires WordPress 5.0 or newer and PHP 7.4 or newer.
|
||||
|
||||
**Q: Is Rank Math SEO plugin required?**
|
||||
A: Yes, the Rank Math SEO plugin must be installed and activated for this plugin to work.
|
||||
|
||||
### 🔧 Installation and Setup
|
||||
|
||||
**Q: How do I install the plugin?**
|
||||
A: Upload the plugin file to `/wp-content/plugins/rank-math-api-manager/` and activate it in the WordPress admin panel.
|
||||
|
||||
**Q: What permissions do I need?**
|
||||
A: You must have `edit_posts` permissions to use the API endpoints.
|
||||
|
||||
**Q: How do I set up authentication?**
|
||||
A: Use WordPress Application Passwords or Basic Auth. See the installation section for details.
|
||||
|
||||
### 🌐 API and Integration
|
||||
|
||||
**Q: Which SEO fields can I update?**
|
||||
A: The plugin supports SEO Title, SEO Description, Canonical URL, and Focus Keyword.
|
||||
|
||||
**Q: Can I use this with WooCommerce?**
|
||||
A: Yes, the plugin automatically supports WooCommerce products if WooCommerce is active.
|
||||
|
||||
**Q: How do I integrate with n8n?**
|
||||
A: See the n8n integration section in the documentation for example configuration.
|
||||
|
||||
**Q: Is there rate limiting on the API endpoints?**
|
||||
A: The plugin uses WordPress's built-in rate limiting. For high-traffic sites, additional rate limiting is recommended.
|
||||
|
||||
### 🛡️ Security
|
||||
|
||||
**Q: Are the API endpoints secure?**
|
||||
A: Yes, all endpoints require authentication and validate user permissions. All input parameters are sanitized.
|
||||
|
||||
**Q: How do I report security issues?**
|
||||
A: Send security reports to security@devora.no. Do not create public GitHub issues for security problems.
|
||||
|
||||
**Q: Is sensitive data logged?**
|
||||
A: No, the plugin does not log sensitive data.
|
||||
|
||||
### 🔄 Updates and Maintenance
|
||||
|
||||
**Q: How do I update the plugin?**
|
||||
A: The plugin can be updated via the WordPress admin panel or by manually uploading a new version.
|
||||
|
||||
**Q: Are there automatic updates?**
|
||||
A: Yes! The plugin includes a complete WordPress-native auto-update system that checks for new releases on GitHub and provides update notifications just like WordPress.org plugins. Users can enable/disable automatic updates and view release details.
|
||||
|
||||
**Q: How do I check if the plugin is working?**
|
||||
A: Test the API endpoint with a simple POST request to `/wp-json/rank-math-api/v1/update-meta`.
|
||||
|
||||
### 🐛 Troubleshooting
|
||||
|
||||
**Q: I get 401 Unauthorized errors?**
|
||||
A: Check that the Application Password is correctly configured and that the user has `edit_posts` permissions.
|
||||
|
||||
**Q: I get 404 Not Found errors?**
|
||||
A: Verify that the plugin is active and that the WordPress REST API is available.
|
||||
|
||||
**Q: I get 400 Bad Request errors?**
|
||||
A: Check that the `post_id` exists and that all parameters are correctly formatted.
|
||||
|
||||
**Q: WooCommerce integration doesn't work?**
|
||||
A: Check that WooCommerce is installed and activated.
|
||||
|
||||
### 📈 Future Features
|
||||
|
||||
**Q: Will there be support for more SEO fields?**
|
||||
A: Yes, see the roadmap section for planned features like social media meta tags and schema markup.
|
||||
|
||||
**Q: Will there be bulk operations?**
|
||||
A: Yes, bulk updates are planned for phase 2 of development.
|
||||
|
||||
**Q: Will there be webhook support?**
|
||||
A: Yes, webhook support is planned for phase 3.
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### Common Problems
|
||||
|
||||
1. **401 Unauthorized**
|
||||
|
||||
- Check that Application Password is correctly configured
|
||||
- Verify that the user has `edit_posts` permissions
|
||||
|
||||
2. **404 Not Found**
|
||||
|
||||
- Check that the plugin is active
|
||||
- Verify that the REST API is available
|
||||
|
||||
3. **400 Bad Request**
|
||||
- Check that `post_id` exists
|
||||
- Validate that all parameters are correctly formatted
|
||||
|
||||
### Debugging
|
||||
|
||||
Enable WordPress debug logging to see detailed error messages:
|
||||
|
||||
```php
|
||||
// wp-config.php
|
||||
define('WP_DEBUG', true);
|
||||
define('WP_DEBUG_LOG', true);
|
||||
```
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
To contribute to this plugin:
|
||||
|
||||
1. Follow WordPress coding standards
|
||||
2. Test changes thoroughly
|
||||
3. Update documentation
|
||||
4. Use descriptive commit messages
|
||||
5. Follow our [Code of Conduct](CODE_OF_CONDUCT.md)
|
||||
|
||||
## 📞 Support
|
||||
|
||||
**Developed by**: Devora AS
|
||||
**Website**: https://devora.no
|
||||
|
||||
### 🐛 Reporting Bugs and Issues
|
||||
|
||||
If you discover a bug or have other problems with the plugin, you can:
|
||||
|
||||
1. **Create a GitHub Issue**: Visit [GitHub Issues](https://github.com/devora-as/rank-math-api-manager/issues) and create a new issue
|
||||
2. **Include the following information**:
|
||||
- WordPress version
|
||||
- Plugin version
|
||||
- PHP version
|
||||
- Description of the problem
|
||||
- Steps to reproduce the problem
|
||||
- Error messages (if any)
|
||||
- Screenshots (if relevant)
|
||||
|
||||
### 🔒 Security Issues
|
||||
|
||||
**Important**: Do not report security issues via GitHub Issues. Send them to **security@devora.no** instead.
|
||||
|
||||
### 📧 Contact
|
||||
|
||||
- **General support**: Contact Devora team via [devora.no](https://devora.no)
|
||||
- **Security issues**: security@devora.no
|
||||
- **Code of Conduct**: conduct@devora.no
|
||||
|
||||
### 📋 Documentation
|
||||
|
||||
- **[Changelog](CHANGELOG.md)**: See changelog for all versions
|
||||
- **[Security Policy](docs/SECURITY.md)**: Security policy and vulnerability reporting
|
||||
- **[Code of Conduct](CODE_OF_CONDUCT.md)**: Community guidelines for contributors
|
||||
- **[Norwegian Documentation](README-NORWEGIAN.md)**: Norwegian version of this documentation
|
||||
- **[Norwegian Changelog](docs/CHANGELOG-NORWEGIAN.md)**: Norwegian changelog
|
||||
- **[Norwegian Security Policy](docs/SECURITY-NORWEGIAN.md)**: Norwegian security policy
|
||||
- **[Norwegian Code of Conduct](docs/CODE_OF_CONDUCT-NORWEGIAN.md)**: Norwegian code of conduct
|
||||
|
||||
---
|
||||
|
||||
**License**: [GPL v3](LICENSE.md) - Devora AS
|
||||
**Last Updated**: July 2025
|
||||
256
wordpress-plugins/rank-math-api-manager/assets/css/admin.css
Normal file
256
wordpress-plugins/rank-math-api-manager/assets/css/admin.css
Normal file
@@ -0,0 +1,256 @@
|
||||
/**
|
||||
* Rank Math API Manager - Admin Styles
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
|
||||
/* Plugin header styling */
|
||||
.rank-math-api-header {
|
||||
background: #fff;
|
||||
border: 1px solid #ccd0d4;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.rank-math-api-header h1 {
|
||||
margin: 0 0 10px 0;
|
||||
color: #23282d;
|
||||
}
|
||||
|
||||
.rank-math-api-header .description {
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Status cards */
|
||||
.rank-math-api-status-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card {
|
||||
background: #fff;
|
||||
border: 1px solid #ccd0d4;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
}
|
||||
|
||||
.rank-math-api-status-card h3 {
|
||||
margin: 0 0 15px 0;
|
||||
color: #23282d;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card .status-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #f0f0f1;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card .status-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card .status-label {
|
||||
font-weight: 500;
|
||||
color: #50575e;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card .status-value {
|
||||
color: #23282d;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card .status-value.success {
|
||||
color: #00a32a;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card .status-value.warning {
|
||||
color: #dba617;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card .status-value.error {
|
||||
color: #d63638;
|
||||
}
|
||||
|
||||
/* Update section */
|
||||
.rank-math-api-update-section {
|
||||
background: #fff;
|
||||
border: 1px solid #ccd0d4;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.rank-math-api-update-section h3 {
|
||||
margin: 0 0 15px 0;
|
||||
color: #23282d;
|
||||
}
|
||||
|
||||
.rank-math-api-update-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.rank-math-api-update-actions .button {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* API endpoints section */
|
||||
.rank-math-api-endpoints {
|
||||
background: #fff;
|
||||
border: 1px solid #ccd0d4;
|
||||
border-radius: 4px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoints h3 {
|
||||
margin: 0 0 15px 0;
|
||||
color: #23282d;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoint {
|
||||
background: #f6f7f7;
|
||||
border: 1px solid #dcdcde;
|
||||
border-radius: 4px;
|
||||
padding: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoint:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoint h4 {
|
||||
margin: 0 0 10px 0;
|
||||
color: #23282d;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoint .endpoint-url {
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
||||
background: #fff;
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #dcdcde;
|
||||
border-radius: 3px;
|
||||
color: #50575e;
|
||||
font-size: 13px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoint .endpoint-method {
|
||||
display: inline-block;
|
||||
background: #0073aa;
|
||||
color: #fff;
|
||||
padding: 2px 8px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoint .endpoint-description {
|
||||
margin: 10px 0 0 0;
|
||||
color: #666;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* Loading states */
|
||||
.rank-math-api-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.rank-math-api-loading .spinner {
|
||||
float: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Notices */
|
||||
.rank-math-api-notice {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.rank-math-api-notice.success {
|
||||
border-left-color: #00a32a;
|
||||
}
|
||||
|
||||
.rank-math-api-notice.warning {
|
||||
border-left-color: #dba617;
|
||||
}
|
||||
|
||||
.rank-math-api-notice.error {
|
||||
border-left-color: #d63638;
|
||||
}
|
||||
|
||||
/* Responsive design */
|
||||
@media (max-width: 782px) {
|
||||
.rank-math-api-status-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.rank-math-api-update-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.rank-math-api-update-actions .button {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* Dark mode support */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.rank-math-api-header,
|
||||
.rank-math-api-status-card,
|
||||
.rank-math-api-update-section,
|
||||
.rank-math-api-endpoints {
|
||||
background: #1e1e1e;
|
||||
border-color: #3c434a;
|
||||
}
|
||||
|
||||
.rank-math-api-header h1,
|
||||
.rank-math-api-status-card h3,
|
||||
.rank-math-api-update-section h3,
|
||||
.rank-math-api-endpoints h3,
|
||||
.rank-math-api-endpoint h4 {
|
||||
color: #f0f0f1;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card .status-label {
|
||||
color: #a7aaad;
|
||||
}
|
||||
|
||||
.rank-math-api-status-card .status-value {
|
||||
color: #f0f0f1;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoint {
|
||||
background: #2c3338;
|
||||
border-color: #3c434a;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoint .endpoint-url {
|
||||
background: #1e1e1e;
|
||||
border-color: #3c434a;
|
||||
color: #a7aaad;
|
||||
}
|
||||
|
||||
.rank-math-api-endpoint .endpoint-description {
|
||||
color: #a7aaad;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
10
wordpress-plugins/rank-math-api-manager/assets/js/admin.js
Normal file
10
wordpress-plugins/rank-math-api-manager/assets/js/admin.js
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Rank Math API Manager - Admin JavaScript
|
||||
*
|
||||
* @since 1.0.7
|
||||
*/
|
||||
|
||||
jQuery(document).ready(function ($) {
|
||||
// Placeholder for future admin functionality
|
||||
console.log("Rank Math API Manager admin scripts loaded");
|
||||
});
|
||||
152
wordpress-plugins/rank-math-api-manager/docs/README.md
Normal file
152
wordpress-plugins/rank-math-api-manager/docs/README.md
Normal file
@@ -0,0 +1,152 @@
|
||||
# Documentation - Rank Math API Manager Plugin
|
||||
|
||||
## 📚 Documentation Overview
|
||||
|
||||
Welcome to the comprehensive documentation for the Rank Math API Manager plugin. This documentation is organized to help you get started quickly and find the information you need.
|
||||
|
||||
## 📖 Available Guides
|
||||
|
||||
### 🚀 Getting Started
|
||||
|
||||
- **[Installation Guide](installation.md)** - Complete installation and setup instructions
|
||||
- **[API Documentation](api-documentation.md)** - Complete technical API reference
|
||||
- **[Example Use Cases](example-use-cases.md)** - Practical examples and scenarios
|
||||
|
||||
### 🔧 Integration & Development
|
||||
|
||||
- **[Integration Guide](integration-guide.md)** - Step-by-step integration with n8n, Zapier, Make, and custom applications
|
||||
- **[Troubleshooting Guide](troubleshooting.md)** - Common issues and solutions
|
||||
- **[Security Guide](security.md)** - Security best practices and configuration
|
||||
|
||||
### 📋 Reference
|
||||
|
||||
- **[Changelog](../CHANGELOG.md)** - Version history and changes
|
||||
- **[Security Policy](../SECURITY.md)** - Security policy and vulnerability reporting
|
||||
- **[Code of Conduct](../CODE_OF_CONDUCT.md)** - Community guidelines
|
||||
|
||||
## 🎯 Quick Start
|
||||
|
||||
### 1. Installation
|
||||
|
||||
1. Follow the [Installation Guide](installation.md) to set up the plugin
|
||||
2. Configure WordPress Application Passwords
|
||||
3. Test the API endpoint
|
||||
|
||||
### 2. Basic Usage
|
||||
|
||||
```bash
|
||||
# Update SEO metadata for a post
|
||||
curl -X POST "https://your-site.com/wp-json/rank-math-api/v1/update-meta" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-H "Authorization: Basic [your-credentials]" \
|
||||
-d "post_id=123&rank_math_title=Your SEO Title&rank_math_description=Your meta description"
|
||||
```
|
||||
|
||||
### 3. Integration
|
||||
|
||||
- **n8n**: See [Integration Guide](integration-guide.md#n8n-integration)
|
||||
- **Zapier**: See [Integration Guide](integration-guide.md#zapier-integration)
|
||||
- **Python**: See [Integration Guide](integration-guide.md#python-integration)
|
||||
|
||||
## 🔍 Finding What You Need
|
||||
|
||||
### By Task
|
||||
|
||||
| Task | Documentation |
|
||||
| ------------------------ | ------------------------------------------- |
|
||||
| **Install the plugin** | [Installation Guide](installation.md) |
|
||||
| **Understand the API** | [API Documentation](api-documentation.md) |
|
||||
| **See examples** | [Example Use Cases](example-use-cases.md) |
|
||||
| **Integrate with tools** | [Integration Guide](integration-guide.md) |
|
||||
| **Fix problems** | [Troubleshooting Guide](troubleshooting.md) |
|
||||
| **Secure your setup** | [Security Guide](security.md) |
|
||||
|
||||
### By Experience Level
|
||||
|
||||
#### Beginner
|
||||
|
||||
1. [Installation Guide](installation.md) - Start here
|
||||
2. [Example Use Cases](example-use-cases.md) - See what's possible
|
||||
3. [API Documentation](api-documentation.md) - Learn the basics
|
||||
|
||||
#### Intermediate
|
||||
|
||||
1. [Integration Guide](integration-guide.md) - Connect with your tools
|
||||
2. [Troubleshooting Guide](troubleshooting.md) - Solve common issues
|
||||
3. [Security Guide](security.md) - Secure your implementation
|
||||
|
||||
#### Advanced
|
||||
|
||||
1. [API Documentation](api-documentation.md) - Complete reference
|
||||
2. [Security Guide](security.md) - Advanced security configuration
|
||||
3. [Integration Guide](integration-guide.md) - Custom integrations
|
||||
|
||||
## 🆘 Getting Help
|
||||
|
||||
### Documentation Issues
|
||||
|
||||
If you find errors or missing information in the documentation:
|
||||
|
||||
- [Create a GitHub issue](https://github.com/devora-as/rank-math-api-manager/issues)
|
||||
- Include the specific documentation page and section
|
||||
|
||||
### Plugin Issues
|
||||
|
||||
For plugin bugs or problems:
|
||||
|
||||
- [Create a GitHub issue](https://github.com/devora-as/rank-math-api-manager/issues)
|
||||
- Include error messages and steps to reproduce
|
||||
|
||||
### Security Issues
|
||||
|
||||
For security vulnerabilities:
|
||||
|
||||
- **Email**: security@devora.no
|
||||
- **Do not** create public GitHub issues for security problems
|
||||
|
||||
## 📝 Contributing to Documentation
|
||||
|
||||
We welcome contributions to improve the documentation:
|
||||
|
||||
1. **Fork the repository**
|
||||
2. **Create a feature branch**
|
||||
3. **Make your changes**
|
||||
4. **Submit a pull request**
|
||||
|
||||
### Documentation Standards
|
||||
|
||||
- Use clear, concise language
|
||||
- Include code examples where helpful
|
||||
- Follow the existing format and structure
|
||||
- Test all code examples before submitting
|
||||
|
||||
## 🔄 Documentation Updates
|
||||
|
||||
This documentation is updated with each plugin release. Check the [Changelog](../CHANGELOG.md) for the latest changes.
|
||||
|
||||
### Version Information
|
||||
|
||||
- **Current Version**: 1.0.6
|
||||
- **Last Updated**: July 2025
|
||||
- **WordPress Compatibility**: 5.0+
|
||||
- **PHP Compatibility**: 7.4+
|
||||
|
||||
## 📞 Support
|
||||
|
||||
- **Documentation**: This documentation
|
||||
- **GitHub Issues**: [Create an issue](https://github.com/devora-as/rank-math-api-manager/issues)
|
||||
- **Email Support**: [devora.no](https://devora.no)
|
||||
- **Security**: security@devora.no
|
||||
|
||||
---
|
||||
|
||||
**Related Links**:
|
||||
|
||||
- [Main README](../README.md)
|
||||
- [Norwegian Documentation](../README-NORWEGIAN.md)
|
||||
- [GitHub Repository](https://github.com/devora-as/rank-math-api-manager)
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: July 2025
|
||||
**Version**: 1.0.6
|
||||
@@ -0,0 +1,126 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
We actively maintain and provide security updates for the following versions:
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 1.0.6 | :white_check_mark: |
|
||||
| 1.0.5 | :white_check_mark: |
|
||||
| 1.0.0 | :white_check_mark: |
|
||||
| < 1.0.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
We take security vulnerabilities seriously. If you discover a security vulnerability in the Rank Math API Manager plugin, please follow these steps:
|
||||
|
||||
### 1. **DO NOT** create a public GitHub issue
|
||||
|
||||
Security vulnerabilities should be reported privately to prevent potential exploitation.
|
||||
|
||||
### 2. **DO** report via email
|
||||
|
||||
Send your security report to: **security@devora.no**
|
||||
|
||||
### 3. Include the following information in your report:
|
||||
|
||||
- **Description**: A clear description of the vulnerability
|
||||
- **Steps to reproduce**: Detailed steps to reproduce the issue
|
||||
- **Impact**: Potential impact of the vulnerability
|
||||
- **Environment**: WordPress version, plugin version, and other relevant details
|
||||
- **Proof of concept**: If possible, include a proof of concept (without exploiting it publicly)
|
||||
|
||||
### 4. What to expect:
|
||||
|
||||
- **Response time**: We aim to respond within 48 hours
|
||||
- **Assessment**: We will assess the reported vulnerability
|
||||
- **Updates**: We will keep you informed of our progress
|
||||
- **Fix timeline**: Critical vulnerabilities will be addressed within 7 days
|
||||
- **Credit**: We will credit you in our security advisories (unless you prefer to remain anonymous)
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
### For Users:
|
||||
|
||||
1. **Keep WordPress updated**: Always use the latest WordPress version
|
||||
2. **Update plugins**: Keep all plugins, including this one, updated
|
||||
3. **Use strong authentication**: Implement strong passwords and two-factor authentication
|
||||
4. **Limit API access**: Only grant API access to trusted applications
|
||||
5. **Monitor logs**: Regularly check WordPress and server logs for suspicious activity
|
||||
6. **Use HTTPS**: Always use HTTPS for API communications
|
||||
|
||||
### For Developers:
|
||||
|
||||
1. **Input validation**: Always validate and sanitize all input data
|
||||
2. **Authentication**: Implement proper authentication for all API endpoints
|
||||
3. **Rate limiting**: Consider implementing rate limiting for API endpoints
|
||||
4. **Logging**: Log security-relevant events
|
||||
5. **Error handling**: Don't expose sensitive information in error messages
|
||||
|
||||
## Security Features
|
||||
|
||||
This plugin implements several security measures:
|
||||
|
||||
### Authentication & Authorization:
|
||||
|
||||
- WordPress Application Password authentication
|
||||
- User capability checks (`edit_posts`)
|
||||
- Proper permission validation for all endpoints
|
||||
|
||||
### Input Validation:
|
||||
|
||||
- All input parameters are sanitized
|
||||
- URL validation for canonical URLs
|
||||
- Text field sanitization using WordPress functions
|
||||
- Post ID validation
|
||||
|
||||
### Data Protection:
|
||||
|
||||
- No sensitive data is logged
|
||||
- Secure transmission via HTTPS
|
||||
- Proper WordPress nonce validation (where applicable)
|
||||
|
||||
## Known Security Considerations
|
||||
|
||||
### API Rate Limiting:
|
||||
|
||||
Currently, the plugin relies on WordPress's built-in rate limiting. For high-traffic sites, consider implementing additional rate limiting.
|
||||
|
||||
### CORS:
|
||||
|
||||
The plugin uses WordPress's default CORS settings. For enhanced security, consider implementing custom CORS policies.
|
||||
|
||||
### Logging:
|
||||
|
||||
The plugin doesn't log sensitive data, but ensure your WordPress installation has appropriate logging configured.
|
||||
|
||||
## Security Updates
|
||||
|
||||
We regularly:
|
||||
|
||||
- Review and update dependencies
|
||||
- Conduct security audits
|
||||
- Monitor WordPress security advisories
|
||||
- Test against common vulnerabilities
|
||||
- Update security best practices
|
||||
|
||||
## Responsible Disclosure
|
||||
|
||||
We follow responsible disclosure practices:
|
||||
|
||||
- We will not publicly disclose vulnerabilities until a fix is available
|
||||
- We will work with security researchers to understand and fix issues
|
||||
- We will credit security researchers in our advisories
|
||||
- We will provide reasonable time for users to update before public disclosure
|
||||
|
||||
## Contact Information
|
||||
|
||||
- **Security Email**: security@devora.no
|
||||
- **Company**: Devora AS
|
||||
- **Website**: https://devora.no
|
||||
- **GitHub**: https://github.com/devora-as/rank-math-api-manager
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: July 2025
|
||||
584
wordpress-plugins/rank-math-api-manager/docs/SECURITY.md
Normal file
584
wordpress-plugins/rank-math-api-manager/docs/SECURITY.md
Normal file
@@ -0,0 +1,584 @@
|
||||
# Security Guide - Rank Math API Manager Plugin
|
||||
|
||||
## 📋 Overview
|
||||
|
||||
This guide covers security best practices, configuration recommendations, and security features for the Rank Math API Manager plugin. Follow these guidelines to ensure your WordPress site and API endpoints remain secure.
|
||||
|
||||
## 🛡️ Security Features
|
||||
|
||||
### Built-in Security Measures
|
||||
|
||||
The Rank Math API Manager plugin implements several security measures:
|
||||
|
||||
#### 1. Authentication & Authorization
|
||||
|
||||
- **WordPress Application Passwords**: Secure authentication method
|
||||
- **User Capability Checks**: Validates `edit_posts` permissions
|
||||
- **Permission Validation**: Ensures users can modify content
|
||||
|
||||
#### 2. Input Validation & Sanitization
|
||||
|
||||
- **Text Field Sanitization**: Uses `sanitize_text_field()`
|
||||
- **URL Validation**: Uses `esc_url_raw()` for canonical URLs
|
||||
- **Post ID Validation**: Ensures posts exist before updates
|
||||
- **Parameter Validation**: Validates all input parameters
|
||||
|
||||
#### 3. Data Protection
|
||||
|
||||
- **No Sensitive Data Logging**: API credentials are never logged
|
||||
- **Secure Transmission**: Requires HTTPS for production use
|
||||
- **WordPress Nonce Validation**: Where applicable
|
||||
|
||||
## 🔐 Authentication Best Practices
|
||||
|
||||
### WordPress Application Passwords
|
||||
|
||||
#### Setting Up Secure Application Passwords
|
||||
|
||||
1. **Create Dedicated User Account**
|
||||
|
||||
```bash
|
||||
# Create a dedicated API user with limited permissions
|
||||
# Go to Users → Add New
|
||||
# Username: api-user
|
||||
# Role: Author (has edit_posts capability)
|
||||
# Email: api@your-domain.com
|
||||
```
|
||||
|
||||
2. **Generate Application Password**
|
||||
|
||||
```bash
|
||||
# Go to Users → Profile → Application Passwords
|
||||
# Name: "Rank Math API Access"
|
||||
# Click "Add New Application Password"
|
||||
# Copy the generated password immediately
|
||||
```
|
||||
|
||||
3. **Store Credentials Securely**
|
||||
```bash
|
||||
# Never store credentials in plain text
|
||||
# Use environment variables or secure configuration
|
||||
export WORDPRESS_API_USERNAME="api-user"
|
||||
export WORDPRESS_API_PASSWORD="your-application-password"
|
||||
```
|
||||
|
||||
#### Credential Management
|
||||
|
||||
```bash
|
||||
# Example: Secure credential storage
|
||||
# .env file (add to .gitignore)
|
||||
WORDPRESS_API_USERNAME=api-user
|
||||
WORDPRESS_API_PASSWORD=your-application-password
|
||||
WORDPRESS_SITE_URL=https://your-site.com
|
||||
|
||||
# Load in your application
|
||||
source .env
|
||||
```
|
||||
|
||||
### API Key Management (Future Feature)
|
||||
|
||||
```php
|
||||
// Future implementation for API key authentication
|
||||
add_action('rest_api_init', function() {
|
||||
register_rest_route('rank-math-api/v1', '/generate-api-key', [
|
||||
'methods' => 'POST',
|
||||
'callback' => 'generate_api_key',
|
||||
'permission_callback' => function() {
|
||||
return current_user_can('manage_options');
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
function generate_api_key() {
|
||||
$api_key = wp_generate_password(64, false);
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
update_user_meta($user_id, 'rank_math_api_key', $api_key);
|
||||
|
||||
return [
|
||||
'api_key' => $api_key,
|
||||
'created_at' => current_time('mysql')
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
## 🔒 Network Security
|
||||
|
||||
### HTTPS Configuration
|
||||
|
||||
#### Force HTTPS for API Endpoints
|
||||
|
||||
```php
|
||||
// Add to wp-config.php or theme functions.php
|
||||
add_action('rest_api_init', function() {
|
||||
if (!is_ssl() && !is_admin()) {
|
||||
add_filter('rest_authentication_errors', function($result) {
|
||||
return new WP_Error('https_required', 'HTTPS is required for API access', ['status' => 403]);
|
||||
});
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
#### SSL Certificate Validation
|
||||
|
||||
```bash
|
||||
# Test SSL configuration
|
||||
curl -I https://your-site.com/wp-json/rank-math-api/v1/update-meta
|
||||
|
||||
# Check SSL certificate
|
||||
openssl s_client -connect your-site.com:443 -servername your-site.com
|
||||
```
|
||||
|
||||
### CORS Configuration
|
||||
|
||||
#### Default WordPress CORS
|
||||
|
||||
The plugin uses WordPress's default CORS settings. For enhanced security:
|
||||
|
||||
```php
|
||||
// Custom CORS configuration
|
||||
add_action('rest_api_init', function() {
|
||||
add_filter('rest_pre_serve_request', function($served, $result, $request, $server) {
|
||||
// Allow only specific origins
|
||||
$allowed_origins = [
|
||||
'https://your-frontend-app.com',
|
||||
'https://your-n8n-instance.com'
|
||||
];
|
||||
|
||||
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
|
||||
|
||||
if (in_array($origin, $allowed_origins)) {
|
||||
header('Access-Control-Allow-Origin: ' . $origin);
|
||||
header('Access-Control-Allow-Methods: POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
}
|
||||
|
||||
return $served;
|
||||
}, 10, 4);
|
||||
});
|
||||
```
|
||||
|
||||
## 🚫 Rate Limiting
|
||||
|
||||
### Basic Rate Limiting Implementation
|
||||
|
||||
```php
|
||||
// Add rate limiting to API endpoints
|
||||
add_action('rest_api_init', function() {
|
||||
add_filter('rest_pre_dispatch', function($result, $server, $request) {
|
||||
if (strpos($request->get_route(), 'rank-math-api') !== false) {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
$user_id = get_current_user_id();
|
||||
$key = "rate_limit_{$user_id}_{$ip}";
|
||||
|
||||
$count = get_transient($key);
|
||||
$limit = 100; // requests per hour
|
||||
$window = 3600; // 1 hour
|
||||
|
||||
if ($count && $count >= $limit) {
|
||||
return new WP_Error(
|
||||
'rate_limit_exceeded',
|
||||
'Rate limit exceeded. Please try again later.',
|
||||
['status' => 429]
|
||||
);
|
||||
}
|
||||
|
||||
set_transient($key, ($count ? $count + 1 : 1), $window);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}, 10, 3);
|
||||
});
|
||||
```
|
||||
|
||||
### Advanced Rate Limiting
|
||||
|
||||
```php
|
||||
// Advanced rate limiting with different tiers
|
||||
class RankMathAPIRateLimiter {
|
||||
private $limits = [
|
||||
'default' => ['requests' => 100, 'window' => 3600],
|
||||
'premium' => ['requests' => 1000, 'window' => 3600],
|
||||
'admin' => ['requests' => 10000, 'window' => 3600]
|
||||
];
|
||||
|
||||
public function check_rate_limit($user_id, $ip) {
|
||||
$user_tier = $this->get_user_tier($user_id);
|
||||
$limit = $this->limits[$user_tier];
|
||||
|
||||
$key = "rate_limit_{$user_tier}_{$user_id}_{$ip}";
|
||||
$count = get_transient($key);
|
||||
|
||||
if ($count && $count >= $limit['requests']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set_transient($key, ($count ? $count + 1 : 1), $limit['window']);
|
||||
return true;
|
||||
}
|
||||
|
||||
private function get_user_tier($user_id) {
|
||||
if (user_can($user_id, 'manage_options')) {
|
||||
return 'admin';
|
||||
}
|
||||
|
||||
// Check for premium user status
|
||||
if (get_user_meta($user_id, 'premium_user', true)) {
|
||||
return 'premium';
|
||||
}
|
||||
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 🔍 Input Validation & Sanitization
|
||||
|
||||
### Enhanced Input Validation
|
||||
|
||||
```php
|
||||
// Enhanced validation for API parameters
|
||||
add_action('rest_api_init', function() {
|
||||
add_filter('rest_pre_dispatch', function($result, $server, $request) {
|
||||
if (strpos($request->get_route(), 'rank-math-api') !== false) {
|
||||
$params = $request->get_params();
|
||||
|
||||
// Validate post_id
|
||||
if (isset($params['post_id'])) {
|
||||
if (!is_numeric($params['post_id']) || $params['post_id'] <= 0) {
|
||||
return new WP_Error('invalid_post_id', 'Invalid post ID', ['status' => 400]);
|
||||
}
|
||||
|
||||
$post = get_post($params['post_id']);
|
||||
if (!$post || !in_array($post->post_type, ['post', 'product'])) {
|
||||
return new WP_Error('post_not_found', 'Post not found or invalid type', ['status' => 404]);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate SEO title length
|
||||
if (isset($params['rank_math_title'])) {
|
||||
if (strlen($params['rank_math_title']) > 60) {
|
||||
return new WP_Error('title_too_long', 'SEO title exceeds 60 characters', ['status' => 400]);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate SEO description length
|
||||
if (isset($params['rank_math_description'])) {
|
||||
if (strlen($params['rank_math_description']) > 160) {
|
||||
return new WP_Error('description_too_long', 'SEO description exceeds 160 characters', ['status' => 400]);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate canonical URL
|
||||
if (isset($params['rank_math_canonical_url'])) {
|
||||
if (!filter_var($params['rank_math_canonical_url'], FILTER_VALIDATE_URL)) {
|
||||
return new WP_Error('invalid_url', 'Invalid canonical URL', ['status' => 400]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}, 10, 3);
|
||||
});
|
||||
```
|
||||
|
||||
### Content Security
|
||||
|
||||
```php
|
||||
// Prevent XSS and injection attacks
|
||||
function sanitize_seo_data($data) {
|
||||
$sanitized = [];
|
||||
|
||||
if (isset($data['rank_math_title'])) {
|
||||
$sanitized['rank_math_title'] = sanitize_text_field($data['rank_math_title']);
|
||||
}
|
||||
|
||||
if (isset($data['rank_math_description'])) {
|
||||
$sanitized['rank_math_description'] = sanitize_textarea_field($data['rank_math_description']);
|
||||
}
|
||||
|
||||
if (isset($data['rank_math_canonical_url'])) {
|
||||
$sanitized['rank_math_canonical_url'] = esc_url_raw($data['rank_math_canonical_url']);
|
||||
}
|
||||
|
||||
if (isset($data['rank_math_focus_keyword'])) {
|
||||
$sanitized['rank_math_focus_keyword'] = sanitize_text_field($data['rank_math_focus_keyword']);
|
||||
}
|
||||
|
||||
return $sanitized;
|
||||
}
|
||||
```
|
||||
|
||||
## 📊 Security Monitoring
|
||||
|
||||
### API Access Logging
|
||||
|
||||
```php
|
||||
// Log API access for security monitoring
|
||||
add_action('rest_api_init', function() {
|
||||
add_filter('rest_post_dispatch', function($response, $handler, $request) {
|
||||
if (strpos($request->get_route(), 'rank-math-api') !== false) {
|
||||
$log_entry = [
|
||||
'timestamp' => current_time('mysql'),
|
||||
'ip' => $_SERVER['REMOTE_ADDR'],
|
||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
|
||||
'user_id' => get_current_user_id(),
|
||||
'route' => $request->get_route(),
|
||||
'method' => $request->get_method(),
|
||||
'status' => $response->get_status(),
|
||||
'params' => array_keys($request->get_params())
|
||||
];
|
||||
|
||||
// Log to WordPress debug log
|
||||
error_log('Rank Math API Access: ' . json_encode($log_entry));
|
||||
|
||||
// Store in database for analysis
|
||||
$logs = get_option('rank_math_api_logs', []);
|
||||
$logs[] = $log_entry;
|
||||
|
||||
// Keep only last 1000 entries
|
||||
if (count($logs) > 1000) {
|
||||
$logs = array_slice($logs, -1000);
|
||||
}
|
||||
|
||||
update_option('rank_math_api_logs', $logs);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}, 10, 3);
|
||||
});
|
||||
```
|
||||
|
||||
### Security Event Monitoring
|
||||
|
||||
```php
|
||||
// Monitor for suspicious activity
|
||||
add_action('rest_api_init', function() {
|
||||
add_filter('rest_authentication_errors', function($result) {
|
||||
if ($result !== null) {
|
||||
// Log failed authentication attempts
|
||||
$log_entry = [
|
||||
'timestamp' => current_time('mysql'),
|
||||
'ip' => $_SERVER['REMOTE_ADDR'],
|
||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
|
||||
'route' => $_SERVER['REQUEST_URI'] ?? '',
|
||||
'error' => 'Authentication failed'
|
||||
];
|
||||
|
||||
error_log('Rank Math API Security Event: ' . json_encode($log_entry));
|
||||
|
||||
// Alert on multiple failed attempts
|
||||
$failed_attempts = get_transient('failed_auth_' . $_SERVER['REMOTE_ADDR']);
|
||||
if ($failed_attempts && $failed_attempts > 10) {
|
||||
// Send alert email
|
||||
wp_mail(
|
||||
get_option('admin_email'),
|
||||
'Security Alert: Multiple Failed API Authentication Attempts',
|
||||
'Multiple failed authentication attempts detected from IP: ' . $_SERVER['REMOTE_ADDR']
|
||||
);
|
||||
}
|
||||
|
||||
set_transient('failed_auth_' . $_SERVER['REMOTE_ADDR'], ($failed_attempts ? $failed_attempts + 1 : 1), 3600);
|
||||
}
|
||||
|
||||
return $result;
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## 🔧 Security Configuration
|
||||
|
||||
### WordPress Security Settings
|
||||
|
||||
#### Essential Security Plugins
|
||||
|
||||
```php
|
||||
// Recommended security plugins
|
||||
// 1. Wordfence Security
|
||||
// 2. Sucuri Security
|
||||
// 3. iThemes Security
|
||||
// 4. All In One WP Security & Firewall
|
||||
```
|
||||
|
||||
#### wp-config.php Security
|
||||
|
||||
```php
|
||||
// Add to wp-config.php
|
||||
// Disable file editing
|
||||
define('DISALLOW_FILE_EDIT', true);
|
||||
|
||||
// Increase memory limit
|
||||
define('WP_MEMORY_LIMIT', '256M');
|
||||
|
||||
// Enable debug logging
|
||||
define('WP_DEBUG', true);
|
||||
define('WP_DEBUG_LOG', true);
|
||||
define('WP_DEBUG_DISPLAY', false);
|
||||
|
||||
// Secure database
|
||||
define('DB_CHARSET', 'utf8mb4');
|
||||
define('DB_COLLATE', 'utf8mb4_unicode_ci');
|
||||
|
||||
// Force SSL for admin
|
||||
define('FORCE_SSL_ADMIN', true);
|
||||
```
|
||||
|
||||
### Server Security
|
||||
|
||||
#### Apache Security Headers
|
||||
|
||||
```apache
|
||||
# Add to .htaccess
|
||||
<IfModule mod_headers.c>
|
||||
Header always set X-Content-Type-Options nosniff
|
||||
Header always set X-Frame-Options DENY
|
||||
Header always set X-XSS-Protection "1; mode=block"
|
||||
Header always set Referrer-Policy "strict-origin-when-cross-origin"
|
||||
Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';"
|
||||
</IfModule>
|
||||
|
||||
# Block access to sensitive files
|
||||
<Files "wp-config.php">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
</Files>
|
||||
|
||||
<Files ".htaccess">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
</Files>
|
||||
```
|
||||
|
||||
#### Nginx Security Headers
|
||||
|
||||
```nginx
|
||||
# Add to nginx.conf
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-Frame-Options DENY;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';";
|
||||
|
||||
# Block access to sensitive files
|
||||
location ~ /(wp-config\.php|\.htaccess) {
|
||||
deny all;
|
||||
}
|
||||
```
|
||||
|
||||
## 🚨 Incident Response
|
||||
|
||||
### Security Incident Checklist
|
||||
|
||||
1. **Immediate Response**
|
||||
|
||||
- Disable API access if compromised
|
||||
- Change all Application Passwords
|
||||
- Review server logs for intrusion
|
||||
- Check for unauthorized changes
|
||||
|
||||
2. **Investigation**
|
||||
|
||||
- Analyze access logs
|
||||
- Review API usage patterns
|
||||
- Check for data breaches
|
||||
- Identify attack vectors
|
||||
|
||||
3. **Recovery**
|
||||
- Restore from clean backup
|
||||
- Update all credentials
|
||||
- Implement additional security measures
|
||||
- Monitor for further attacks
|
||||
|
||||
### Security Contact Information
|
||||
|
||||
```php
|
||||
// Add security contact information
|
||||
add_action('admin_menu', function() {
|
||||
add_options_page(
|
||||
'Security Settings',
|
||||
'Security',
|
||||
'manage_options',
|
||||
'security-settings',
|
||||
function() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1>Security Settings</h1>
|
||||
<h2>Emergency Contacts</h2>
|
||||
<p><strong>Security Email:</strong> security@devora.no</p>
|
||||
<p><strong>Emergency Phone:</strong> [Your emergency number]</p>
|
||||
<h2>Security Checklist</h2>
|
||||
<ul>
|
||||
<li>✅ HTTPS enabled</li>
|
||||
<li>✅ Application Passwords configured</li>
|
||||
<li>✅ Rate limiting enabled</li>
|
||||
<li>✅ Input validation active</li>
|
||||
<li>✅ Security monitoring active</li>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
## 📋 Security Checklist
|
||||
|
||||
### Pre-Deployment Checklist
|
||||
|
||||
- [ ] **HTTPS enabled** for all API communications
|
||||
- [ ] **Application Passwords** configured for API access
|
||||
- [ ] **User permissions** properly set (edit_posts capability)
|
||||
- [ ] **Input validation** and sanitization active
|
||||
- [ ] **Rate limiting** implemented
|
||||
- [ ] **Security headers** configured
|
||||
- [ ] **Error logging** enabled
|
||||
- [ ] **Backup strategy** in place
|
||||
- [ ] **Monitoring** and alerting configured
|
||||
- [ ] **Incident response plan** documented
|
||||
|
||||
### Regular Security Audits
|
||||
|
||||
- [ ] **Review access logs** monthly
|
||||
- [ ] **Update Application Passwords** quarterly
|
||||
- [ ] **Check for plugin updates** weekly
|
||||
- [ ] **Review user permissions** monthly
|
||||
- [ ] **Test security measures** quarterly
|
||||
- [ ] **Update security documentation** as needed
|
||||
|
||||
## 📞 Security Support
|
||||
|
||||
### Reporting Security Issues
|
||||
|
||||
**Important**: Do not report security issues via GitHub Issues. Send them to **security@devora.no** instead.
|
||||
|
||||
### Required Information for Security Reports
|
||||
|
||||
```
|
||||
Subject: Security Issue - Rank Math API Manager
|
||||
|
||||
Details:
|
||||
- Description of the vulnerability
|
||||
- Steps to reproduce
|
||||
- Potential impact
|
||||
- Environment details
|
||||
- Proof of concept (if applicable)
|
||||
|
||||
Contact Information:
|
||||
- Your name and email
|
||||
- Preferred contact method
|
||||
- Disclosure timeline preference
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Related Documentation**:
|
||||
|
||||
- [Installation Guide](installation.md)
|
||||
- [API Documentation](api-documentation.md)
|
||||
- [Troubleshooting Guide](troubleshooting.md)
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: July 2025
|
||||
**Version**: 1.0.6
|
||||
@@ -0,0 +1,498 @@
|
||||
# Example Use Cases - Rank Math API Manager Plugin
|
||||
|
||||
## 🎯 Overview
|
||||
|
||||
This guide provides practical examples of how to use the Rank Math API Manager plugin in various real-world scenarios. Each example includes complete code snippets and step-by-step instructions.
|
||||
|
||||
## 📝 Content Syndication
|
||||
|
||||
### Scenario: Automatically Update SEO When Content is Syndicated
|
||||
|
||||
When content is published on multiple platforms, you need to ensure consistent SEO metadata across all sites.
|
||||
|
||||
#### Example: Cross-Site SEO Synchronization
|
||||
|
||||
```bash
|
||||
# Update SEO metadata when content is syndicated
|
||||
curl -X POST "https://primary-site.com/wp-json/rank-math-api/v1/update-meta" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-H "Authorization: Basic [base64-encoded-credentials]" \
|
||||
-d "post_id=123&rank_math_title=How to Optimize WordPress SEO&rank_math_description=Learn the best practices for optimizing your WordPress site for search engines&rank_math_focus_keyword=WordPress SEO optimization"
|
||||
```
|
||||
|
||||
#### n8n Workflow Example
|
||||
|
||||
```json
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"name": "Content Published",
|
||||
"type": "trigger",
|
||||
"parameters": {
|
||||
"event": "content_published"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generate SEO Metadata",
|
||||
"type": "ai_generate",
|
||||
"parameters": {
|
||||
"prompt": "Generate SEO title, description, and focus keyword for: {{ $('Content Published').first().json.content }}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Update Primary Site",
|
||||
"type": "http_request",
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://primary-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
"headers": {
|
||||
"Authorization": "Basic [credentials]"
|
||||
},
|
||||
"bodyParameters": {
|
||||
"post_id": "={{ $('Content Published').first().json.post_id }}",
|
||||
"rank_math_title": "={{ $('Generate SEO Metadata').first().json.title }}",
|
||||
"rank_math_description": "={{ $('Generate SEO Metadata').first().json.description }}",
|
||||
"rank_math_focus_keyword": "={{ $('Generate SEO Metadata').first().json.keyword }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 🤖 AI-Driven SEO Optimization
|
||||
|
||||
### Scenario: Automatic SEO Generation Based on Content
|
||||
|
||||
Use AI to analyze content and generate optimized SEO metadata automatically.
|
||||
|
||||
#### Example: AI-Powered SEO Generation
|
||||
|
||||
```python
|
||||
import requests
|
||||
import json
|
||||
|
||||
def generate_seo_metadata(content):
|
||||
"""Generate SEO metadata using AI"""
|
||||
# This would integrate with your AI service
|
||||
ai_response = ai_service.analyze(content)
|
||||
|
||||
return {
|
||||
'title': ai_response['seo_title'],
|
||||
'description': ai_response['seo_description'],
|
||||
'keyword': ai_response['focus_keyword']
|
||||
}
|
||||
|
||||
def update_wordpress_seo(post_id, seo_data):
|
||||
"""Update WordPress SEO metadata via API"""
|
||||
url = "https://your-site.com/wp-json/rank-math-api/v1/update-meta"
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': 'Basic [base64-encoded-credentials]'
|
||||
}
|
||||
|
||||
data = {
|
||||
'post_id': post_id,
|
||||
'rank_math_title': seo_data['title'],
|
||||
'rank_math_description': seo_data['description'],
|
||||
'rank_math_focus_keyword': seo_data['keyword']
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, data=data)
|
||||
return response.json()
|
||||
|
||||
# Usage example
|
||||
content = "Your article content here..."
|
||||
post_id = 123
|
||||
|
||||
seo_data = generate_seo_metadata(content)
|
||||
result = update_wordpress_seo(post_id, seo_data)
|
||||
print(f"SEO updated: {result}")
|
||||
```
|
||||
|
||||
#### n8n Workflow: AI Content Analysis
|
||||
|
||||
```json
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"name": "New Content",
|
||||
"type": "trigger"
|
||||
},
|
||||
{
|
||||
"name": "Analyze Content",
|
||||
"type": "openai",
|
||||
"parameters": {
|
||||
"prompt": "Analyze this content and generate SEO metadata:\n\n{{ $('New Content').first().json.content }}\n\nProvide:\n1. SEO title (max 60 characters)\n2. Meta description (max 160 characters)\n3. Primary focus keyword"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Parse AI Response",
|
||||
"type": "code",
|
||||
"parameters": {
|
||||
"code": "const response = $('Analyze Content').first().json.text;\nconst lines = response.split('\\n');\n\nreturn {\n title: lines[0].replace('1. ', ''),\n description: lines[1].replace('2. ', ''),\n keyword: lines[2].replace('3. ', '')\n};"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Update SEO",
|
||||
"type": "http_request",
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
"bodyParameters": {
|
||||
"post_id": "={{ $('New Content').first().json.post_id }}",
|
||||
"rank_math_title": "={{ $('Parse AI Response').first().json.title }}",
|
||||
"rank_math_description": "={{ $('Parse AI Response').first().json.description }}",
|
||||
"rank_math_focus_keyword": "={{ $('Parse AI Response').first().json.keyword }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 🛒 E-commerce SEO Automation
|
||||
|
||||
### Scenario: Product Catalog Optimization
|
||||
|
||||
Automatically update SEO metadata for WooCommerce products based on inventory, categories, or seasonal campaigns.
|
||||
|
||||
#### Example: Seasonal Product SEO Updates
|
||||
|
||||
```bash
|
||||
# Update product SEO for seasonal campaign
|
||||
curl -X POST "https://ecommerce-site.com/wp-json/rank-math-api/v1/update-meta" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-H "Authorization: Basic [base64-encoded-credentials]" \
|
||||
-d "post_id=456&rank_math_title=Christmas Sale - Premium Wireless Headphones&rank_math_description=Get 30% off premium wireless headphones this Christmas. Free shipping and 2-year warranty included.&rank_math_focus_keyword=wireless headphones christmas sale"
|
||||
```
|
||||
|
||||
#### PHP Script: Bulk Product SEO Update
|
||||
|
||||
```php
|
||||
<?php
|
||||
// Bulk update product SEO metadata
|
||||
function update_product_seo_bulk($products) {
|
||||
$api_url = 'https://your-site.com/wp-json/rank-math-api/v1/update-meta';
|
||||
$credentials = base64_encode('username:application_password');
|
||||
|
||||
foreach ($products as $product) {
|
||||
$data = [
|
||||
'post_id' => $product['id'],
|
||||
'rank_math_title' => $product['seo_title'],
|
||||
'rank_math_description' => $product['seo_description'],
|
||||
'rank_math_focus_keyword' => $product['focus_keyword']
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $api_url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'Authorization: Basic ' . $credentials
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
echo "Updated product {$product['id']}: " . $response . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Example usage
|
||||
$products = [
|
||||
[
|
||||
'id' => 123,
|
||||
'seo_title' => 'Premium Wireless Headphones - Best Sound Quality',
|
||||
'seo_description' => 'Experience crystal clear sound with our premium wireless headphones. Perfect for music lovers and professionals.',
|
||||
'focus_keyword' => 'premium wireless headphones'
|
||||
],
|
||||
[
|
||||
'id' => 124,
|
||||
'seo_title' => 'Bluetooth Speaker - Portable and Waterproof',
|
||||
'seo_description' => 'Take your music anywhere with our portable and waterproof Bluetooth speaker. Perfect for outdoor adventures.',
|
||||
'focus_keyword' => 'portable bluetooth speaker'
|
||||
]
|
||||
];
|
||||
|
||||
update_product_seo_bulk($products);
|
||||
?>
|
||||
```
|
||||
|
||||
## 📊 Bulk SEO Administration
|
||||
|
||||
### Scenario: Mass SEO Updates for Multiple Posts
|
||||
|
||||
Update SEO metadata for multiple posts at once, useful for site-wide SEO improvements.
|
||||
|
||||
#### Example: Category-Based SEO Updates
|
||||
|
||||
```javascript
|
||||
// JavaScript/Node.js example for bulk updates
|
||||
const axios = require("axios");
|
||||
|
||||
async function updateCategorySEO(categoryId, seoTemplate) {
|
||||
// First, get all posts in the category
|
||||
const postsResponse = await axios.get(
|
||||
`https://your-site.com/wp-json/wp/v2/posts?categories=${categoryId}`
|
||||
);
|
||||
|
||||
const posts = postsResponse.data;
|
||||
const results = [];
|
||||
|
||||
for (const post of posts) {
|
||||
try {
|
||||
// Generate SEO data based on template and post content
|
||||
const seoData = generateSEOFromTemplate(seoTemplate, post);
|
||||
|
||||
// Update via API
|
||||
const response = await axios.post(
|
||||
"https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
{
|
||||
post_id: post.id,
|
||||
rank_math_title: seoData.title,
|
||||
rank_math_description: seoData.description,
|
||||
rank_math_focus_keyword: seoData.keyword,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Authorization: "Basic [base64-encoded-credentials]",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
results.push({
|
||||
post_id: post.id,
|
||||
status: "success",
|
||||
response: response.data,
|
||||
});
|
||||
} catch (error) {
|
||||
results.push({
|
||||
post_id: post.id,
|
||||
status: "error",
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function generateSEOFromTemplate(template, post) {
|
||||
return {
|
||||
title: template.title.replace("{post_title}", post.title.rendered),
|
||||
description: template.description.replace(
|
||||
"{post_excerpt}",
|
||||
post.excerpt.rendered
|
||||
),
|
||||
keyword: template.keyword,
|
||||
};
|
||||
}
|
||||
|
||||
// Usage
|
||||
const seoTemplate = {
|
||||
title: "{post_title} - Your Brand Name",
|
||||
description: "{post_excerpt} Read more about this topic on our website.",
|
||||
keyword: "your category keyword",
|
||||
};
|
||||
|
||||
updateCategorySEO(5, seoTemplate)
|
||||
.then((results) => console.log("Bulk update results:", results))
|
||||
.catch((error) => console.error("Error:", error));
|
||||
```
|
||||
|
||||
## 🔄 Automated Content Workflows
|
||||
|
||||
### Scenario: Content Publishing Pipeline
|
||||
|
||||
Integrate SEO updates into your content publishing workflow.
|
||||
|
||||
#### Example: WordPress + n8n + AI Workflow
|
||||
|
||||
```json
|
||||
{
|
||||
"workflow": {
|
||||
"name": "Content Publishing with SEO",
|
||||
"nodes": [
|
||||
{
|
||||
"name": "New Post Created",
|
||||
"type": "webhook",
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "new-post"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Extract Content",
|
||||
"type": "code",
|
||||
"parameters": {
|
||||
"code": "const post = $('New Post Created').first().json;\nreturn {\n post_id: post.ID,\n title: post.post_title,\n content: post.post_content,\n excerpt: post.post_excerpt\n};"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generate SEO",
|
||||
"type": "openai",
|
||||
"parameters": {
|
||||
"prompt": "Generate SEO metadata for this WordPress post:\n\nTitle: {{ $('Extract Content').first().json.title }}\nContent: {{ $('Extract Content').first().json.content }}\n\nProvide:\n- SEO title (max 60 chars)\n- Meta description (max 160 chars)\n- Primary keyword"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Update SEO Metadata",
|
||||
"type": "http_request",
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
"headers": {
|
||||
"Authorization": "Basic [credentials]"
|
||||
},
|
||||
"bodyParameters": {
|
||||
"post_id": "={{ $('Extract Content').first().json.post_id }}",
|
||||
"rank_math_title": "={{ $('Generate SEO').first().json.title }}",
|
||||
"rank_math_description": "={{ $('Generate SEO').first().json.description }}",
|
||||
"rank_math_focus_keyword": "={{ $('Generate SEO').first().json.keyword }}"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Send Notification",
|
||||
"type": "email",
|
||||
"parameters": {
|
||||
"to": "admin@your-site.com",
|
||||
"subject": "SEO Updated for Post {{ $('Extract Content').first().json.post_id }}",
|
||||
"text": "SEO metadata has been automatically updated for the new post."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 📈 Competitor Analysis Integration
|
||||
|
||||
### Scenario: SEO Optimization Based on Competitor Analysis
|
||||
|
||||
Use competitor analysis tools to generate optimized SEO metadata.
|
||||
|
||||
#### Example: Competitor-Based SEO Generation
|
||||
|
||||
```python
|
||||
import requests
|
||||
import json
|
||||
|
||||
def analyze_competitors(keyword):
|
||||
"""Analyze competitor content for a keyword"""
|
||||
# This would integrate with your competitor analysis tool
|
||||
competitor_data = competitor_tool.analyze(keyword)
|
||||
|
||||
return {
|
||||
'avg_title_length': competitor_data['avg_title_length'],
|
||||
'common_keywords': competitor_data['common_keywords'],
|
||||
'title_patterns': competitor_data['title_patterns']
|
||||
}
|
||||
|
||||
def generate_optimized_seo(content, keyword, competitor_data):
|
||||
"""Generate SEO based on competitor analysis"""
|
||||
# Use competitor insights to optimize SEO
|
||||
optimized_title = create_title_with_patterns(content, competitor_data['title_patterns'])
|
||||
optimized_description = create_description_with_keywords(content, competitor_data['common_keywords'])
|
||||
|
||||
return {
|
||||
'title': optimized_title,
|
||||
'description': optimized_description,
|
||||
'keyword': keyword
|
||||
}
|
||||
|
||||
def update_wordpress_seo(post_id, seo_data):
|
||||
"""Update WordPress SEO via API"""
|
||||
url = "https://your-site.com/wp-json/rank-math-api/v1/update-meta"
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': 'Basic [base64-encoded-credentials]'
|
||||
}
|
||||
|
||||
data = {
|
||||
'post_id': post_id,
|
||||
'rank_math_title': seo_data['title'],
|
||||
'rank_math_description': seo_data['description'],
|
||||
'rank_math_focus_keyword': seo_data['keyword']
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, data=data)
|
||||
return response.json()
|
||||
|
||||
# Usage
|
||||
keyword = "WordPress SEO optimization"
|
||||
content = "Your article content..."
|
||||
post_id = 123
|
||||
|
||||
competitor_data = analyze_competitors(keyword)
|
||||
seo_data = generate_optimized_seo(content, keyword, competitor_data)
|
||||
result = update_wordpress_seo(post_id, seo_data)
|
||||
```
|
||||
|
||||
## 🎯 Best Practices
|
||||
|
||||
### 1. Error Handling
|
||||
|
||||
Always implement proper error handling in your API calls:
|
||||
|
||||
```javascript
|
||||
try {
|
||||
const response = await updateSEO(postId, seoData);
|
||||
console.log("SEO updated successfully:", response);
|
||||
} catch (error) {
|
||||
console.error("Failed to update SEO:", error.response?.data || error.message);
|
||||
// Implement retry logic or fallback
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Rate Limiting
|
||||
|
||||
Respect API rate limits and implement delays between requests:
|
||||
|
||||
```javascript
|
||||
async function bulkUpdateWithRateLimit(posts, delayMs = 1000) {
|
||||
for (const post of posts) {
|
||||
await updateSEO(post.id, post.seoData);
|
||||
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Validation
|
||||
|
||||
Always validate your data before sending to the API:
|
||||
|
||||
```javascript
|
||||
function validateSEOData(seoData) {
|
||||
const errors = [];
|
||||
|
||||
if (!seoData.title || seoData.title.length > 60) {
|
||||
errors.push("Title must be between 1-60 characters");
|
||||
}
|
||||
|
||||
if (!seoData.description || seoData.description.length > 160) {
|
||||
errors.push("Description must be between 1-160 characters");
|
||||
}
|
||||
|
||||
if (!seoData.keyword) {
|
||||
errors.push("Focus keyword is required");
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Next Steps**: See the [API Documentation](api-documentation.md) for complete technical details.
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: July 2025
|
||||
**Version**: 1.0.6
|
||||
244
wordpress-plugins/rank-math-api-manager/docs/installation.md
Normal file
244
wordpress-plugins/rank-math-api-manager/docs/installation.md
Normal file
@@ -0,0 +1,244 @@
|
||||
# Installation Guide - Rank Math API Manager Plugin
|
||||
|
||||
## 📋 Prerequisites
|
||||
|
||||
Before installing the Rank Math API Manager plugin, ensure you have:
|
||||
|
||||
- **WordPress 5.0 or newer**
|
||||
- **PHP 7.4 or newer**
|
||||
- **Rank Math SEO plugin** (installed and activated)
|
||||
- **Administrator access** to your WordPress site
|
||||
|
||||
## 🚀 Installation Methods
|
||||
|
||||
### Method 1: Manual Installation (Recommended)
|
||||
|
||||
#### Step 1: Download the Plugin
|
||||
|
||||
1. Visit the [GitHub repository](https://github.com/devora-as/rank-math-api-manager)
|
||||
2. Click the green "Code" button
|
||||
3. Select "Download ZIP"
|
||||
4. Extract the ZIP file to your local computer
|
||||
|
||||
#### Step 2: Upload to WordPress
|
||||
|
||||
1. **Log in to your WordPress admin panel**
|
||||
2. **Navigate to Plugins → Add New**
|
||||
3. **Click "Upload Plugin"** at the top of the page
|
||||
4. **Choose File** and select the extracted plugin folder
|
||||
5. **Click "Install Now"**
|
||||
6. **Activate the plugin** when prompted
|
||||
|
||||

|
||||
|
||||
### Method 2: FTP Installation
|
||||
|
||||
#### Step 1: Prepare the Files
|
||||
|
||||
1. Download the plugin from GitHub
|
||||
2. Extract the ZIP file
|
||||
3. Upload the `rank-math-api-manager` folder to `/wp-content/plugins/`
|
||||
|
||||
#### Step 2: Activate the Plugin
|
||||
|
||||
1. Log in to WordPress admin
|
||||
2. Go to **Plugins → Installed Plugins**
|
||||
3. Find "Rank Math API Manager"
|
||||
4. Click **"Activate"**
|
||||
|
||||
## ⚙️ Configuration
|
||||
|
||||
### Step 1: Verify Installation
|
||||
|
||||
After activation, you should see:
|
||||
|
||||
- ✅ Plugin appears in the plugins list
|
||||
- ✅ No error messages in WordPress admin
|
||||
- ✅ REST API endpoints are available
|
||||
|
||||
### Step 2: Test API Endpoints
|
||||
|
||||
#### Using cURL (Command Line)
|
||||
|
||||
```bash
|
||||
# Test the API endpoint
|
||||
curl -X POST "https://your-site.com/wp-json/rank-math-api/v1/update-meta" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-H "Authorization: Basic [base64-encoded-credentials]" \
|
||||
-d "post_id=1&rank_math_title=Test Title"
|
||||
```
|
||||
|
||||
#### Using Postman
|
||||
|
||||
1. **Create a new POST request**
|
||||
2. **URL**: `https://your-site.com/wp-json/rank-math-api/v1/update-meta`
|
||||
3. **Headers**:
|
||||
- `Content-Type: application/x-www-form-urlencoded`
|
||||
- `Authorization: Basic [base64-encoded-credentials]`
|
||||
4. **Body** (form-data):
|
||||
- `post_id`: `1`
|
||||
- `rank_math_title`: `Test Title`
|
||||
|
||||
### Step 3: Set Up Authentication
|
||||
|
||||
#### WordPress Application Passwords
|
||||
|
||||
1. **Go to Users → Profile**
|
||||
2. **Scroll to "Application Passwords"**
|
||||
3. **Enter a name** (e.g., "API Access")
|
||||
4. **Click "Add New Application Password"**
|
||||
5. **Copy the generated password**
|
||||
|
||||
#### Basic Auth Setup
|
||||
|
||||
```bash
|
||||
# Encode credentials
|
||||
echo -n "username:password" | base64
|
||||
```
|
||||
|
||||
## 🔧 Integration Setup
|
||||
|
||||
### n8n Workflow Integration
|
||||
|
||||
1. **Add HTTP Request node** to your n8n workflow
|
||||
2. **Configure the request**:
|
||||
- Method: `POST`
|
||||
- URL: `https://your-site.com/wp-json/rank-math-api/v1/update-meta`
|
||||
- Headers: Add authentication headers
|
||||
- Body: Configure form data
|
||||
|
||||
### Example n8n Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"method": "POST",
|
||||
"url": "https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
"contentType": "form-urlencoded",
|
||||
"headers": {
|
||||
"Authorization": "Basic [base64-encoded-credentials]"
|
||||
},
|
||||
"bodyParameters": {
|
||||
"post_id": "={{ $('Post on Wordpress').first().json.id }}",
|
||||
"rank_math_title": "={{ $('Generate metatitle e metadescription').first().json.output.metatitle }}",
|
||||
"rank_math_description": "={{ $('Generate metatitle e metadescription').first().json.output.metadescription }}",
|
||||
"rank_math_focus_keyword": "={{ $('Generate metatitle e metadescription').first().json.output.metakeywords }}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 🛡️ Security Configuration
|
||||
|
||||
### 1. Enable HTTPS
|
||||
|
||||
Ensure your WordPress site uses HTTPS for secure API communications.
|
||||
|
||||
### 2. Restrict API Access
|
||||
|
||||
- Use strong application passwords
|
||||
- Limit API access to trusted applications
|
||||
- Monitor API usage logs
|
||||
|
||||
### 3. WordPress Security
|
||||
|
||||
- Keep WordPress updated
|
||||
- Use security plugins
|
||||
- Enable two-factor authentication
|
||||
|
||||
## 🔍 Verification Steps
|
||||
|
||||
### 1. Check Plugin Status
|
||||
|
||||
1. Go to **Plugins → Installed Plugins**
|
||||
2. Verify "Rank Math API Manager" is **Active**
|
||||
3. Check for any error messages
|
||||
|
||||
### 2. Test API Endpoint
|
||||
|
||||
```bash
|
||||
# Test endpoint availability
|
||||
curl -X GET "https://your-site.com/wp-json/rank-math-api/v1/update-meta"
|
||||
```
|
||||
|
||||
Expected response: `{"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}`
|
||||
|
||||
This confirms the endpoint exists but requires POST method.
|
||||
|
||||
### 3. Verify Permissions
|
||||
|
||||
1. Create a test post
|
||||
2. Use the API to update its SEO metadata
|
||||
3. Verify the changes appear in Rank Math
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### Issue: "Plugin could not be activated"
|
||||
|
||||
**Solution:**
|
||||
|
||||
- Check PHP version (requires 7.4+)
|
||||
- Verify WordPress version (requires 5.0+)
|
||||
- Check for plugin conflicts
|
||||
|
||||
#### Issue: "401 Unauthorized" API errors
|
||||
|
||||
**Solution:**
|
||||
|
||||
- Verify application password is correct
|
||||
- Check user permissions (`edit_posts`)
|
||||
- Ensure authentication headers are properly formatted
|
||||
|
||||
#### Issue: "404 Not Found" API errors
|
||||
|
||||
**Solution:**
|
||||
|
||||
- Verify plugin is activated
|
||||
- Check WordPress REST API is enabled
|
||||
- Ensure URL is correct
|
||||
|
||||
#### Issue: "400 Bad Request" API errors
|
||||
|
||||
**Solution:**
|
||||
|
||||
- Verify `post_id` exists
|
||||
- Check parameter formatting
|
||||
- Ensure all required fields are provided
|
||||
|
||||
### Debug Mode
|
||||
|
||||
Enable WordPress debug mode for detailed error messages:
|
||||
|
||||
```php
|
||||
// Add to wp-config.php
|
||||
define('WP_DEBUG', true);
|
||||
define('WP_DEBUG_LOG', true);
|
||||
define('WP_DEBUG_DISPLAY', false);
|
||||
```
|
||||
|
||||
## 📞 Support
|
||||
|
||||
If you encounter issues during installation:
|
||||
|
||||
1. **Check the troubleshooting section above**
|
||||
2. **Review WordPress error logs**
|
||||
3. **Create a GitHub issue** with detailed information
|
||||
4. **Contact support** at [devora.no](https://devora.no)
|
||||
|
||||
### Required Information for Support
|
||||
|
||||
- WordPress version
|
||||
- PHP version
|
||||
- Plugin version
|
||||
- Error messages
|
||||
- Steps to reproduce the issue
|
||||
- Screenshots (if applicable)
|
||||
|
||||
---
|
||||
|
||||
**Next Steps**: After installation, see the [API Documentation](api-documentation.md) for detailed usage instructions.
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: July 2025
|
||||
**Version**: 1.0.6
|
||||
@@ -0,0 +1,766 @@
|
||||
# Integration Guide - Rank Math API Manager Plugin
|
||||
|
||||
## 📋 Overview
|
||||
|
||||
This guide provides step-by-step instructions for integrating the Rank Math API Manager plugin with various automation tools and platforms. Learn how to connect the plugin with n8n, Zapier, Make (Integromat), and custom applications.
|
||||
|
||||
## 🔧 Prerequisites
|
||||
|
||||
Before starting integration:
|
||||
|
||||
- ✅ **Plugin installed and activated** (see [Installation Guide](installation.md))
|
||||
- ✅ **WordPress Application Password** configured
|
||||
- ✅ **Test post or product** created for testing
|
||||
- ✅ **API endpoint tested** and working
|
||||
|
||||
## 🚀 n8n Integration
|
||||
|
||||
### Step 1: Set Up n8n
|
||||
|
||||
1. **Install n8n** (if not already installed)
|
||||
2. **Create a new workflow**
|
||||
3. **Add an HTTP Request node**
|
||||
|
||||
### Step 2: Configure HTTP Request Node
|
||||
|
||||
#### Basic Configuration
|
||||
|
||||
1. **Method**: `POST`
|
||||
2. **URL**: `https://your-site.com/wp-json/rank-math-api/v1/update-meta`
|
||||
3. **Content Type**: `form-urlencoded`
|
||||
|
||||
#### Authentication Setup
|
||||
|
||||
1. **Click on "Add Credential"**
|
||||
2. **Select "HTTP Basic Auth"**
|
||||
3. **Enter your WordPress username**
|
||||
4. **Enter your Application Password**
|
||||
5. **Save the credential**
|
||||
|
||||
#### Body Parameters
|
||||
|
||||
Configure the following parameters:
|
||||
|
||||
| Parameter | Value | Description |
|
||||
| ------------------------- | -------------------------------------------------------- | -------------------------- |
|
||||
| `post_id` | `={{ $('Previous Node').first().json.post_id }}` | Post ID from previous node |
|
||||
| `rank_math_title` | `={{ $('Previous Node').first().json.seo_title }}` | SEO title |
|
||||
| `rank_math_description` | `={{ $('Previous Node').first().json.seo_description }}` | SEO description |
|
||||
| `rank_math_focus_keyword` | `={{ $('Previous Node').first().json.focus_keyword }}` | Focus keyword |
|
||||
|
||||
### Step 3: Complete n8n Workflow Example
|
||||
|
||||
#### AI Content Generation + SEO Update
|
||||
|
||||
```json
|
||||
{
|
||||
"workflow": {
|
||||
"name": "AI Content + SEO Update",
|
||||
"nodes": [
|
||||
{
|
||||
"name": "Webhook Trigger",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "new-content",
|
||||
"responseMode": "responseNode"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generate SEO with AI",
|
||||
"type": "n8n-nodes-base.openAi",
|
||||
"parameters": {
|
||||
"operation": "completion",
|
||||
"model": "gpt-3.5-turbo",
|
||||
"prompt": "Generate SEO metadata for this content:\n\nTitle: {{ $('Webhook Trigger').first().json.title }}\nContent: {{ $('Webhook Trigger').first().json.content }}\n\nProvide in JSON format:\n{\n \"seo_title\": \"SEO title (max 60 chars)\",\n \"seo_description\": \"Meta description (max 160 chars)\",\n \"focus_keyword\": \"Primary keyword\"\n}",
|
||||
"options": {
|
||||
"temperature": 0.7,
|
||||
"maxTokens": 200
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Parse AI Response",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"parameters": {
|
||||
"code": "const aiResponse = $('Generate SEO with AI').first().json.text;\nconst seoData = JSON.parse(aiResponse);\n\nreturn {\n post_id: $('Webhook Trigger').first().json.post_id,\n seo_title: seoData.seo_title,\n seo_description: seoData.seo_description,\n focus_keyword: seoData.focus_keyword\n};"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Update WordPress SEO",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
"contentType": "form-urlencoded",
|
||||
"authentication": "httpBasicAuth",
|
||||
"options": {
|
||||
"bodyParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "post_id",
|
||||
"value": "={{ $('Parse AI Response').first().json.post_id }}"
|
||||
},
|
||||
{
|
||||
"name": "rank_math_title",
|
||||
"value": "={{ $('Parse AI Response').first().json.seo_title }}"
|
||||
},
|
||||
{
|
||||
"name": "rank_math_description",
|
||||
"value": "={{ $('Parse AI Response').first().json.seo_description }}"
|
||||
},
|
||||
{
|
||||
"name": "rank_math_focus_keyword",
|
||||
"value": "={{ $('Parse AI Response').first().json.focus_keyword }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Send Success Response",
|
||||
"type": "n8n-nodes-base.respondToWebhook",
|
||||
"parameters": {
|
||||
"respondWith": "json",
|
||||
"responseBody": "{\n \"success\": true,\n \"message\": \"SEO updated successfully\",\n \"data\": {{ $('Update WordPress SEO').first().json }}\n}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### WordPress + n8n Integration
|
||||
|
||||
```json
|
||||
{
|
||||
"workflow": {
|
||||
"name": "WordPress Post + SEO Update",
|
||||
"nodes": [
|
||||
{
|
||||
"name": "WordPress Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "wordpress-post",
|
||||
"responseMode": "responseNode"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Extract Post Data",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"parameters": {
|
||||
"code": "const post = $('WordPress Webhook').first().json;\n\nreturn {\n post_id: post.ID,\n title: post.post_title,\n content: post.post_content,\n excerpt: post.post_excerpt\n};"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generate SEO",
|
||||
"type": "n8n-nodes-base.openAi",
|
||||
"parameters": {
|
||||
"operation": "completion",
|
||||
"model": "gpt-3.5-turbo",
|
||||
"prompt": "Generate SEO metadata for this WordPress post:\n\nTitle: {{ $('Extract Post Data').first().json.title }}\nContent: {{ $('Extract Post Data').first().json.content }}\n\nProvide:\n1. SEO title (max 60 characters)\n2. Meta description (max 160 characters)\n3. Primary focus keyword",
|
||||
"options": {
|
||||
"temperature": 0.7,
|
||||
"maxTokens": 150
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Parse SEO Response",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"parameters": {
|
||||
"code": "const response = $('Generate SEO').first().json.text;\nconst lines = response.split('\\n');\n\nreturn {\n post_id: $('Extract Post Data').first().json.post_id,\n seo_title: lines[0].replace(/^\\d+\\.\\s*/, ''),\n seo_description: lines[1].replace(/^\\d+\\.\\s*/, ''),\n focus_keyword: lines[2].replace(/^\\d+\\.\\s*/, '')\n};"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Update SEO",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
"contentType": "form-urlencoded",
|
||||
"authentication": "httpBasicAuth",
|
||||
"options": {
|
||||
"bodyParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "post_id",
|
||||
"value": "={{ $('Parse SEO Response').first().json.post_id }}"
|
||||
},
|
||||
{
|
||||
"name": "rank_math_title",
|
||||
"value": "={{ $('Parse SEO Response').first().json.seo_title }}"
|
||||
},
|
||||
{
|
||||
"name": "rank_math_description",
|
||||
"value": "={{ $('Parse SEO Response').first().json.seo_description }}"
|
||||
},
|
||||
{
|
||||
"name": "rank_math_focus_keyword",
|
||||
"value": "={{ $('Parse SEO Response').first().json.focus_keyword }}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Send Notification",
|
||||
"type": "n8n-nodes-base.emailSend",
|
||||
"parameters": {
|
||||
"toEmail": "admin@your-site.com",
|
||||
"subject": "SEO Updated for Post {{ $('Parse SEO Response').first().json.post_id }}",
|
||||
"text": "SEO metadata has been automatically updated for the new post."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Step 4: Testing the n8n Workflow
|
||||
|
||||
1. **Activate the workflow**
|
||||
2. **Send a test webhook** with sample data
|
||||
3. **Check the execution logs** for any errors
|
||||
4. **Verify the SEO update** in WordPress admin
|
||||
|
||||
## 🔌 Zapier Integration
|
||||
|
||||
### Step 1: Create a Zap
|
||||
|
||||
1. **Log in to Zapier**
|
||||
2. **Click "Create Zap"**
|
||||
3. **Choose a trigger** (e.g., "New Post" in WordPress)
|
||||
|
||||
### Step 2: Add Code Action
|
||||
|
||||
1. **Add a "Code by Zapier" action**
|
||||
2. **Select "Run JavaScript"**
|
||||
3. **Use the following code**:
|
||||
|
||||
```javascript
|
||||
// Zapier Code Action for SEO Update
|
||||
const postId = inputData.post_id;
|
||||
const postTitle = inputData.post_title;
|
||||
const postContent = inputData.post_content;
|
||||
|
||||
// Generate SEO data (you can customize this logic)
|
||||
const seoTitle =
|
||||
postTitle.length > 60 ? postTitle.substring(0, 57) + "..." : postTitle;
|
||||
const seoDescription =
|
||||
postContent.length > 160
|
||||
? postContent.substring(0, 157) + "..."
|
||||
: postContent;
|
||||
const focusKeyword = postTitle.split(" ").slice(0, 3).join(" ");
|
||||
|
||||
// Make API request
|
||||
const response = await fetch(
|
||||
"https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Authorization: "Basic " + btoa("username:application_password"),
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
post_id: postId,
|
||||
rank_math_title: seoTitle,
|
||||
rank_math_description: seoDescription,
|
||||
rank_math_focus_keyword: focusKeyword,
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
return {
|
||||
success: response.ok,
|
||||
data: result,
|
||||
post_id: postId,
|
||||
seo_title: seoTitle,
|
||||
seo_description: seoDescription,
|
||||
focus_keyword: focusKeyword,
|
||||
};
|
||||
```
|
||||
|
||||
### Step 3: Test the Zap
|
||||
|
||||
1. **Test the trigger** with a sample post
|
||||
2. **Check the execution** in Zapier
|
||||
3. **Verify the results** in WordPress
|
||||
|
||||
## 🔗 Make (Integromat) Integration
|
||||
|
||||
### Step 1: Create a Scenario
|
||||
|
||||
1. **Log in to Make**
|
||||
2. **Create a new scenario**
|
||||
3. **Add a trigger** (e.g., WordPress webhook)
|
||||
|
||||
### Step 2: Add HTTP Module
|
||||
|
||||
1. **Add an HTTP module**
|
||||
2. **Configure the request**:
|
||||
|
||||
#### HTTP Configuration
|
||||
|
||||
- **URL**: `https://your-site.com/wp-json/rank-math-api/v1/update-meta`
|
||||
- **Method**: `POST`
|
||||
- **Headers**:
|
||||
- `Content-Type`: `application/x-www-form-urlencoded`
|
||||
- `Authorization`: `Basic [base64-encoded-credentials]`
|
||||
|
||||
#### Body Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"post_id": "{{1.post_id}}",
|
||||
"rank_math_title": "{{1.seo_title}}",
|
||||
"rank_math_description": "{{1.seo_description}}",
|
||||
"rank_math_focus_keyword": "{{1.focus_keyword}}"
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: Complete Make Scenario
|
||||
|
||||
```json
|
||||
{
|
||||
"scenario": {
|
||||
"name": "WordPress SEO Update",
|
||||
"modules": [
|
||||
{
|
||||
"name": "WordPress Webhook",
|
||||
"type": "webhook",
|
||||
"config": {
|
||||
"url": "https://hook.eu1.make.com/your-webhook-url"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Generate SEO",
|
||||
"type": "openai",
|
||||
"config": {
|
||||
"prompt": "Generate SEO metadata for: {{1.post_title}}",
|
||||
"model": "gpt-3.5-turbo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Update SEO",
|
||||
"type": "http",
|
||||
"config": {
|
||||
"url": "https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"Authorization": "Basic [credentials]"
|
||||
},
|
||||
"body": {
|
||||
"post_id": "{{1.post_id}}",
|
||||
"rank_math_title": "{{2.seo_title}}",
|
||||
"rank_math_description": "{{2.seo_description}}",
|
||||
"rank_math_focus_keyword": "{{2.focus_keyword}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 🐍 Python Integration
|
||||
|
||||
### Step 1: Install Required Packages
|
||||
|
||||
```bash
|
||||
pip install requests
|
||||
```
|
||||
|
||||
### Step 2: Create Integration Script
|
||||
|
||||
```python
|
||||
import requests
|
||||
import base64
|
||||
import json
|
||||
from typing import Dict, Optional
|
||||
|
||||
class RankMathAPIClient:
|
||||
def __init__(self, site_url: str, username: str, application_password: str):
|
||||
self.base_url = f"{site_url}/wp-json/rank-math-api/v1"
|
||||
self.credentials = base64.b64encode(
|
||||
f"{username}:{application_password}".encode()
|
||||
).decode()
|
||||
|
||||
def update_seo(self, post_id: int, seo_data: Dict[str, str]) -> Dict:
|
||||
"""
|
||||
Update SEO metadata for a post
|
||||
|
||||
Args:
|
||||
post_id: WordPress post ID
|
||||
seo_data: Dictionary containing SEO data
|
||||
|
||||
Returns:
|
||||
API response as dictionary
|
||||
"""
|
||||
url = f"{self.base_url}/update-meta"
|
||||
|
||||
headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': f'Basic {self.credentials}'
|
||||
}
|
||||
|
||||
data = {
|
||||
'post_id': post_id,
|
||||
'rank_math_title': seo_data.get('title'),
|
||||
'rank_math_description': seo_data.get('description'),
|
||||
'rank_math_canonical_url': seo_data.get('canonical_url'),
|
||||
'rank_math_focus_keyword': seo_data.get('focus_keyword')
|
||||
}
|
||||
|
||||
# Remove None values
|
||||
data = {k: v for k, v in data.items() if v is not None}
|
||||
|
||||
response = requests.post(url, headers=headers, data=data)
|
||||
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
else:
|
||||
raise Exception(f"API request failed: {response.status_code} - {response.text}")
|
||||
|
||||
def bulk_update_seo(self, updates: list) -> list:
|
||||
"""
|
||||
Update SEO metadata for multiple posts
|
||||
|
||||
Args:
|
||||
updates: List of dictionaries with post_id and seo_data
|
||||
|
||||
Returns:
|
||||
List of results for each update
|
||||
"""
|
||||
results = []
|
||||
|
||||
for update in updates:
|
||||
try:
|
||||
result = self.update_seo(update['post_id'], update['seo_data'])
|
||||
results.append({
|
||||
'post_id': update['post_id'],
|
||||
'success': True,
|
||||
'data': result
|
||||
})
|
||||
except Exception as e:
|
||||
results.append({
|
||||
'post_id': update['post_id'],
|
||||
'success': False,
|
||||
'error': str(e)
|
||||
})
|
||||
|
||||
return results
|
||||
|
||||
# Usage example
|
||||
def main():
|
||||
# Initialize client
|
||||
client = RankMathAPIClient(
|
||||
site_url="https://your-site.com",
|
||||
username="your_username",
|
||||
application_password="your_application_password"
|
||||
)
|
||||
|
||||
# Single update
|
||||
try:
|
||||
result = client.update_seo(123, {
|
||||
'title': 'How to Optimize WordPress SEO',
|
||||
'description': 'Learn the best practices for optimizing your WordPress site for search engines',
|
||||
'focus_keyword': 'WordPress SEO optimization'
|
||||
})
|
||||
print(f"SEO updated successfully: {result}")
|
||||
except Exception as e:
|
||||
print(f"Error updating SEO: {e}")
|
||||
|
||||
# Bulk update
|
||||
updates = [
|
||||
{
|
||||
'post_id': 123,
|
||||
'seo_data': {
|
||||
'title': 'Post 1 SEO Title',
|
||||
'description': 'Post 1 SEO Description',
|
||||
'focus_keyword': 'keyword 1'
|
||||
}
|
||||
},
|
||||
{
|
||||
'post_id': 124,
|
||||
'seo_data': {
|
||||
'title': 'Post 2 SEO Title',
|
||||
'description': 'Post 2 SEO Description',
|
||||
'focus_keyword': 'keyword 2'
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
results = client.bulk_update_seo(updates)
|
||||
for result in results:
|
||||
if result['success']:
|
||||
print(f"Post {result['post_id']}: Updated successfully")
|
||||
else:
|
||||
print(f"Post {result['post_id']}: Failed - {result['error']}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
```
|
||||
|
||||
## 🔧 Custom WordPress Integration
|
||||
|
||||
### Step 1: WordPress Plugin Integration
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* Custom WordPress plugin integration example
|
||||
*/
|
||||
|
||||
// Add action to update SEO when post is published
|
||||
add_action('publish_post', 'auto_update_seo_on_publish', 10, 2);
|
||||
|
||||
function auto_update_seo_on_publish($post_id, $post) {
|
||||
// Skip revisions and autosaves
|
||||
if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate SEO data based on post content
|
||||
$seo_data = generate_seo_from_content($post);
|
||||
|
||||
// Update via API
|
||||
$result = update_seo_via_api($post_id, $seo_data);
|
||||
|
||||
// Log the result
|
||||
if ($result['success']) {
|
||||
error_log("SEO updated successfully for post {$post_id}");
|
||||
} else {
|
||||
error_log("Failed to update SEO for post {$post_id}: " . $result['error']);
|
||||
}
|
||||
}
|
||||
|
||||
function generate_seo_from_content($post) {
|
||||
// Simple SEO generation logic
|
||||
$title = wp_trim_words($post->post_title, 8, '');
|
||||
$description = wp_trim_words(wp_strip_all_tags($post->post_content), 25, '...');
|
||||
$keyword = implode(' ', array_slice(explode(' ', $post->post_title), 0, 3));
|
||||
|
||||
return [
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'focus_keyword' => $keyword
|
||||
];
|
||||
}
|
||||
|
||||
function update_seo_via_api($post_id, $seo_data) {
|
||||
$url = home_url('/wp-json/rank-math-api/v1/update-meta');
|
||||
|
||||
// Get application password (you should store this securely)
|
||||
$app_password = get_option('rank_math_api_app_password');
|
||||
$username = get_option('rank_math_api_username');
|
||||
|
||||
if (!$app_password || !$username) {
|
||||
return ['success' => false, 'error' => 'API credentials not configured'];
|
||||
}
|
||||
|
||||
$credentials = base64_encode("{$username}:{$app_password}");
|
||||
|
||||
$response = wp_remote_post($url, [
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||
'Authorization' => "Basic {$credentials}"
|
||||
],
|
||||
'body' => [
|
||||
'post_id' => $post_id,
|
||||
'rank_math_title' => $seo_data['title'],
|
||||
'rank_math_description' => $seo_data['description'],
|
||||
'rank_math_focus_keyword' => $seo_data['focus_keyword']
|
||||
],
|
||||
'timeout' => 30
|
||||
]);
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
return ['success' => false, 'error' => $response->get_error_message()];
|
||||
}
|
||||
|
||||
$status_code = wp_remote_retrieve_response_code($response);
|
||||
$body = wp_remote_retrieve_body($response);
|
||||
|
||||
if ($status_code === 200) {
|
||||
return ['success' => true, 'data' => json_decode($body, true)];
|
||||
} else {
|
||||
return ['success' => false, 'error' => "HTTP {$status_code}: {$body}"];
|
||||
}
|
||||
}
|
||||
|
||||
// Add admin settings page
|
||||
add_action('admin_menu', 'add_rank_math_api_settings_page');
|
||||
|
||||
function add_rank_math_api_settings_page() {
|
||||
add_options_page(
|
||||
'Rank Math API Settings',
|
||||
'Rank Math API',
|
||||
'manage_options',
|
||||
'rank-math-api-settings',
|
||||
'rank_math_api_settings_page'
|
||||
);
|
||||
}
|
||||
|
||||
function rank_math_api_settings_page() {
|
||||
if (isset($_POST['submit'])) {
|
||||
update_option('rank_math_api_username', sanitize_text_field($_POST['username']));
|
||||
update_option('rank_math_api_app_password', sanitize_text_field($_POST['app_password']));
|
||||
echo '<div class="notice notice-success"><p>Settings saved!</p></div>';
|
||||
}
|
||||
|
||||
$username = get_option('rank_math_api_username');
|
||||
$app_password = get_option('rank_math_api_app_password');
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1>Rank Math API Settings</h1>
|
||||
<form method="post">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row">Username</th>
|
||||
<td><input type="text" name="username" value="<?php echo esc_attr($username); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Application Password</th>
|
||||
<td><input type="password" name="app_password" value="<?php echo esc_attr($app_password); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php submit_button(); ?>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
```
|
||||
|
||||
## 🧪 Testing Your Integration
|
||||
|
||||
### Step 1: Create Test Data
|
||||
|
||||
```bash
|
||||
# Create a test post
|
||||
curl -X POST "https://your-site.com/wp-json/wp/v2/posts" \
|
||||
-H "Authorization: Basic [credentials]" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"title": "Test Post for SEO Integration",
|
||||
"content": "This is a test post to verify the SEO integration is working correctly.",
|
||||
"status": "publish"
|
||||
}'
|
||||
```
|
||||
|
||||
### Step 2: Test SEO Update
|
||||
|
||||
```bash
|
||||
# Test the SEO update
|
||||
curl -X POST "https://your-site.com/wp-json/rank-math-api/v1/update-meta" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-H "Authorization: Basic [credentials]" \
|
||||
-d "post_id=123&rank_math_title=Test SEO Title&rank_math_description=Test SEO description for integration testing&rank_math_focus_keyword=test integration"
|
||||
```
|
||||
|
||||
### Step 3: Verify Results
|
||||
|
||||
1. **Check WordPress admin** for updated SEO metadata
|
||||
2. **View the post** to see the changes
|
||||
3. **Check Rank Math SEO** settings for the post
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### Common Integration Issues
|
||||
|
||||
#### Issue: Authentication Errors
|
||||
|
||||
**Symptoms**: 401 Unauthorized errors
|
||||
**Solutions**:
|
||||
|
||||
- Verify Application Password is correct
|
||||
- Check username spelling
|
||||
- Ensure credentials are properly encoded
|
||||
|
||||
#### Issue: Post Not Found
|
||||
|
||||
**Symptoms**: 404 errors
|
||||
**Solutions**:
|
||||
|
||||
- Verify post ID exists
|
||||
- Check post status (published vs draft)
|
||||
- Ensure post type is supported
|
||||
|
||||
#### Issue: Invalid Data
|
||||
|
||||
**Symptoms**: 400 Bad Request errors
|
||||
**Solutions**:
|
||||
|
||||
- Check parameter names and values
|
||||
- Verify data types
|
||||
- Ensure required fields are provided
|
||||
|
||||
### Debug Mode
|
||||
|
||||
Enable WordPress debug mode for detailed error messages:
|
||||
|
||||
```php
|
||||
// Add to wp-config.php
|
||||
define('WP_DEBUG', true);
|
||||
define('WP_DEBUG_LOG', true);
|
||||
define('WP_DEBUG_DISPLAY', false);
|
||||
```
|
||||
|
||||
### Logging
|
||||
|
||||
Add logging to your integration:
|
||||
|
||||
```javascript
|
||||
// JavaScript logging
|
||||
console.log("API Request:", {
|
||||
url: apiUrl,
|
||||
data: requestData,
|
||||
headers: requestHeaders,
|
||||
});
|
||||
|
||||
console.log("API Response:", response);
|
||||
```
|
||||
|
||||
```php
|
||||
// PHP logging
|
||||
error_log('Rank Math API Request: ' . json_encode($request_data));
|
||||
error_log('Rank Math API Response: ' . json_encode($response));
|
||||
```
|
||||
|
||||
## 📞 Support
|
||||
|
||||
For integration issues:
|
||||
|
||||
1. **Check this documentation**
|
||||
2. **Review error messages**
|
||||
3. **Test with provided examples**
|
||||
4. **Create a GitHub issue** with details
|
||||
5. **Contact support** at [devora.no](https://devora.no)
|
||||
|
||||
### Required Information for Support
|
||||
|
||||
- Integration platform (n8n, Zapier, etc.)
|
||||
- Complete error messages
|
||||
- Request/response data
|
||||
- Steps to reproduce the issue
|
||||
- WordPress and plugin versions
|
||||
|
||||
---
|
||||
|
||||
**Related Documentation**:
|
||||
|
||||
- [Installation Guide](installation.md)
|
||||
- [API Documentation](api-documentation.md)
|
||||
- [Example Use Cases](example-use-cases.md)
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: July 2025
|
||||
**Version**: 1.0.6
|
||||
607
wordpress-plugins/rank-math-api-manager/docs/troubleshooting.md
Normal file
607
wordpress-plugins/rank-math-api-manager/docs/troubleshooting.md
Normal file
@@ -0,0 +1,607 @@
|
||||
# Troubleshooting Guide - Rank Math API Manager Plugin
|
||||
|
||||
## 📋 Overview
|
||||
|
||||
This guide helps you identify and resolve common issues with the Rank Math API Manager plugin. Follow the troubleshooting steps to diagnose and fix problems quickly.
|
||||
|
||||
## 🔍 Quick Diagnostic Checklist
|
||||
|
||||
Before diving into specific issues, run through this checklist:
|
||||
|
||||
- ✅ **Plugin is activated** in WordPress admin
|
||||
- ✅ **Rank Math SEO plugin** is installed and active
|
||||
- ✅ **WordPress REST API** is accessible
|
||||
- ✅ **Application Password** is correctly configured
|
||||
- ✅ **User has `edit_posts` permissions**
|
||||
- ✅ **Post ID exists** and is published
|
||||
- ✅ **HTTPS is enabled** (recommended for security)
|
||||
|
||||
## 🚨 Common Error Codes
|
||||
|
||||
### 401 Unauthorized
|
||||
|
||||
**Error Message**: `"Sorry, you are not allowed to do that."`
|
||||
|
||||
#### Possible Causes:
|
||||
|
||||
1. **Invalid credentials**
|
||||
2. **Missing Application Password**
|
||||
3. **Incorrect username**
|
||||
4. **User lacks permissions**
|
||||
|
||||
#### Solutions:
|
||||
|
||||
**Step 1: Verify Application Password**
|
||||
|
||||
```bash
|
||||
# Test with cURL
|
||||
curl -X POST "https://your-site.com/wp-json/rank-math-api/v1/update-meta" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-H "Authorization: Basic [your-base64-credentials]" \
|
||||
-d "post_id=123&rank_math_title=Test"
|
||||
```
|
||||
|
||||
**Step 2: Check User Permissions**
|
||||
|
||||
1. Go to **Users → All Users**
|
||||
2. Find your user account
|
||||
3. Verify role has `edit_posts` capability
|
||||
4. Check if user is active
|
||||
|
||||
**Step 3: Regenerate Application Password**
|
||||
|
||||
1. Go to **Users → Profile**
|
||||
2. Scroll to "Application Passwords"
|
||||
3. Delete existing password
|
||||
4. Create new Application Password
|
||||
5. Update your integration
|
||||
|
||||
**Step 4: Verify Base64 Encoding**
|
||||
|
||||
```bash
|
||||
# Test encoding
|
||||
echo -n "username:application_password" | base64
|
||||
```
|
||||
|
||||
### 404 Not Found
|
||||
|
||||
**Error Message**: `"No route was found matching the URL and request method"`
|
||||
|
||||
#### Possible Causes:
|
||||
|
||||
1. **Plugin not activated**
|
||||
2. **WordPress REST API disabled**
|
||||
3. **Incorrect endpoint URL**
|
||||
4. **Permalink structure issues**
|
||||
|
||||
#### Solutions:
|
||||
|
||||
**Step 1: Check Plugin Status**
|
||||
|
||||
1. Go to **Plugins → Installed Plugins**
|
||||
2. Verify "Rank Math API Manager" is **Active**
|
||||
3. Check for any error messages
|
||||
|
||||
**Step 2: Test REST API**
|
||||
|
||||
```bash
|
||||
# Test WordPress REST API
|
||||
curl -X GET "https://your-site.com/wp-json/wp/v2/posts"
|
||||
```
|
||||
|
||||
**Step 3: Check Permalinks**
|
||||
|
||||
1. Go to **Settings → Permalinks**
|
||||
2. Select any option other than "Plain"
|
||||
3. Save changes
|
||||
|
||||
**Step 4: Verify Endpoint URL**
|
||||
|
||||
```bash
|
||||
# Test endpoint availability
|
||||
curl -X GET "https://your-site.com/wp-json/rank-math-api/v1/update-meta"
|
||||
```
|
||||
|
||||
Expected response: 404 (confirms endpoint exists but requires POST)
|
||||
|
||||
### 400 Bad Request
|
||||
|
||||
**Error Message**: `"No metadata was updated"`
|
||||
|
||||
#### Possible Causes:
|
||||
|
||||
1. **Missing `post_id`**
|
||||
2. **Invalid post ID**
|
||||
3. **No SEO fields provided**
|
||||
4. **Invalid data format**
|
||||
|
||||
#### Solutions:
|
||||
|
||||
**Step 1: Verify Post ID**
|
||||
|
||||
```bash
|
||||
# Check if post exists
|
||||
curl -X GET "https://your-site.com/wp-json/wp/v2/posts/123"
|
||||
```
|
||||
|
||||
**Step 2: Check Request Format**
|
||||
|
||||
```bash
|
||||
# Ensure proper form data
|
||||
curl -X POST "https://your-site.com/wp-json/rank-math-api/v1/update-meta" \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-H "Authorization: Basic [credentials]" \
|
||||
-d "post_id=123&rank_math_title=Test Title"
|
||||
```
|
||||
|
||||
**Step 3: Verify Post Status**
|
||||
|
||||
1. Go to **Posts → All Posts**
|
||||
2. Find the post by ID
|
||||
3. Ensure status is "Published"
|
||||
|
||||
### 500 Internal Server Error
|
||||
|
||||
**Error Message**: Various server error messages
|
||||
|
||||
#### Possible Causes:
|
||||
|
||||
1. **PHP memory limit exceeded**
|
||||
2. **Plugin conflicts**
|
||||
3. **Server configuration issues**
|
||||
4. **Database connection problems**
|
||||
|
||||
#### Solutions:
|
||||
|
||||
**Step 1: Enable Debug Mode**
|
||||
|
||||
```php
|
||||
// Add to wp-config.php
|
||||
define('WP_DEBUG', true);
|
||||
define('WP_DEBUG_LOG', true);
|
||||
define('WP_DEBUG_DISPLAY', false);
|
||||
```
|
||||
|
||||
**Step 2: Check Error Logs**
|
||||
|
||||
```bash
|
||||
# Check WordPress debug log
|
||||
tail -f wp-content/debug.log
|
||||
|
||||
# Check server error logs
|
||||
tail -f /var/log/apache2/error.log
|
||||
# or
|
||||
tail -f /var/log/nginx/error.log
|
||||
```
|
||||
|
||||
**Step 3: Increase Memory Limit**
|
||||
|
||||
```php
|
||||
// Add to wp-config.php
|
||||
define('WP_MEMORY_LIMIT', '256M');
|
||||
```
|
||||
|
||||
**Step 4: Test Plugin Conflicts**
|
||||
|
||||
1. Deactivate all plugins except Rank Math SEO and Rank Math API Manager
|
||||
2. Test the API endpoint
|
||||
3. Reactivate plugins one by one to identify conflicts
|
||||
|
||||
## 🔧 Integration-Specific Issues
|
||||
|
||||
### n8n Integration Problems
|
||||
|
||||
#### Issue: Authentication Fails in n8n
|
||||
|
||||
**Symptoms**: 401 errors in n8n workflow
|
||||
|
||||
**Solutions**:
|
||||
|
||||
1. **Check Credential Configuration**
|
||||
|
||||
- Verify username and Application Password
|
||||
- Ensure no extra spaces or characters
|
||||
- Test credentials manually first
|
||||
|
||||
2. **Update n8n Node Configuration**
|
||||
|
||||
```json
|
||||
{
|
||||
"authentication": "httpBasicAuth",
|
||||
"username": "your_username",
|
||||
"password": "your_application_password"
|
||||
}
|
||||
```
|
||||
|
||||
3. **Test with Simple Request**
|
||||
|
||||
```json
|
||||
{
|
||||
"method": "POST",
|
||||
"url": "https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
"contentType": "form-urlencoded",
|
||||
"bodyParameters": {
|
||||
"post_id": "123",
|
||||
"rank_math_title": "Test Title"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Issue: Data Mapping Errors
|
||||
|
||||
**Symptoms**: Missing or incorrect data in API calls
|
||||
|
||||
**Solutions**:
|
||||
|
||||
1. **Add Data Validation Node**
|
||||
|
||||
```javascript
|
||||
// Add Code node before HTTP Request
|
||||
const postId = $("Previous Node").first().json.post_id;
|
||||
const seoTitle = $("Previous Node").first().json.seo_title;
|
||||
|
||||
if (!postId || !seoTitle) {
|
||||
throw new Error("Missing required data");
|
||||
}
|
||||
|
||||
return {
|
||||
post_id: postId,
|
||||
rank_math_title: seoTitle,
|
||||
rank_math_description: $("Previous Node").first().json.seo_description || "",
|
||||
rank_math_focus_keyword: $("Previous Node").first().json.focus_keyword || "",
|
||||
};
|
||||
```
|
||||
|
||||
2. **Add Error Handling**
|
||||
|
||||
```javascript
|
||||
// Add Code node after HTTP Request
|
||||
const response = $("HTTP Request").first().json;
|
||||
|
||||
if (response.error) {
|
||||
throw new Error(`API Error: ${response.error}`);
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: response,
|
||||
};
|
||||
```
|
||||
|
||||
### Zapier Integration Problems
|
||||
|
||||
#### Issue: Code Action Fails
|
||||
|
||||
**Symptoms**: JavaScript errors in Zapier
|
||||
|
||||
**Solutions**:
|
||||
|
||||
1. **Add Error Handling**
|
||||
|
||||
```javascript
|
||||
try {
|
||||
const response = await fetch(
|
||||
"https://your-site.com/wp-json/rank-math-api/v1/update-meta",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Authorization: "Basic " + btoa("username:application_password"),
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
post_id: inputData.post_id,
|
||||
rank_math_title: inputData.seo_title,
|
||||
rank_math_description: inputData.seo_description,
|
||||
rank_math_focus_keyword: inputData.focus_keyword,
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`HTTP ${response.status}: ${result.message || "Unknown error"}`
|
||||
);
|
||||
}
|
||||
|
||||
return { success: true, data: result };
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
```
|
||||
|
||||
2. **Validate Input Data**
|
||||
|
||||
```javascript
|
||||
// Validate required fields
|
||||
if (!inputData.post_id) {
|
||||
throw new Error("Post ID is required");
|
||||
}
|
||||
|
||||
if (!inputData.seo_title) {
|
||||
throw new Error("SEO title is required");
|
||||
}
|
||||
```
|
||||
|
||||
### Python Integration Problems
|
||||
|
||||
#### Issue: SSL Certificate Errors
|
||||
|
||||
**Symptoms**: SSL verification failures
|
||||
|
||||
**Solutions**:
|
||||
|
||||
```python
|
||||
import requests
|
||||
import urllib3
|
||||
|
||||
# Disable SSL warnings (not recommended for production)
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
# Make request with SSL verification disabled
|
||||
response = requests.post(url, headers=headers, data=data, verify=False)
|
||||
```
|
||||
|
||||
#### Issue: Connection Timeouts
|
||||
|
||||
**Symptoms**: Request timeouts
|
||||
|
||||
**Solutions**:
|
||||
|
||||
```python
|
||||
import requests
|
||||
|
||||
# Set timeout
|
||||
response = requests.post(url, headers=headers, data=data, timeout=30)
|
||||
|
||||
# Retry logic
|
||||
from requests.adapters import HTTPAdapter
|
||||
from requests.packages.urllib3.util.retry import Retry
|
||||
|
||||
session = requests.Session()
|
||||
retry = Retry(connect=3, backoff_factor=0.5)
|
||||
adapter = HTTPAdapter(max_retries=retry)
|
||||
session.mount('http://', adapter)
|
||||
session.mount('https://', adapter)
|
||||
|
||||
response = session.post(url, headers=headers, data=data)
|
||||
```
|
||||
|
||||
## 🛠️ Advanced Troubleshooting
|
||||
|
||||
### Debug Mode Setup
|
||||
|
||||
**Step 1: Enable WordPress Debug**
|
||||
|
||||
```php
|
||||
// Add to wp-config.php
|
||||
define('WP_DEBUG', true);
|
||||
define('WP_DEBUG_LOG', true);
|
||||
define('WP_DEBUG_DISPLAY', false);
|
||||
define('WP_DEBUG_DISPLAY', false);
|
||||
define('SCRIPT_DEBUG', true);
|
||||
```
|
||||
|
||||
**Step 2: Add Plugin Debug Logging**
|
||||
|
||||
```php
|
||||
// Add to your theme's functions.php or a custom plugin
|
||||
add_action('rest_api_init', function() {
|
||||
error_log('REST API initialized');
|
||||
});
|
||||
|
||||
add_action('wp_rest_server_class', function($class) {
|
||||
error_log('REST server class: ' . $class);
|
||||
});
|
||||
```
|
||||
|
||||
**Step 3: Monitor API Requests**
|
||||
|
||||
```php
|
||||
// Add to your theme's functions.php
|
||||
add_action('rest_api_init', function() {
|
||||
add_filter('rest_pre_dispatch', function($result, $server, $request) {
|
||||
error_log('API Request: ' . $request->get_route());
|
||||
error_log('API Method: ' . $request->get_method());
|
||||
error_log('API Params: ' . json_encode($request->get_params()));
|
||||
return $result;
|
||||
}, 10, 3);
|
||||
});
|
||||
```
|
||||
|
||||
### Performance Issues
|
||||
|
||||
#### Issue: Slow API Responses
|
||||
|
||||
**Solutions**:
|
||||
|
||||
1. **Optimize Database Queries**
|
||||
|
||||
```php
|
||||
// Add to wp-config.php
|
||||
define('SAVEQUERIES', true);
|
||||
```
|
||||
|
||||
2. **Check Server Resources**
|
||||
|
||||
```bash
|
||||
# Monitor server resources
|
||||
htop
|
||||
free -h
|
||||
df -h
|
||||
```
|
||||
|
||||
3. **Enable Caching**
|
||||
|
||||
```php
|
||||
// Add caching headers
|
||||
add_action('rest_api_init', function() {
|
||||
add_filter('rest_post_dispatch', function($response, $handler, $request) {
|
||||
$response->header('Cache-Control', 'public, max-age=300');
|
||||
return $response;
|
||||
}, 10, 3);
|
||||
});
|
||||
```
|
||||
|
||||
### Security Issues
|
||||
|
||||
#### Issue: Unauthorized Access Attempts
|
||||
|
||||
**Solutions**:
|
||||
|
||||
1. **Implement Rate Limiting**
|
||||
|
||||
```php
|
||||
// Add rate limiting
|
||||
add_action('rest_api_init', function() {
|
||||
add_filter('rest_pre_dispatch', function($result, $server, $request) {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
$key = 'api_rate_limit_' . $ip;
|
||||
$count = get_transient($key);
|
||||
|
||||
if ($count && $count > 100) {
|
||||
return new WP_Error('rate_limit_exceeded', 'Rate limit exceeded', ['status' => 429]);
|
||||
}
|
||||
|
||||
set_transient($key, ($count ? $count + 1 : 1), 3600);
|
||||
return $result;
|
||||
}, 10, 3);
|
||||
});
|
||||
```
|
||||
|
||||
2. **Log Security Events**
|
||||
|
||||
```php
|
||||
// Log failed authentication attempts
|
||||
add_action('rest_authentication_errors', function($result) {
|
||||
if ($result !== null) {
|
||||
error_log('Failed API authentication attempt from IP: ' . $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
return $result;
|
||||
});
|
||||
```
|
||||
|
||||
## 📊 Monitoring and Logging
|
||||
|
||||
### Set Up Monitoring
|
||||
|
||||
**Step 1: Create Health Check Endpoint**
|
||||
|
||||
```php
|
||||
// Add to your plugin
|
||||
add_action('rest_api_init', function() {
|
||||
register_rest_route('rank-math-api/v1', '/health', [
|
||||
'methods' => 'GET',
|
||||
'callback' => function() {
|
||||
return [
|
||||
'status' => 'healthy',
|
||||
'timestamp' => current_time('mysql'),
|
||||
'version' => '1.0.6'
|
||||
];
|
||||
},
|
||||
'permission_callback' => '__return_true'
|
||||
]);
|
||||
});
|
||||
```
|
||||
|
||||
**Step 2: Monitor API Usage**
|
||||
|
||||
```php
|
||||
// Track API usage
|
||||
add_action('rest_api_init', function() {
|
||||
add_filter('rest_post_dispatch', function($response, $handler, $request) {
|
||||
if (strpos($request->get_route(), 'rank-math-api') !== false) {
|
||||
$usage = get_option('rank_math_api_usage', []);
|
||||
$date = date('Y-m-d');
|
||||
$usage[$date] = ($usage[$date] ?? 0) + 1;
|
||||
update_option('rank_math_api_usage', $usage);
|
||||
}
|
||||
return $response;
|
||||
}, 10, 3);
|
||||
});
|
||||
```
|
||||
|
||||
### Log Analysis
|
||||
|
||||
**Step 1: Parse WordPress Debug Log**
|
||||
|
||||
```bash
|
||||
# Find API-related errors
|
||||
grep "rank-math-api" wp-content/debug.log
|
||||
|
||||
# Find authentication errors
|
||||
grep "authentication" wp-content/debug.log
|
||||
|
||||
# Find recent errors
|
||||
tail -n 100 wp-content/debug.log | grep "ERROR"
|
||||
```
|
||||
|
||||
**Step 2: Monitor Server Logs**
|
||||
|
||||
```bash
|
||||
# Apache error logs
|
||||
tail -f /var/log/apache2/error.log | grep "your-domain.com"
|
||||
|
||||
# Nginx error logs
|
||||
tail -f /var/log/nginx/error.log | grep "your-domain.com"
|
||||
```
|
||||
|
||||
## 🆘 Getting Help
|
||||
|
||||
### Before Contacting Support
|
||||
|
||||
1. **Collect Information**:
|
||||
|
||||
- WordPress version
|
||||
- Plugin version
|
||||
- PHP version
|
||||
- Server environment
|
||||
- Complete error messages
|
||||
- Request/response data
|
||||
|
||||
2. **Test with Minimal Setup**:
|
||||
|
||||
- Deactivate other plugins
|
||||
- Switch to default theme
|
||||
- Test with basic cURL request
|
||||
|
||||
3. **Check Known Issues**:
|
||||
- Review GitHub issues
|
||||
- Check documentation
|
||||
- Search community forums
|
||||
|
||||
### Contact Information
|
||||
|
||||
- **GitHub Issues**: [Create an issue](https://github.com/devora-as/rank-math-api-manager/issues)
|
||||
- **Email Support**: [devora.no](https://devora.no)
|
||||
- **Documentation**: [docs/](docs/)
|
||||
|
||||
### Required Information for Support
|
||||
|
||||
When contacting support, include:
|
||||
|
||||
```
|
||||
WordPress Version: X.X.X
|
||||
Plugin Version: X.X.X
|
||||
PHP Version: X.X.X
|
||||
Server: Apache/Nginx
|
||||
Error Message: [Complete error message]
|
||||
Request Data: [API request details]
|
||||
Response Data: [API response details]
|
||||
Steps to Reproduce: [Detailed steps]
|
||||
Environment: [Local/Staging/Production]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Related Documentation**:
|
||||
|
||||
- [Installation Guide](installation.md)
|
||||
- [API Documentation](api-documentation.md)
|
||||
- [Integration Guide](integration-guide.md)
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: July 2025
|
||||
**Version**: 1.0.6
|
||||
1119
wordpress-plugins/rank-math-api-manager/rank-math-api-manager.php
Normal file
1119
wordpress-plugins/rank-math-api-manager/rank-math-api-manager.php
Normal file
File diff suppressed because it is too large
Load Diff
67
wordpress-plugins/rank-math-api-manager/readme.txt
Normal file
67
wordpress-plugins/rank-math-api-manager/readme.txt
Normal file
@@ -0,0 +1,67 @@
|
||||
=== Rank Math API Manager ===
|
||||
Contributors: devoraas
|
||||
Tags: seo, rank-math, api, rest-api, automation
|
||||
Requires at least: 5.0
|
||||
Tested up to: 6.8
|
||||
Requires PHP: 7.4
|
||||
Stable tag: 1.0.7
|
||||
License: GPLv3 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
WordPress extension that exposes REST API endpoints to update Rank Math SEO metadata programmatically.
|
||||
|
||||
== Description ==
|
||||
|
||||
This extension enhances the WordPress REST API with custom endpoints that allow external systems (such as n8n workflows) to update Rank Math SEO fields directly via API calls.
|
||||
|
||||
= Features =
|
||||
|
||||
* REST API endpoints for Rank Math metadata
|
||||
* Support for SEO Title, Description, Canonical URL, and Focus Keyword
|
||||
* Dependency checking for Rank Math SEO
|
||||
* Secure API access with proper authentication
|
||||
* Compatible with WordPress posts and WooCommerce products
|
||||
|
||||
= Requirements =
|
||||
|
||||
* WordPress 5.0 or higher
|
||||
* PHP 7.4 or higher
|
||||
* Rank Math SEO extension
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Download the extension from GitHub
|
||||
2. Upload to your WordPress site
|
||||
3. Activate the extension
|
||||
4. Ensure Rank Math SEO is installed and active
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Does this work with WordPress.org? =
|
||||
|
||||
This extension is currently distributed via GitHub only.
|
||||
|
||||
= What Rank Math fields are supported? =
|
||||
|
||||
* SEO Title (rank_math_title)
|
||||
* SEO Description (rank_math_description)
|
||||
* Canonical URL (rank_math_canonical_url)
|
||||
* Focus Keyword (rank_math_focus_keyword)
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0.7 =
|
||||
* Added dependency checking system
|
||||
* Improved security and validation
|
||||
* Enhanced admin notices
|
||||
* Fixed Plugin Check compatibility issues
|
||||
|
||||
= 1.0.6 =
|
||||
* Initial stable release
|
||||
* Basic REST API functionality
|
||||
* Core SEO field support
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 1.0.7 =
|
||||
This version includes important security improvements and dependency checking.
|
||||
Reference in New Issue
Block a user