Add themes, plugins, ...

master
root 2 years ago
parent 1351889ff5
commit 9234c6ca3a
  1. 46
      php-fpm/wordpress_files/plugins/add-meta-tags/AUTHORS
  2. 39
      php-fpm/wordpress_files/plugins/add-meta-tags/CONTRIBUTORS
  3. 202
      php-fpm/wordpress_files/plugins/add-meta-tags/LICENSE
  4. 22
      php-fpm/wordpress_files/plugins/add-meta-tags/NOTICE
  5. 47
      php-fpm/wordpress_files/plugins/add-meta-tags/README.rst
  6. 882
      php-fpm/wordpress_files/plugins/add-meta-tags/add-meta-tags.php
  7. 1353
      php-fpm/wordpress_files/plugins/add-meta-tags/add-meta-tags.pot
  8. 2636
      php-fpm/wordpress_files/plugins/add-meta-tags/amt-admin-panel.php
  9. 580
      php-fpm/wordpress_files/plugins/add-meta-tags/amt-cli.php
  10. 292
      php-fpm/wordpress_files/plugins/add-meta-tags/amt-embed.php
  11. 404
      php-fpm/wordpress_files/plugins/add-meta-tags/amt-settings.php
  12. 266
      php-fpm/wordpress_files/plugins/add-meta-tags/amt-template-tags.php
  13. 4436
      php-fpm/wordpress_files/plugins/add-meta-tags/amt-utils.php
  14. 1
      php-fpm/wordpress_files/plugins/add-meta-tags/css/README.txt
  15. 18
      php-fpm/wordpress_files/plugins/add-meta-tags/css/amt-metabox-tabs.css
  16. 115
      php-fpm/wordpress_files/plugins/add-meta-tags/css/amt-metadata-review-mode.css
  17. 27
      php-fpm/wordpress_files/plugins/add-meta-tags/css/amt-settings.css
  18. 3
      php-fpm/wordpress_files/plugins/add-meta-tags/index.php
  19. 1
      php-fpm/wordpress_files/plugins/add-meta-tags/js/README.txt
  20. 99
      php-fpm/wordpress_files/plugins/add-meta-tags/js/amt-image-selector.js
  21. 23
      php-fpm/wordpress_files/plugins/add-meta-tags/js/amt-metadata-review-mode-enhanced.js
  22. 19
      php-fpm/wordpress_files/plugins/add-meta-tags/js/amt-metadata-review-mode.js
  23. 646
      php-fpm/wordpress_files/plugins/add-meta-tags/metadata/amt_basic.php
  24. 282
      php-fpm/wordpress_files/plugins/add-meta-tags/metadata/amt_dublin_core.php
  25. 2642
      php-fpm/wordpress_files/plugins/add-meta-tags/metadata/amt_extended.php
  26. 1093
      php-fpm/wordpress_files/plugins/add-meta-tags/metadata/amt_opengraph.php
  27. 3190
      php-fpm/wordpress_files/plugins/add-meta-tags/metadata/amt_schemaorg.php
  28. 1001
      php-fpm/wordpress_files/plugins/add-meta-tags/metadata/amt_twitter_cards.php
  29. 232
      php-fpm/wordpress_files/plugins/add-meta-tags/readme.txt
  30. 43
      php-fpm/wordpress_files/plugins/add-meta-tags/templates/amt-embed-audio-template.php
  31. 51
      php-fpm/wordpress_files/plugins/add-meta-tags/templates/amt-embed-video-template.php
  32. 46
      php-fpm/wordpress_files/plugins/add-meta-tags/uninstall.php
  33. 22
      php-fpm/wordpress_files/plugins/add-meta-tags/wpml-config.xml
  34. 49
      php-fpm/wordpress_files/plugins/attachment-importer/README.md
  35. 1199
      php-fpm/wordpress_files/plugins/attachment-importer/inc/jquery-ui.css
  36. 8
      php-fpm/wordpress_files/plugins/attachment-importer/inc/style.css
  37. 329
      php-fpm/wordpress_files/plugins/attachment-importer/index.php
  38. 226
      php-fpm/wordpress_files/plugins/attachment-importer/main.js
  39. 83
      php-fpm/wordpress_files/plugins/attachment-importer/readme.txt
  40. 172
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/client.php
  41. 172
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/form.tpl.php
  42. 1
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/img/donate.svg
  43. BIN
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/img/patron.png
  44. BIN
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/img/paypal.png
  45. 45
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/img/post/direct.svg
  46. 46
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/img/post/private.svg
  47. 56
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/img/post/public.svg
  48. 47
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/img/post/unlisted.svg
  49. 9
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/instanceList.php
  50. 41
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/js/settings_page.js
  51. BIN
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.mo
  52. 114
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.po
  53. BIN
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-nl_NL.mo
  54. 110
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-nl_NL.po
  55. 620
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/mastodon_autopost.php
  56. 184
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/readme.txt
  57. 196
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/style.css
  58. 24
      php-fpm/wordpress_files/plugins/autopost-to-mastodon/uninstall.php
  59. 9
      php-fpm/wordpress_files/plugins/backwpup/.htaccess
  60. 339
      php-fpm/wordpress_files/plugins/backwpup/LICENSE
  61. 1
      php-fpm/wordpress_files/plugins/backwpup/assets/css/main.min.css
  62. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/fonts/backwpup.eot
  63. 11
      php-fpm/wordpress_files/plugins/backwpup/assets/fonts/backwpup.svg
  64. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/fonts/backwpup.ttf
  65. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/fonts/backwpup.woff
  66. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/current.png
  67. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/erroreven.png
  68. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/errorhover.png
  69. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/errorodd.png
  70. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/even.png
  71. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/execute.png
  72. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/help.png
  73. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/hgbox.png
  74. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/hgboxleft.png
  75. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/hgbtgreen.png
  76. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/hgbtgreenhover.png
  77. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/hgbtred.png
  78. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/hgbtredhover.png
  79. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/hgtopgreen.png
  80. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/hover.png
  81. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/imagecloud.png
  82. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/imagedata.png
  83. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/imagesave.png
  84. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/imagesec.png
  85. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/imagexml.png
  86. 1
      php-fpm/wordpress_files/plugins/backwpup/assets/images/inpsyde.svg
  87. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/odd.png
  88. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/progressbarhg.jpg
  89. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/tickeven.png
  90. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/tickhover.png
  91. BIN
      php-fpm/wordpress_files/plugins/backwpup/assets/images/tickodd.png
  92. 285
      php-fpm/wordpress_files/plugins/backwpup/assets/js/backup-downloader.js
  93. 1
      php-fpm/wordpress_files/plugins/backwpup/assets/js/backup-downloader.min.js
  94. 44
      php-fpm/wordpress_files/plugins/backwpup/assets/js/general.js
  95. 1
      php-fpm/wordpress_files/plugins/backwpup/assets/js/general.min.js
  96. 53
      php-fpm/wordpress_files/plugins/backwpup/assets/js/notice.js
  97. 1
      php-fpm/wordpress_files/plugins/backwpup/assets/js/notice.min.js
  98. 97
      php-fpm/wordpress_files/plugins/backwpup/assets/js/page_edit_jobtype_dbdump.js
  99. 1
      php-fpm/wordpress_files/plugins/backwpup/assets/js/page_edit_jobtype_dbdump.min.js
  100. 73
      php-fpm/wordpress_files/plugins/backwpup/assets/js/page_edit_jobtype_file.js
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,46 @@
= Developers =
The ``Add-Meta-Tags`` plugin for WordPress has been developed by:
George Notaras <gnot@g-loaded.eu>
Sponsored by:
- http://www.g-loaded.eu
- http://www.codetrax.org
= Translations =
There is an ongoing effort to translate Add-Meta-Tags to as many languages as
possible at the translations project on the Transifex service:
- https://www.transifex.com/projects/p/add-meta-tags
A big THANK YOU to all contributors of the project!
= Top Donators =
TODO: list top donators here. (Ask permission?)
= Contributors =
A big THANK YOU to all who have provided feedback, corrections, suggestions,
feature requests at:
* the old plugin home page:
- http://www.g-loaded.eu/2006/01/05/add-meta-tags-wordpress-plugin/
- http://www.g-loaded.eu/2006/01/05/add-meta-tags-legacy/
* bug trackers at:
- CodeTRAX: http://www.codetrax.org/projects/wp-add-meta-tags/issues
- Bitbucket: https://bitbucket.org/gnotaras/wordpress-add-meta-tags/overview
- Github: https://github.com/gnotaras/wordpress-add-meta-tags
* the Community support forums at WordPress.org:
- http://wordpress.org/support/plugin/add-meta-tags
* through email, although they should have used one of the methods above! ;)

@ -0,0 +1,39 @@
Contributors
============
This file contains a list of individuals or companies which have contributed
to this project over the years in one way or another, including donations,
patches and bug reports.
Top Contributors
----------------
TODO
Contributors
------------
TODO
* Dan Rossiter
* SpeKopuZ
* theblade24
* BHopkins
* Rick
* Barmala
* Chris
* James
* Ronald
* Christian
* moeffju
* marhgil
* Sam
* Jan Teriete
* Marie-Laure Bouchet
* dandv
* morethanwords
* anve
* Ed Glaser

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

@ -0,0 +1,22 @@
This product includes software developed at:
- G-loaded Journal (http://www.g-loaded.eu/)
- CodeTRAX (http://www.codetrax.org/)
Copyright 2006-2016 George Notaras <gnot@g-loaded.eu>, CodeTRAX.org
The following brand names must not appear in the names of products derived
from this software or in the names of products that extend the functionality
of this software:
* add-meta-tags
* CodeTRAX
* G-Loaded
* G-Loaded Journal
For licensing information, please read the LICENSE file. Alternatively, please
read the full license text online at:
http://www.apache.org/licenses/LICENSE-2.0
WordPress is a registered trademark of Automattic Inc.

@ -0,0 +1,47 @@
Add-Meta-Tags
=============
Add-Meta-Tags (AMT) is a Free open-source plugin for the WordPress Publishing
Platform that generates *metadata* for your content and WooCommerce products,
including the basic *description* and *keywords* meta tags, Opengraph, Schema.org,
Twitter Cards and Dublin Core metadata.
It also supports advanced *SEO title* customization letting you take control of
the title generation on every part of the web site. Moreover, a basic *breadcrumb
trail* generator is provided for use with hierarchical post types. Last, but not
least, it lets you customize the *locale* on a per post basis generating a proper
*hreflang* for a signle language and, also, is out-of-the-box compatible with
WPML and Polylang multilingual plugins (through the WPML language configuration
file that ships with the plugin).
Add-Meta-Tags is one of the personal software projects of George Notaras.
It is developed in his free time and released to the open source WordPress
community as Free software.
Please visit the `official Add-Meta-Tags development web site`_ for more information.
It is actively maintained since 2006 (`historical Add-Meta-Tags homepage`_).
.. _`official Add-Meta-Tags development web site`: http://www.codetrax.org/projects/wp-add-meta-tags
.. _`historical Add-Meta-Tags homepage`: http://www.g-loaded.eu/2006/01/05/add-meta-tags-wordpress-plugin/
Legal Notice
------------
Add-Meta-Tags is Copyright (c) 2006-2016 George Notaras. All rights reserved.
Permission is granted to use this software under the terms of the `Apache
License version 2`_ and the NOTICE file that ships with the distribution package.
.. _`Apache License version 2`: http://www.apache.org/licenses/LICENSE-2.0
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH
THE SOFTWARE.
WordPress is a registered trademark of Automattic Inc.

@ -0,0 +1,882 @@
<?php
/*
Plugin Name: Add Meta Tags
Plugin URI: http://www.g-loaded.eu/2006/01/05/add-meta-tags-wordpress-plugin/
Description: Add basic meta tags and also Opengraph, Schema.org Microdata, Twitter Cards and Dublin Core metadata to optimize your web site for better SEO.
Version: 2.11.3
Author: George Notaras
Author URI: http://www.g-loaded.eu/
License: Apache License v2
Text Domain: add-meta-tags
Domain Path: /languages/
*/
/**
* This file is part of the Add-Meta-Tags distribution package.
*
* Add-Meta-Tags is an extension for the WordPress publishing platform.
*
* Homepage:
* - http://wordpress.org/plugins/add-meta-tags/
* Documentation:
* - http://www.codetrax.org/projects/wp-add-meta-tags/wiki
* Development Web Site and Bug Tracker:
* - http://www.codetrax.org/projects/wp-add-meta-tags
* Main Source Code Repository (Mercurial):
* - https://bitbucket.org/gnotaras/wordpress-add-meta-tags
* Mirror repository (Git):
* - https://github.com/gnotaras/wordpress-add-meta-tags
* Historical plugin home:
* - http://www.g-loaded.eu/2006/01/05/add-meta-tags-wordpress-plugin/
*
* Licensing Information
*
* Copyright 2006-2016 George Notaras <gnot@g-loaded.eu>, CodeTRAX.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* The NOTICE file contains additional licensing and copyright information.
*/
// Prevent direct access to this file.
if ( ! defined( 'ABSPATH' ) ) {
header( 'HTTP/1.0 403 Forbidden' );
echo 'This file should not be accessed directly!';
exit; // Exit if accessed directly
}
// Store plugin main file path
define( 'AMT_PLUGIN_FILE', __FILE__ );
// Store plugin directory
// NOTE: TODO: Consider using __DIR__ (requires PHP >=5.3) instead of dirname.
// See: http://stackoverflow.com/questions/2220443/whats-better-of-requiredirname-file-myparent-php-than-just-require#comment18170996_12129877
//define( 'AMT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'AMT_PLUGIN_DIR', dirname(AMT_PLUGIN_FILE) . '/' );
// Import modules
require( AMT_PLUGIN_DIR . 'amt-settings.php' );
require( AMT_PLUGIN_DIR . 'amt-admin-panel.php' );
require( AMT_PLUGIN_DIR . 'amt-utils.php' );
require( AMT_PLUGIN_DIR . 'amt-template-tags.php' );
require( AMT_PLUGIN_DIR . 'amt-embed.php' );
require( AMT_PLUGIN_DIR . 'metadata/amt_basic.php' );
require( AMT_PLUGIN_DIR . 'metadata/amt_twitter_cards.php' );
require( AMT_PLUGIN_DIR . 'metadata/amt_opengraph.php' );
require( AMT_PLUGIN_DIR . 'metadata/amt_dublin_core.php' );
require( AMT_PLUGIN_DIR . 'metadata/amt_schemaorg.php' );
require( AMT_PLUGIN_DIR . 'metadata/amt_extended.php' );
// Command Line Interface via WPCLI
require( AMT_PLUGIN_DIR . 'amt-cli.php' );
/**
* Translation Domain
*
* Translation files are searched in: wp-content/plugins
*/
//load_plugin_textdomain('add-meta-tags', false, dirname( plugin_basename( AMT_PLUGIN_FILE ) ) . '/languages/');
//load_plugin_textdomain('add-meta-tags', false, AMT_PLUGIN_DIR . 'languages/');
// For language packs check:
load_plugin_textdomain('add-meta-tags');
/**
* Settings Link in the ``Installed Plugins`` page
*/
function amt_plugin_actions( $links, $file ) {
if( $file == plugin_basename( AMT_PLUGIN_FILE ) && function_exists( "admin_url" ) ) {
$settings_link = '<a href="' . admin_url( 'options-general.php?page=add-meta-tags-options' ) . '">' . __('Settings') . '</a>';
// Add the settings link before other links
array_unshift( $links, $settings_link );
}
return $links;
}
add_filter( 'plugin_action_links', 'amt_plugin_actions', 10, 2 );
//
// Adds prefixes to the html element of the page
// ex xmlns
//
function amt_add_html_prefixes_and_namespaces( $content ) {
$options = amt_get_options();
$prefixes = array();
if ( $options['og_add_xml_namespaces'] == '1' ) {
$prefixes['og'] = 'http://ogp.me/ns#';
$prefixes['fb'] = 'https://www.facebook.com/2008/fbml';
}
// Dublin Core
// See: http://wiki.dublincore.org/index.php/Dublin_Core_Prefixes
if ( $options['dc_add_xml_namespaces'] == '1' ) {
$prefixes['dcterms'] = 'http://purl.org/dc/terms/';
}
// Generate the value of the prefix attribute
$prefix_value = '';
foreach ( $prefixes as $key => $val ) {
$prefix_value .= sprintf(' %s: %s', $key, $val);
}
// return the final attributes
$output = '';
// Although not necessary in HTML 5, we also add the xmlns="http://www.w3.org/1999/xhtml"
// Comment out if duplicate
$output .= ' xmlns="http://www.w3.org/1999/xhtml"';
// Add our prefixes
$output .= ' prefix="' . trim($prefix_value) . '"';
return $output . ' ' . $content;
}
add_filter('language_attributes', 'amt_add_html_prefixes_and_namespaces');
/**
* Replaces the text to be used in the title element, if a replacement text has been set.
*/
// function amt_custom_title_tag($title, $separator) {
function amt_custom_title_tag($title) {
// var_dump($title);
if ( is_feed() || is_search() || is_404() ) {
return $title;
}
// Get the options
$options = get_option('add_meta_tags_opts');
// Get current post object
$post = amt_get_queried_object();
$processed_title = amt_get_title_for_title_element($options, $post);
if ( ! empty($processed_title) ) {
if ( is_array($title) ) {
// WP >= 4.4
$processed_title = str_replace('%title%', $title['title'], $processed_title);
return array('title' => esc_attr($processed_title));
} else {
// WP < 4.4
$processed_title = str_replace('%title%', $title, $processed_title);
return esc_attr($processed_title);
}
}
// WordPress adds multipage information if a custom title is not set.
return $title;
}
// Both filter hooks are used so as to support themes with the 'title-tag' feature
// and also themes that generate the title using the 'wp_title()' template function.
add_filter('document_title_parts', 'amt_custom_title_tag', 9999, 1);
if ( apply_filters('amt_enable_legacy_title_support', true) ) {
add_filter('wp_title', 'amt_custom_title_tag', 9999, 1);
}
// if ( version_compare( get_bloginfo('version'), '4.4', '>=' ) ) {
// Since WP 4.4
// - https://make.wordpress.org/core/2015/10/20/document-title-in-4-4/
// add_filter('document_title_parts', 'amt_custom_title_tag', 9999, 1);
// } else {
// add_filter('wp_title', 'amt_custom_title_tag', 1000, 2);
// Reverting back to the one argument version of the fitlering function.
// add_filter('wp_title', 'amt_custom_title_tag', 9999, 1);
// }
/**
* Sets the correct lang attribute of the html element of the page,
* according to the content's locale.
*/
function amt_set_html_lang_attribute( $lang ) {
//var_dump($lang);
$options = get_option('add_meta_tags_opts');
if ( ! is_array($options) ) {
return $lang;
} elseif ( ! array_key_exists( 'manage_html_lang_attribute', $options) ) {
return $lang;
} elseif ( $options['manage_html_lang_attribute'] == '0' ) {
return $lang;
}
// Set the html lang attribute according to the locale
$locale = '';
if ( is_singular() ) {
$post = amt_get_queried_object();
// Store locale
$locale = str_replace( '_', '-', amt_get_language_content($options, $post) );
} else {
$locale = str_replace( '_', '-', amt_get_language_site($options) );
}
// Allow filtering
$locale = apply_filters( 'amt_wordpress_lang', $locale );
if ( ! empty($locale) ) {
// Replace WordPress locale with ours. (even if it's the same)
$lang = str_replace( get_bloginfo('language'), $locale, $lang );
}
return $lang;
}
add_filter( 'language_attributes', 'amt_set_html_lang_attribute' );
/**
* Returns an array of all the generated metadata for the head area.
*/
function amt_get_metadata_head($post, $options) {
$do_add_metadata = true;
$metadata_arr = array();
// No metadata for password protected posts.
if ( post_password_required() ) {
return $metadata_arr;
}
// Robots Meta Tag content.
$robots_content = '';
// Check for NOINDEX,FOLLOW on archives.
// There is no need to further process metadata as we explicitly ask search
// engines not to index the content.
if ( is_archive() || is_search() ) {
if (
( is_search() && ($options["noindex_search_results"] == "1") ) || // Search results
( is_date() && ($options["noindex_date_archives"] == "1") ) || // Date and time archives
( is_category() && is_paged() && ($options["noindex_category_archives"] == "1") ) || // Category archives (except 1st page)
( is_tag() && is_paged() && ($options["noindex_tag_archives"] == "1") ) || // Tag archives (except 1st page)
( is_tax() && is_paged() && ($options["noindex_taxonomy_archives"] == "1") ) || // Custom taxonomy archives (except 1st page)
( is_author() && is_paged() && ($options["noindex_author_archives"] == "1") ) // Author archives (except 1st page)
) {
$do_add_metadata = false; // No need to process metadata
// $robots_content is old. Should remove.
////$robots_content = 'NOINDEX,FOLLOW';
// Allow filtering of the robots meta tag content.
// Dev Note: Filtering of the robots meta tag takes place here, so as to avoid double filtering in case $do_add_metadata is true.
////$robots_content = apply_filters( 'amt_robots_data', $robots_content );
$robots_options = array( 'noindex', 'follow' );
// Allow filtering of the robots meta tag content.
// Dev Note: Filtering of the robots meta tag takes place here, so as to avoid double filtering in case $do_add_metadata is true.
$robots_options = apply_filters( 'amt_robots_options_noindex', $robots_options );
}
}
// Add a robots meta tag if its content is not empty.
if ( ! empty( $robots_options ) ) {
$metadata_arr[] = '<meta name="robots" content="' . implode(',', $robots_options) . '" />';
}
// Check post object
if ( is_null( $post ) ) {
// Allow metadata on the default front page (latest posts).
// A post object is not available on that page, but we still need to
// generate metadata for it. A $post object exists for the "front page"
// and the "posts page" when static pages are used. No allow rule needed.
if ( ! amt_is_default_front_page() ) {
$do_add_metadata = false;
}
} elseif ( is_singular() ) {
// The post type check should only take place on content pages.
// Check if metadata should be added to this content type.
$post_type = get_post_type( $post );
if ( ! in_array( $post_type, amt_get_supported_post_types() ) ) {
$do_add_metadata = false;
}
}
// Add Metadata
if ($do_add_metadata) {
// Attachments and embedded media are collected only on content pages.
if ( is_singular() ) {
// Get an array containing the attachments
$attachments = amt_get_ordered_attachments( $post );
//var_dump($attachments);
// Get an array containing the URLs of the embedded media
$embedded_media = amt_get_embedded_media( $post );
//var_dump($embedded_media);
} else {
$attachments = array();
$embedded_media = array();
}
// Basic Meta tags
$metadata_arr = array_merge( $metadata_arr, amt_add_basic_metadata_head( $post, $attachments, $embedded_media, $options ) );
//var_dump(amt_add_basic_metadata());
// Add Opengraph
$metadata_arr = array_merge( $metadata_arr, amt_add_opengraph_metadata_head( $post, $attachments, $embedded_media, $options ) );
// Add Twitter Cards
$metadata_arr = array_merge( $metadata_arr, amt_add_twitter_cards_metadata_head( $post, $attachments, $embedded_media, $options ) );
// Add Dublin Core
$metadata_arr = array_merge( $metadata_arr, amt_add_dublin_core_metadata_head( $post, $attachments, $embedded_media, $options ) );
// Add Google+ Author/Publisher links
$metadata_arr = array_merge( $metadata_arr, amt_add_schemaorg_metadata_head( $post, $attachments, $embedded_media, $options ) );
// Add JSON+LD Schema.org
$metadata_arr = array_merge( $metadata_arr, amt_add_jsonld_schemaorg_metadata_head( $post, $attachments, $embedded_media, $options ) );
}
// Allow filtering of the all the generated metatags
$metadata_arr = apply_filters( 'amt_metadata_head', $metadata_arr );
return $metadata_arr;
}
/**
* Prints the generated metadata for the head area.
*/
function amt_add_metadata_head() {
// For AMT timings
$t = microtime(true);
// Get the options the DB
$options = get_option("add_meta_tags_opts");
// Get current post object
$post = amt_get_queried_object();
// Caching indicator
$is_cached = 'no';
// Get the metadata
if ( absint($options['transient_cache_expiration']) > 0 && apply_filters('amt_enable_metadata_cache', true) ) {
$metadata_arr = amt_get_transient_cache($post, $options, $where='head');
if ( empty($metadata_arr) ) {
$metadata_arr = amt_get_metadata_head($post, $options);
// Cache the metadata
if ( ! empty($metadata_arr) ) {
amt_set_transient_cache($post, $options, $metadata_arr, $where='head');
}
} else {
$is_cached = 'yes';
}
} else {
$metadata_arr = amt_get_metadata_head($post, $options);
}
// For AMT timings
if ( ! empty($metadata_arr) && $options['enable_timings'] == '1' ) {
array_unshift( $metadata_arr, sprintf( '<!-- Add-Meta-Tags Timings (milliseconds) - Block total time: %.3f msec - Cached: %s -->', (microtime(true) - $t) * 1000, $is_cached ) );
}
// Add our comment
if ( $options["omit_vendor_html_comments"] == "0" ) {
if ( count( $metadata_arr ) > 0 ) {
array_unshift( $metadata_arr, "<!-- BEGIN Metadata added by the Add-Meta-Tags WordPress plugin -->" );
array_push( $metadata_arr, "<!-- END Metadata added by the Add-Meta-Tags WordPress plugin -->" );
}
}
// Return complete metadata array
return $metadata_arr;
}
function amt_print_head_block() {
// Get the options the DB
$options = get_option("add_meta_tags_opts");
if ( amt_check_run_metadata_review_code($options) ) {
// Here we use non persistent caching in order to be able to use the same output in the review mode.
// Non persistent object cache
$amtcache_key = amt_get_amtcache_key('amt_metadata_block_head');
$metadata_block_head = wp_cache_get( $amtcache_key, $group='add-meta-tags' );
if ( $metadata_block_head === false ) {
$metadata_block_head = amt_add_metadata_head();
// Cache even empty
wp_cache_add( $amtcache_key, $metadata_block_head, $group='add-meta-tags' );
}
} else {
$metadata_block_head = amt_add_metadata_head();
}
// Print the metadata block
echo PHP_EOL . implode( PHP_EOL, $metadata_block_head ) . PHP_EOL . PHP_EOL;
}
add_action('wp_head', 'amt_print_head_block', 0);
// AMP page
//if ( function_exists('is_amp_endpoint') && is_amp_endpoint() ) {
add_action('amp_post_template_head', 'amt_print_head_block', 0);
//}
/**
* Returns an array of all the generated metadata for the footer area.
*/
function amt_get_metadata_footer($post, $options) {
$do_add_metadata = true;
$metadata_arr = array();
// Check post object
if ( is_null( $post ) ) {
// Allow metadata on the default front page (latest posts).
// A post object is not available on that page, but we still need to
// generate metadata for it. A $post object exists for the "front page"
// and the "posts page" when static pages are used. No allow rule needed.
if ( ! amt_is_default_front_page() ) {
$do_add_metadata = false;
}
} elseif ( is_singular() ) {
// The post type check should only take place on content pages.
// Check if metadata should be added to this content type.
$post_type = get_post_type( $post );
if ( ! in_array( $post_type, amt_get_supported_post_types() ) ) {
$do_add_metadata = false;
}
}
// Add Metadata
if ($do_add_metadata) {
// Attachments and embedded media are collected only on content pages.
if ( is_singular() ) {
// Get an array containing the attachments
$attachments = amt_get_ordered_attachments( $post );
//var_dump($attachments);
// Get an array containing the URLs of the embedded media
$embedded_media = amt_get_embedded_media( $post );
//var_dump($embedded_media);
} else {
$attachments = array();
$embedded_media = array();
}
// Add Schema.org Microdata
$metadata_arr = array_merge( $metadata_arr, amt_add_schemaorg_metadata_footer( $post, $attachments, $embedded_media, $options ) );
}
// Allow filtering of all the generated metatags
$metadata_arr = apply_filters( 'amt_metadata_footer', $metadata_arr );
return $metadata_arr;
}
/**
* Prints the generated metadata for the footer area.
*/
function amt_add_metadata_footer() {
// For AMT timings
$t = microtime(true);
// Get the options the DB
$options = get_option("add_meta_tags_opts");
// Get current post object
$post = amt_get_queried_object();
// Caching indicator
$is_cached = 'no';
// Get the metadata
// NOTE: Currently metadata is cached for content pages only (is_singular())
if ( absint($options['transient_cache_expiration']) > 0 && apply_filters('amt_enable_metadata_cache', true) ) {
$metadata_arr = amt_get_transient_cache($post, $options, $where='footer');
if ( empty($metadata_arr) ) {
$metadata_arr = amt_get_metadata_footer($post, $options);
// Cache the metadata
if ( ! empty($metadata_arr) ) {
amt_set_transient_cache($post, $options, $metadata_arr, $where='footer');
}
} else {
$is_cached = 'yes';
}
} else {
$metadata_arr = amt_get_metadata_footer($post, $options);
}
// For AMT timings
if ( ! empty($metadata_arr) && $options['enable_timings'] == '1' ) {
array_unshift( $metadata_arr, sprintf( '<!-- Add-Meta-Tags Timings (milliseconds) - Block total time: %.3f msec - Cached: %s -->', (microtime(true) - $t) * 1000, $is_cached ) );
}
// Add our comment
if ( $options["omit_vendor_html_comments"] == "0" ) {
if ( count( $metadata_arr ) > 0 ) {
array_unshift( $metadata_arr, "<!-- BEGIN Metadata added by the Add-Meta-Tags WordPress plugin -->" );
array_push( $metadata_arr, "<!-- END Metadata added by the Add-Meta-Tags WordPress plugin -->" );
}
}
// Return complete metadata array
return $metadata_arr;
}
function amt_print_footer_block() {
// Get the options the DB
$options = get_option("add_meta_tags_opts");
if ( amt_check_run_metadata_review_code($options) ) {
// Here we use non persistent caching in order to be able to use the same output in the review mode.
// Non persistent object cache
$amtcache_key = amt_get_amtcache_key('amt_metadata_block_footer');
$metadata_block_footer = wp_cache_get( $amtcache_key, $group='add-meta-tags' );
if ( $metadata_block_footer === false ) {
$metadata_block_footer = amt_add_metadata_footer();
// Cache even empty
wp_cache_add( $amtcache_key, $metadata_block_footer, $group='add-meta-tags' );
}
} else {
$metadata_block_footer = amt_add_metadata_footer();
}
// Print the metadata block
echo PHP_EOL . implode( PHP_EOL, $metadata_block_footer ) . PHP_EOL . PHP_EOL;
}
add_action('wp_footer', 'amt_print_footer_block', 0);
//
// Metadata Review Mode
//
// Prints the AMT Metadata Review Mode styles
function amt_metadata_review_mode_enqueue_styles_scripts() {
$options = get_option("add_meta_tags_opts");
if ( amt_check_run_metadata_review_code($options) ) {
// Register metadata review mode stylesheet.
wp_register_style( 'amt_metadata_review_mode', plugins_url( 'css/amt-metadata-review-mode.css', AMT_PLUGIN_FILE ) );
//wp_register_style( 'custom_toolbar_css', plugin_dir_url( __FILE__ ) . 'custom-toolbar.css', '', '', 'screen' );
// Enqueue the style
wp_enqueue_style( 'amt_metadata_review_mode' );
$script_path = 'js/amt-metadata-review-mode.js';
if ( apply_filters('amt_metadata_review_mode_enable_enhanced_script', false) ) {
$script_path = 'js/amt-metadata-review-mode-enhanced.js';
}
// Register metadata review mode script
wp_register_script( 'amt_metadata_review_mode', plugins_url( $script_path, AMT_PLUGIN_FILE ), array('jquery') );
// Enqueue the style
wp_enqueue_script( 'amt_metadata_review_mode' );
}
}
// Add styles and scripts for Metadata Review.
//add_action( 'admin_enqueue_scripts', 'amt_metadata_review_mode_enqueue_styles_scripts' );
add_action( 'wp_enqueue_scripts', 'amt_metadata_review_mode_enqueue_styles_scripts' );
// Build the review data
function amt_get_metadata_review($options, $add_as_view=false) {
// Collect metadata
//
// Metadata from head section
//
$metadata_block_head = null;
// Non persistent object cache
$amtcache_key = amt_get_amtcache_key('amt_metadata_block_head');
$metadata_block_head = wp_cache_get( $amtcache_key, $group='add-meta-tags' );
if ( $metadata_block_head === false ) {
$metadata_block_head = amt_add_metadata_head();
// Cache even empty
wp_cache_add( $amtcache_key, $metadata_block_head, $group='add-meta-tags' );
}
//
// Metadata from footer
//
$metadata_block_footer = null;
// Non persistent object cache
$amtcache_key = amt_get_amtcache_key('amt_metadata_block_footer');
$metadata_block_footer = wp_cache_get( $amtcache_key, $group='add-meta-tags' );
if ( $metadata_block_footer === false ) {
$metadata_block_footer = amt_add_metadata_footer();
// Cache even empty
wp_cache_add( $amtcache_key, $metadata_block_footer, $group='add-meta-tags' );
}
//
// Metadata from content filter (Schema.org Microdata)
//
$metadata_block_content_filter = null;
if ( $options["schemaorg_force_jsonld"] == "0" ) {
// What happens here:
// The Metadata Review mode content filter should have a bigger priority that the Schema.org
// Microdata filter. There the metadata has been stored in non persistent cache.
// Here we retrieve it. See the notes there for more info.
$metadata_block_content_filter = wp_cache_get( 'amt_cache_metadata_block_content_filter', $group='add-meta-tags' );
}
// Build texts
if ( $add_as_view ) {
// $BR = '<br />';
$BR = PHP_EOL;
$enclosure_start = '<div id="amt-metadata-review">' . '<pre id="amt-metadata-review-pre">' . $BR;
$enclosure_end = '</pre>' . '</div>' . $BR . $BR;
} else {
$BR = PHP_EOL;
$enclosure_start = '<pre id="amt-metadata-review-pre">' . $BR;
$enclosure_end = '</pre>' . $BR . $BR;
}
if ( $options['review_mode_omit_notices'] == '0' ) {
$text_title = '<span class="amt-ht-title">Add-Meta-Tags &mdash; Metadata Review Mode</span>' . $BR . $BR;
} else {
$text_title = '';
}
if ( $options['review_mode_omit_notices'] == '0' ) {
$text_intro = '<span class="amt-ht-notice"><span class="amt-ht-important">NOTE</span>: This menu has been added because <span class="amt-ht-important">Metadata Review Mode</span> has been enabled in';
$text_intro .= $BR . 'the Add-Meta-Tags settings. Only logged in administrators can see this menu.</span>';
} else {
$text_intro = '';
}
if ( $options['review_mode_omit_notices'] == '0' ) {
//$text_head_intro = $BR . $BR . '<span class="amt-ht-notice">The following metadata has been added to the head section.</span>' . $BR . $BR;
$text_head_intro = $BR . $BR . 'Metadata at the head section' . $BR;
$text_head_intro .= '============================' . $BR . $BR;
} else {
$text_head_intro = '';
}
if ( $options['review_mode_omit_notices'] == '0' ) {
//$text_footer_intro = $BR . $BR . '<span class="amt-ht-notice">The following metadata has been embedded in the body of the page.</span>' . $BR . $BR;
$text_footer_intro = $BR . $BR . 'Metadata within the body area' . $BR;
$text_footer_intro .= '=============================' . $BR . $BR;
} else {
$text_footer_intro = $BR . $BR;
}
if ( $options['review_mode_omit_notices'] == '0' ) {
//$text_content_filter_intro = $BR . $BR . '<span class="amt-ht-notice">The following metadata has been embedded in the body of the page.</span>' . $BR;
$text_content_filter_intro = $BR . $BR . 'Metadata within the body area' . $BR;
$text_content_filter_intro .= '=============================' . $BR;
} else {
$text_content_filter_intro = $BR;
}
//
// Build view
//
$data = $enclosure_start . $text_title;
$data .= apply_filters('amt_metadata_review_text_before', $text_intro, $metadata_block_head, $metadata_block_footer, $metadata_block_content_filter);
//
// Metadata Overview
//
if ( $options["review_mode_metadata_report"] == '1' ) {
$metadata_overview_default_text = '';
$data .= amt_metadata_analysis($metadata_overview_default_text, $metadata_block_head, $metadata_block_footer, $metadata_block_content_filter);
}
//
// Metadata from head section
//
// Add for review
if ( ! empty($metadata_block_head) ) {
// Pretty print JSON+LD
if ( array_key_exists('json+ld_data', $metadata_block_head) ) {
$jsonld_data_arr = json_decode( $metadata_block_head['json+ld_data'] );
$metadata_block_head['json+ld_data'] = json_encode($jsonld_data_arr, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
$data .= apply_filters('amt_metadata_review_head', $text_head_intro, $metadata_block_head);
$data .= amt_metatag_highlighter( implode( $BR, $metadata_block_head ) );
}
//
// Metadata from footer
//
// Add for review
if ( ! empty($metadata_block_footer) ) {
$data .= apply_filters('amt_metadata_review_footer', $text_footer_intro, $metadata_block_footer);
$data .= amt_metatag_highlighter( implode( $BR, $metadata_block_footer ) );
}
//
// Metadata from content filter (Schema.org Microdata)
//
if ( $options["schemaorg_force_jsonld"] == "0" ) {
if ( $metadata_block_content_filter !== false ) {
// Add for review
$data .= apply_filters('amt_metadata_review_content_filter', $text_content_filter_intro, $metadata_block_content_filter);
$data .= amt_metatag_highlighter( implode( $BR, $metadata_block_content_filter ) );
}
}
$data .= apply_filters('amt_metadata_review_text_after', '', $metadata_block_head, $metadata_block_footer, $metadata_block_content_filter);
// End
$data .= $BR . $BR . $enclosure_end;
return $data;
}
// Old view within the content
function amt_add_metadata_review($post_body) {
// Only works in content pages
if ( ! is_singular() ) {
return $post_body;
}
$options = get_option("add_meta_tags_opts");
// Only administrators can see the review box if is_singular() is true.
if ( amt_check_run_metadata_review_code($options) ) {
if ( ! apply_filters('amt_metadata_review_mode_enable_alternative', false) ) {
return $post_body;
}
// Get current post object
$post = amt_get_queried_object();
if ( is_null( $post ) ) {
return $post_body;
}
// Check if metadata is supported on this content type.
$post_type = get_post_type( $post );
if ( ! in_array( $post_type, amt_get_supported_post_types() ) ) {
return $post_body;
}
$post_body = amt_get_metadata_review($options) . '<br /><br />' . $post_body;
}
return $post_body;
}
// Has to be higher (so as to be executed later) than the schema.org microdata content filter.
add_filter('the_content', 'amt_add_metadata_review', 10000);
// New view -- Adds the 'Metadata' menu to the admin bar
function amt_metadata_review_mode_admin_bar_links( $admin_bar ){
// Do not display the menu when the user is in the WP administration panel.
if ( is_admin() ) {
return;
}
// Add 'Metadata' menu to the admin bar
$admin_bar->add_menu( array(
'id' => 'amt',
'title' => '<span class="ab-icon"></span><span class="ab-label">' . __('Metadata', 'add-meta-tags') . '</span>',
'href' => '#',
'meta' => array(
'onclick' => 'jQuery("#amt-metadata-review").toggle(); jQuery("#amt-metadata-review").focus(); return false;',
'class' => 'amt-metadata',
'title' => __('Metadata Review Mode', 'add-meta-tags'),
)
));
// 'onclick' => 'jQuery("#amt-metadata-review").toggleClass("amt-metadata-review-visible"); return false;'
}
// Prints the review mode screen
function amt_metadata_review_mode_print() {
$options = get_option("add_meta_tags_opts");
do_action('amt_metadata_review_mode_pretext');
echo amt_get_metadata_review($options, $add_as_view=true) . '<br /><br />';
do_action('amt_metadata_review_mode_posttext');
}
// Main function for metadata review mode
function amt_metadata_review_mode_as_panel() {
$options = get_option("add_meta_tags_opts");
// Only administrators can see the review box if is_singular() is true.
if ( amt_check_run_metadata_review_code($options) ) {
if ( apply_filters('amt_metadata_review_mode_enable_alternative', false) ) {
return;
}
// Add Purge Links to Admin Bar
add_action('admin_bar_menu', 'amt_metadata_review_mode_admin_bar_links', 250);
// Print the view
add_action('wp_footer', 'amt_metadata_review_mode_print', 99999);
}
}
add_action('wp', 'amt_metadata_review_mode_as_panel');
//
// Automatic purging of cached metadata
//
// Purging triggered by post activities
// wrapper of amt_purge_transient_cache_post for transition_post_status
function amt_purge_transient_cache_post_status($new, $old, $post) {
if ( $old == 'publish' || $new == 'publish' ) {
amt_purge_transient_cache_post( $post->ID );
}
}
// Auto purge metadata cache for a post object
function amt_purge_transient_cache_post($post_id) {
// Verify if this is an auto save routine.
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( absint($post_id) <= 0 ) {
return;
}
// Get the options the DB
$options = get_option("add_meta_tags_opts");
if ( absint($options['transient_cache_expiration']) > 0 ) {
// Purge transient data
amt_delete_transient_cache_for_post($post_id);
}
}
// When an attachment is updated. Required!
//add_action('edit_attachment', 'amt_purge_transient_cache_post', 10, 2);
add_action('edit_attachment', 'amt_purge_transient_cache_post');
// Check this
//add_action( 'edit_post', 'amt_purge_transient_cache_post' );
// Also works, but purges on every save
//add_action( 'save_post', 'amt_purge_transient_cache_post' );
// When post status is changed.
add_action('transition_post_status', 'amt_purge_transient_cache_post_status', 10, 3);
// Purging triggered by comment activities
// wrapper of amt_purge_transient_cache_post_comments for transition_post_status
function amt_purge_transient_cache_post_comments_status($comment_id, $new_comment_status) {
amt_purge_transient_cache_post_comments($comment_id);
}
// Auto purge metadata cache for a post object
function amt_purge_transient_cache_post_comments($comment_id) {
$comment = get_comment($comment_id);
$post_id = $comment->comment_post_ID;
if ( absint($post_id) <= 0 ) {
return;
}
// Get the options the DB
$options = get_option("add_meta_tags_opts");
if ( absint($options['transient_cache_expiration']) > 0 ) {
// Purge transient data
amt_delete_transient_cache_for_post($post_id);
}
}
if ( apply_filters('amt_purge_cached_metadata_on_comment_actions', false) ) {
add_action('comment_post', 'amt_purge_transient_cache_post_comments', 10);
add_action('edit_comment', 'amt_purge_transient_cache_post_comments', 10);
add_action('deleted_comment', 'amt_purge_transient_cache_post_comments', 10);
add_action('trashed_comment', 'amt_purge_transient_cache_post_comments', 10);
add_action('pingback_post', 'amt_purge_transient_cache_post_comments', 10);
add_action('trackback_post', 'amt_purge_transient_cache_post_comments', 10);
add_action('wp_set_comment_status', 'amt_purge_transient_cache_post_comments_status', 10, 2);
}

@ -0,0 +1,580 @@
<?php
/**
* This file is part of the Add-Meta-Tags distribution package.
*
* Add-Meta-Tags is an extension for the WordPress publishing platform.
*
* Homepage:
* - http://wordpress.org/plugins/add-meta-tags/
* Documentation:
* - http://www.codetrax.org/projects/wp-add-meta-tags/wiki
* Development Web Site and Bug Tracker:
* - http://www.codetrax.org/projects/wp-add-meta-tags
* Main Source Code Repository (Mercurial):
* - https://bitbucket.org/gnotaras/wordpress-add-meta-tags
* Mirror repository (Git):
* - https://github.com/gnotaras/wordpress-add-meta-tags
* Historical plugin home:
* - http://www.g-loaded.eu/2006/01/05/add-meta-tags-wordpress-plugin/
*
* Licensing Information
*
* Copyright 2006-2016 George Notaras <gnot@g-loaded.eu>, CodeTRAX.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* The NOTICE file contains additional licensing and copyright information.
*/
/**
* Module containing the Add-Meta-Tags Command Line Interface.
*/
// Prevent direct access to this file.
if ( ! defined( 'ABSPATH' ) ) {
header( 'HTTP/1.0 403 Forbidden' );
echo 'This file should not be accessed directly!';
exit; // Exit if accessed directly
}
if ( defined('WP_CLI') && WP_CLI ):
/**
* Implements the Add-Meta-Tags command line interface.
*
* @package wp-cli
* @subpackage commands/community
* @maintainer George Notaras (http://www.g-loaded.eu)
*/
class AMT_Command extends WP_CLI_Command {
/**
* Prints a status message about Add-Meta-Tags installation. (not implemented)
*
* ## EXAMPLES
*
* wp amt status
*
* @synopsis
*/
function status( $args, $assoc_args ) {
/*
if ( is_multisite() ) {
$blog_list = get_blog_list( 0, 'all' );
} else {
$blog_list = array();
$blog_list[] = array( 'blog_id' => 1 );
}
foreach ( $blog_list as $blog ) {
if ( is_multisite() ) {
switch_to_blog( $blog['blog_id'] );
}
$plugin_info = get_plugin_data( plugin_dir_path( __FILE__ ) . 'add-meta-tags.php', $markup = true, $translate = true );
WP_CLI::line( ' ' );
WP_CLI::line( get_bloginfo('name') . ' - ' . $blog['blog_id'] );
WP_CLI::line( $plugin_info['Version'] );
WP_CLI::line( ' ' );
if ( is_multisite() ) {
restore_current_blog();
}
}
// get_plugin_data( $plugin_file, $markup = true, $translate = true )
//$plugin info = get_plugin_data( AMT_PLUGIN_DIR . 'add-meta-tags.php', $markup = true, $translate = true );
// WP_CLI::line( ' ' );
// WP_CLI::line( count( $field_groups ) . ' field groups found for blog_id ' . $blog['blog_id'] );
// Print a success message
WP_CLI::success( "Operation complete." );
*/
WP_CLI::error('Not implemented.');
}
/**
* Upgrades the settings.
*
* ## OPTIONS
*
* [--network-wide]
* : Perform the settings upgrade on all blogs of the network.
*
* ## EXAMPLES
*
* wp amt upgrade
* wp amt upgrade --network-wide
*
* @synopsis [--network-wide]
*/
function upgrade( $args, $assoc_args ) {
// Multisite
if ( $assoc_args['network-wide'] ) {
if ( is_multisite() ) {
// Check for large network
if ( wp_is_large_network( $using='sites' ) ) {
WP_CLI::error('Too large network. Aborting...');
}
$blog_list = wp_get_sites();
//var_dump($blog_list);
if ( empty($blog_list) ) {
WP_CLI::error('No blogs could be found.'); // Check for large network is done above
}
foreach ( $blog_list as $blog ) {
switch_to_blog( $blog['blog_id'] );
$plugin_info = get_plugin_data( plugin_dir_path( __FILE__ ) . 'add-meta-tags.php', $markup=true, $translate=true );
WP_CLI::line( 'Upgrading settings of: ' . get_bloginfo('name') . ' - (ID: ' . $blog['blog_id'] . ')' );
amt_plugin_upgrade();
restore_current_blog();
}
WP_CLI::success('Add-Meta-Tags settings have been upgraded network wide.');
} else {
WP_CLI::warning('No network detected. Reverting to single site mode.');
}
}
if ( ! is_multisite() ) {
// Single site installation
amt_plugin_upgrade();
WP_CLI::success('Add-Meta-Tags settings have been upgraded.');
}
/*
if ( is_multisite() ) {
$blog_list = get_blog_list( 0, 'all' );
} else {
$blog_list = array();
$blog_list[] = array( 'blog_id' => 1 );
}
foreach ( $blog_list as $blog ) {
if ( is_multisite() ) {
switch_to_blog( $blog['blog_id'] );
}
$plugin_info = get_plugin_data( plugin_dir_path( __FILE__ ) . 'add-meta-tags.php', $markup = true, $translate = true );
WP_CLI::line( 'Upgrading settings of: ' . get_bloginfo('name') . ' - (ID: ' . $blog['blog_id'] . ')' );
amt_plugin_upgrade();
if ( is_multisite() ) {
restore_current_blog();
}
}
*/
// get_plugin_data( $plugin_file, $markup = true, $translate = true )
//$plugin info = get_plugin_data( AMT_PLUGIN_DIR . 'add-meta-tags.php', $markup = true, $translate = true );
// WP_CLI::line( ' ' );
// WP_CLI::line( count( $field_groups ) . ' field groups found for blog_id ' . $blog['blog_id'] );
// Print a success message
//WP_CLI::success( "Operation complete." );
}
/**
* Export settings and data to standard output.
*
* ## OPTIONS
*
* <what>
* : The type of data to be exported. Supported: settings|postdata|userdata|termdata
*
* ## EXAMPLES
*
* wp amt export settings > amt-settings.json
* wp amt export postdata > amt-postdata.json
* wp amt export userdata > amt-userdata.json
* wp amt export termdata > amt-termdata.json
*
* @synopsis <settings|postdata|userdata|termdata>
*/
function export( $args, $assoc_args ) {
list( $what ) = $args;
if ( ! in_array($what, array('settings', 'postdata', 'userdata', 'termdata')) ) {
WP_CLI::error( 'Invalid argument: ' . $what . ' (valid: settings|postdata|userdata|termdata)' );
}
$output = array();
// Export AMT settings
if ( $what == 'settings' ) {
$opts = amt_get_options();
// Every time Add-Meta-Tags is run it checks and upgrades its settings.
// Here we perform a check whether the returned settings are the defaults.
//$default_options = amt_get_default_options();
//var_dump(array_diff($opts, $default_options));
//if ( empty( array_diff($opts, $default_options) ) ) {
// WP_CLI::error( 'No custom settings detected.' );
//}
if ( empty($opts) ) {
WP_CLI::error( 'Could not retrieve Add-Meta-Tags options.' );
}
$output = $opts;
}
// Export AMT custom fields
elseif ( $what == 'postdata' ) {
$qr_args = array(
'numberposts' => -1,
'post_type' => 'any',
'post_status' => 'any',
'orderby' => 'id',
'order' => 'ASC',
'suppress_filters' => true,
);
$posts_arr = get_posts( $qr_args );
$amt_post_fields = amt_get_post_custom_field_names();
foreach ( $posts_arr as $post ) {
foreach ( $amt_post_fields as $amt_post_field ) {
$amt_post_field_value = get_post_meta( $post->ID, $amt_post_field, true );
//var_dump($amt_field_value);
if ( ! empty($amt_post_field_value) ) {
// Export format: <post_id>;<amt_post_field>;<serialized_value>
//echo json_encode( sprintf( '%s;%s;%s', $post->ID, $amt_field, $amt_field_value ) );
$output[] = array($post->ID, $amt_post_field, $amt_post_field_value);
}
}
}
}
// Export AMT user data
elseif ( $what == 'userdata' ) {
$qr_args = array(
'orderby' => 'login',
'order' => 'ASC',
'fields' => 'all',
);
$users_arr = get_users( $qr_args );
$amt_user_fields = amt_get_user_custom_field_names();
foreach ( $users_arr as $user ) {
foreach ( $amt_user_fields as $amt_user_field ) {
$amt_user_field_value = get_user_meta( $user->ID, $amt_user_field, true );
if ( ! empty($amt_user_field_value) ) {
// Export format: <user_id>;<amt_user_field>;<serialized_value>
//echo json_encode( sprintf( '%s;%s;%s', $post->ID, $amt_field, $amt_field_value ) );
$output[] = array($user->ID, $amt_user_field, $amt_user_field_value);
}
}
}
}
// Export AMT term data
elseif ( $what == 'termdata' ) {
// Get taxonomies
// Get the custom taxonomy names.
// Arguments in order to retrieve all public custom taxonomies
$tax_args = array(
'public' => true,
'_builtin' => true,
);
$tax_output = 'names'; // names or objects
$tax_operator = 'and'; // 'and' or 'or'
$taxonomies = get_taxonomies( $tax_args, $tax_output, $tax_operator );
// Get terms
$qr_args = array(
'orderby' => 'id',
'order' => 'ASC',
'fields' => 'all',
);
$terms_arr = get_terms( $taxonomies, $qr_args );
// Iterate over our fields and export
$amt_term_fields = amt_get_term_custom_field_names();
foreach ( $terms_arr as $term ) {
foreach ( $amt_term_fields as $amt_term_field ) {
$amt_term_field_value = get_term_meta( $term->term_id, $amt_term_field, true );
if ( ! empty($amt_term_field_value) ) {
// Export format: <term_id>;<amt_term_field>;<serialized_value>
//echo json_encode( sprintf( '%s;%s;%s', $term->term_id, $amt_field, $amt_field_value ) );
$output[] = array($term->term_id, $amt_term_field, $amt_term_field_value);
}
}
}
}
// Print output
if ( ! empty($output) ) {
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
}
/**
* Import settings and data from standard input.
*
* ## OPTIONS
*
* <what>
* : The type of data to be imported. Supported: settings|postdata|userdata|termdata
*
* ## EXAMPLES
*
* wp amt import settings < amt-settings.json
* wp amt import postdata < amt-postdata.json
* wp amt import userdata < amt-userdata.json
* wp amt import termdata < amt-termdata.json
*
* @synopsis <settings|postdata|userdata|termdata>