Add themes, plugins, ...
46
php-fpm/wordpress_files/plugins/add-meta-tags/AUTHORS
Normal file
@ -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! ;)
|
||||
|
39
php-fpm/wordpress_files/plugins/add-meta-tags/CONTRIBUTORS
Normal file
@ -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
|
202
php-fpm/wordpress_files/plugins/add-meta-tags/LICENSE
Normal file
@ -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.
|
22
php-fpm/wordpress_files/plugins/add-meta-tags/NOTICE
Normal file
@ -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.
|
47
php-fpm/wordpress_files/plugins/add-meta-tags/README.rst
Normal file
@ -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.
|
882
php-fpm/wordpress_files/plugins/add-meta-tags/add-meta-tags.php
Normal file
@ -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 — 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);
|
||||
}
|
||||
|
1353
php-fpm/wordpress_files/plugins/add-meta-tags/add-meta-tags.pot
Normal file
2636
php-fpm/wordpress_files/plugins/add-meta-tags/amt-admin-panel.php
Normal file
580
php-fpm/wordpress_files/plugins/add-meta-tags/amt-cli.php
Normal file
@ -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>
|
||||
*/
|
||||
function import( $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)' );
|
||||
}
|
||||
|
||||
// Import AMT settings
|
||||
if ( $what == 'settings' ) {
|
||||
$data = json_decode( file_get_contents('php://stdin'), true ); // true converts to associative array
|
||||
//var_dump($data);
|
||||
if ( empty($data) || ! is_array($data) ) {
|
||||
WP_CLI::error( 'No data found.' );
|
||||
}
|
||||
// Since all other options might come and go, we only check for the 'settings_version' key.
|
||||
if ( ! array_key_exists('settings_version', $data) ) {
|
||||
WP_CLI::error('Invalid data: not option data');
|
||||
}
|
||||
//var_dump( $options );
|
||||
update_option("add_meta_tags_opts", $data);
|
||||
amt_plugin_upgrade();
|
||||
|
||||
WP_CLI::success( 'Add-Meta-Tags settings imported successfully.' );
|
||||
}
|
||||
|
||||
// Import AMT post custom fields
|
||||
elseif ( $what == 'postdata' ) {
|
||||
$data = json_decode( file_get_contents('php://stdin') );
|
||||
if ( empty($data) || ! is_array($data) || empty($data[0]) ) {
|
||||
WP_CLI::error( 'No data found.' );
|
||||
}
|
||||
$amt_post_fields = amt_get_post_custom_field_names();
|
||||
foreach ( $data as $post_meta_info ) {
|
||||
// Format: array( <id>, <field_name>, <field_value> )
|
||||
if ( ! is_array($post_meta_info) || count($post_meta_info) != 3 || ! in_array( $post_meta_info[1], $amt_post_fields) || ! is_numeric($post_meta_info[0] ) ) {
|
||||
WP_CLI::error('Invalid data: not post custom field data');
|
||||
}
|
||||
update_post_meta( $post_meta_info[0], $post_meta_info[1], $post_meta_info[2] );
|
||||
}
|
||||
|
||||
WP_CLI::success( 'Add-Meta-Tags post data was imported successfully.' );
|
||||
}
|
||||
|
||||
// Import AMT user meta
|
||||
elseif ( $what == 'userdata' ) {
|
||||
$data = json_decode( file_get_contents('php://stdin') );
|
||||
if ( empty($data) || ! is_array($data) || empty($data[0]) ) {
|
||||
WP_CLI::error( 'No data found.' );
|
||||
}
|
||||
$amt_user_fields = amt_get_user_custom_field_names();
|
||||
foreach ( $data as $user_meta_info ) {
|
||||
// Format: array( <id>, <field_name>, <field_value> )
|
||||
if ( ! is_array($user_meta_info) || count($user_meta_info) != 3 || ! in_array( $user_meta_info[1], $amt_user_fields) || ! is_numeric($user_meta_info[0] ) ) {
|
||||
WP_CLI::error('Invalid data: not user contact infos');
|
||||
}
|
||||
update_user_meta( $user_meta_info[0], $user_meta_info[1], $user_meta_info[2] );
|
||||
}
|
||||
|
||||
WP_CLI::success( 'Add-Meta-Tags user data was imported successfully.' );
|
||||
}
|
||||
|
||||
// Import AMT term meta
|
||||
elseif ( $what == 'termdata' ) {
|
||||
$data = json_decode( file_get_contents('php://stdin') );
|
||||
if ( empty($data) || ! is_array($data) || empty($data[0]) ) {
|
||||
WP_CLI::error( 'No data found.' );
|
||||
}
|
||||
$amt_term_fields = amt_get_term_custom_field_names();
|
||||
foreach ( $data as $term_meta_info ) {
|
||||
// Format: array( <id>, <field_name>, <field_value> )
|
||||
if ( ! is_array($term_meta_info) || count($term_meta_info) != 3 || ! in_array( $term_meta_info[1], $amt_term_fields) || ! is_numeric($term_meta_info[0] ) ) {
|
||||
WP_CLI::error('Invalid data: not term contact infos');
|
||||
}
|
||||
update_term_meta( $term_meta_info[0], $term_meta_info[1], $term_meta_info[2] );
|
||||
}
|
||||
|
||||
WP_CLI::success( 'Add-Meta-Tags term data was imported successfully.' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete settings, data and metadata cache.
|
||||
*
|
||||
* ## OPTIONS
|
||||
*
|
||||
* <what>
|
||||
* : The type of data to be removed. Supported: all|settings|postdata|userdata|termdata|cache
|
||||
*
|
||||
* [--assume-yes]
|
||||
* : Run in non interactive mode.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* wp amt clean all
|
||||
* wp amt clean settings
|
||||
* wp amt clean postdata
|
||||
* wp amt clean userdata
|
||||
* wp amt clean termdata
|
||||
* wp amt clean cache
|
||||
* wp amt clean cache --assume-yes
|
||||
*
|
||||
* @synopsis <all|settings|postdata|userdata|termdata|cache> [--assume-yes]
|
||||
*/
|
||||
function clean( $args, $assoc_args ) {
|
||||
list( $what ) = $args;
|
||||
|
||||
if ( ! in_array($what, array('all', 'settings', 'postdata', 'userdata', 'termdata', 'cache')) ) {
|
||||
WP_CLI::error( 'Invalid argument: ' . $what . ' (valid: all|settings|postdata|userdata|termdata|cache)' );
|
||||
}
|
||||
|
||||
if ( $assoc_args['assume-yes'] ) {
|
||||
WP_CLI::line( ' ' );
|
||||
WP_CLI::line( 'Running in non-interactive mode.' );
|
||||
WP_CLI::line( 'Proceeding with ' . $what . ' cleanup...' );
|
||||
} else {
|
||||
// Confirmation
|
||||
WP_CLI::line( ' ' );
|
||||
WP_CLI::line( 'This commands deletes Add-Meta-Tags data from the database.' );
|
||||
WP_CLI::line( 'This action is final and cannot be undone.' );
|
||||
WP_CLI::line( ' ' );
|
||||
echo 'Are you sure you want to do this? Type \'yes\' to continue: ';
|
||||
$handle = fopen( 'php://stdin', 'r' );
|
||||
$choice = fgets($handle);
|
||||
fclose($handle);
|
||||
if ( trim($choice) != 'yes' ) {
|
||||
WP_CLI::line( 'Aborting...' );
|
||||
exit;
|
||||
}
|
||||
WP_CLI::line( ' ' );
|
||||
WP_CLI::line( 'Proceeding with ' . $what . ' cleanup...' );
|
||||
}
|
||||
|
||||
// Delete AMT settings
|
||||
if ( $what == 'settings' || $what == 'all' ) {
|
||||
delete_option('add_meta_tags_opts');
|
||||
WP_CLI::line( 'Deleted settings.' );
|
||||
}
|
||||
|
||||
// Delete AMT post custom fields
|
||||
elseif ( $what == 'postdata' || $what == 'all' ) {
|
||||
$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 ) {
|
||||
delete_post_meta( $post->ID, $amt_post_field );
|
||||
}
|
||||
}
|
||||
WP_CLI::line( 'Deleted post custom fields.' );
|
||||
}
|
||||
|
||||
// Delete AMT user data
|
||||
elseif ( $what == 'userdata' || $what == 'all' ) {
|
||||
$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 ) {
|
||||
delete_user_meta( $user->ID, $amt_user_field );
|
||||
}
|
||||
}
|
||||
WP_CLI::line( 'Deleted user meta fields.' );
|
||||
}
|
||||
|
||||
// Delete AMT term data
|
||||
elseif ( $what == 'termdata' || $what == 'all' ) {
|
||||
// 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 ) {
|
||||
delete_term_meta( $term->term_id, $amt_term_field );
|
||||
}
|
||||
}
|
||||
WP_CLI::line( 'Deleted term meta fields.' );
|
||||
}
|
||||
|
||||
// Delete transient metadata cache
|
||||
elseif ( $what == 'cache' || $what == 'all' ) {
|
||||
|
||||
// Transients may not be cached in the database, but in a different storage backend.
|
||||
// So, here amt_delete_all_transient_metadata_cache() is not used.
|
||||
//$result = amt_delete_all_transient_metadata_cache();
|
||||
//WP_CLI::line( sprintf('Deleted %d transient metadata cache entries.', $result) );
|
||||
|
||||
global $wpdb;
|
||||
|
||||
// Get the current blog id.
|
||||
$blog_id = get_current_blog_id();
|
||||
|
||||
// Construct the options table name for the current blog
|
||||
$posts_table = $wpdb->get_blog_prefix($blog_id) . 'posts';
|
||||
//var_dump($posts_table);
|
||||
|
||||
// Construct SQL query that fetched the post IDs.
|
||||
$sql = "SELECT ID FROM $posts_table WHERE post_status = 'publish'";
|
||||
|
||||
// Get number of cache entries
|
||||
$results = $wpdb->get_results($sql);
|
||||
|
||||
foreach ( $results as $post) {
|
||||
// Delete the metadata cache for this post object
|
||||
amt_delete_transient_cache_for_post( absint($post->ID) );
|
||||
}
|
||||
|
||||
WP_CLI::line( sprintf('Force purged cached metadata of %d published post objects.', count($results)) );
|
||||
}
|
||||
|
||||
WP_CLI::success( 'Data clean up complete.' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WP_CLI::add_command( 'amt', 'AMT_Command' );
|
||||
|
||||
|
||||
endif;
|
||||
|
292
php-fpm/wordpress_files/plugins/add-meta-tags/amt-embed.php
Normal file
@ -0,0 +1,292 @@
|
||||
<?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 functions that implement the player container page.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Support for player embed page.
|
||||
*
|
||||
* See ticket: http://www.codetrax.org/issues/1294
|
||||
*/
|
||||
|
||||
|
||||
// Register function that adds Twitter Cards (TC) related rules on plugin activation.
|
||||
function amt_embed_actions_on_plugin_activation() {
|
||||
// Add rewrite rules for the page that contains the embedded player.
|
||||
amt_embed_rewrite_rules();
|
||||
// See important notes about flushing rewrite rules at: http://codex.wordpress.org/Function_Reference/flush_rewrite_rules
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
register_activation_hook( AMT_PLUGIN_FILE, 'amt_embed_actions_on_plugin_activation' );
|
||||
|
||||
|
||||
// Register function that adds Twitter Cards (TC) related rules on plugin activation.
|
||||
function amt_embed_actions_on_plugin_deactivation() {
|
||||
// See important notes about flushing rewrite rules at: http://codex.wordpress.org/Function_Reference/flush_rewrite_rules
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
register_deactivation_hook( AMT_PLUGIN_FILE, 'amt_embed_actions_on_plugin_deactivation' );
|
||||
|
||||
|
||||
// Adds the rewrite rules for the page with the local embedded player.
|
||||
function amt_embed_rewrite_rules() {
|
||||
// NOTE: if `amt_embed_enabled` is filtered to `false`, it is required
|
||||
// to re-save the permalinks (Settings->Permalinks) or deactivate/activate
|
||||
// the plugin before embeds are fully disabled.
|
||||
if ( apply_filters( 'amt_embed_enabled', true ) ) {
|
||||
add_rewrite_rule( '^amtembed/([0-9]+)/?$', 'index.php?amtembed=$matches[1]', 'top' );
|
||||
}
|
||||
}
|
||||
add_action( 'init', 'amt_embed_rewrite_rules' );
|
||||
|
||||
|
||||
// Register the query vars
|
||||
function amt_embed_register_query_vars( $vars ) {
|
||||
// NOTE: if `amt_embed_enabled` is filtered to `false`, it is required
|
||||
// to re-save the permalinks (Settings->Permalinks) or deactivate/activate
|
||||
// the plugin before embeds are fully disabled.
|
||||
if ( apply_filters( 'amt_embed_enabled', true ) ) {
|
||||
$vars[] = 'amtembed';
|
||||
//var_dump($vars);
|
||||
}
|
||||
return $vars;
|
||||
}
|
||||
add_filter( 'query_vars', 'amt_embed_register_query_vars' );
|
||||
|
||||
|
||||
|
||||
function amt_embed_template_redirect() {
|
||||
|
||||
if ( is_amtembed() ) {
|
||||
// The container page with the embedded audio/video has been requested.
|
||||
|
||||
if ( ! is_ssl() && apply_filters( 'amt_embed_enforce_ssl', true ) ) {
|
||||
// Here we explicitly want an HTTPS URL and that's why `amt_make_https()` is used instead of `amt_embed_make_https()`.
|
||||
$location = amt_make_https( amt_embed_get_container_url( amt_embed_get_id() ) );
|
||||
//$location = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
|
||||
wp_redirect( $location, 301 );
|
||||
exit;
|
||||
} else {
|
||||
// Make it compatible with WooCommerce
|
||||
// It has been brought to my attention that WooCommerce has an option that forces
|
||||
// a redirection from the HTTPS version of the page back to the HTTP version.
|
||||
// This happens only if the `woocommerce_unforce_ssl_checkout` option is checked.
|
||||
// Fortunatelly the WooCommerce developers have added a filter for easy resolution
|
||||
// of any issues. See the `class-wc-https.php` of the WooCommerce plugin.
|
||||
add_filter( 'woocommerce_unforce_ssl_checkout', 'amt_return_false' );
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'template_redirect', 'amt_embed_template_redirect', 10 );
|
||||
|
||||
|
||||
|
||||
function amt_embed_template_include( $default_template ) {
|
||||
|
||||
if ( is_amtembed() ) {
|
||||
// The container page with the embedded audio/video has been requested.
|
||||
|
||||
// We only process requests for local video or audio embedded attachments.
|
||||
$embed_type = amt_embed_get_type( amt_embed_get_id() );
|
||||
if ( $embed_type === false ) {
|
||||
return amt_force_404_template();
|
||||
}
|
||||
|
||||
// Construct the template name
|
||||
$embed_template = sprintf('amt-embed-%s-template.php', $embed_type);
|
||||
//var_dump($embed_template);
|
||||
|
||||
// Return the proper template
|
||||
// First try to locate the template in the theme directory
|
||||
// Here ``get_template_directory()`` is not used to retrieve the theme's directory
|
||||
// because in case of child themes, it returns the directory of the parent theme.
|
||||
// Instead we use ``get_stylesheet_directory()``.
|
||||
// See info:
|
||||
// - http://codex.wordpress.org/Function_Reference/get_template_directory
|
||||
// - http://codex.wordpress.org/Function_Reference/get_stylesheet_directory
|
||||
$template_in_theme_dir = get_stylesheet_directory() . '/' . $embed_template;
|
||||
//var_dump($template_in_theme_dir);
|
||||
$template_in_plugin_dir = AMT_PLUGIN_DIR . 'templates/' . $embed_template;
|
||||
//var_dump($template_in_plugin_dir);
|
||||
if ( file_exists( $template_in_theme_dir ) ) {
|
||||
return $template_in_theme_dir;
|
||||
} else {
|
||||
return $template_in_plugin_dir;
|
||||
}
|
||||
// In any other case of embed request, just return a 404 error.
|
||||
return amt_force_404_template();
|
||||
}
|
||||
// If this is not an embed, just return the default template.
|
||||
return $default_template;
|
||||
}
|
||||
add_filter( 'template_include', 'amt_embed_template_include', 10 );
|
||||
|
||||
|
||||
function amt_force_404_template() {
|
||||
global $wp_query;
|
||||
// Use set_404() so that WordPress can correctly set any `is_*()` conditional tags.
|
||||
$wp_query->set_404();
|
||||
$wp_query->max_num_pages = 0; // stop theme from showing Next/Prev links
|
||||
status_header( 404 );
|
||||
// Set Cache-Control and Expires headers so that the response is not cached.
|
||||
nocache_headers();
|
||||
// Return the theme's 404 template.
|
||||
return get_404_template();
|
||||
}
|
||||
|
||||
|
||||
function is_amtembed() {
|
||||
if ( absint( get_query_var( 'amtembed' ) ) > 0 ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Returns an integer
|
||||
function amt_embed_get_id() {
|
||||
if ( is_amtembed() ) {
|
||||
return absint( get_query_var( 'amtembed' ) );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function amt_embed_get_container_url( $attachment_id ) {
|
||||
if ( ! empty( $attachment_id ) ) {
|
||||
return site_url( sprintf( 'amtembed/%d/', $attachment_id ) );
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
function amt_embed_get_stream_url( $attachment_id ) {
|
||||
if ( ! empty( $attachment_id ) ) {
|
||||
return wp_get_attachment_url( $attachment_id );
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
// Returns the embed type.
|
||||
// Expects post id.
|
||||
// Returns: string ('audio' or 'video'), boolean false if unsupported.
|
||||
function amt_embed_get_type( $attachment_id ) {
|
||||
if ( empty( $attachment_id ) ) {
|
||||
return false;
|
||||
}
|
||||
// We only process video or audio attachments
|
||||
$attachment = get_post( $attachment_id );
|
||||
if ( get_post_type($attachment) != 'attachment' ) {
|
||||
return false;
|
||||
}
|
||||
$mime_type = get_post_mime_type( $attachment->ID );
|
||||
//$attachment_type = strstr( $mime_type, '/', true );
|
||||
// See why we do not use strstr(): http://www.codetrax.org/issues/1091
|
||||
$attachment_type = preg_replace( '#\/[^\/]*$#', '', $mime_type );
|
||||
// Return embed type
|
||||
if ( 'video' == $attachment_type ) {
|
||||
return 'video';
|
||||
} elseif ( 'audio' == $attachment_type ) {
|
||||
return 'audio';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Accepts a URL and converts the protocol to https if certain conditions are met.
|
||||
// Returns the processed URL.
|
||||
function amt_embed_make_https( $url ) {
|
||||
// If the web site is served over https, convert the URL.
|
||||
if ( is_ssl() ) {
|
||||
return preg_replace( '#^http://#' , 'https://', $url );
|
||||
// If https is enforced on embeds, convert the URL.
|
||||
} elseif ( apply_filters( 'amt_embed_enforce_ssl', true ) ) {
|
||||
return preg_replace( '#^http://#' , 'https://', $url );
|
||||
// In any other case return the URL as is.
|
||||
} else {
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Returns the URL to an image that can be used as the preview image of video
|
||||
// or audio players or be displayed in the place of media players if they
|
||||
// are not supported by the client.
|
||||
function amt_embed_get_preview_image( $attachment_id ) {
|
||||
|
||||
// This function has been primarily developed in order to return an image
|
||||
// URL suitable for the `twitter:image` meta tags of the player Twitter Card.
|
||||
//
|
||||
// From the Player Twitter Card specs about `twitter:image`:
|
||||
// Image to be displayed in place of the player on platforms that don’t support iframes or inline players.
|
||||
// You should make this image the same dimensions as your player. Images with fewer than 68,600 pixels
|
||||
// (a 262x262 square image, or a 350x196 16:9 image) will cause the player card not to render. Image must be less than 1MB in size.
|
||||
//
|
||||
// Here, we try to retrieve an image with size 'full'. The user is expected to have uploaded a properly resized image
|
||||
// or have resized the uploaded image using the WordPress image editing tools or, finally, have filtered the used image
|
||||
// size with a user-defined size that matches that of the video player (and not of the video itself).
|
||||
// NOTE: To create an on-demand properly resized image check out:
|
||||
// http://codex.wordpress.org/Class_Reference/WP_Image_Editor
|
||||
$image_size = apply_filters( 'amt_image_video_preview', 'full' );
|
||||
// In WordPress audio and video attachments can have a featured image. In order to generate the
|
||||
// twitter:image meta tag of the player card, we first try to use the featured image of the __attachment__ and NOT of the post.
|
||||
if ( function_exists( 'has_post_thumbnail' ) && has_post_thumbnail( $attachment_id ) ) { // Read above why we use $attachment->ID
|
||||
$main_size_meta = wp_get_attachment_image_src( get_post_thumbnail_id( $attachment_id ), $image_size );
|
||||
return $main_size_meta[0];
|
||||
}
|
||||
// Alternatively we try to use the post's featured image if available.
|
||||
$attachment = get_post( $attachment_id );
|
||||
$parent_post_id = $attachment->post_parent; // $attachment->post_parent: is the ID of the attachment post's parent post
|
||||
if ( ! empty( $parent_post_id ) && function_exists( 'has_post_thumbnail' ) && has_post_thumbnail( $parent_post_id ) ) {
|
||||
// We retrieve an image with size equal to the size of the player (array $image_size) (According to the specs).
|
||||
$main_size_meta = wp_get_attachment_image_src( get_post_thumbnail_id( $parent_post_id ), $image_size );
|
||||
return $main_size_meta[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function amt_embed_get_includes_url( $path ) {
|
||||
return apply_filters( 'amt_embed_includes_url', includes_url( $path ) );
|
||||
}
|
||||
|
404
php-fpm/wordpress_files/plugins/add-meta-tags/amt-settings.php
Normal file
@ -0,0 +1,404 @@
|
||||
<?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 settings related functions.
|
||||
*/
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array with the default options.
|
||||
*/
|
||||
function amt_get_default_options() {
|
||||
return array(
|
||||
"settings_version" => 23, // IMPORTANT: SETTINGS UPGRADE: Every time settings are added or removed this has to be incremented.
|
||||
"site_description" => "", // Front page description
|
||||
"site_keywords" => "", // Front page keywords
|
||||
"global_keywords" => "", // These keywords are added to the 'keywords' meta tag on all posts and pages
|
||||
"site_wide_meta" => "",
|
||||
"auto_description" => "1", // Descriptions auto-generated by default
|
||||
"auto_keywords" => "1", // Keywords auto-generated by default
|
||||
"auto_opengraph" => "0", // Opengraph
|
||||
"og_omit_video_metadata" => "0", // Omit og:video and og:video:* meta tags
|
||||
"og_add_xml_namespaces" => "0",
|
||||
"auto_dublincore" => "0",
|
||||
"dc_add_xml_namespaces" => "0",
|
||||
"auto_twitter" => "0", // Twitter Cards
|
||||
"tc_enable_player_card_local" => "0", // Enable the player card for locally hosted audio and video attachments.
|
||||
"tc_enforce_summary_large_image" => "0", // Set summary_large_image as the default card.
|
||||
"auto_schemaorg" => "0",
|
||||
"schemaorg_force_jsonld" => "0",
|
||||
"noodp_description" => "0",
|
||||
"noindex_search_results" => "1",
|
||||
"noindex_date_archives" => "0",
|
||||
"noindex_category_archives" => "0",
|
||||
"noindex_tag_archives" => "0",
|
||||
"noindex_taxonomy_archives" => "0",
|
||||
"noindex_author_archives" => "0",
|
||||
"enforce_custom_title_in_metadata" => "0",
|
||||
"enable_advanced_title_management" => "0",
|
||||
"metabox_enable_description" => "1",
|
||||
"metabox_enable_keywords" => "1",
|
||||
"metabox_enable_title" => "1",
|
||||
"metabox_enable_news_keywords" => "0",
|
||||
"metabox_enable_full_metatags" => "0",
|
||||
"metabox_enable_image_url" => "0",
|
||||
"metabox_enable_content_locale" => "0",
|
||||
"metabox_enable_express_review" => "0",
|
||||
"metabox_enable_referenced_list" => "0",
|
||||
"metabox_term_enable_full_metatags" => "0",
|
||||
"metabox_term_enable_image_url" => "0",
|
||||
"metabox_user_enable_full_metatags" => "0",
|
||||
"metabox_user_enable_image_url" => "0",
|
||||
"social_main_facebook_publisher_profile_url" => "",
|
||||
//"social_main_facebook_app_id" => "",
|
||||
//"social_main_facebook_admins" => "",
|
||||
"social_main_googleplus_publisher_profile_url" => "",
|
||||
"social_main_twitter_publisher_username" => "",
|
||||
"author_profile_source" => "default", // default/frontpage/buddypress/url
|
||||
"global_locale" => "",
|
||||
"generate_hreflang_links" => "0",
|
||||
"hreflang_strip_region" => "0",
|
||||
"manage_html_lang_attribute" => "0",
|
||||
"has_https_access" => "0",
|
||||
"force_media_limit" => "0",
|
||||
"expand_shortcodes" => "0",
|
||||
"copyright_url" => "",
|
||||
"default_image_url" => "",
|
||||
"extended_support_woocommerce" => "0",
|
||||
"extended_support_edd" => "0",
|
||||
"extended_support_buddypress" => "0",
|
||||
"extended_support_bbpress" => "0",
|
||||
"enable_timings" => "0",
|
||||
"transient_cache_expiration" => "0", // Not check box
|
||||
"review_mode" => "0",
|
||||
"review_mode_metadata_report" => "0",
|
||||
"review_mode_omit_notices" => "0",
|
||||
"omit_vendor_html_comments" => "0",
|
||||
"i_have_donated" => "0",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs upgrade of the plugin settings.
|
||||
*/
|
||||
function amt_plugin_upgrade() {
|
||||
|
||||
// First we try to determine if this is a new installation or if the
|
||||
// current installation requires upgrade.
|
||||
|
||||
// Default Add-Meta-Tags Settings
|
||||
$default_options = amt_get_default_options();
|
||||
|
||||
// Try to get the current Add-Meta-Tags options from the database
|
||||
$stored_options = get_option("add_meta_tags_opts");
|
||||
if ( empty($stored_options) ) {
|
||||
// This is the first run, so set our defaults.
|
||||
update_option("add_meta_tags_opts", $default_options);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the settings version
|
||||
|
||||
// If the settings version of the default options matches the settings version
|
||||
// of the stored options, there is no need to upgrade.
|
||||
if (array_key_exists('settings_version', $stored_options) &&
|
||||
(intval($stored_options["settings_version"]) == intval($default_options["settings_version"])) ) {
|
||||
// Settings are up to date. No upgrade required.
|
||||
return;
|
||||
}
|
||||
|
||||
// On any other case a settings upgrade is required.
|
||||
|
||||
// 1) Add any missing options to the stored Add-Meta-Tags options
|
||||
foreach ($default_options as $opt => $value) {
|
||||
// Always upgrade the ``settings_version`` option
|
||||
if ($opt == 'settings_version') {
|
||||
$stored_options['settings_version'] = $value;
|
||||
}
|
||||
// Add missing options
|
||||
elseif ( !array_key_exists($opt, $stored_options) ) {
|
||||
$stored_options[$opt] = $value;
|
||||
}
|
||||
// Existing stored options are untouched here.
|
||||
}
|
||||
|
||||
// 2) Migrate any current options to new ones.
|
||||
// Migration rules should go here.
|
||||
|
||||
// Version 2.2.0 (settings_version 1->2)
|
||||
// Removed ``noindex_archives``
|
||||
// No migrations required. Clean-up takes place in step (3) below.
|
||||
|
||||
// Version 2.2.1 (settings_version 2->3)
|
||||
// Added ``review_mode``
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.3.3 (settings_version 3->4)
|
||||
// Added ``auto_twitter``
|
||||
// Added ``auto_schemaorg``
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.5.0 (settings_version 4->5)
|
||||
// Added ``noindex_taxonomy_archives``
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.5.6 (settings_version 5->6)
|
||||
// Added ``tc_enable_player_card_local``
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.6.0 (settings_version 6->7)
|
||||
// Added "metabox_enable_description"
|
||||
// Added "metabox_enable_keywords"
|
||||
// Added "metabox_enable_title"
|
||||
// Added "metabox_enable_news_keywords"
|
||||
// Added "metabox_enable_full_metatags"
|
||||
// Added "metabox_enable_referenced_list"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.7.2 (settings_version 7->8)
|
||||
// Added "social_main_facebook_publisher_profile_url"
|
||||
// Added "social_main_googleplus_publisher_profile_url"
|
||||
// Added "social_main_twitter_publisher_username"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.7.3 (settings_version 8->9)
|
||||
// Added "has_https_access"
|
||||
// Added "tc_enforce_summary_large_image"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.7.5 (settings_version 9->10)
|
||||
// Added "global_locale"
|
||||
// Added "metabox_enable_image_url"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.8.1 (settings_version 10->11)
|
||||
// Added "extended_support_woocommerce"
|
||||
// Added "extended_support_edd"
|
||||
// Added "og_omit_video_metadata"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.8.1 (settings_version 11->12)
|
||||
// Added "metabox_enable_express_review"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.8.10 (settings_version 12->13)
|
||||
// Added "metabox_enable_content_locale"
|
||||
// Added "generate_hreflang_links"
|
||||
// Added "hreflang_strip_region"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.8.12 (settings_version 13->14)
|
||||
// Added "manage_html_lang_attribute"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.9.0 (settings_version 14->15)
|
||||
// Added "schemaorg_force_jsonld"
|
||||
// Added "force_media_limit"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.9.2 (settings_version 15->16)
|
||||
// Added "enforce_custom_title_in_metadata"
|
||||
// Added "enable_advanced_title_management"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.9.7 (settings_version 16->17)
|
||||
// Added "extended_support_buddypress"
|
||||
// Added "extended_support_bbpress"
|
||||
// Added "author_profile_source"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.10.0 (settings_version 17->18)
|
||||
// Added "enable_timings"
|
||||
// Added "transient_cache_expiration"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.10.6 (settings_version 18->19)
|
||||
// Added "review_mode_metadata_report"
|
||||
// Added "omit_vendor_html_comments"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.10.7 (settings_version 19->20)
|
||||
// Added "review_mode_omit_notices"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.10.8 (settings_version 20->21)
|
||||
// Added "expand_shortcodes"
|
||||
// Added "og_add_xml_namespaces"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.10.9 (settings_version 21->22)
|
||||
// Added "metabox_term_enable_full_metatags"
|
||||
// Added "metabox_term_enable_image_url"
|
||||
// Added "metabox_user_enable_full_metatags"
|
||||
// Added "metabox_user_enable_image_url"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
// Version 2.10.10 (settings_version 22->23)
|
||||
// Added "dc_add_xml_namespaces"
|
||||
// No migrations required. Addition takes place in (1).
|
||||
|
||||
|
||||
// 3) Clean stored options.
|
||||
foreach ($stored_options as $opt => $value) {
|
||||
if ( !array_key_exists($opt, $default_options) ) {
|
||||
// Remove any options that do not exist in the default options.
|
||||
unset($stored_options[$opt]);
|
||||
}
|
||||
}
|
||||
|
||||
// Finally save the updated options.
|
||||
update_option("add_meta_tags_opts", $stored_options);
|
||||
|
||||
}
|
||||
add_action('plugins_loaded', 'amt_plugin_upgrade');
|
||||
// No longer called in function amt_admin_init() in amt-admin-panel.php. See notes there.
|
||||
|
||||
|
||||
/**
|
||||
* Saves the new settings in the database.
|
||||
* Accepts the POST request data.
|
||||
*/
|
||||
function amt_save_settings($post_payload) {
|
||||
|
||||
// Default Add-Meta-Tags Settings
|
||||
$default_options = amt_get_default_options();
|
||||
|
||||
$add_meta_tags_opts = array();
|
||||
|
||||
foreach ($default_options as $def_key => $def_value) {
|
||||
|
||||
// **Always** use the ``settings_version`` from the defaults
|
||||
if ($def_key == 'settings_version') {
|
||||
$add_meta_tags_opts['settings_version'] = $def_value;
|
||||
}
|
||||
|
||||
// Add options from the POST request (saved by the user)
|
||||
elseif ( array_key_exists($def_key, $post_payload) ) {
|
||||
|
||||
// Validate and sanitize input before adding to 'add_meta_tags_opts'
|
||||
if ( $def_key == 'site_description' ) {
|
||||
$add_meta_tags_opts[$def_key] = sanitize_text_field( amt_sanitize_description( stripslashes( $post_payload[$def_key] ) ) );
|
||||
} elseif ( $def_key == 'site_keywords' ) {
|
||||
// No placeholders here
|
||||
$add_meta_tags_opts[$def_key] = sanitize_text_field( amt_sanitize_keywords( stripslashes( $post_payload[$def_key] ) ) );
|
||||
} elseif ( $def_key == 'global_keywords' ) {
|
||||
// placeholder may exist here
|
||||
$add_meta_tags_opts[$def_key] = amt_sanitize_keywords( amt_revert_placeholders( sanitize_text_field( amt_convert_placeholders( stripslashes( $post_payload[$def_key] ) ) ) ) );
|
||||
} elseif ( $def_key == 'site_wide_meta' ) {
|
||||
$add_meta_tags_opts[$def_key] = esc_textarea( wp_kses( stripslashes( $post_payload[$def_key] ), amt_get_allowed_html_kses() ) );
|
||||
} elseif ( $def_key == 'copyright_url' ) {
|
||||
$add_meta_tags_opts[$def_key] = esc_url_raw( stripslashes( $post_payload[$def_key] ), array( 'http', 'https') );
|
||||
} elseif ( $def_key == 'default_image_url' ) {
|
||||
$add_meta_tags_opts[$def_key] = amt_esc_id_or_url_notation( stripslashes( $post_payload[$def_key] ), array( 'http', 'https') );
|
||||
} elseif ( $def_key == 'social_main_facebook_publisher_profile_url' ) {
|
||||
$add_meta_tags_opts[$def_key] = esc_url_raw( stripslashes( $post_payload[$def_key] ), array( 'http', 'https') );
|
||||
} elseif ( $def_key == 'social_main_googleplus_publisher_profile_url' ) {
|
||||
$add_meta_tags_opts[$def_key] = esc_url_raw( stripslashes( $post_payload[$def_key] ), array( 'http', 'https') );
|
||||
} elseif ( $def_key == 'author_profile_source' ) {
|
||||
$author_profile_source_value = sanitize_text_field( stripslashes( $post_payload[$def_key] ) );
|
||||
if ( ! in_array( $author_profile_source_value, array('default', 'frontpage', 'buddypress', 'url') ) ) {
|
||||
$author_profile_source_value = 'default';
|
||||
}
|
||||
$add_meta_tags_opts[$def_key] = $author_profile_source_value;
|
||||
} elseif ( $def_key == 'transient_cache_expiration' ) {
|
||||
$transient_cache_expiration_value = sanitize_text_field( stripslashes( $post_payload[$def_key] ) );
|
||||
if ( ! is_numeric($transient_cache_expiration_value) || intval($transient_cache_expiration_value) < 0 ) {
|
||||
$transient_cache_expiration_value = '0';
|
||||
}
|
||||
$add_meta_tags_opts[$def_key] = $transient_cache_expiration_value;
|
||||
} else {
|
||||
$add_meta_tags_opts[$def_key] = sanitize_text_field( stripslashes( $post_payload[$def_key] ) );
|
||||
}
|
||||
}
|
||||
|
||||
// If missing (eg checkboxes), use the default value, except for the case
|
||||
// those checkbox settings whose default value is 1.
|
||||
else {
|
||||
|
||||
// The following settings have a default value of 1, so they can never be
|
||||
// deactivated, unless the following check takes place.
|
||||
if ( $def_key == 'auto_description'
|
||||
|| $def_key == 'auto_keywords'
|
||||
|| $def_key == 'noindex_search_results'
|
||||
|| $def_key == 'metabox_enable_description'
|
||||
|| $def_key == 'metabox_enable_keywords'
|
||||
|| $def_key == 'metabox_enable_title'
|
||||
) {
|
||||
if( !isset($post_payload[$def_key]) ){
|
||||
$add_meta_tags_opts[$def_key] = "0";
|
||||
}
|
||||
} else {
|
||||
// Else save the default value in the db.
|
||||
$add_meta_tags_opts[$def_key] = $def_value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Finally update the Add-Meta-Tags options.
|
||||
update_option("add_meta_tags_opts", $add_meta_tags_opts);
|
||||
|
||||
//var_dump($post_payload);
|
||||
//var_dump($add_meta_tags_opts);
|
||||
|
||||
amt_show_info_msg(__('Add-Meta-Tags options saved', 'add-meta-tags'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset settings to the defaults.
|
||||
*/
|
||||
function amt_reset_settings() {
|
||||
// Default Add-Meta-Tags Settings
|
||||
$default_options = amt_get_default_options();
|
||||
|
||||
delete_option("add_meta_tags_opts");
|
||||
update_option("add_meta_tags_opts", $default_options);
|
||||
amt_show_info_msg(__('Add-Meta-Tags options were reset to defaults', 'add-meta-tags'));
|
||||
}
|
||||
|
@ -0,0 +1,266 @@
|
||||
<?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 template tags.
|
||||
*/
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
function amt_content_description() {
|
||||
$options = get_option("add_meta_tags_opts");
|
||||
$post = amt_get_queried_object();
|
||||
if ( ! is_null( $post ) ) {
|
||||
echo amt_get_content_description( $post );
|
||||
}
|
||||
}
|
||||
|
||||
function amt_content_keywords() {
|
||||
$options = get_option("add_meta_tags_opts");
|
||||
$post = amt_get_queried_object();
|
||||
if ( ! is_null( $post ) ) {
|
||||
echo amt_get_content_keywords( $post );
|
||||
}
|
||||
}
|
||||
|
||||
function amt_metadata_head() {
|
||||
// Prints full metadata for head area.
|
||||
amt_print_head_block();
|
||||
}
|
||||
|
||||
function amt_metadata_footer() {
|
||||
// Prints full metadata for footer area.
|
||||
amt_print_footer_block();
|
||||
}
|
||||
|
||||
function amt_metadata_review() {
|
||||
// Prints full metadata in review mode. No user level checks here.
|
||||
echo amt_get_metadata_inspect();
|
||||
}
|
||||
|
||||
function amt_breadcrumbs( $user_options ) {
|
||||
echo amt_get_breadcrumbs( $user_options );
|
||||
}
|
||||
|
||||
function amt_local_author_profile_url( $author_id=null, $display=true ) {
|
||||
$options = get_option("add_meta_tags_opts");
|
||||
if ( empty($options) ) {
|
||||
return '';
|
||||
}
|
||||
if ( is_null($author_id) ) {
|
||||
$post = amt_get_queried_object();
|
||||
if ( is_null($post) || $post->ID == 0 ) {
|
||||
return '';
|
||||
}
|
||||
$author_id = get_the_author_meta( 'ID', $post->post_author );
|
||||
}
|
||||
if ( $display ) {
|
||||
echo esc_url( amt_get_local_author_profile_url( $author_id, $options ) );
|
||||
} else {
|
||||
return esc_url( amt_get_local_author_profile_url( $author_id, $options ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// User image template tags
|
||||
//
|
||||
// Returns array with image info about the custom user image set in the user profile (AMT section)
|
||||
//
|
||||
function amt_get_user_image_info( $size='thumbnail', $user_id=null ) {
|
||||
// Initial checks
|
||||
if ( empty($user_id) ) {
|
||||
if ( is_author() ) {
|
||||
// The post object is the author object
|
||||
$post = amt_get_queried_object();
|
||||
if ( ! isset($post->ID) ) {
|
||||
return false;
|
||||
}
|
||||
$user_id = $post->ID;
|
||||
} elseif ( is_singular() ) {
|
||||
// Get the user ID of the author of the current post.
|
||||
$post = amt_get_queried_object();
|
||||
if ( ! isset($post->post_author) ) {
|
||||
return false;
|
||||
}
|
||||
$user_id = $post->post_author;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} elseif ( ! is_numeric($user_id) ) {
|
||||
return false;
|
||||
}
|
||||
// Get data from Custom Field
|
||||
$custom_image_url_value = amt_get_user_meta_image_url( $user_id );
|
||||
// Get image data
|
||||
$image_data = amt_get_image_data( amt_esc_id_or_url_notation( stripslashes( $custom_image_url_value ) ) );
|
||||
// Construct image info array
|
||||
$image_info = array(
|
||||
'url' => null,
|
||||
'width' => null,
|
||||
'height' => null,
|
||||
);
|
||||
if ( is_numeric($image_data['id']) ) {
|
||||
$main_size_meta = wp_get_attachment_image_src( $image_data['id'], $size );
|
||||
if ( empty($main_size_meta) ) {
|
||||
return false;
|
||||
}
|
||||
$image_info['url'] = $main_size_meta[0];
|
||||
$image_info['width'] = $main_size_meta[1];
|
||||
$image_info['height'] = $main_size_meta[2];
|
||||
} elseif ( ! is_null($image_data['url']) ) {
|
||||
$image_info['url'] = $main_size_meta[0];
|
||||
$image_info['width'] = $main_size_meta[1];
|
||||
$image_info['height'] = $main_size_meta[2];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $image_info;
|
||||
}
|
||||
|
||||
// Prints img of user image
|
||||
function amt_print_user_image( $size='thumbnail', $user_id=null, $force_width=null, $force_height=null ) {
|
||||
$image_info = amt_get_user_image_info( $size=$size, $user_id=$user_id );
|
||||
if ( empty($image_info) ) {
|
||||
echo '';
|
||||
} else {
|
||||
if ( is_numeric($force_width) ) {
|
||||
$image_info['width'] = sprintf('%d', $force_width);
|
||||
}
|
||||
if ( is_numeric($force_height) ) {
|
||||
$image_info['height'] = sprintf('%d', $force_height);
|
||||
}
|
||||
echo '<img class="amt-user-image amt-user-image-' . esc_attr($size) . '" src="' . esc_url($image_info['url']) . '" width="' . esc_attr($image_info['width']) . '" height="' . esc_attr($image_info['height']) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
// Override get_avatar_url with the URL of our user image
|
||||
//
|
||||
// Enable with:
|
||||
//
|
||||
// add_filter('amt_set_user_image_as_avatar_url', '__return_true');
|
||||
//
|
||||
function amt_set_user_image_as_avatar( $default_url ) {
|
||||
if ( apply_filters('amt_set_user_image_as_avatar', false) ) {
|
||||
$image_info = amt_get_user_image_info( $size='thumbnail' );
|
||||
if ( ! empty($image_info) ) {
|
||||
return $image_info['url'];
|
||||
}
|
||||
}
|
||||
return $default_url;
|
||||
}
|
||||
add_action('get_avatar_url', 'amt_set_user_image_as_avatar');
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Term image template tags
|
||||
//
|
||||
// Returns array with image info about the custom term image set in the term edit screen (AMT section)
|
||||
//
|
||||
function amt_get_term_image_info( $size='thumbnail', $term_id=null ) {
|
||||
// Initial checks
|
||||
if ( empty($term_id) ) {
|
||||
if ( is_category() || is_tag() || is_tax() ) {
|
||||
// The post object is the term object
|
||||
$post = amt_get_queried_object();
|
||||
if ( ! isset($post->term_id) ) {
|
||||
return false;
|
||||
}
|
||||
$term_id = $post->term_id;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} elseif ( ! is_numeric($term_id) ) {
|
||||
return false;
|
||||
}
|
||||
// Get data from Custom Field
|
||||
$custom_image_url_value = amt_get_term_meta_image_url( $term_id );
|
||||
// Get image data
|
||||
$image_data = amt_get_image_data( amt_esc_id_or_url_notation( stripslashes( $custom_image_url_value ) ) );
|
||||
// Construct image info array
|
||||
$image_info = array(
|
||||
'url' => null,
|
||||
'width' => null,
|
||||
'height' => null,
|
||||
);
|
||||
if ( is_numeric($image_data['id']) ) {
|
||||
$main_size_meta = wp_get_attachment_image_src( $image_data['id'], $size );
|
||||
if ( empty($main_size_meta) ) {
|
||||
return false;
|
||||
}
|
||||
$image_info['url'] = $main_size_meta[0];
|
||||
$image_info['width'] = $main_size_meta[1];
|
||||
$image_info['height'] = $main_size_meta[2];
|
||||
} elseif ( ! is_null($image_data['url']) ) {
|
||||
$image_info['url'] = $main_size_meta[0];
|
||||
$image_info['width'] = $main_size_meta[1];
|
||||
$image_info['height'] = $main_size_meta[2];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $image_info;
|
||||
}
|
||||
|
||||
// Prints img of term image
|
||||
function amt_print_term_image( $size='thumbnail', $term_id=null, $force_width=null, $force_height=null ) {
|
||||
$image_info = amt_get_term_image_info( $size=$size, $term_id=$term_id );
|
||||
if ( empty($image_info) ) {
|
||||
echo '';
|
||||
} else {
|
||||
if ( is_numeric($force_width) ) {
|
||||
$image_info['width'] = sprintf('%d', $force_width);
|
||||
}
|
||||
if ( is_numeric($force_height) ) {
|
||||
$image_info['height'] = sprintf('%d', $force_height);
|
||||
}
|
||||
echo '<img class="amt-term-image amt-term-image-' . esc_attr($size) . '" src="' . esc_url($image_info['url']) . '" width="' . esc_attr($image_info['width']) . '" height="' . esc_attr($image_info['height']) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
4436
php-fpm/wordpress_files/plugins/add-meta-tags/amt-utils.php
Normal file
@ -0,0 +1 @@
|
||||
Contains custom CSS.
|
@ -0,0 +1,18 @@
|
||||
|
||||
#amt-metabox-tabs ul.category-tabs li {
|
||||
background-color: white;
|
||||
padding: 5px 0px;
|
||||
}
|
||||
|
||||
#amt-metabox-tabs ul.category-tabs li a {
|
||||
padding: 5px 20px;
|
||||
}
|
||||
|
||||
#amt-metabox-tabs ul li.ui-state-active {
|
||||
background-color: #777;
|
||||
}
|
||||
|
||||
#amt-metabox-tabs ul li.ui-state-active a {
|
||||
color: white;
|
||||
}
|
||||
|
@ -0,0 +1,115 @@
|
||||
/**
|
||||
* This file is part of the Add-Meta-Tags plugin for WordPress.
|
||||
*
|
||||
* Contains style information for the Add-Meta-Tags Metadata Review Mode.
|
||||
*
|
||||
* For licensing information, please check the LICENSE file that ships with
|
||||
* the Add-Meta-Tags distribution package.
|
||||
*/
|
||||
|
||||
.amt-metadata-review-visible #amt-metadata-review {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#amt-metadata-review {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 32px;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
bottom: 0px;
|
||||
z-index: 99123;
|
||||
overflow: scroll;
|
||||
/* height: 33%;
|
||||
height: 100%; */
|
||||
min-height: 350px;
|
||||
background: #F1F1F1 none repeat scroll 0% 0%;
|
||||
color: #000;
|
||||
line-height: 150% !important;
|
||||
text-align: left;
|
||||
/* font-family: "Helvetica Neue",sans-serif; */
|
||||
font-family: Monospace;
|
||||
font-size: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
#amt-metadata-review-pre {
|
||||
}
|
||||
|
||||
/* Metadata Highlighter */
|
||||
|
||||
.amt-ht-title {
|
||||
font-family: sans-serif;
|
||||
font-size: 18px;
|
||||
/* font-weight: bold;
|
||||
text-decoration: underline; */
|
||||
}
|
||||
|
||||
.amt-ht-notice {
|
||||
text-decoration: underline;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.amt-ht-important {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.amt-ht-itemscope {
|
||||
font-weight: bold;
|
||||
color: #B90746;
|
||||
}
|
||||
|
||||
.amt-ht-attribute {
|
||||
font-weight: bold;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.amt-ht-value {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.amt-ht-comment {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.amt-ht-yes {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.amt-ht-no {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.amt-ht-table {
|
||||
border: 1px solid black;
|
||||
}
|
||||
.amt-ht-table th {
|
||||
font-weight: bold;
|
||||
}
|
||||
.amt-ht-table td, .amt-ht-table th {
|
||||
padding: 4px 8px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
/* Menu Icon */
|
||||
|
||||
#wpadminbar li#wp-admin-bar-amt {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#wpadminbar #wp-admin-bar-amt .ab-icon:before {
|
||||
content: "\f123";
|
||||
top: 3px;
|
||||
}
|
||||
|
||||
@media screen and (max-width:782px) {
|
||||
|
||||
#wpadminbar #wp-admin-bar-amt .ab-icon:before {
|
||||
display: block;
|
||||
font-size: 34px;
|
||||
height: 46px;
|
||||
line-height: 47px;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* This file is part of the Add-Meta-Tags plugin for WordPress.
|
||||
*
|
||||
* Contains style information for the Add-Meta-Tags administration interface.
|
||||
*
|
||||
* For licensing information, please check the LICENSE file that ships with
|
||||
* the Add-Meta-Tags distribution package.
|
||||
*/
|
||||
.amt-settings-notice {
|
||||
/* border-left: 4px solid #7AD03A; */
|
||||
border-left: 4px solid #00CCFF;
|
||||
padding: 1px 12px;
|
||||
/* background-color: #FFF; */
|
||||
background-color: #F6FBFD;
|
||||
/* background-color: #FFFFE1; */
|
||||
-webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.amt-settings-donations-msg {
|
||||
border-left: 4px solid #7AD03A;
|
||||
padding: 1px 12px;
|
||||
background-color: #FFF;
|
||||
-webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
3
php-fpm/wordpress_files/plugins/add-meta-tags/index.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
// Empty
|
||||
?>
|
@ -0,0 +1 @@
|
||||
Contains custom Javascript.
|
@ -0,0 +1,99 @@
|
||||
//
|
||||
// This file is part of the Add-Meta-Tags plugin for WordPress.
|
||||
//
|
||||
// Contains the Add-Meta-Tags admin scripts.
|
||||
//
|
||||
// For licensing information, please check the LICENSE file that ships with
|
||||
// the Add-Meta-Tags distribution package.
|
||||
//
|
||||
|
||||
jQuery( function($) {
|
||||
|
||||
// Set all variables to be used in scope
|
||||
var frame,
|
||||
//metaBox = $('.form-table'), // Your meta box id here
|
||||
metaBox = $('#add-meta-tags-settings, .add-meta-tags-setting'), // Your meta box id here
|
||||
//metaBox = $('.form-field'), // Your meta box id here
|
||||
//metaBox = $('#add-meta-tags-settings'), // Your meta box id here
|
||||
//metaBox = $('#add-meta-tags-settings, .add-meta-tags-setting'), // Your meta box id here
|
||||
// Default Image
|
||||
buttonSelectDefaultImage = metaBox.find('#amt-default-image-selector-button'),
|
||||
inputDefaultImage = metaBox.find( '#default_image_url' );
|
||||
// Global Image Override
|
||||
buttonSelectImage = metaBox.find('#amt-image-selector-button'),
|
||||
inputImage = metaBox.find( '#amt_custom_image_url' );
|
||||
|
||||
// Default Image
|
||||
buttonSelectDefaultImage.on( 'click', function( event ){
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// If the media frame already exists, reopen it.
|
||||
if ( frame ) {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new media frame
|
||||
frame = wp.media({
|
||||
title: 'Select or upload the default image',
|
||||
button: {
|
||||
text: 'Use this media'
|
||||
},
|
||||
multiple: false // Set to true to allow multiple files to be selected
|
||||
});
|
||||
|
||||
|
||||
// When an image is selected in the media frame...
|
||||
frame.on( 'select', function() {
|
||||
|
||||
// Get media attachment details from the frame state
|
||||
var attachment = frame.state().get('selection').first().toJSON();
|
||||
|
||||
// Send the attachment id to our hidden input
|
||||
inputDefaultImage.val( attachment.id );
|
||||
|
||||
});
|
||||
|
||||
// Finally, open the modal on click
|
||||
frame.open();
|
||||
});
|
||||
|
||||
|
||||
// Global Image Override
|
||||
buttonSelectImage.on( 'click', function( event ){
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// If the media frame already exists, reopen it.
|
||||
if ( frame ) {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new media frame
|
||||
frame = wp.media({
|
||||
title: 'Select or upload an image',
|
||||
button: {
|
||||
text: 'Use this media'
|
||||
},
|
||||
multiple: false // Set to true to allow multiple files to be selected
|
||||
});
|
||||
|
||||
|
||||
// When an image is selected in the media frame...
|
||||
frame.on( 'select', function() {
|
||||
|
||||
// Get media attachment details from the frame state
|
||||
var attachment = frame.state().get('selection').first().toJSON();
|
||||
|
||||
// Send the attachment id to our hidden input
|
||||
inputImage.val( attachment.id );
|
||||
|
||||
});
|
||||
|
||||
// Finally, open the modal on click
|
||||
frame.open();
|
||||
});
|
||||
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
//
|
||||
// This file is part of the Add-Meta-Tags plugin for WordPress.
|
||||
//
|
||||
// Is a script for the Add-Meta-Tags Metadata Review Mode.
|
||||
//
|
||||
// For licensing information, please check the LICENSE file that ships with
|
||||
// the Add-Meta-Tags distribution package.
|
||||
//
|
||||
|
||||
// Detect the press of the Esc button and hide the Metadata Review panel.
|
||||
jQuery(document).keyup(function(e) {
|
||||
// escape key maps to keycode 27
|
||||
if (e.keyCode == 27) {
|
||||
if (jQuery('#amt-metadata-review').css('display').toLowerCase() == 'none') {
|
||||
// If the panel is hidden, show it.
|
||||
jQuery('#amt-metadata-review').css('display', 'block');
|
||||
jQuery('#amt-metadata-review').focus();
|
||||
} else {
|
||||
// If the panel is displayed, hide it.
|
||||
jQuery('#amt-metadata-review').css('display', 'none');
|
||||
}
|
||||
}
|
||||
});
|
@ -0,0 +1,19 @@
|
||||
//
|
||||
// This file is part of the Add-Meta-Tags plugin for WordPress.
|
||||
//
|
||||
// Is a script for the Add-Meta-Tags Metadata Review Mode.
|
||||
//
|
||||
// For licensing information, please check the LICENSE file that ships with
|
||||
// the Add-Meta-Tags distribution package.
|
||||
//
|
||||
|
||||
// Detect the press of the Esc button and hide the Metadata Review panel.
|
||||
jQuery(document).keyup(function(e) {
|
||||
// escape key maps to keycode 27
|
||||
if (e.keyCode == 27) {
|
||||
if (jQuery('#amt-metadata-review').css('display').toLowerCase() == 'block') {
|
||||
// If the panel is displayed, hide it.
|
||||
jQuery('#amt-metadata-review').css('display', 'none');
|
||||
}
|
||||
}
|
||||
});
|
@ -0,0 +1,646 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Basic Metadata
|
||||
*
|
||||
* Module containing functions related to Basic Metadata
|
||||
*/
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates basic metadata for the head area.
|
||||
*
|
||||
*/
|
||||
function amt_add_basic_metadata_head( $post, $attachments, $embedded_media, $options ) {
|
||||
|
||||
if ( apply_filters('amt_exclude_basic_metadata', false) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$do_description = (($options["auto_description"] == "1") ? true : false );
|
||||
$do_keywords = (($options["auto_keywords"] == "1") ? true : false );
|
||||
$do_noodp_description = (($options["noodp_description"] == "1") ? true : false );
|
||||
|
||||
// Array to store metadata
|
||||
$metadata_arr = array();
|
||||
|
||||
// Pre-processing
|
||||
|
||||
// Store hreflang links in array
|
||||
$hreflang_links_arr = array();
|
||||
|
||||
// Store base robots options
|
||||
$robots_options = array();
|
||||
|
||||
if ( $do_noodp_description && ( is_front_page() || is_singular() || is_category() || is_tag() || is_tax() || is_author() ) ) {
|
||||
// Add NOODP on posts and pages
|
||||
$robots_options[] = 'noodp';
|
||||
$robots_options[] = 'noydir';
|
||||
}
|
||||
|
||||
// Store full meta tags (site wide and post specific)
|
||||
|
||||
// Add site wide meta tags
|
||||
$full_metatags_as_string = '';
|
||||
if ( ! empty( $options['site_wide_meta'] ) ) {
|
||||
$full_metatags_for_site = html_entity_decode( stripslashes( $options['site_wide_meta'] ) );
|
||||
$full_metatags_as_string .= apply_filters('amt_full_metatags_site', $full_metatags_for_site);
|
||||
$full_metatags_as_string .= PHP_EOL;
|
||||
}
|
||||
|
||||
// Full meta tags
|
||||
if ( is_singular() || amt_is_static_front_page() || amt_is_static_home() ) {
|
||||
// per post full meta tags
|
||||
$full_metatags_for_content = amt_get_post_meta_full_metatags( $post->ID );
|
||||
$full_metatags_for_content = html_entity_decode( stripslashes( $full_metatags_for_content ) );
|
||||
$full_metatags_as_string .= apply_filters('amt_full_metatags_post', $full_metatags_for_content);
|
||||
} elseif ( is_category() || is_tag() || is_tax() ) {
|
||||
// Term specific full meta tags ($post is a term object)
|
||||
$full_metatags_for_term = amt_get_term_meta_full_metatags( $post->term_id );
|
||||
$full_metatags_for_term = html_entity_decode( stripslashes( $full_metatags_for_term ) );
|
||||
$full_metatags_as_string .= apply_filters('amt_full_metatags_term', $full_metatags_for_term);
|
||||
} elseif ( is_author() ) {
|
||||
// User specific full meta tags ($post is a user object)
|
||||
$full_metatags_for_user = amt_get_user_meta_full_metatags( $post->ID );
|
||||
$full_metatags_for_user = html_entity_decode( stripslashes( $full_metatags_for_user ) );
|
||||
$full_metatags_as_string .= apply_filters('amt_full_metatags_term', $full_metatags_for_user);
|
||||
}
|
||||
|
||||
// Sanitize
|
||||
//$full_metatags_as_string = esc_textarea( wp_kses( $full_metatags_as_string, amt_get_allowed_html_kses() ) );
|
||||
$full_metatags_as_string = wp_kses( $full_metatags_as_string, amt_get_allowed_html_kses() );
|
||||
|
||||
// Make array of full meta tags
|
||||
$full_meta_tags = preg_split('#\R#', $full_metatags_as_string, NULL, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// Process
|
||||
|
||||
if ( apply_filters('amt_full_metatags_processor_enable', true) ) {
|
||||
|
||||
// Store processed meta tags here
|
||||
$processed_full_meta_tags = array();
|
||||
|
||||
// Field substitutions currently take place only on content pages.
|
||||
// TODO: See if this can be expanded to terms, authors.
|
||||
|
||||
// Store the post's custom fields
|
||||
$custom_fields = null;
|
||||
|
||||
// Store the post object's custom fields.
|
||||
//
|
||||
if ( is_singular() || amt_is_static_front_page() || amt_is_static_home() ) {
|
||||
// Get an array of all custom fields names of the post object.
|
||||
$custom_fields = get_post_custom_keys( $post->ID );
|
||||
}
|
||||
|
||||
// Iterate over full meta tags
|
||||
|
||||
foreach ($full_meta_tags as $single_meta_tag) {
|
||||
|
||||
// Note: Field value substitutions take place first, outside the elseif clauses.
|
||||
|
||||
// Process substitutions of special notation with data from Custom Fields
|
||||
// Supported special notation:
|
||||
// [field=Field Name]
|
||||
// Notes:
|
||||
// - 'Field Name' is the name of custom field.
|
||||
// - If the custom field with name 'Field Name' does not exist, the meta tag
|
||||
// that contains it is omitted.
|
||||
// - If the value of the field is an empty string, then the substitution
|
||||
// takes place normally.
|
||||
//
|
||||
|
||||
// The regex pattern fo our special notation.
|
||||
$special_notation_pattern = '#(?:\[field\=)([^\]]+)(?:\])#';
|
||||
|
||||
// The following covers content pages, as $custom_fields is only set on content pages. See above.
|
||||
if ( ! empty( $custom_fields ) && isset($post->ID) ) {
|
||||
// This also assumes that we have a post object since custom fields
|
||||
// are set only on content pages, otherwise it is null.
|
||||
|
||||
// Check for special notation
|
||||
if ( preg_match($special_notation_pattern, $single_meta_tag, $matches) ) {
|
||||
//var_dump($matches);
|
||||
// If the field name of the special notation does not match
|
||||
// any custom field name, omit the meta tag as per the rules above.
|
||||
if ( ! in_array($matches[1], $custom_fields) ) {
|
||||
continue;
|
||||
}
|
||||
// Since there is special notation and the field name from the special
|
||||
// notation exists in the $custom_fields array, iterate over the available
|
||||
// custom fields and perform the substitutions.
|
||||
foreach ( $custom_fields as $custom_field ) {
|
||||
// Check if it matches the field name of the special notation
|
||||
if ( $custom_field == $matches[1] ) {
|
||||
// Fetch the custom field's value
|
||||
$field_value = get_post_meta( $post->ID, $custom_field, true );
|
||||
// Sanitize value
|
||||
// TODO: this can be a problem depending on the value and the used sanitization function.
|
||||
$field_value = esc_attr( sanitize_text_field( $field_value ) );
|
||||
// Perform the substitution even if the the value is an empty string as per the rules above
|
||||
$single_meta_tag = str_replace( sprintf('[field=%s]', $custom_field), $field_value, $single_meta_tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// In any other case, just remove the meta tags which contain the special notation.
|
||||
if ( preg_match($special_notation_pattern, $single_meta_tag, $tmp) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Process the PAGEINFO variable.
|
||||
// If the current page is the 1st page of any archive or of multipage content,
|
||||
// PAGEINFO is just stripped. For subsequent pages of archives or multipage
|
||||
// content, PAGEINFO is replaced with page based path (page/N/ for archives or N/ for multipage content)
|
||||
//
|
||||
// For paginated archives or paginated main page with latest posts.
|
||||
$has_paging_info = false;
|
||||
if ( is_paged() ) {
|
||||
$paged = get_query_var( 'paged' ); // paged
|
||||
if ( $paged && $paged >= 2 ) {
|
||||
$single_meta_tag = str_replace('PAGEINFO', 'page/' . $paged . '/', $single_meta_tag);
|
||||
$has_paging_info = true;
|
||||
}
|
||||
// For a Post or Page that has been divided into pages using the <!--nextpage--> QuickTag
|
||||
} else {
|
||||
$paged = get_query_var( 'page' ); // page
|
||||
if ( $paged && $paged >= 2 ) {
|
||||
$single_meta_tag = str_replace('PAGEINFO', $paged . '/', $single_meta_tag);
|
||||
$has_paging_info = true;
|
||||
}
|
||||
}
|
||||
// If this is not paged, strip PAGEINFO
|
||||
if ( $has_paging_info === false ) {
|
||||
$single_meta_tag = str_replace('PAGEINFO', '', $single_meta_tag);
|
||||
}
|
||||
|
||||
// Process custom canonical link
|
||||
// If a rel="canonical" meta tags exists, we deactivate WordPress' 'rel_canonical' action,
|
||||
// Since it is assumed that a custom canonical link has been added.
|
||||
//if ( preg_match( '# rel="canonical" #', $post_full_meta_tags, $tmp ) ) {
|
||||
if ( strpos($single_meta_tag, ' rel="canonical" ') !== false ) {
|
||||
// Remove default WordPress action
|
||||
remove_action('wp_head', 'rel_canonical');
|
||||
}
|
||||
|
||||
// Process robots meta tags.
|
||||
// Multiple robots meta tags may exist. Here we collect the options.
|
||||
elseif ( strpos($single_meta_tag, ' name="robots" ') !== false ) {
|
||||
if ( preg_match( '# content="([^"]+)" #', $single_meta_tag, $matches ) ) {
|
||||
$tmp_robots_opts = explode(',', $matches[1]);
|
||||
foreach ($tmp_robots_opts as $single_robots_option) {
|
||||
$single_robots_option_cleaned = strtolower(trim($single_robots_option));
|
||||
if ( ! empty($single_robots_option_cleaned) ) {
|
||||
$robots_options[] = $single_robots_option_cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
// We simply collect options. Do not add any robots meta tags to the processed meta tags array.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Process hreflang links.
|
||||
// Here we just collect them and let them be process later below at the special section.
|
||||
elseif ( strpos($single_meta_tag, ' hreflang="') !== false ) {
|
||||
// Simply add to the hreflang links array for later processing
|
||||
$hreflang_links_arr[] = $single_meta_tag;
|
||||
// We simply collect hreflang links for later processing. Do not add them to the processed meta tags array.
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// If we have reached here, add the meta tags to the array with processed meta tags.
|
||||
$processed_full_meta_tags[] = $single_meta_tag;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
// Full meta tags processor not enabled
|
||||
$processed_full_meta_tags = $full_meta_tags;
|
||||
}
|
||||
|
||||
//var_dump($full_meta_tags);
|
||||
//var_dump($processed_full_meta_tags);
|
||||
|
||||
// Add Meta Tags
|
||||
|
||||
// Add a robots meta tag if robots options exist.
|
||||
// Backwards compatible filter. TODO: This is deprecated. Needs to be deleted after a while.
|
||||
$old_options_as_string = apply_filters( 'amt_robots_data', '' );
|
||||
if ( ! empty($old_options_as_string) ) {
|
||||
foreach ( explode(',', $old_options_as_string) as $single_robots_option) {
|
||||
$single_robots_option_cleaned = strtolower(trim($single_robots_option));
|
||||
if ( ! empty($single_robots_option_cleaned) ) {
|
||||
$robots_options[] = $single_robots_option_cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add robot_options filtering
|
||||
$robots_options = apply_filters( 'amt_robots_options', $robots_options );
|
||||
if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
|
||||
// The flag is not supported
|
||||
$robots_options = array_unique( $robots_options );
|
||||
} else {
|
||||
$robots_options = array_unique( $robots_options, SORT_STRING );
|
||||
}
|
||||
if ( ! empty( $robots_options ) ) {
|
||||
$metadata_arr['basic:robots'] = '<meta name="robots" content="' . esc_attr( implode(',', $robots_options) ) . '" />';
|
||||
}
|
||||
|
||||
// Add full meta tags
|
||||
// Merge meta tags
|
||||
$processed_full_meta_tags = apply_filters('amt_full_metatags_processed', $processed_full_meta_tags);
|
||||
if ( ! empty($processed_full_meta_tags) ) {
|
||||
$metadata_arr = array_merge($metadata_arr, $processed_full_meta_tags);
|
||||
}
|
||||
|
||||
// Add copyright link
|
||||
// On every page print the copyright head link
|
||||
$copyright_url = amt_get_site_copyright_url($options);
|
||||
//if ( empty($copyright_url)) {
|
||||
// $copyright_url = trailingslashit( get_bloginfo('url') );
|
||||
//}
|
||||
if ( ! empty($copyright_url) ) {
|
||||
$metadata_arr['basic:copyright'] = '<link rel="copyright" type="text/html" title="' . esc_attr( get_bloginfo('name') ) . ' '.__('copyright information', 'add-meta-tags').'" href="' . esc_url( $copyright_url ) . '" />';
|
||||
}
|
||||
|
||||
// hreflang link element
|
||||
// This section also expects an array of extra hreflang links that may have
|
||||
// been collected from the full meta tags boxes.
|
||||
if ( $options['generate_hreflang_links'] == '1' ) {
|
||||
if ( is_singular() ) {
|
||||
$locale = amt_get_language_content($options, $post);
|
||||
$hreflang = amt_get_the_hreflang($locale, $options);
|
||||
$hreflang_url = amt_get_permalink_for_multipage($post);
|
||||
} else {
|
||||
$locale = amt_get_language_site($options);
|
||||
$hreflang = amt_get_the_hreflang($locale, $options);
|
||||
$hreflang_url = '';
|
||||
if ( amt_is_default_front_page() ) {
|
||||
$hreflang_url = trailingslashit( get_bloginfo('url') );
|
||||
} elseif ( is_category() || is_tag() || is_tax() ) {
|
||||
// $post is a term object
|
||||
$hreflang_url = get_term_link($post);
|
||||
} elseif ( is_author() ) {
|
||||
// $post is an author object
|
||||
$hreflang_url = get_author_posts_url( $post->ID );
|
||||
} elseif ( is_year() ) {
|
||||
$archive_year = get_the_time('Y');
|
||||
$hreflang_url = get_year_link($archive_year);
|
||||
} elseif ( is_month() ) {
|
||||
$archive_year = get_the_time('Y');
|
||||
$archive_month = get_the_time('m');
|
||||
$hreflang_url = get_month_link($archive_year, $archive_month);
|
||||
} elseif ( is_day() ) {
|
||||
$archive_year = get_the_time('Y');
|
||||
$archive_month = get_the_time('m');
|
||||
$archive_day = get_the_time('d');
|
||||
$hreflang_url = get_day_link($archive_year, $archive_month, $archive_day);
|
||||
}
|
||||
// If paged information is available
|
||||
if ( is_paged() ) {
|
||||
//$hreflang_url = trailingslashit( $hreflang_url ) . get_query_var('paged') . '/';
|
||||
$hreflang_url = get_pagenum_link( get_query_var('paged') );
|
||||
}
|
||||
}
|
||||
// hreflang links array
|
||||
$hreflang_arr = array();
|
||||
// Add link element
|
||||
if ( ! empty($hreflang) && ! empty($hreflang_url) ) {
|
||||
$hreflang_arr[] = '<link rel="alternate" hreflang="' . esc_attr( $hreflang ) . '" href="' . esc_url_raw( $hreflang_url ) . '" />';
|
||||
}
|
||||
// Add extra hreflang links that have been collected from the full meta tags boxes
|
||||
if ( ! empty($hreflang_links_arr) ) {
|
||||
$hreflang_arr = array_merge($hreflang_arr, $hreflang_links_arr);
|
||||
}
|
||||
// Allow filtering of the hreflang array
|
||||
$hreflang_arr = apply_filters( 'amt_hreflang_links', $hreflang_arr );
|
||||
// Add to to metadata array
|
||||
foreach ( $hreflang_arr as $hreflang_link ) {
|
||||
if ( preg_match('# hreflang="([^"]+)" #', $hreflang_link, $matches) ) {
|
||||
$metadata_arr['basic:hreflang:' . $matches[1]] = $hreflang_link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Basic Meta Tags
|
||||
|
||||
// Custom content override
|
||||
if ( amt_is_custom($post, $options) ) {
|
||||
// Return metadata with:
|
||||
// add_filter( 'amt_custom_metadata_basic', 'my_function', 10, 5 );
|
||||
// Return an array of meta tags. Array item format: ['key_can_be_whatever'] = '<meta name="foo" content="bar" />'
|
||||
$metadata_arr = apply_filters( 'amt_custom_metadata_basic', $metadata_arr, $post, $options, $attachments, $embedded_media );
|
||||
|
||||
// Default front page displaying latest posts
|
||||
} elseif ( amt_is_default_front_page() ) {
|
||||
|
||||
// Description and Keywords from the Add-Meta-Tags settings override
|
||||
// default behaviour.
|
||||
|
||||
// Description
|
||||
if ($do_description) {
|
||||
// Use the site description from the Add-Meta-Tags settings.
|
||||
// Fall back to the blog description.
|
||||
$site_description = amt_get_site_description($options);
|
||||
if ( empty($site_description ) ) {
|
||||
// Alternatively, use the blog description
|
||||
// Here we sanitize the provided description for safety
|
||||
$site_description = sanitize_text_field( amt_sanitize_description( get_bloginfo('description') ) );
|
||||
}
|
||||
// If we have a description, use it in the description meta-tag of the front page
|
||||
if ( ! empty( $site_description ) ) {
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $site_description ) ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
// Keywords
|
||||
if ($do_keywords) {
|
||||
// Use the site keywords from the Add-Meta-Tags settings.
|
||||
// Fall back to the blog categories.
|
||||
$site_keywords = amt_get_site_keywords($options);
|
||||
if ( empty( $site_keywords ) ) {
|
||||
// Alternatively, use the blog categories
|
||||
// Here we sanitize the provided keywords for safety
|
||||
$site_keywords = sanitize_text_field( amt_sanitize_keywords( amt_get_all_categories() ) );
|
||||
}
|
||||
// If we have keywords, use them in the keywords meta-tag of the front page
|
||||
if ( ! empty( $site_keywords ) ) {
|
||||
$metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr( $site_keywords ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Attachments
|
||||
} elseif ( is_attachment() ) { // has to be before is_singular() since is_singular() is true for attachments.
|
||||
|
||||
// Description
|
||||
if ($do_description) {
|
||||
$description = amt_get_content_description($post, $auto=$do_description);
|
||||
if ( ! empty($description ) ) {
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $description ) ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
// No keywords
|
||||
|
||||
|
||||
// Content pages and static pages used as "front page" and "posts page"
|
||||
// This also supports products via is_singular()
|
||||
} elseif ( is_singular() || amt_is_static_front_page() || amt_is_static_home() ) {
|
||||
|
||||
// Description
|
||||
if ($do_description) {
|
||||
$description = amt_get_content_description($post, $auto=$do_description);
|
||||
if ( ! empty( $description ) ) {
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $description ) ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
// Keywords
|
||||
if ($do_keywords) {
|
||||
$keywords = amt_get_content_keywords($post, $auto=$do_keywords);
|
||||
if ( ! empty( $keywords ) ) {
|
||||
$metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr( $keywords ) . '" />';
|
||||
|
||||
// Static Posts Index Page
|
||||
// If no keywords have been set in the metabox and this is the static page,
|
||||
// which displayes the latest posts, use the categories of the posts in the loop.
|
||||
} elseif ( amt_is_static_home() ) {
|
||||
// Here we sanitize the provided keywords for safety
|
||||
$cats_from_loop = sanitize_text_field( amt_sanitize_keywords( implode( ', ', amt_get_categories_from_loop() ) ) );
|
||||
if ( ! empty( $cats_from_loop ) ) {
|
||||
$metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr( $cats_from_loop ) . '" />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 'news_keywords'
|
||||
$newskeywords = amt_get_post_meta_newskeywords( $post->ID );
|
||||
if ( ! empty( $newskeywords ) ) {
|
||||
$metadata_arr['basic:news_keywords'] = '<meta name="news_keywords" content="' . esc_attr( $newskeywords ) . '" />';
|
||||
}
|
||||
|
||||
|
||||
// Category based archives
|
||||
} elseif ( is_category() ) {
|
||||
|
||||
if ($do_description) {
|
||||
// If set, the description of the category is used in the 'description' metatag.
|
||||
// Otherwise, a generic description is used.
|
||||
// Here we sanitize the provided description for safety
|
||||
$description_content = sanitize_text_field( amt_sanitize_description( category_description() ) );
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
if ( empty( $description_content ) ) {
|
||||
// Add a filtered generic description.
|
||||
$generic_description = apply_filters( 'amt_generic_description_category_archive', __('Content filed under the %s category.', 'add-meta-tags') );
|
||||
$generic_description = sprintf( $generic_description, single_cat_title( $prefix='', $display=false ) );
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $generic_description ) ) . '" />';
|
||||
} else {
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $description_content ) ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
if ($do_keywords) {
|
||||
// The category name alone is included in the 'keywords' metatag
|
||||
// Here we sanitize the provided keywords for safety
|
||||
$cur_cat_name = sanitize_text_field( amt_sanitize_keywords( single_cat_title($prefix = '', $display = false ) ) );
|
||||
if ( ! empty($cur_cat_name) ) {
|
||||
$metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr( $cur_cat_name ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ( is_tag() ) {
|
||||
|
||||
if ($do_description) {
|
||||
// If set, the description of the tag is used in the 'description' metatag.
|
||||
// Otherwise, a generic description is used.
|
||||
// Here we sanitize the provided description for safety
|
||||
$description_content = sanitize_text_field( amt_sanitize_description( tag_description() ) );
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
if ( empty( $description_content ) ) {
|
||||
// Add a filtered generic description.
|
||||
$generic_description = apply_filters( 'amt_generic_description_tag_archive', __('Content tagged with %s.', 'add-meta-tags') );
|
||||
$generic_description = sprintf( $generic_description, single_tag_title( $prefix='', $display=false ) );
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $generic_description ) ) . '" />';
|
||||
} else {
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $description_content ) ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
if ($do_keywords) {
|
||||
// The tag name alone is included in the 'keywords' metatag
|
||||
// Here we sanitize the provided keywords for safety
|
||||
$cur_tag_name = sanitize_text_field( amt_sanitize_keywords( single_tag_title($prefix = '', $display = false ) ) );
|
||||
if ( ! empty($cur_tag_name) ) {
|
||||
$metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr( $cur_tag_name ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
// Custom taxonomies - Should be after is_category() and is_tag(), as it would catch those taxonomies as well.
|
||||
// This also supports product groups via is_tax(). Only product groups that are WordPress custom taxonomies are supported.
|
||||
} elseif ( is_tax() ) {
|
||||
|
||||
// Taxonomy term object.
|
||||
// When viewing taxonomy archives, the $post object is the taxonomy term object. Check with: var_dump($post);
|
||||
$tax_term_object = $post;
|
||||
//var_dump($tax_term_object);
|
||||
|
||||
if ($do_description) {
|
||||
// If set, the description of the custom taxonomy term is used in the 'description' metatag.
|
||||
// Otherwise, a generic description is used.
|
||||
// Here we sanitize the provided description for safety
|
||||
$description_content = sanitize_text_field( amt_sanitize_description( term_description( $tax_term_object->term_id, $tax_term_object->taxonomy ) ) );
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
if ( empty( $description_content ) ) {
|
||||
// Add a filtered generic description.
|
||||
// Construct the filter name. Template: ``amt_generic_description_TAXONOMYSLUG_archive``
|
||||
$taxonomy_description_filter_name = sprintf( 'amt_generic_description_%s_archive', $tax_term_object->taxonomy);
|
||||
// var_dump($taxonomy_description_filter_name);
|
||||
$generic_description = apply_filters( $taxonomy_description_filter_name, __('Content filed under the %s taxonomy.', 'add-meta-tags') );
|
||||
$generic_description = sprintf( $generic_description, single_term_title( $prefix='', $display=false ) );
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $generic_description ) ) . '" />';
|
||||
} else {
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $description_content ) ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
if ($do_keywords) {
|
||||
// The taxonomy term name alone is included in the 'keywords' metatag.
|
||||
// Here we sanitize the provided keywords for safety.
|
||||
$cur_tax_term_name = sanitize_text_field( amt_sanitize_keywords( single_term_title( $prefix = '', $display = false ) ) );
|
||||
if ( ! empty($cur_tax_term_name) ) {
|
||||
$metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr( $cur_tax_term_name ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ( is_author() ) {
|
||||
|
||||
// Author object
|
||||
// NOTE: Inside the author archives `$post->post_author` does not contain the author object.
|
||||
// In this case the $post (get_queried_object()) contains the author object itself.
|
||||
// We also can get the author object with the following code. Slug is what WP uses to construct urls.
|
||||
// $author = get_user_by( 'slug', get_query_var( 'author_name' ) );
|
||||
// Also, ``get_the_author_meta('....', $author)`` returns nothing under author archives.
|
||||
// Access user meta with: $author->description, $author->user_email, etc
|
||||
// $author = get_queried_object();
|
||||
$author = $post;
|
||||
|
||||
// If a bio has been set in the user profile, use it in the description metatag of the
|
||||
// first page of the author archive *ONLY*. The other pages of the author archive use a generic description.
|
||||
// This happens because the 1st page of the author archive is considered the profile page
|
||||
// by the other metadata modules.
|
||||
// Otherwise use a generic meta tag.
|
||||
if ($do_description) {
|
||||
// Here we sanitize the provided description for safety
|
||||
$author_description = sanitize_text_field( amt_sanitize_description( $author->description ) );
|
||||
if ( empty( $author_description ) || is_paged() ) {
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
// Add a filtered generic description.
|
||||
$generic_description = apply_filters( 'amt_generic_description_author_archive', __('Content published by %s.', 'add-meta-tags') );
|
||||
$generic_description = sprintf( $generic_description, $author->display_name );
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $generic_description ) ) . '" />';
|
||||
} else {
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( $author_description ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
// For the keywords metatag use the categories of the posts the author has written and are displayed in the current page.
|
||||
if ($do_keywords) {
|
||||
// Here we sanitize the provided keywords for safety
|
||||
$cats_from_loop = sanitize_text_field( amt_sanitize_keywords( implode( ', ', amt_get_categories_from_loop() ) ) );
|
||||
if ( ! empty( $cats_from_loop ) ) {
|
||||
$metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr( $cats_from_loop ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
// Custom Post Type Archive
|
||||
} elseif ( is_post_type_archive() ) {
|
||||
|
||||
// Custom post type object.
|
||||
// When viewing custom post type archives, the $post object is the custom post type object. Check with: var_dump($post);
|
||||
$post_type_object = $post;
|
||||
//var_dump($post_type_object);
|
||||
|
||||
if ($do_description) {
|
||||
// Description
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
// Add a filtered generic description.
|
||||
// Construct the filter name. Template: ``amt_generic_description_posttype_POSTTYPESLUG_archive``
|
||||
$custom_post_type_description_filter_name = sprintf( 'amt_generic_description_posttype_%s_archive', $post_type_object->name);
|
||||
// var_dump($custom_post_type_description_filter_name);
|
||||
// Generic description
|
||||
$generic_description = apply_filters( $custom_post_type_description_filter_name, __('%s archive.', 'add-meta-tags') );
|
||||
// Final generic description
|
||||
$generic_description = sprintf( $generic_description, post_type_archive_title( $prefix='', $display=false ) );
|
||||
$metadata_arr['basic:description'] = '<meta name="description" content="' . esc_attr( amt_process_paged( $generic_description ) ) . '" />';
|
||||
}
|
||||
|
||||
// For the keywords metatag use the categories of the posts that are listed in the current page.
|
||||
if ($do_keywords) {
|
||||
// Here we sanitize the provided keywords for safety
|
||||
$cats_from_loop = sanitize_text_field( amt_sanitize_keywords( implode( ', ', amt_get_categories_from_loop() ) ) );
|
||||
if ( ! empty( $cats_from_loop ) ) {
|
||||
$metadata_arr['basic:keywords'] = '<meta name="keywords" content="' . esc_attr( $cats_from_loop ) . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Filtering of the generated basic metadata
|
||||
$metadata_arr = apply_filters( 'amt_basic_metadata_head', $metadata_arr );
|
||||
|
||||
return $metadata_arr;
|
||||
}
|
||||
|
@ -0,0 +1,282 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Dublin Core metadata on posts, pages and attachments.
|
||||
*
|
||||
* * http://dublincore.org/documents/dcmi-terms/
|
||||
* * http://dublincore.org/documents/dces/
|
||||
* * Examples: http://www.metatags.org/dublin_core_metadata_element_set
|
||||
*
|
||||
* * Generic Examples: http://dublincore.org/documents/2001/04/12/usageguide/generic.shtml
|
||||
* * XML examples: http://dublincore.org/documents/dc-xml-guidelines/
|
||||
*
|
||||
* Module containing functions related to Dublin Core
|
||||
*/
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
function amt_add_dublin_core_metadata_head( $post, $attachments, $embedded_media, $options ) {
|
||||
|
||||
if ( apply_filters('amt_exclude_dublin_core_metadata', false) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$metadata_arr = array();
|
||||
|
||||
$do_auto_dublincore = (($options["auto_dublincore"] == "1") ? true : false );
|
||||
if ( ! $do_auto_dublincore ) {
|
||||
return $metadata_arr;
|
||||
}
|
||||
|
||||
// Custom content override
|
||||
if ( amt_is_custom($post, $options) ) {
|
||||
// Return metadata with:
|
||||
// add_filter( 'amt_custom_metadata_dublin_core', 'my_function', 10, 5 );
|
||||
// Return an array of meta tags. Array item format: ['key_can_be_whatever'] = '<meta name="foo" content="bar" />'
|
||||
$metadata_arr = apply_filters( 'amt_custom_metadata_dublin_core', $metadata_arr, $post, $options, $attachments, $embedded_media );
|
||||
return $metadata_arr;
|
||||
}
|
||||
|
||||
// A front page using a static page has DC metadata.
|
||||
if ( ! is_singular() ) { // is_front_page() is used for the case in which a static page is used as the front page.
|
||||
// Dublin Core metadata has a meaning for content only.
|
||||
return array();
|
||||
}
|
||||
|
||||
// The Dublin Core metadata generator does not support products or product groups.
|
||||
if ( amt_is_product() || amt_is_product_group() ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Title
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
$metadata_arr['dcterms:title'] = '<meta name="dcterms:title" content="' . esc_attr( amt_get_title_for_metadata($options, $post) ) . '" />';
|
||||
|
||||
// Resource identifier - Uses amt_get_permalink_for_multipage()
|
||||
$metadata_arr[] = '<meta name="dcterms:identifier" content="' . esc_url_raw( amt_get_permalink_for_multipage( $post ) ) . '" />';
|
||||
|
||||
$metadata_arr[] = '<meta name="dcterms:creator" content="' . esc_attr( amt_get_dublin_core_author_notation($post) ) . '" />';
|
||||
//$metadata_arr[] = '<meta name="dcterms:date" content="' . esc_attr( amt_iso8601_date($post->post_date) ) . '" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:created" content="' . esc_attr( amt_iso8601_date($post->post_date) ) . '" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:available" content="' . esc_attr( amt_iso8601_date($post->post_date) ) . '" />';
|
||||
//$metadata_arr[] = '<meta name="dcterms:issued" content="' . esc_attr( amt_iso8601_date($post->post_date) ) . '" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:modified" content="' . esc_attr( amt_iso8601_date($post->post_modified) ) . '" />';
|
||||
|
||||
// Description
|
||||
// We use the same description as the ``description`` meta tag.
|
||||
// Note: Contains multipage information through amt_process_paged()
|
||||
$content_desc = amt_get_content_description($post);
|
||||
if ( !empty($content_desc) ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:description" content="' . esc_attr( amt_process_paged( $content_desc ) ) . '" />';
|
||||
}
|
||||
|
||||
// Keywords
|
||||
if ( ! is_attachment() ) { // Attachments do not support keywords
|
||||
// dcterms:subject - one for each keyword.
|
||||
$keywords = explode(',', amt_get_content_keywords($post));
|
||||
foreach ( $keywords as $subject ) {
|
||||
$subject = trim( $subject );
|
||||
if ( ! empty($subject) ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:subject" content="' . esc_attr( $subject ) . '" />';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$metadata_arr[] = '<meta name="dcterms:language" content="' . esc_attr( amt_get_language_content($options, $post) ) . '" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:publisher" content="' . esc_url_raw( trailingslashit( get_bloginfo('url') ) ) . '" />';
|
||||
|
||||
// Copyright page
|
||||
$copyright_url = amt_get_site_copyright_url($options);
|
||||
if ( empty($copyright_url)) {
|
||||
$copyright_url = trailingslashit( get_bloginfo('url') );
|
||||
}
|
||||
if ( ! empty($copyright_url) ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:rights" content="' . esc_url_raw( $copyright_url ) . '" />';
|
||||
}
|
||||
|
||||
// License
|
||||
$license_url = '';
|
||||
// The following requires creative commons configurator
|
||||
if (function_exists('bccl_get_license_url')) {
|
||||
$license_url = bccl_get_license_url();
|
||||
}
|
||||
// Allow filtering of the license URL
|
||||
$license_url = apply_filters( 'amt_dublin_core_license', $license_url, $post->ID );
|
||||
// Add metatag if $license_url is not empty.
|
||||
if ( ! empty( $license_url ) ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:license" content="' . esc_url_raw( $license_url ) . '" />';
|
||||
}
|
||||
|
||||
// Coverage
|
||||
$metadata_arr[] = '<meta name="dcterms:coverage" content="World" />';
|
||||
|
||||
if ( is_attachment() ) {
|
||||
|
||||
$mime_type = get_post_mime_type( $post->ID );
|
||||
//$attachment_type = strstr( $mime_type, '/', true );
|
||||
// See why we do not use strstr(): http://www.codetrax.org/issues/1091
|
||||
$attachment_type = preg_replace( '#\/[^\/]*$#', '', $mime_type );
|
||||
|
||||
$metadata_arr[] = '<meta name="dcterms:isPartOf" content="' . esc_url_raw( get_permalink( $post->post_parent ) ) . '" />';
|
||||
|
||||
if ( 'image' == $attachment_type ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:type" content="Image" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:format" content="' . $mime_type . '" />';
|
||||
} elseif ( 'video' == $attachment_type ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:type" content="MovingImage" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:format" content="' . $mime_type . '" />';
|
||||
} elseif ( 'audio' == $attachment_type ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:type" content="Sound" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:format" content="' . $mime_type . '" />';
|
||||
}
|
||||
|
||||
// Finally add the hasFormat
|
||||
$metadata_arr[] = '<meta name="dcterms:hasFormat" content="' . esc_url_raw( wp_get_attachment_url($post->ID) ) . '" />';
|
||||
|
||||
} else { // Default: Text
|
||||
$metadata_arr[] = '<meta name="dcterms:type" content="Text" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:format" content="text/html" />';
|
||||
|
||||
// Add media files
|
||||
|
||||
// Media Limits
|
||||
$image_limit = amt_metadata_get_image_limit($options);
|
||||
$video_limit = amt_metadata_get_video_limit($options);
|
||||
$audio_limit = amt_metadata_get_audio_limit($options);
|
||||
|
||||
// Counters
|
||||
$ic = 0; // image counter
|
||||
$vc = 0; // video counter
|
||||
$ac = 0; // audio counter
|
||||
|
||||
// List attachments
|
||||
foreach( $attachments as $attachment ) {
|
||||
|
||||
$mime_type = get_post_mime_type( $attachment->ID );
|
||||
//$attachment_type = strstr( $mime_type, '/', true );
|
||||
// See why we do not use strstr(): http://www.codetrax.org/issues/1091
|
||||
$attachment_type = preg_replace( '#\/[^\/]*$#', '', $mime_type );
|
||||
|
||||
if ( 'image' == $attachment_type && $ic < $image_limit ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:hasPart" content="' . esc_url_raw( get_permalink( $attachment->ID ) ) . '" />';
|
||||
// Increase image counter
|
||||
$ic++;
|
||||
} elseif ( 'video' == $attachment_type && $vc < $video_limit ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:hasPart" content="' . esc_url_raw( get_permalink( $attachment->ID ) ) . '" />';
|
||||
// Increase video counter
|
||||
$vc++;
|
||||
} elseif ( 'audio' == $attachment_type && $ac < $audio_limit ) {
|
||||
$metadata_arr[] = '<meta name="dcterms:hasPart" content="' . esc_url_raw( get_permalink( $attachment->ID ) ) . '" />';
|
||||
// Increase audio counter
|
||||
$ac++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Embedded Media
|
||||
foreach( $embedded_media['images'] as $embedded_item ) {
|
||||
if ( $ic == $image_limit ) {
|
||||
break;
|
||||
}
|
||||
$metadata_arr[] = '<meta name="dcterms:hasPart" content="' . esc_url_raw( $embedded_item['page'] ) . '" />';
|
||||
// Increase image counter
|
||||
$ic++;
|
||||
}
|
||||
foreach( $embedded_media['videos'] as $embedded_item ) {
|
||||
if ( $vc == $video_limit ) {
|
||||
break;
|
||||
}
|
||||
$metadata_arr[] = '<meta name="dcterms:hasPart" content="' . esc_url_raw( $embedded_item['page'] ) . '" />';
|
||||
// Increase video counter
|
||||
$vc++;
|
||||
}
|
||||
foreach( $embedded_media['sounds'] as $embedded_item ) {
|
||||
if ( $ac == $audio_limit ) {
|
||||
break;
|
||||
}
|
||||
$metadata_arr[] = '<meta name="dcterms:hasPart" content="' . esc_url_raw( $embedded_item['page'] ) . '" />';
|
||||
// Increase audio counter
|
||||
$ac++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WordPress Post Formats: http://codex.wordpress.org/Post_Formats
|
||||
* Dublin Core Format: http://dublincore.org/documents/dcmi-terms/#terms-format
|
||||
* Dublin Core DCMIType: http://dublincore.org/documents/dcmi-type-vocabulary/
|
||||
*/
|
||||
/**
|
||||
* TREAT ALL POST FORMATS AS TEXT (for now)
|
||||
*/
|
||||
/**
|
||||
$format = get_post_format( $post->id );
|
||||
if ( empty($format) || $format=="aside" || $format=="link" || $format=="quote" || $format=="status" || $format=="chat") {
|
||||
// Default format
|
||||
$metadata_arr[] = '<meta name="dcterms:type" content="Text" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:format" content="text/html" />';
|
||||
} elseif ($format=="gallery") {
|
||||
$metadata_arr[] = '<meta name="dcterms:type" content="Collection" />';
|
||||
// $metadata_arr[] = '<meta name="dcterms:format" content="image" />';
|
||||
} elseif ($format=="image") {
|
||||
$metadata_arr[] = '<meta name="dcterms:type" content="Image" />';
|
||||
// $metadata_arr[] = '<meta name="dcterms:format" content="image/png" />';
|
||||
} elseif ($format=="video") {
|
||||
$metadata_arr[] = '<meta name="dcterms:type" content="Moving Image" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:format" content="application/x-shockwave-flash" />';
|
||||
} elseif ($format=="audio") {
|
||||
$metadata_arr[] = '<meta name="dcterms:type" content="Sound" />';
|
||||
$metadata_arr[] = '<meta name="dcterms:format" content="audio/mpeg" />';
|
||||
}
|
||||
*/
|
||||
|
||||
// Filtering of the generated Dublin Core metadata
|
||||
$metadata_arr = apply_filters( 'amt_dublin_core_metadata_head', $metadata_arr );
|
||||
|
||||
return $metadata_arr;
|
||||
}
|
||||
|
||||
|
232
php-fpm/wordpress_files/plugins/add-meta-tags/readme.txt
Normal file
@ -0,0 +1,232 @@
|
||||
=== Add Meta Tags ===
|
||||
Contributors: gnotaras
|
||||
Tags:
|
||||
Requires at least: 3.6.0
|
||||
Tested up to: 4.5
|
||||
Stable tag: 2.11.3
|
||||
License: Apache License v2
|
||||
License URI: http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
|
||||
A metadata plugin that can optimize your web site for more efficient indexing and easier sharing of your content. [DEPRECATED]
|
||||
|
||||
== Description ==
|
||||
|
||||
_Add-Meta-Tags_ is a Free metadata plugin for the _WordPress Publishing Platform_ that can optimize your web site for more efficient indexing of your content by search engines and easier sharing on social networks. It achieves this by generating machine friendly information about your content, called <em>metadata</em>, according to widely used standard specifications.
|
||||
|
||||
**NOTICE:** THIS PLUGIN HAS BEEN **DEPRECATED**. IT IS NO LONGER SUPPORTED. IT IS NO LONGER TESTED WITH NEW WORDPRESS RELEASES. USING IT IN PRODUCTION IS NOT RECOMMENDED.
|
||||
|
||||
IT IS STRONGLY SUGGESTED TO MIGRATE TO OTHER MORE MODERN AND BETTER MAINTAINED PLUGINS.
|
||||
|
||||
IF YOU ARE STARTING A NEW BLOG, IT IS HIGHLY RECOMMENDED TO SEARCH FOR OTHER PLUGINS IN ORDER TO AVOID THE INEVITABLE FUTURE MIGRATION.
|
||||
|
||||
REGARDING EXISTING USERS, AT THE TIME OF WRITING, THERE ARE NO MAJOR BUGS. PROVIDED THAT THE WORDPRESS API DOES NOT CHANGE SOON, YOU HAVE THE TIME TO EXPERIMENT WITH OTHER PLUGINS AND PLAN YOUR MIGRATION.
|
||||
|
||||
SUPPORT VOLUNTEERS IN THE WORDPRESS FORUMS SHOULD NOT RECOMMEND THIS PLUGIN TO NEW USERS.
|
||||
|
||||
<blockquote>
|
||||
|
||||
<strong>Notice about the development status</strong>
|
||||
|
||||
<br /><br />
|
||||
|
||||
The current feature set of this plugin is already beyond what I need or use, so further development, enhancement and testing of it is no longer in my priorities. Moreover, since the release of version 2.11.0, <strong>I do not provide any support</strong> for it and <strong>I no longer recommend using it in production</strong>. Due to lack of free time, there are no plans to do any more work on it. If you continue using this plugin in <em>production</em>, you are on your own.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Furthermore, please consider that Add-Meta-Tags was started many years ago. In many cases it does its job in an inefficient way and its design and implementation should now be considered <strong>outdated</strong>. Addressing the implementation flaws would require rewriting the plugin almost from scratch, which is out of the question, since there are already many excellent and modern plugins in the WordPress Plugin Repository that are actively maintained and fully supported.
|
||||
|
||||
<br /><br />
|
||||
|
||||
So, <strong>I highly recommend to start planning your migration to other plugins</strong> as soon as possible. Regarding data migration, you can find specific information about how Add-Meta-Tags stores its data and general information about how you could migrate that data to other plugins in the <a href="https://wordpress.org/plugins/add-meta-tags/other_notes/">Other Notes</a> section.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Last, but not least, there are several strong indications that during the last months my plugins have been the target of spammers. Be cautious! I strongly suggest that you <strong>completely avoid</strong> any forks of this plugin or any third party downloads. Instead, <strong>I strongly encourage you to migrate to other plugins</strong>.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Also, please note that Add-Meta-Tags is not for sale and that I'm not interested in any idea about it.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Finally, please note that the available documentation on the wiki may contain outdated information in some parts about the customization of the plugin. Since the plugin is now deprecated, there are no plans to work on the documentation. Again, I highly recommend starting your experimentation with other more modern plugins.
|
||||
|
||||
<br /><br />
|
||||
|
||||
</blockquote>
|
||||
|
||||
Add-Meta-Tags was started in 2006. Please visit the [Add-Meta-Tags historical homepage](http://www.g-loaded.eu/2006/01/05/add-meta-tags-wordpress-plugin/).
|
||||
|
||||
|
||||
= Official Project Homepage =
|
||||
|
||||
More technical information and documentation about the features can be found at the [Add-Meta-Tags Development Web Site](http://www.codetrax.org/projects/wp-add-meta-tags/wiki).
|
||||
|
||||
|
||||
= Support =
|
||||
|
||||
Add-Meta-Tags is released without support of any kind. The developer no longer offers support for this 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.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
== Installation ==
|
||||
|
||||
Add-Meta-Tags can be easily installed through the plugin management interface of WordPress.
|
||||
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
No special requirements when upgrading.
|
||||
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
Please read the [Add-Meta-Tags FAQ](http://www.codetrax.org/projects/wp-add-meta-tags/wiki/FAQ) at the development web site.
|
||||
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
No screenshots are available at this time.
|
||||
|
||||
|
||||
== Changelog ==
|
||||
|
||||
**NOTICE:** THIS PLUGIN HAS BEEN **DEPRECATED**. IT IS NO LONGER SUPPORTED. IT IS NO LONGER TESTED WITH NEW WORDPRESS RELEASES. USING IT IN PRODUCTION IS NOT RECOMMENDED.
|
||||
|
||||
IT IS STRONGLY SUGGESTED TO MIGRATE TO OTHER MORE MODERN AND BETTER MAINTAINED PLUGINS.
|
||||
|
||||
IF YOU ARE STARTING A NEW BLOG, IT IS HIGHLY RECOMMENDED TO SEARCH FOR OTHER PLUGINS IN ORDER TO AVOID THE INEVITABLE FUTURE MIGRATION.
|
||||
|
||||
REGARDING EXISTING USERS, AT THE TIME OF WRITING, THERE ARE NO MAJOR BUGS. PROVIDED THAT THE WORDPRESS API DOES NOT CHANGE SOON, YOU HAVE THE TIME TO EXPERIMENT WITH OTHER PLUGINS AND PLAN YOUR MIGRATION.
|
||||
|
||||
SUPPORT VOLUNTEERS IN THE WORDPRESS FORUMS SHOULD NOT RECOMMEND THIS PLUGIN TO NEW USERS.
|
||||
|
||||
<blockquote>
|
||||
|
||||
<strong>Notice about the development status</strong>
|
||||
|
||||
<br /><br />
|
||||
|
||||
The current feature set of this plugin is already beyond what I need or use, so further development, enhancement and testing of it is no longer in my priorities. Moreover, since the release of version 2.11.0, <strong>I do not provide any support</strong> for it and <strong>I no longer recommend using it in production</strong>. Due to lack of free time, there are no plans to do any more work on it. If you continue using this plugin in <em>production</em>, you are on your own.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Furthermore, please consider that Add-Meta-Tags was started many years ago. In many cases it does its job in an inefficient way and its design and implementation should now be considered <strong>outdated</strong>. Addressing the implementation flaws would require rewriting the plugin almost from scratch, which is out of the question, since there are already many excellent and modern plugins in the WordPress Plugin Repository that are actively maintained and fully supported.
|
||||
|
||||
<br /><br />
|
||||
|
||||
So, <strong>I highly recommend to start planning your migration to other plugins</strong> as soon as possible. Regarding data migration, you can find specific information about how Add-Meta-Tags stores its data and general information about how you could migrate that data to other plugins in the <a href="https://wordpress.org/plugins/add-meta-tags/other_notes/">Other Notes</a> section.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Last, but not least, there are several strong indications that during the last months my plugins have been the target of spammers. Be cautious! I strongly suggest that you <strong>completely avoid</strong> any forks of this plugin or any third party downloads. Instead, <strong>I strongly encourage you to migrate to other plugins</strong>.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Also, please note that Add-Meta-Tags is not for sale and that I'm not interested in any idea about it.
|
||||
|
||||
<br /><br />
|
||||
|
||||
Finally, please note that the available documentation on the wiki may contain outdated information in some parts about the customization of the plugin. Since the plugin is now deprecated, there are no plans to work on the documentation. Again, I highly recommend starting your experimentation with other more modern plugins.
|
||||
|
||||
<br /><br />
|
||||
|
||||
</blockquote>
|
||||
|
||||
|
||||
== Other Notes ==
|
||||
|
||||
Add-Meta-Tags uses the WordPress API to store its data in [Custom Fields](https://codex.wordpress.org/Custom_Fields). The following notes outline the types of data stored in each field.
|
||||
|
||||
Since the plugin has been *deprecated*, this information is provided in order to facilitate the *migration of your data to other plugins*. For more information, you can refer to the relevant [Data Storage](http://www.codetrax.org/projects/wp-add-meta-tags/wiki/Data_Storage) page on the wiki.
|
||||
|
||||
= Post objects =
|
||||
|
||||
The data of the following post related _Custom Fields_ is stored in the `wp_postmeta` table of the database.
|
||||
|
||||
- `_amt_description` - the content's custom description (the `description` field is also read as a fallback for backwards compatibility).
|
||||
- `_amt_keywords` - the content's custom keywords (the `keywords` field is also read as a fallback for backwards compatibility).
|
||||
- `_amt_title` - the content's custom title.
|
||||
- `_amt_news_keywords` - the content's custom news keywords.
|
||||
- `_amt_full_metatags` - the content's full meta tag code.
|
||||
- `_amt_image_url` - URL of an image that overrides all other content images (see Notes below).
|
||||
- `_amt_content_locale` - contains a content locale that overrides the global locale setting.
|
||||
- `_amt_express_review` - contains special notation of review related information.
|
||||
- `_amt_referenced_list` - list of URLs of items referenced in the post.
|
||||
|
||||
|
||||
= Term objects =
|
||||
|
||||
The data of the following term related _Custom Fields_ is stored in the `wp_termmeta` table of the database.
|
||||
|
||||
- `_amt_term_full_metatags` - contents of the full meta tags box.
|
||||
- `_amt_term_image_url` - custom image URL field (see Notes below).
|
||||
|
||||
|
||||
= User objects =
|
||||
|
||||
The data of the following user related _Custom Fields_ is stored in the `wp_usermeta` table of the database.
|
||||
|
||||
- `_amt_user_full_metatags` - contents of the full meta tags box.
|
||||
- `_amt_user_image_url` - custom image URL field (see Notes below).
|
||||
|
||||
|
||||
= Notes =
|
||||
|
||||
The fields that store information about images may contain:
|
||||
|
||||
- An integer (attachment ID)
|
||||
- An image URL
|
||||
- The special notation: `URL,WIDTHxHEIGHT`
|
||||
|
||||
|
||||
= Contact Methods =
|
||||
|
||||
The contact methods are Custom Fields of user objects.
|
||||
|
||||
The data of the following user related _Custom Fields_ is stored in the `wp_usermeta` table of the database.
|
||||
|
||||
The extra contact methods added by Add-Meta-Tags are:
|
||||
|
||||
- `amt_facebook_author_profile_url` as _Facebook author profile URL (AMT)_
|
||||
- `amt_googleplus_author_profile_url` as _Google+ author profile URL (AMT)_
|
||||
- `amt_twitter_author_username` as _Twitter author username (AMT)_
|
||||
|
||||
The following contact methods were also used in older releases:
|
||||
|
||||
- `amt_facebook_publisher_profile_url` as _Facebook publisher profile URL (AMT)_
|
||||
- `amt_googleplus_publisher_profile_url` as _Google+ publisher page URL (AMT)_
|
||||
- `amt_twitter_publisher_username` as _Twitter publisher username (AMT)_
|
||||
|
||||
|
||||
= Example data migration by renaming the custom fields in the database =
|
||||
|
||||
This is an example SQL query which can migrate data from a Custom Field used by Add-Meta-Tags to a Custom Field used by another plugin.
|
||||
|
||||
Please note that the following example is provided for *informational purposes and for advanced users only* who have knowledge about how to issue SQL statements directly at the MySQL shell. If it seems too advanced for you, then please consult a technical expert.
|
||||
|
||||
Also, please, *always keep a backup of your database* before making any changes to it from the MySQL shell.
|
||||
|
||||
<pre>
|
||||
UPDATE wp_postmeta SET meta_key='_other_description' WHERE meta_key='_amt_description';
|
||||
</pre>
|
||||
|
||||
The above SQL statement renames the `_amt_description` field of the `wp_postmeta` table to `_other_description`.
|
||||
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the Add-Meta-Tags WordPress plugin.
|
||||
*
|
||||
* Template for audio embeds, used by the Add-Meta-Tags Twitter Card generator.
|
||||
*
|
||||
*/
|
||||
?><!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width; height=device-height;">
|
||||
|
||||
<title><?php bloginfo('name') ?></title>
|
||||
|
||||
<script src="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/jquery/jquery.js' ) ); ?>"></script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
/* <![CDATA[ */
|
||||
var mejsL10n = {"language":"en-US","strings":{"Close":"Close","Fullscreen":"Fullscreen","Download File":"Download File","Download Video":"Download Video","Play\/Pause":"Play\/Pause","Mute Toggle":"Mute Toggle","None":"None","Turn off Fullscreen":"Turn off Fullscreen","Go Fullscreen":"Go Fullscreen","Unmute":"Unmute","Mute":"Mute","Captions\/Subtitles":"Captions\/Subtitles"}};
|
||||
var _wpmejsSettings = {"pluginPath":"\/wp-includes\/js\/mediaelement\/"};
|
||||
/* ]]> */
|
||||
</script>
|
||||
<script src="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/mediaelement/mediaelement-and-player.min.js' ) ); ?>"></script>
|
||||
<script src="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/mediaelement/wp-mediaelement.js' ) ); ?>"></script>
|
||||
|
||||
<link rel="stylesheet" href="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/mediaelement/mediaelementplayer.min.css' ) ); ?>" />
|
||||
<link rel="stylesheet" href="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/mediaelement/wp-mediaelement.css' ) ); ?>" />
|
||||
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0">
|
||||
|
||||
<?php
|
||||
$attrs = array(
|
||||
'src' => amt_embed_make_https( amt_embed_get_stream_url( amt_embed_get_id() ) ),
|
||||
'loop' => '',
|
||||
'autoplay' => '',
|
||||
'preload' => 'none'
|
||||
);
|
||||
echo do_shortcode( wp_audio_shortcode( $attrs ) );
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the Add-Meta-Tags WordPress plugin.
|
||||
*
|
||||
* Template for video embeds, used by the Add-Meta-Tags Twitter Card generator.
|
||||
*
|
||||
*/
|
||||
?><!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width; height=device-height;">
|
||||
|
||||
<title><?php bloginfo('name') ?></title>
|
||||
|
||||
<script src="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/jquery/jquery.js' ) ); ?>"></script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
/* <![CDATA[ */
|
||||
var mejsL10n = {"language":"en-US","strings":{"Close":"Close","Fullscreen":"Fullscreen","Download File":"Download File","Download Video":"Download Video","Play\/Pause":"Play\/Pause","Mute Toggle":"Mute Toggle","None":"None","Turn off Fullscreen":"Turn off Fullscreen","Go Fullscreen":"Go Fullscreen","Unmute":"Unmute","Mute":"Mute","Captions\/Subtitles":"Captions\/Subtitles"}};
|
||||
var _wpmejsSettings = {"pluginPath":"\/wp-includes\/js\/mediaelement\/"};
|
||||
/* ]]> */
|
||||
</script>
|
||||
<script src="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/mediaelement/mediaelement-and-player.min.js' ) ); ?>"></script>
|
||||
<script src="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/mediaelement/wp-mediaelement.js' ) ); ?>"></script>
|
||||
|
||||
<link rel="stylesheet" href="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/mediaelement/mediaelementplayer.min.css' ) ); ?>" />
|
||||
<link rel="stylesheet" href="<?php echo amt_embed_make_https( amt_embed_get_includes_url( 'js/mediaelement/wp-mediaelement.css' ) ); ?>" />
|
||||
|
||||
<style>
|
||||
video { width: 100%; height: 100%; max-width: 100%; }
|
||||
.wp-video, .wp-video-shortcode, .mejs-overlay, .mejs-poster { width: 100% !important; }
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0">
|
||||
|
||||
<?php
|
||||
$attrs = array(
|
||||
'src' => amt_embed_make_https( amt_embed_get_stream_url( amt_embed_get_id() ) ),
|
||||
'poster' => amt_embed_make_https( amt_embed_get_preview_image( amt_embed_get_id() ) ),
|
||||
'loop' => '',
|
||||
'autoplay' => '',
|
||||
'preload' => 'none',
|
||||
//'width' => '',
|
||||
//'height' => ''
|
||||
);
|
||||
echo do_shortcode( wp_video_shortcode( $attrs ) );
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
46
php-fpm/wordpress_files/plugins/add-meta-tags/uninstall.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// delete_option('add_meta_tags_opts');
|
@ -0,0 +1,22 @@
|
||||
<wpml-config>
|
||||
<custom-fields>
|
||||
<custom-field action="translate">_amt_description</custom-field>
|
||||
<custom-field action="translate">_amt_keywords</custom-field>
|
||||
<custom-field action="translate">_amt_title</custom-field>
|
||||
<custom-field action="translate">_amt_news_keywords</custom-field>
|
||||
<custom-field action="translate">_amt_full_metatags</custom-field>
|
||||
<custom-field action="copy">_amt_image_url</custom-field>
|
||||
<custom-field action="ignore">_amt_content_locale</custom-field>
|
||||
<custom-field action="translate">_amt_express_review</custom-field>
|
||||
<custom-field action="copy">_amt_referenced_list</custom-field>
|
||||
</custom-fields>
|
||||
<admin-texts>
|
||||
<key name="add_meta_tags_opts">
|
||||
<key name="site_description" />
|
||||
<key name="site_keywords" />
|
||||
<key name="global_keywords" />
|
||||
<key name="copyright_url" />
|
||||
</key>
|
||||
</admin-texts>
|
||||
</wpml-config>
|
||||
|
@ -0,0 +1,49 @@
|
||||
Attachment Importer
|
||||
===================
|
||||
Import attachments from another WordPress blog using a WXR file.
|
||||
|
||||
What is this?
|
||||
-------------
|
||||
I found the WordPress Importer plugin is good for importing posts and comments, but is lacking when it comes to importing large attachments (like images) from large sites. My import would often time out and crash. I wrote this plugin to help with my own blog migrations, but I hope you find it useful too.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
1. Either a) download from the WordPress plugin repository, or b) upload the attachment-importer directory to your plugins directory.
|
||||
2. Navigate to Plugins -> Attachment Importer and activate.
|
||||
3. Go to Tools -> Import -> Attachment Importer to run.
|
||||
|
||||
Usage
|
||||
-----
|
||||
0. As a prerequisite, import your WXR file using the WordPress importer, but do not select the option to Download and Import Attachments. I have found that an import file up to 15MB big will work as long as you don't import attachments.
|
||||
1. Navigate to the Attachment Importer screen.
|
||||
2. Select your WXR export file.
|
||||
3. Select the user you would like to be the owner of the downloaded images. Default: current user.
|
||||
4. Sit back and let the importer run. The process can take as little as 10 seconds for 10 images, or about two hours for 2000 images. These times depend on the server that hosts your WordPress site.
|
||||
5. If you receive any errors during the process, try running the file again after it finishes. The plugin is programmed to ignore files that match the following criteria:
|
||||
* Same name
|
||||
* Same file name
|
||||
* Same upload date
|
||||
* Same file size
|
||||
|
||||
How it works
|
||||
------------
|
||||
This plugin uses [FileReader](https://developer.mozilla.org/en-US/docs/Web/API/FileReader) and to parse the XML file in the browser, then uses ajax to request WordPress perform individual uploads.
|
||||
|
||||
License
|
||||
-------
|
||||
Attachment Importer - A plugin for WordPress to import attachments from another blog using a WXR file.
|
||||
Copyright (C) 2014 Toasted Lime
|
||||
|
||||
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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
The license and copyright applies to all resources bundled with this plugin, except as noted below:
|
||||
|
||||
Portions of this plugin use code from:
|
||||
|
||||
* [WordPress Importer](http://wordpress.org/extend/plugins/wordpress-importer/) which is distributed under the terms of the GNU GPL v2, Copyright (C) 2013 wordpressdotorg.
|
||||
* [jQuery UI Smoothness Theme](http://jqueryui.com/themeroller/) which is distributed under the terms of MIT License, Copyright (C) 2014 jQuery Foundation and other contributors.
|
1199
php-fpm/wordpress_files/plugins/attachment-importer/inc/jquery-ui.css
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
.ui-progressbar{
|
||||
position:relative;
|
||||
}
|
||||
#attachment-importer-progresslabel{
|
||||
position:absolute;
|
||||
top:4px;
|
||||
left:1%;
|
||||
}
|
329
php-fpm/wordpress_files/plugins/attachment-importer/index.php
Normal file
@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Attachment Importer
|
||||
* Plugin URI: http://github.com/toastedlime/wp-attachment-importer
|
||||
* Description: Imports images from a WordPress XML export file. This is useful if you have a large number of images to import and your server times out while importing using the WordPress Importer plugin.
|
||||
* Version: 0.6.0
|
||||
* Author: Toasted Lime
|
||||
* Author URI: http://www.toastedlime.com
|
||||
* License: GPL v2 or later
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Text Domain: attachment-importer
|
||||
*/
|
||||
|
||||
function attachment_importer_scripts(){
|
||||
|
||||
wp_register_script( 'attachment-importer-js', plugins_url( 'main.js', __FILE__ ), array( 'jquery', 'jquery-ui-tooltip', 'jquery-ui-progressbar' ), 20140421, true );
|
||||
|
||||
}
|
||||
|
||||
function attachment_importer_add_page(){
|
||||
|
||||
register_importer( 'attachment-importer', 'Attachment Importer', 'Import attachments from a WordPress export file.', 'attachment_importer_options_page' );
|
||||
|
||||
}
|
||||
|
||||
function attachment_importer_options_page(){
|
||||
|
||||
wp_enqueue_script( 'attachment-importer-js' );
|
||||
wp_localize_script( 'attachment-importer-js', 'aiL10n', array(
|
||||
'emptyInput' => __( 'Please select a file.', 'attachment-importer' ),
|
||||
'noAttachments' => __( 'There were no attachment files found in the import file.', 'attachment-importer' ),
|
||||
'parsing' => __( 'Parsing the file.', 'attachment-importer' ),
|
||||
'importing' => __( 'Importing file ', 'attachment-importer' ),
|
||||
'progress' => __( 'Overall progress: ', 'attachment-importer' ),
|
||||
'retrying' => __( 'An error occured. In 5 seconds, retrying file ', 'attachment-importer' ),
|
||||
'done' => __( 'All done!', 'attachment-importer' ),
|
||||
'ajaxFail' => __( 'There was an error connecting to the server.', 'attachment-importer' ),
|
||||
'pbAjaxFail' => __( 'The program could not run. Check the error log below or your JavaScript console for more information', 'attachment-importer' ),
|
||||
'fatalUpload' => __( 'There was a fatal error. Check the last entry in the error log below.', 'attachment-importer' )
|
||||
) );
|
||||
wp_localize_script( 'attachment-importer-js', 'aiSecurity', array(
|
||||
'nonce' => wp_create_nonce( 'import-attachment-plugin' )
|
||||
) );
|
||||
wp_enqueue_style( 'jquery-ui', plugins_url( 'inc/jquery-ui.css', __FILE__ ) );
|
||||
wp_enqueue_style( 'attachment-importer', plugins_url( 'inc/style.css', __FILE__ ) );
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<h2><?php _e( 'Attachment Importer', 'attachment-importer' ); ?></h2>
|
||||
|
||||
<noscript>
|
||||
|
||||
<div class="error">
|
||||
|
||||
<p><?php _e( 'Sorry, but your browser doesn\'t have JavaScript enabled, and this plugin requires JavaScript.', 'attachment-importer' ); ?></p>
|
||||
|
||||
<p><?php _e( 'Please enable JavaScript for this site to continue.', 'attachment-importer' ); ?></p>
|
||||
|
||||
</div>
|
||||
|
||||
</noscript>
|
||||
|
||||
<div id="attachment-importer-init"></div>
|
||||
|
||||
<div id="attachment-importer-progressbar"><div id="attachment-importer-progresslabel"></div></div>
|
||||
|
||||
<div id="attachment-importer-output"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'admin_enqueue_scripts', 'attachment_importer_scripts' );
|
||||
|
||||
add_action( 'admin_menu', 'attachment_importer_add_page' );
|
||||
|
||||
add_action( 'wp_ajax_attachment_importer_init_success', 'attachment_importer_init_success' );
|
||||
|
||||
add_action( 'wp_ajax_attachment_importer_init_failure', 'attachment_importer_init_failure' );
|
||||
|
||||
add_action( 'wp_ajax_attachment_importer_upload', 'attachment_importer_uploader' );
|
||||
|
||||
// AJAX functions are below this line.
|
||||
|
||||
function attachment_importer_init_success(){
|
||||
?>
|
||||
<p><?php _e( 'Select the WordPress eXtended RSS (WXR) file and we\'ll try to get the images and upload them to your blog.', 'attachment-importer' ); ?></p>
|
||||
|
||||
<p><?php _e( 'Choose a WXR (.xml) file from your computer and press upload.', 'attachment-importer' ); ?></p>
|
||||
|
||||
<p><input type="file" name="file" id="file"/></p>
|
||||
|
||||
<p><?php _e( 'Attribute uploaded images to:', 'attachment-importer' ); ?><br/>
|
||||
<input type="radio" name="author" value=1 checked /> <?php _e( 'Current User', 'attachment-importer' ); ?><br/>
|
||||
<input type="radio" name="author" value=2 /> <?php _e( 'User in the import file', 'attachment-importer'); ?><br/>
|
||||
<input type="radio" name="author" value=3 /> <?php _e( 'Select User:', 'attachment-importer' ); ?> <?php wp_dropdown_users(); ?>
|
||||
|
||||
<p><input type="checkbox" name="delay" /> <?php _e( 'Delay file requests by at least five seconds.', 'attachment-importer' ); ?> <a href="#" title="<?php _e( 'This delay can be useful to mitigate hosts that throttle traffic when too many requests are detected from an IP address and mistaken for a DDOS attack.', 'attachment-importer' ); ?>" style="text-decoration:none;"><span class="dashicons dashicons-editor-help"></span></a></p>
|
||||
|
||||
<p><?php submit_button( _x( 'Upload', 'A button which will submit the attachment for processing when clicked.', 'attachment-importer'), 'secondary', 'upload', false ); ?></p>
|
||||
|
||||
<?php
|
||||
die();}
|
||||
|
||||
function attachment_importer_init_failure(){
|
||||
?>
|
||||
|
||||
<div class="error">
|
||||
<p><?php _e( 'Sorry, but you\'re using an <strong>outdated</strong> browser that doesn\'t support the features required to use this plugin.', 'attachment-importer' ); ?></p>
|
||||
<p><?php echo sprintf( __( 'You must <a href="%s">upgrade your browser</a> in order to use this plugin.', 'attachment-importer' ), 'http://browsehappy.com' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
die();}
|
||||
|
||||
function attachment_importer_uploader(){
|
||||
|
||||
// check nonce before doing anything else
|
||||
if( !check_ajax_referer( 'import-attachment-plugin', false, false ) ){
|
||||
$nonce_error = new WP_Error( 'nonce_error', __('Are you sure you want to do this?', 'attachment-importer') );
|
||||
echo json_encode ( array(
|
||||
'fatal' => true,
|
||||
'type' => 'error',
|
||||
'code' => $nonce_error->get_error_code(),
|
||||
'message' => $nonce_error->get_error_message(),
|
||||
'text' => sprintf( __( 'The <a href="%1$s">security key</a> provided with this request is invalid. Is someone trying to trick you to upload something you don\'t want to? If you really meant to take this action, reload your browser window and try again. (<strong>%2$s</strong>: %3$s)', 'attachment-importer' ), 'http://codex.wordpress.org/WordPress_Nonces', $nonce_error->get_error_code(), $nonce_error->get_error_message() )
|
||||
) );
|
||||
die();
|
||||
}
|
||||
|
||||
$parameters = array(
|
||||
'url' => $_POST['url'],
|
||||
'post_title' => $_POST['title'],
|
||||
'link' => $_POST['link'],
|
||||
'pubDate' => $_POST['pubDate'],
|
||||
'post_author' => $_POST['creator'],
|
||||
'guid' => $_POST['guid'],
|
||||
'import_id' => $_POST['post_id'],
|
||||
'post_date' => $_POST['post_date'],
|
||||
'post_date_gmt' => $_POST['post_date_gmt'],
|
||||
'comment_status' => $_POST['comment_status'],
|
||||
'ping_status' => $_POST['ping_status'],
|
||||
'post_name' => $_POST['post_name'],
|
||||
'post_status' => $_POST['status'],
|
||||
'post_parent' => $_POST['post_parent'],
|
||||
'menu_order' => $_POST['menu_order'],
|
||||
'post_type' => $_POST['post_type'],
|
||||
'post_password' => $_POST['post_password'],
|
||||
'is_sticky' => $_POST['is_sticky'],
|
||||
'attribute_author1' => $_POST['author1'],
|
||||
'attribute_author2' => $_POST['author2']
|
||||
);
|
||||
|
||||
function process_attachment( $post, $url ) {
|
||||
|
||||
$pre_process = pre_process_attachment( $post, $url );
|
||||
if( is_wp_error( $pre_process ) )
|
||||
return array(
|
||||
'fatal' => false,
|
||||
'type' => 'error',
|
||||
'code' => $pre_process->get_error_code(),
|
||||
'message' => $pre_process->get_error_message(),
|
||||
'text' => sprintf( __( '%1$s was not uploaded. (<strong>%2$s</strong>: %3$s)', 'attachment-importer' ), $post['post_title'], $pre_process->get_error_code(), $pre_process->get_error_message() )
|
||||
);
|
||||
|
||||
// if the URL is absolute, but does not contain address, then upload it assuming base_site_url
|
||||
if ( preg_match( '|^/[\w\W]+$|', $url ) )
|
||||
$url = rtrim( $this->base_url, '/' ) . $url;
|
||||
|
||||
$upload = fetch_remote_file( $url, $post );
|
||||
if ( is_wp_error( $upload ) )
|
||||
return array(
|
||||
'fatal' => ( $upload->get_error_code() == 'upload_dir_error' && $upload->get_error_message() != 'Invalid file type' ? true : false ),
|
||||
'type' => 'error',
|
||||
'code' => $upload->get_error_code(),
|
||||
'message' => $upload->get_error_message(),
|
||||
'text' => sprintf( __( '%1$s could not be uploaded because of an error. (<strong>%2$s</strong>: %3$s)', 'attachment-importer' ), $post['post_title'], $upload->get_error_code(), $upload->get_error_message() )
|
||||
);
|
||||
|
||||
if ( $info = wp_check_filetype( $upload['file'] ) )
|
||||
$post['post_mime_type'] = $info['type'];
|
||||
else {
|
||||
$upload = new WP_Error( 'attachment_processing_error', __('Invalid file type', 'attachment-importer') );
|
||||
return array(
|
||||
'fatal' => false,
|
||||
'type' => 'error',
|
||||
'code' => $upload->get_error_code(),
|
||||
'message' => $upload->get_error_message(),
|
||||
'text' => sprintf( __( '%1$s could not be uploaded because of an error. (<strong>%2$s</strong>: %3$s)', 'attachment-importer' ), $post['post_title'], $upload->get_error_code(), $upload->get_error_message() )
|
||||
);
|
||||
}
|
||||
|
||||
$post['guid'] = $upload['url'];
|
||||
|
||||
// Set author per user options.
|
||||
switch( $post['attribute_author1'] ){
|
||||
|
||||
case 1: // Attribute to current user.
|
||||
$post['post_author'] = (int) wp_get_current_user()->ID;
|
||||
break;
|
||||
|
||||
case 2: // Attribute to user in import file.
|
||||
if( !username_exists( $post['post_author'] ) )
|
||||
wp_create_user( $post['post_author'], wp_generate_password() );
|
||||
$post['post_author'] = (int) username_exists( $post['post_author'] );
|
||||
break;
|
||||
|
||||
case 3: // Attribute to selected user.
|
||||
$post['post_author'] = (int) $post['attribute_author2'];
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// as per wp-admin/includes/upload.php
|
||||
$post_id = wp_insert_attachment( $post, $upload['file'] );
|
||||
wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) );
|
||||
|
||||
// remap image URL's
|
||||
backfill_attachment_urls( $url, $upload['url'] );
|
||||
|
||||
return array(
|
||||
'fatal' => false,
|
||||
'type' => 'updated',
|
||||
'text' => sprintf( __( '%s was uploaded successfully', 'attachment-importer' ), $post['post_title'] )
|
||||
);
|
||||
}
|
||||
|
||||
function pre_process_attachment( $post, $url ){
|
||||
global $wpdb;
|
||||
|
||||
$imported = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
SELECT ID, post_date_gmt, guid
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = 'attachment'
|
||||
AND post_title = %s
|
||||
",
|
||||
$post['post_title']
|
||||
)
|
||||
);
|
||||
|
||||
if( $imported ){
|
||||
foreach( $imported as $attachment ){
|
||||
if( basename( $url ) == basename( $attachment->guid ) ){
|
||||
if( $post['post_date_gmt'] == $attachment->post_date_gmt ){
|
||||
$headers = wp_get_http( $url );
|
||||
if( filesize( get_attached_file( $attachment->ID ) ) == $headers['content-length'] ){
|
||||
return new WP_Error( 'duplicate_file_notice', __( 'File already exists', 'attachment-importer' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function fetch_remote_file( $url, $post ) {
|
||||
// extract the file name and extension from the url
|
||||
$file_name = basename( $url );
|
||||
|
||||
// get placeholder file in the upload dir with a unique, sanitized filename
|
||||
$upload = wp_upload_bits( $file_name, 0, '', $post['post_date'] );
|
||||
if ( $upload['error'] )
|
||||
return new WP_Error( 'upload_dir_error', $upload['error'] );
|
||||
|
||||
// fetch the remote url and write it to the placeholder file
|
||||
$headers = wp_get_http( $url, $upload['file'] );
|
||||
|
||||
// request failed
|
||||
if ( ! $headers ) {
|
||||
@unlink( $upload['file'] );
|
||||
return new WP_Error( 'import_file_error', __('Remote server did not respond', 'attachment-importer') );
|
||||
}
|
||||
|
||||
// make sure the fetch was successful
|
||||
if ( $headers['response'] != '200' ) {
|
||||
@unlink( $upload['file'] );
|
||||
return new WP_Error( 'import_file_error', sprintf( __('Remote server returned error response %1$d %2$s', 'attachment-importer'), esc_html($headers['response']), get_status_header_desc($headers['response']) ) );
|
||||
}
|
||||
|
||||
$filesize = filesize( $upload['file'] );
|
||||
|
||||
if ( isset( $headers['content-length'] ) && $filesize != $headers['content-length'] ) {
|
||||
@unlink( $upload['file'] );
|
||||
return new WP_Error( 'import_file_error', __('Remote file is incorrect size', 'attachment-importer') );
|
||||
}
|
||||
|
||||
if ( 0 == $filesize ) {
|
||||
@unlink( $upload['file'] );
|
||||
return new WP_Error( 'import_file_error', __('Zero size file downloaded', 'attachment-importer') );
|
||||
}
|
||||
|
||||
return $upload;
|
||||
}
|
||||
|
||||
function backfill_attachment_urls( $from_url, $to_url ) {
|
||||
global $wpdb;
|
||||
// remap urls in post_content
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
UPDATE {$wpdb->posts}
|
||||
SET post_content = REPLACE(post_content, %s, %s)
|
||||
",
|
||||
$from_url, $to_url
|
||||
)
|
||||
);
|
||||
// remap enclosure urls
|
||||
$result = $wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
UPDATE {$wpdb->postmeta}
|
||||
SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'
|
||||
",
|
||||
$from_url, $to_url
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$remote_url = ! empty($parameters['attachment_url']) ? $parameters['attachment_url'] : $parameters['guid'];
|
||||
|
||||
echo json_encode( process_attachment( $parameters, $remote_url ) );
|
||||
|
||||
die();}
|
226
php-fpm/wordpress_files/plugins/attachment-importer/main.js
Normal file
@ -0,0 +1,226 @@
|
||||
jQuery(document).ready(function($){
|
||||
|
||||
$( document ).tooltip();
|
||||
|
||||
var divInit = $( '#attachment-importer-init' );
|
||||
|
||||
if ( ! window.FileReader ){
|
||||
|
||||
$.get(
|
||||
ajaxurl,
|
||||
{action:'attachment_importer_init_failure'},
|
||||
function( data ){
|
||||
$( data ).appendTo( divInit );
|
||||
});
|
||||
|
||||
} else{
|
||||
|
||||
$.get(
|
||||
ajaxurl,
|
||||
{action:'attachment_importer_init_success'},
|
||||
function( data ){
|
||||
$( data ).appendTo( divInit );
|
||||
});
|
||||
|
||||
$( document ).on('click', '.button', function(){
|
||||
|
||||
var input = $( '#file' ).get(0).files[0],
|
||||
reader = new FileReader(),
|
||||
divOutput = $( '#attachment-importer-output' ),
|
||||
author1 = $( "input[name='author']:checked" ).val(),
|
||||
author2 = $( "select[name='user']" ).val(),
|
||||
delay = ( $( "input[name='delay']" ).is( ':checked' ) ? 5000 : 0 ),
|
||||
progressBar = $( "#attachment-importer-progressbar" ),
|
||||
progressLabel = $( "#attachment-importer-progresslabel" );
|
||||
|
||||
if ( ! input ){
|
||||
|
||||
alert( aiL10n.emptyInput );
|
||||
|
||||
} else {
|
||||
|
||||
divOutput.empty();
|
||||
|
||||
$( function(){
|
||||
progressBar.progressbar({
|
||||
value: false
|
||||
});
|
||||
progressLabel.text( aiL10n.parsing );
|
||||
});
|
||||
|
||||
reader.readAsText(input);
|
||||
|
||||
reader.onload = function(e){
|
||||
|
||||
var file = e.target.result,
|
||||
parser = new DOMParser(),
|
||||
xml = parser.parseFromString( file, "text/xml" ),
|
||||
url = [],
|
||||
title = [],
|
||||
link = [],
|
||||
pubDate = [],
|
||||
creator = [],
|
||||
guid = [],
|
||||
postID = [],
|
||||
postDate = [],
|
||||
postDateGMT = [],
|
||||
commentStatus = [],
|
||||
pingStatus = [],
|
||||
postName = [],
|
||||
status = [],
|
||||
postParent = [],
|
||||
menuOrder = [],
|
||||
postType = [],
|
||||
postPassword = [],
|
||||
isSticky = [];
|
||||
|
||||
$( xml ).find( 'item' ).each(function(){
|
||||
|
||||
var xml_post_type = $( this ).find( 'wp\\:post_type, post_type' ).text();
|
||||
|
||||
if( xml_post_type == 'attachment' ){ // We're only looking for image attachments.
|
||||
url.push( $( this ).find( 'wp\\:attachment_url, attachment_url' ).text() );
|
||||
title.push( $( this ).find( 'title' ).text() );
|
||||
link.push( $( this ).find( 'link' ).text() );
|
||||
pubDate.push( $( this ).find( 'pubDate' ).text() );
|
||||
creator.push( $( this ).find( 'dc\\:creator, creator' ).text() );
|
||||
guid.push( $( this ).find( 'guid' ).text() );
|
||||
postID.push( $( this ).find( 'wp\\:post_id, post_id' ).text() );
|
||||
postDate.push( $( this ).find( 'wp\\:post_date, post_date' ).text() );
|
||||
postDateGMT.push( $( this ).find( 'wp\\:post_date_gmt, post_date_gmt' ).text() );
|
||||
commentStatus.push( $( this ).find( 'wp\\:comment_status, comment_status' ).text() );
|
||||
pingStatus.push( $( this ).find( 'wp\\:ping_status, ping_status' ).text() );
|
||||
postName.push( $( this ).find( 'wp\\:post_name, post_name' ).text() );
|
||||
status.push( $( this ).find( 'wp\\:status, status' ).text() );
|
||||
postParent.push( $( this ).find( 'wp\\:post_parent, post_parent' ).text() );
|
||||
menuOrder.push( $( this ).find( 'wp\\:menu_order, menu_order' ).text() );
|
||||
postType.push( xml_post_type );
|
||||
postPassword.push( $( this ).find( 'wp\\:post_password, post_password' ).text() );
|
||||
isSticky.push( $( this ).find( 'wp\\:is_sticky, is_sticky' ).text() );
|
||||
}
|
||||
});
|
||||
|
||||
var pbMax = postType.length;
|
||||
|
||||
$( function(){
|
||||
progressBar.progressbar({
|
||||
value:0,
|
||||
max: postType.length,
|
||||
complete: function(){
|
||||
progressLabel.text( aiL10n.done );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Define counter variable outside the import attachments function
|
||||
// to keep track of the failed attachments to re-import them.
|
||||
var failedAttachments = 0;
|
||||
|
||||
function import_attachments( i ){
|
||||
progressLabel.text( aiL10n.importing + '" ' + title[i] + '". ' + aiL10n.progress + progressBar.progressbar( "value" ) + "/" + pbMax );
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'attachment_importer_upload',
|
||||
_ajax_nonce: aiSecurity.nonce,
|
||||
author1:author1,
|
||||
author2:author2,
|
||||
url:url[i],
|
||||
title:title[i],
|
||||
link:link[i],
|
||||
pubDate:pubDate[i],
|
||||
creator:creator[i],
|
||||
guid:guid[i],
|
||||
post_id:postID[i],
|
||||
post_date:postDate[i],
|
||||
post_date_gmt:postDateGMT[i],
|
||||
comment_status:commentStatus[i],
|
||||
ping_status:pingStatus[i],
|
||||
post_name:postName[i],
|
||||
status:status[i],
|
||||
post_parent:postParent[i],
|
||||
menu_order:menuOrder[i],
|
||||
post_type:postType[i],
|
||||
post_password:postPassword[i],
|
||||
is_sticky:isSticky[i]
|
||||
}
|
||||
})
|
||||
.done(function( data, status, xhr ){
|
||||
// Parse the response.
|
||||
var obj = $.parseJSON( data );
|
||||
|
||||
// If error shows the server did not respond,
|
||||
// try the upload again, to a max of 3 tries.
|
||||
if( obj.message == "Remote server did not respond" && failedAttachments < 5 ){
|
||||
failedAttachments++;
|
||||
progressLabel.text( aiL10n.retrying + '"' + title[i] + '". ' + aiL10n.progress + progressBar.progressbar( "value" ) + "/" + pbMax );
|
||||
setTimeout( function(){
|
||||
import_attachments( i );
|
||||
}, 5000 );
|
||||
}
|
||||
|
||||
// If a non-fatal error occurs, note it and move on.
|
||||
else if( obj.type == "error" && !obj.fatal ){
|
||||
$( '<p>' + obj.text + '</p>' ).appendTo( divOutput );
|
||||
next_image(i);
|
||||
}
|
||||
|
||||
// If a fatal error occurs, stop the program and print the error to the browser.
|
||||
else if( obj.fatal ){
|
||||
progressBar.progressbar( "value", pbMax );
|
||||
progressLabel.text( aiL10n.fatalUpload );
|
||||
$( '<div class="' + obj.type + '">' + obj.text +'</div>' ).appendTo( divOutput );
|
||||
return false;
|
||||
}
|
||||
|
||||
else { // Moving on.
|
||||
next_image(i);
|
||||
}
|
||||
})
|
||||
.fail(function( xhr, status, error ){
|
||||
console.error(status);
|
||||
console.error(error);
|
||||
progressBar.progressbar( "value", pbMax );
|
||||
progressLabel.text( aiL10n.pbAjaxFail );
|
||||
$( '<div class="error">' + aiL10n.ajaxFail +'</div>' ).appendTo( divOutput );
|
||||
});
|
||||
}
|
||||
|
||||
function next_image( i ){
|
||||
// Increment the internal counter and progress bar.
|
||||
i++;
|
||||
progressBar.progressbar( "value", progressBar.progressbar( "value" ) + 1 );
|
||||
failedAttachments = 0;
|
||||
|
||||
// If every thing is normal, but we still have posts to process,
|
||||
// then continue with the program.
|
||||
if( postType[i] ){
|
||||
setTimeout( function(){
|
||||
import_attachments( i )
|
||||
}, delay );
|
||||
}
|
||||
|
||||
// Getting this far means there are no more attachments, so stop the program.
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if( postType[0] ){
|
||||
import_attachments( 0 );
|
||||
} else{
|
||||
progressBar.progressbar( "value", pbMax );
|
||||
progressLabel.text( aiL10n.pbAjaxFail );
|
||||
$( '<div class="error">' + aiL10n.noAttachments +'</div>' ).appendTo( divOutput );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
@ -0,0 +1,83 @@
|
||||
=== Attachment Importer ===
|
||||
Contributors: piontkowski
|
||||
Tags: importer, import, attachment, attachments, image, images, wordpress, wxr, xml
|
||||
Requires at least: 3.0
|
||||
Tested up to: 4.0
|
||||
Stable tag: 0.6.0
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Import attachments from another WordPress blog using a WXR file.
|
||||
|
||||
== Description ==
|
||||
|
||||
= What is this? =
|
||||
|
||||
I found the WordPress Importer plugin is good for importing posts and comments, but is lacking when it comes to importing large attachments (like images) from large sites. My import would often time out and crash. I wrote this plugin to help with my own blog migrations, but I hope you find it useful too.
|
||||
|
||||
= Usage =
|
||||
|
||||
0. As a prerequisite, import your WXR file using the WordPress importer, but do not select the option to Download and Import Attachments. I have found that an import file up to 15MB big will work as long as you don't import attachments.
|
||||
1. Navigate to the Attachment Importer screen.
|
||||
2. Select your WXR export file.
|
||||
3. Select the user you would like to be the owner of the downloaded images. Default: current user.
|
||||
4. Sit back and let the importer run. The process can take as little as 10 seconds for 10 images, or about two hours for 2000 images. These times depend on the server that hosts your WordPress site.
|
||||
5. If you receive any errors during the process, try running the file again after it finishes. The plugin is programmed to ignore files that match the following criteria:
|
||||
* Same name
|
||||
* Same file name
|
||||
* Same upload date
|
||||
* Same file size
|
||||
|
||||
= How it works. =
|
||||
|
||||
This plugin uses [FileReader](https://developer.mozilla.org/en-US/docs/Web/API/FileReader) and to parse the XML file in the browser, then uses ajax to request WordPress perform individual uploads.
|
||||
|
||||
= License =
|
||||
|
||||
Attachment Importer - A plugin for WordPress to import attachments from another blog using a WXR file.
|
||||
Copyright (C) 2014 Toasted Lime
|
||||
|
||||
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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
The license and copyright applies to all resources bundled with this plugin, except as noted below:
|
||||
|
||||
Portions of this plugin use code from:
|
||||
|
||||
* [WordPress Importer](http://wordpress.org/extend/plugins/wordpress-importer/) which is distributed under the terms of the GNU GPL v2, Copyright (C) 2013 wordpressdotorg.
|
||||
* [jQuery UI Smoothness Theme](http://jqueryui.com/themeroller/) which is distributed under the terms of MIT License, Copyright (C) 2014 jQuery Foundation and other contributors.
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Either a) download from the WordPress plugin repository, or b) upload the attachment-importer directory to your plugins directory.
|
||||
2. Navigate to Plugins -> Attachment Importer and activate.
|
||||
3. Go to Tools -> Import -> Attachment Importer to run.
|
||||
|
||||
== Changeset ==
|
||||
|
||||
= 0.6.0 =
|
||||
Should not get "Remote server did not respond" as often.
|
||||
|
||||
= 0.5.6 =
|
||||
|
||||
* Invalid file type produces non-fatal error.
|
||||
|
||||
= 0.5.5 =
|
||||
|
||||
* Added an overall progress bar.
|
||||
* Improve how the program responds to events like fatal errors, AJAX failure, or if there are no attachments in the import file.
|
||||
|
||||
= 0.5.4 =
|
||||
|
||||
* Fixed issue reading namespaces in import file that caused the program not to work in FireFox and Internet Explorer.
|
||||
* Moved plugin to Import menu from the Media menu.
|
||||
|
||||
= 0.5.3 =
|
||||
|
||||
* Added option to add five second delay between image ajax requests
|
||||
* Reformat Readme
|
||||
* Added jQuery tooltip
|
||||
|
172
php-fpm/wordpress_files/plugins/autopost-to-mastodon/client.php
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
class Client
|
||||
{
|
||||
private $instance_url;
|
||||
private $access_token;
|
||||
private $app;
|
||||
|
||||
public function __construct($instance_url, $access_token = '') {
|
||||
$this->instance_url = $instance_url;
|
||||
$this->access_token = $access_token;
|
||||
}
|
||||
|
||||
public function register_app($redirect_uri) {
|
||||
|
||||
$response = $this->_post('/api/v1/apps', array(
|
||||
'client_name' => 'Mastodon Share for WordPress',
|
||||
'redirect_uris' => $redirect_uri,
|
||||
'scopes' => 'write:statuses write:media read:accounts',
|
||||
'website' => $this->instance_url
|
||||
));
|
||||
|
||||
if (!isset($response->client_id)){
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
|
||||
$this->app = $response;
|
||||
|
||||
|
||||
$params = http_build_query(array(
|
||||
'response_type' => 'code',
|
||||
'redirect_uri' => $redirect_uri,
|
||||
'scope' => 'write:statuses write:media read:accounts',
|
||||
'client_id' =>$this->app->client_id
|
||||
));
|
||||
|
||||
return $this->instance_url.'/oauth/authorize?'.$params;
|
||||
}
|
||||
|
||||
public function verify_credentials($access_token){
|
||||
|
||||
$headers = array(
|
||||
'Authorization'=>'Bearer '.$access_token
|
||||
);
|
||||
|
||||
$response = $this->_get('/api/v1/accounts/verify_credentials', null, $headers);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function get_bearer_token($client_id, $client_secret, $code, $redirect_uri) {
|
||||
|
||||
$response = $this->_post('/oauth/token',array(
|
||||
'grant_type' => 'authorization_code',
|
||||
'redirect_uri' => $redirect_uri,
|
||||
'client_id' => $client_id,
|
||||
'client_secret' => $client_secret,
|
||||
'code' => $code
|
||||
));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function get_client_id() {
|
||||
return $this->app->client_id;
|
||||
}
|
||||
|
||||
public function get_client_secret() {
|
||||
return $this->app->client_secret;
|
||||
}
|
||||
|
||||
public function postStatus($status, $mode, $media = '', $spoiler_text = '') {
|
||||
|
||||
$headers = array(
|
||||
'Authorization'=> 'Bearer '.$this->access_token
|
||||
);
|
||||
|
||||
$response = $this->_post('/api/v1/statuses', array(
|
||||
'status' => $status,
|
||||
'visibility' => $mode,
|
||||
'spoiler_text' => $spoiler_text,
|
||||
'media_ids[]' => $media
|
||||
), $headers);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function create_attachment($media_path) {
|
||||
|
||||
$filename =basename($media_path);
|
||||
$mime_type = mime_content_type($media_path);
|
||||
|
||||
$boundary ='hlx'.time();
|
||||
|
||||
$headers = array (
|
||||
'Authorization'=> 'Bearer '.$this->access_token,
|
||||
'Content-Type' => 'multipart/form-data; boundary='. $boundary,
|
||||
);
|
||||
|
||||
$nl = "\r\n";
|
||||
|
||||
$data = '--'.$boundary.$nl;
|
||||
$data .= 'Content-Disposition: form-data; name="file"; filename="'.$filename.'"'.$nl;
|
||||
$data .= 'Content-Type: '. $mime_type .$nl.$nl;
|
||||
$data .= file_get_contents($media_path) .$nl;
|
||||
$data .= '--'.$boundary.'--';
|
||||
|
||||
$response = $this->_post('/api/v1/media', $data, $headers);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function _post($url, $data = array(), $headers = array()) {
|
||||
return $this->post($this->instance_url.$url, $data, $headers);
|
||||
}
|
||||
|
||||
public function _get($url, $data = array(), $headers = array()) {
|
||||
return $this->get($this->instance_url.$url, $data, $headers);
|
||||
}
|
||||
|
||||
private function post($url, $data = array(), $headers = array()) {
|
||||
$args = array(
|
||||
'headers' => $headers,
|
||||
'body'=> $data,
|
||||
'redirection' => 5
|
||||
);
|
||||
|
||||
$response = wp_remote_post( $this->getValidURL($url), $args );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$error_message = $response->get_error_message();
|
||||
|
||||
} else {
|
||||
$responseBody = wp_remote_retrieve_body($response);
|
||||
return json_decode($responseBody);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function get($url, $data = array(), $headers = array()) {
|
||||
$args = array(
|
||||
'headers' => $headers,
|
||||
'redirection' => 5
|
||||
);
|
||||
$response = wp_remote_get( $this->getValidURL($url), $args );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$error_message = $response->get_error_message();
|
||||
|
||||
} else {
|
||||
$responseBody = wp_remote_retrieve_body($response);
|
||||
return json_decode($responseBody);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function dump($value){
|
||||
echo '<pre>';
|
||||
print_r($value);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
private function getValidURL($url){
|
||||
if ( $ret = parse_url($url) ) {
|
||||
if ( !isset($ret["scheme"]) ){
|
||||
$url = "http://{$url}";
|
||||
}
|
||||
}
|
||||
return $url;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
define("ACCOUNT_CONNECTED",isset($account) && $account !== null);
|
||||
define("ADVANCED_VIEW",false);
|
||||
?>
|
||||
|
||||
|
||||
<div class="wrap">
|
||||
<h1><?php esc_html_e( 'Mastodon Autopost Configuration', 'autopost-to-mastodon' ); ?></h1>
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
<a href="https://github.com/simonfrey/mastodon_wordpress_autopost" target="_blank" class="github-icon" target="_blank">
|
||||
<svg aria-hidden="true" class="octicon octicon-mark-github" height="32" version="1.1" viewBox="0 0 16 16" width="32"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg>
|
||||
</a>
|
||||
|
||||
<a href="https://paypal.me/51edpo" target="_blank"><img src="<?php echo plugins_url( 'img/paypal.png', __FILE__ );?>" style="height:30px;"></a>
|
||||
<br>
|
||||
<br>
|
||||
<?php if(ACCOUNT_CONNECTED): ?>
|
||||
<input type="button" class="button active tab-button" value="<?php esc_attr_e( 'Simple configuration', 'autopost-to-mastodon' ); ?>" id="hide_advanced_configuration">
|
||||
<input type="button" class="button tab-button" value="<?php esc_attr_e( 'Advanced configuration', 'autopost-to-mastodon' ); ?>" id="show_advanced_configuration">
|
||||
<?php endif ?>
|
||||
<form method="POST">
|
||||
<?php wp_nonce_field( 'autopostToMastodon-configuration' ); ?>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr style="display:<?php echo !ACCOUNT_CONNECTED ? "block":"none"?>">
|
||||
<th scope="row">
|
||||
<label for="instance"><?php esc_html_e( 'Instance', 'autopost-to-mastodon' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" id="instance" name="instance" size="80" value="<?php esc_attr_e( $instance ); ?>" list="mInstances">
|
||||
</td>
|
||||
<td>
|
||||
<input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Connect to Mastodon', 'autopost-to-mastodon' ); ?>" name="save" id="save">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
|
||||
<th scope="row">
|
||||
<label><?php esc_html_e( 'Status', 'autopost-to-mastodon' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<div class="account">
|
||||
<?php if(ACCOUNT_CONNECTED): ?>
|
||||
<a href="<?php echo $account->url ?>" target="_blank"><img class="m-avatar" src="<?php echo $account->avatar ?>"></a>
|
||||
<?php endif ?>
|
||||
<div class="details">
|
||||
<?php if(ACCOUNT_CONNECTED): ?>
|
||||
<div class="connected"><?php esc_html_e( 'Connected as', 'autopost-to-mastodon' ); ?> <?php echo $account->username ?></div>
|
||||
<a class="link" href="<?php echo $account->url ?>" target="_blank"><?php echo $account->url ?></a>
|
||||
|
||||
<p><a href="<?php echo $_SERVER['REQUEST_URI'] . '&disconnect' ?>" class="button"><?php esc_html_e( 'Disconnect', 'autopost-to-mastodon' ); ?></a>
|
||||
<a href="<?php echo $_SERVER['REQUEST_URI'] . '&testToot' ?>" class="button"><?php esc_html_e( 'Send test toot', 'autopost-to-mastodon' ); ?></a></p>
|
||||
<?php else: ?>
|
||||
<div class="disconnected"><?php esc_html_e( 'Disconnected', 'autopost-to-mastodon' ); ?></div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div class="separator"></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="advanced_setting">
|
||||
<th scope="row">
|
||||
<label for="content_warning"><?php esc_html_e( 'Default Content Warning', 'autopost-to-mastodon' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" id="content_warning" name="content_warning" style="width:300px" value="<?php esc_attr_e( $content_warning ); ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
|
||||
<th scope="row">
|
||||
<label for="message"><?php esc_html_e( 'Message', 'autopost-to-mastodon' ); ?></label>
|
||||
</th>
|
||||
<td class="advanced_setting">
|
||||
<textarea rows="10" cols="80" name="message" id="message"><?php esc_html_e( stripslashes( $message ) ); ?></textarea>
|
||||
<p class="description"><i><?php esc_html_e( 'You can use these metas in the message', 'autopost-to-mastodon' ); ?></i>
|
||||
: [title], [excerpt], [permalink] <?php esc_html_e( 'and', 'autopost-to-mastodon' ); ?> [tags]</p>
|
||||
</td>
|
||||
<td class="not_advanced_setting messageRadioButtons">
|
||||
<label>
|
||||
<b>title</b><br>
|
||||
<a href="">permalink</a><br><br><br>
|
||||
|
||||
<input type="radio" name="message_template" value="[title] [permalink]">
|
||||
</label>
|
||||
<label>
|
||||
<b>title</b><br>
|
||||
<a href="">permalink</a><br>#tags<br><br>
|
||||
<input type="radio" name="message_template" value="[title] [permalink] [tags]">
|
||||
</label>
|
||||
<label>
|
||||
<b>title</b><br>
|
||||
<i>Here comes the excerpt...</i><br><a href="">permalink</a><br>
|
||||
#tags<br>
|
||||
<input type="radio" name="message_template" value="[title] [excerpt] [permalink] [tags]">
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
|
||||
<th scope="row">
|
||||
<label for="mode"><?php esc_html_e( 'Toot mode', 'autopost-to-mastodon' ); ?></label>
|
||||
</th>
|
||||
<td class="scopeRadioButtons">
|
||||
<label><input type="radio" name="mode" <?php if ( 'public' === $mode ): ?>checked<?php endif; ?> value="public"><img src="<?php echo plugins_url( 'img/post/public.svg', __FILE__ );?>" class="modeIcon"> <?php esc_html_e( 'Public', 'autopost-to-mastodon' ); ?></label>
|
||||
<label><input type="radio" name="mode" <?php if ( 'unlisted' === $mode ): ?>checked<?php endif; ?> value="unlisted"><img src="<?php echo plugins_url( 'img/post/unlisted.svg', __FILE__ );?>" class="modeIcon"> <?php esc_html_e( 'Unlisted', 'autopost-to-mastodon' ); ?></label>
|
||||
<label><input type="radio" name="mode" <?php if ( 'private' === $mode ): ?>checked<?php endif; ?> value="private"><img src="<?php echo plugins_url( 'img/post/private.svg', __FILE__ );?>" class="modeIcon"> <?php esc_html_e( 'Private', 'autopost-to-mastodon' ); ?></label>
|
||||
<label><input type="radio" name="mode" <?php if ( 'direct' === $mode ): ?>checked<?php endif; ?> value="direct"><img src="<?php echo plugins_url( 'img/post/direct.svg', __FILE__ );?>" class="modeIcon"> <?php esc_html_e( 'Direct', 'autopost-to-mastodon' ); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="advanced_setting">
|
||||
<th scope="row">
|
||||
<label for="size"><?php esc_html_e( 'Toot size', 'autopost-to-mastodon' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input name="size" id="size" type="number" min="100" max="500" value="<?php esc_attr_e( $toot_size ); ?>"> <?php esc_html_e( 'characters', 'autopost-to-mastodon' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
|
||||
<th scope="row">
|
||||
<label for="cats_as_tags"><?php esc_html_e( 'Use categories as tags', 'autopost-to-mastodon' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="checkbox" id="cats_as_tags" name="cats_as_tags" value="on" <?php echo ( $cats_as_tags == 'on')?'checked':''; ?>>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
|
||||
<th scope="row">
|
||||
<label for="autopost_standard"><?php esc_html_e( 'Autopost new posts', 'autopost-to-mastodon' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="checkbox" id="autopost_standard" name="autopost_standard" value="on" <?php echo ( $autopost == 'on')?'checked':''; ?>>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
|
||||
<th scope="row">
|
||||
<label for="post_types"><?php esc_html_e( 'Choose active post types', 'autopost-to-mastodon' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<fieldset id="post_types">
|
||||
<?php
|
||||
// get all post types
|
||||
$args = array(
|
||||
'public' => true,
|
||||
// '_builtin' => false,
|
||||
);
|
||||
$output = 'objects';
|
||||
$operator = 'and';
|
||||
$wp_post_types = get_post_types( $args, $output, $operator );
|
||||
foreach ( $wp_post_types as $post_type ) {
|
||||
$checked = ($post_types[$post_type->name] == 'on')?'checked':'';
|
||||
echo "<label for=\"" . $post_type->name . "\"><input type=\"checkbox\" id=\"" . $post_type->name . "\" name=\"" . $post_type->name . "\"" . $checked . " />" . $post_type->label . "</label></br>";
|
||||
}
|
||||
?>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php if(ACCOUNT_CONNECTED): ?>
|
||||
<input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Save configuration', 'autopost-to-mastodon' ); ?>" name="save" id="save">
|
||||
<?php endif ?>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
require("instanceList.php")
|
||||
?>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="83" height="30"><rect id="back" fill="#f6c915" x="1" y=".5" width="82" height="29" rx="4"/><svg viewBox="0 0 80 80" height="16" width="16" x="7" y="7"><g transform="translate(-78.37-208.06)" fill="#1a171b"><path d="m104.28 271.1c-3.571 0-6.373-.466-8.41-1.396-2.037-.93-3.495-2.199-4.375-3.809-.88-1.609-1.308-3.457-1.282-5.544.025-2.086.313-4.311.868-6.675l9.579-40.05 11.69-1.81-10.484 43.44c-.202.905-.314 1.735-.339 2.489-.026.754.113 1.421.415 1.999.302.579.817 1.044 1.546 1.395.729.353 1.747.579 3.055.679l-2.263 9.278"/><path d="m146.52 246.14c0 3.671-.604 7.03-1.811 10.07-1.207 3.043-2.879 5.669-5.01 7.881-2.138 2.213-4.702 3.935-7.693 5.167-2.992 1.231-6.248 1.848-9.767 1.848-1.71 0-3.42-.151-5.129-.453l-3.394 13.651h-11.162l12.52-52.19c2.01-.603 4.311-1.143 6.901-1.622 2.589-.477 5.393-.716 8.41-.716 2.815 0 5.242.428 7.278 1.282 2.037.855 3.708 2.024 5.02 3.507 1.307 1.484 2.274 3.219 2.904 5.205.627 1.987.942 4.11.942 6.373m-27.378 15.461c.854.202 1.91.302 3.167.302 1.961 0 3.746-.364 5.355-1.094 1.609-.728 2.979-1.747 4.111-3.055 1.131-1.307 2.01-2.877 2.64-4.714.628-1.835.943-3.858.943-6.071 0-2.161-.479-3.998-1.433-5.506-.956-1.508-2.615-2.263-4.978-2.263-1.61 0-3.118.151-4.525.453l-5.28 21.948"/></g></svg><text fill="#1a171b" text-anchor="middle" font-family="Helvetica Neue,Helvetica,Arial,sans-serif" font-weight="700" font-size="14" x="50" y="20">Donate</text></svg>
|
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 13 KiB |
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 14 14" style="enable-background:new 0 0 14 14;" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path style="fill:#030104;" d="M7,9L5.268,7.484l-4.952,4.245C0.496,11.896,0.739,12,1.007,12h11.986
|
||||
c0.267,0,0.509-0.104,0.688-0.271L8.732,7.484L7,9z"/>
|
||||
<path style="fill:#030104;" d="M13.684,2.271C13.504,2.103,13.262,2,12.993,2H1.007C0.74,2,0.498,2.104,0.318,2.273L7,8
|
||||
L13.684,2.271z"/>
|
||||
<polygon style="fill:#030104;" points="0,2.878 0,11.186 4.833,7.079 "/>
|
||||
<polygon style="fill:#030104;" points="9.167,7.079 14,11.186 14,2.875 "/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 962 B |
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="401.998px" height="401.998px" viewBox="0 0 401.998 401.998" style="enable-background:new 0 0 401.998 401.998;"
|
||||
xml:space="preserve">
|
||||
<g>
|
||||
<path d="M357.45,190.721c-5.331-5.33-11.8-7.993-19.417-7.993h-9.131v-54.821c0-35.022-12.559-65.093-37.685-90.218
|
||||
C266.093,12.563,236.025,0,200.998,0c-35.026,0-65.1,12.563-90.222,37.688C85.65,62.814,73.091,92.884,73.091,127.907v54.821
|
||||
h-9.135c-7.611,0-14.084,2.663-19.414,7.993c-5.33,5.326-7.994,11.799-7.994,19.417V374.59c0,7.611,2.665,14.086,7.994,19.417
|
||||
c5.33,5.325,11.803,7.991,19.414,7.991H338.04c7.617,0,14.085-2.663,19.417-7.991c5.325-5.331,7.994-11.806,7.994-19.417V210.135
|
||||
C365.455,202.523,362.782,196.051,357.45,190.721z M274.087,182.728H127.909v-54.821c0-20.175,7.139-37.402,21.414-51.675
|
||||
c14.277-14.275,31.501-21.411,51.678-21.411c20.179,0,37.399,7.135,51.677,21.411c14.271,14.272,21.409,31.5,21.409,51.675V182.728
|
||||
z"/>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="31.416px" height="31.416px" viewBox="0 0 31.416 31.416" style="enable-background:new 0 0 31.416 31.416;"
|
||||
xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path d="M28.755,6.968l-0.47,0.149L25.782,7.34l-0.707,1.129l-0.513-0.163L22.57,6.51l-0.289-0.934L21.894,4.58l-1.252-1.123
|
||||
l-1.477-0.289l-0.034,0.676l1.447,1.412l0.708,0.834L20.49,6.506l-0.648-0.191L18.871,5.91l0.033-0.783l-1.274-0.524l-0.423,1.841
|
||||
l-1.284,0.291l0.127,1.027l1.673,0.322l0.289-1.641l1.381,0.204l0.642,0.376h1.03l0.705,1.412l1.869,1.896l-0.137,0.737
|
||||
l-1.507-0.192l-2.604,1.315l-1.875,2.249l-0.244,0.996h-0.673l-1.254-0.578l-1.218,0.578l0.303,1.285l0.53-0.611l0.932-0.029
|
||||
l-0.065,1.154l0.772,0.226l0.771,0.866l1.259-0.354l1.438,0.227l1.67,0.449l0.834,0.098l1.414,1.605l2.729,1.605l-1.765,3.372
|
||||
l-1.863,0.866l-0.707,1.927l-2.696,1.8l-0.287,1.038c6.892-1.66,12.019-7.851,12.019-15.253
|
||||
C31.413,12.474,30.433,9.465,28.755,6.968z"/>
|
||||
<path d="M17.515,23.917l-1.144-2.121l1.05-2.188l-1.05-0.314l-1.179-1.184l-2.612-0.586l-0.867-1.814v1.077h-0.382l-2.251-3.052
|
||||
v-2.507L7.43,8.545L4.81,9.012H3.045L2.157,8.43L3.29,7.532L2.16,7.793c-1.362,2.326-2.156,5.025-2.156,7.916
|
||||
c0,8.673,7.031,15.707,15.705,15.707c0.668,0,1.323-0.059,1.971-0.137l-0.164-1.903c0,0,0.721-2.826,0.721-2.922
|
||||
C18.236,26.357,17.515,23.917,17.515,23.917z"/>
|
||||
<path d="M5.84,5.065l2.79-0.389l1.286-0.705l1.447,0.417l2.312-0.128l0.792-1.245l1.155,0.19l2.805-0.263L19.2,2.09l1.09-0.728
|
||||
l1.542,0.232l0.562-0.085C20.363,0.553,18.103,0,15.708,0C10.833,0,6.474,2.222,3.596,5.711h0.008L5.84,5.065z M16.372,1.562
|
||||
l1.604-0.883l1.03,0.595l-1.491,1.135l-1.424,0.143l-0.641-0.416L16.372,1.562z M11.621,1.691l0.708,0.295l0.927-0.295
|
||||
l0.505,0.875l-2.14,0.562l-1.029-0.602C10.591,2.526,11.598,1.878,11.621,1.691z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="438.533px" height="438.533px" viewBox="0 0 438.533 438.533" style="enable-background:new 0 0 438.533 438.533;"
|
||||
xml:space="preserve">
|
||||
<g>
|
||||
<path d="M375.721,227.259c-5.331-5.331-11.8-7.992-19.417-7.992H146.176v-91.36c0-20.179,7.139-37.402,21.415-51.678
|
||||
c14.277-14.273,31.501-21.411,51.678-21.411c20.175,0,37.402,7.137,51.673,21.411c14.277,14.276,21.416,31.5,21.416,51.678
|
||||
c0,4.947,1.807,9.229,5.42,12.845c3.621,3.617,7.905,5.426,12.847,5.426h18.281c4.945,0,9.227-1.809,12.848-5.426
|
||||
c3.606-3.616,5.42-7.898,5.42-12.845c0-35.216-12.515-65.331-37.541-90.362C284.603,12.513,254.48,0,219.269,0
|
||||
c-35.214,0-65.334,12.513-90.366,37.544c-25.028,25.028-37.542,55.146-37.542,90.362v91.36h-9.135
|
||||
c-7.611,0-14.084,2.667-19.414,7.992c-5.33,5.325-7.994,11.8-7.994,19.414v164.452c0,7.617,2.665,14.089,7.994,19.417
|
||||
c5.33,5.325,11.803,7.991,19.414,7.991h274.078c7.617,0,14.092-2.666,19.417-7.991c5.325-5.328,7.994-11.8,7.994-19.417V246.673
|
||||
C383.719,239.059,381.053,232.591,375.721,227.259z"/>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,41 @@
|
||||
jQuery(document).ready(function($) {
|
||||
//Select the right radio button for message on load
|
||||
let textareaValue = $('textarea[name=message]').val();
|
||||
$('input:radio[name=message_template]').prop("checked",false);
|
||||
$('input[value="'+textareaValue+'"]').prop("checked", true);
|
||||
|
||||
$('input:radio').parent().css({ opacity: 0.5 });;
|
||||
$('input:radio:checked').parent().css({ opacity: 1 });;
|
||||
|
||||
$('textarea[name=message]').change(function(){
|
||||
$('input:radio[name=message_template]').prop("checked",false);
|
||||
$('input[value="'+this.value+'"]').prop("checked", true);
|
||||
});
|
||||
|
||||
//Show advanced config
|
||||
$("#show_advanced_configuration").click(function(){
|
||||
$(".not_advanced_setting").fadeOut("fast");
|
||||
$("td.advanced_setting").fadeIn("slow");
|
||||
$("tr.advanced_setting").fadeIn("slow").css("display","block");
|
||||
$("#hide_advanced_configuration").removeClass("active");
|
||||
$("#show_advanced_configuration").addClass("active");
|
||||
});
|
||||
|
||||
//Hide advanced config
|
||||
$("#hide_advanced_configuration").click(function(){
|
||||
$(".advanced_setting").fadeOut("fast");
|
||||
$(".not_advanced_setting").fadeIn("slow");
|
||||
$("#show_advanced_configuration").removeClass("active");
|
||||
$("#hide_advanced_configuration").addClass("active");
|
||||
});
|
||||
//Set the message value on radio select
|
||||
$('input:radio[name=message_template]').change(function(){
|
||||
let value = $('input:radio[name=message_template]:checked').val();
|
||||
$('textarea[name=message]').val(value);
|
||||
});
|
||||
|
||||
$('input:radio').change(function(){
|
||||
$('input:radio').parent().css({ opacity: 0.5 });;
|
||||
$('input:radio:checked').parent().css({ opacity: 1 });;
|
||||
});
|
||||
});
|
@ -0,0 +1,114 @@
|
||||
msgid "Mastodon Autopost Configuration"
|
||||
msgstr "Mastodon Autopost Konfiguration"
|
||||
|
||||
msgid "Simple configuration"
|
||||
msgstr "Einfache Konfiguration"
|
||||
|
||||
msgid "Advanced configuration"
|
||||
msgstr "Erweiterte Konfiguration"
|
||||
|
||||
msgid "Instance"
|
||||
msgstr "Instanz"
|
||||
|
||||
msgid "Connected as"
|
||||
msgstr "Verbunden als"
|
||||
|
||||
msgid "Connect to Mastodon"
|
||||
msgstr "Mit Mastodon verbinden"
|
||||
|
||||
msgid "Disconnect"
|
||||
msgstr "Trennen"
|
||||
|
||||
msgid "Send test toot"
|
||||
msgstr "Test Toot senden"
|
||||
|
||||
msgid "Disconnected"
|
||||
msgstr "Getrennt"
|
||||
|
||||
msgid "Default Content Warning"
|
||||
msgstr "Standart Content Warnung"
|
||||
|
||||
msgid "and"
|
||||
msgstr "und"
|
||||
|
||||
msgid "You can use these metas in the message"
|
||||
msgstr "Du kannst folgende Metas in der Nachricht verwenden"
|
||||
|
||||
msgid "Save configuration"
|
||||
msgstr "Konfiguration Speichern"
|
||||
|
||||
msgid "Autopost new posts"
|
||||
msgstr "Neue Posts automatisch posten"
|
||||
|
||||
msgid "Authentification, please wait"
|
||||
msgstr "Bitte kurz warten"
|
||||
|
||||
msgid "Toot mode"
|
||||
msgstr "Toot Modus"
|
||||
|
||||
msgid "Message"
|
||||
msgstr "Nachricht"
|
||||
|
||||
msgid "Toot size"
|
||||
msgstr "Toot Länge"
|
||||
|
||||
msgid "Can't log you in."
|
||||
msgstr "Login hat nicht funktioniert."
|
||||
|
||||
msgid "Please login to your mastodon account!"
|
||||
msgstr "Bitte log dich in deinen Mastodon Account ein!"
|
||||
|
||||
msgid "Go to Mastodon Autopost Settings"
|
||||
msgstr "Zu den Mastodon Autopost Einstellungen gehen"
|
||||
|
||||
msgid "Instance message"
|
||||
msgstr "Instanz Nachricht"
|
||||
|
||||
msgid "The given instance url belongs to no valid mastodon instance !"
|
||||
msgstr "Die eingegebene Url ist keine valide Mastodon Instanz !"
|
||||
|
||||
msgid "Thank you to set your Mastodon instance before connect !"
|
||||
msgstr "Danke für das einstellen der Mastodon Instanz !"
|
||||
|
||||
msgid "Redirect to "
|
||||
msgstr "Weiterleiten zu "
|
||||
|
||||
msgid "Configuration successfully saved !"
|
||||
msgstr "Konfiguration wurde erfolgreich gespeichert!"
|
||||
|
||||
msgid "Toot saved for schedule !"
|
||||
msgstr "Toot für die Zukunft eingestellt !"
|
||||
|
||||
msgid "This is my first post with Mastodon Autopost for Wordpress"
|
||||
msgstr "Das ist mein erster Post mit Mastodon Autopost für Wordpress"
|
||||
|
||||
msgid "Sorry, can't send toot !"
|
||||
msgstr "Entschuldigung, Toot kann nicht gesendet werden !"
|
||||
|
||||
msgid "Toot successfully sent !"
|
||||
msgstr "Toot erfolgreich gesendet !"
|
||||
|
||||
msgid "Toot on Mastodon"
|
||||
msgstr "Autopost auf Mastodon"
|
||||
|
||||
msgid "Public"
|
||||
msgstr "Öffentlich"
|
||||
|
||||
msgid "Unlisted"
|
||||
msgstr "Nicht gelistet"
|
||||
|
||||
msgid "Private"
|
||||
msgstr "Privat"
|
||||
|
||||
msgid "Direct"
|
||||
msgstr "Direkt"
|
||||
|
||||
msgid "characters"
|
||||
msgstr "Zeichen"
|
||||
|
||||
msgid "View Toot"
|
||||
msgstr "Zum Toot"
|
||||
|
||||
msgid "Choose active post types"
|
||||
msgstr "Aktiviere für folgende Post-Types"
|
||||
|
@ -0,0 +1,110 @@
|
||||
msgid "Mastodon Autopost Configuration"
|
||||
msgstr "Mastodon Autopost Configuratie"
|
||||
|
||||
msgid "Simple configuration"
|
||||
msgstr "Eenvoudige configuratie"
|
||||
|
||||
msgid "Advanced configuration"
|
||||
msgstr "Uitgebreide configuratie"
|
||||
|
||||
msgid "Instance"
|
||||
msgstr "Instantie"
|
||||
|
||||
msgid "Connected as"
|
||||
msgstr "Verbonden als"
|
||||
|
||||
msgid "Connect to Mastodon"
|
||||
msgstr "Met Mastodon verbinden"
|
||||
|
||||
msgid "Disconnect"
|
||||
msgstr "Loskoppelen"
|
||||
|
||||
msgid "Send test toot"
|
||||
msgstr "Test Toot verzenden"
|
||||
|
||||
msgid "Disconnected"
|
||||
msgstr "Losgekoppeld"
|
||||
|
||||
msgid "Default Content Warning"
|
||||
msgstr "Standaard Content Waarschuwing"
|
||||
|
||||
msgid "and"
|
||||
msgstr "en"
|
||||
|
||||
msgid "You can use these metas in the message"
|
||||
msgstr "U kunt de volgende meta's in het bericht gebruiken"
|
||||
|
||||
msgid "Save configuration"
|
||||
msgstr "Configuratie opslaan"
|
||||
|
||||
msgid "Autopost new posts"
|
||||
msgstr "Nieuwe berichten automatisch plaatsen"
|
||||
|
||||
msgid "Authentification, please wait"
|
||||
msgstr "Even geduld alstublieft"
|
||||
|
||||
msgid "Toot mode"
|
||||
msgstr "Toot modus"
|
||||
|
||||
msgid "Message"
|
||||
msgstr "Bericht"
|
||||
|
||||
msgid "Toot size"
|
||||
msgstr "Toot lengte"
|
||||
|
||||
msgid "Can't log you in."
|
||||
msgstr "Inloggen werkte niet."
|
||||
|
||||
msgid "Please login to your mastodon account!"
|
||||
msgstr "Meld u aan bij uw Mastodon-account!"
|
||||
|
||||
msgid "Go to Mastodon Autopost Settings"
|
||||
msgstr "Naar de instellingen van Mastopost Autopost gaan"
|
||||
|
||||
msgid "Instance message"
|
||||
msgstr "Instantie bericht"
|
||||
|
||||
msgid "The given instance url belongs to no valid mastodon instance !"
|
||||
msgstr "De ingevoerde URL is geen geldige Mastodon-instantie!"
|
||||
|
||||
msgid "Thank you to set your Mastodon instance before connect !"
|
||||
msgstr "Bedankt voor het configureren van de Mastodon instantie!"
|
||||
|
||||
msgid "Redirect to "
|
||||
msgstr "Doorsturen naar "
|
||||
|
||||
msgid "Configuration successfully saved !"
|
||||
msgstr "Configuratie is succesvol opgeslagen!"
|
||||
|
||||
msgid "Toot saved for schedule !"
|
||||
msgstr "Toot opgeslagen voor de toekomst!"
|
||||
|
||||
msgid "This is my first post with Mastodon Autopost for Wordpress"
|
||||
msgstr "Dit is mijn eerste bericht met Mastodon Autopost voor Wordpress"
|
||||
|
||||
msgid "Sorry, can't send toot !"
|
||||
msgstr "Verontschuldigingen, de toot kan niet worden verzonden!"
|
||||
|
||||
msgid "Toot successfully sent !"
|
||||
msgstr "Toot succesvol verzonden!"
|
||||
|
||||
msgid "Toot on Mastodon"
|
||||
msgstr "Autopost op Mastodon"
|
||||
|
||||
msgid "Public"
|
||||
msgstr "Openbaar"
|
||||
|
||||
msgid "Unlisted"
|
||||
msgstr "Minder openbaar"
|
||||
|
||||
msgid "Private"
|
||||
msgstr "Alleen volgers"
|
||||
|
||||
msgid "Direct"
|
||||
msgstr "Direct"
|
||||
|
||||
msgid "characters"
|
||||
msgstr "tekens"
|
||||
|
||||
msgid "View Toot"
|
||||
msgstr "Bekijk Toot"
|
@ -0,0 +1,620 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Mastodon Autopost
|
||||
* Plugin URI: https://github.com/simonfrey/mastodon_wordpress_autopost
|
||||
* Description: A Wordpress Plugin that automatically posts your new articles to Mastodon
|
||||
* Version: 3.6
|
||||
* Author: L1am0
|
||||
* Author URI: https://www.simon-frey.eu
|
||||
* License: GPL2
|
||||
* Text Domain: autopost-to-mastodon
|
||||
* Domain Path: /languages
|
||||
*/
|
||||
|
||||
require_once 'client.php';
|
||||
|
||||
class autopostToMastodon
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_action('plugins_loaded', array($this, 'init'));
|
||||
add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
|
||||
add_action('admin_menu', array($this, 'configuration_page'));
|
||||
add_action('save_post', array($this, 'toot_post'));
|
||||
add_action('admin_notices', array($this, 'admin_notices'));
|
||||
add_action('add_meta_boxes', array($this, 'add_metabox'));
|
||||
add_action('publish_future_post', array($this, 'toot_scheduled_post'));
|
||||
add_action('wp_ajax_get_toot_preview', array($this, 'get_toot_preview_ajax_handler'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* Plugin initialization
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$plugin_dir = basename(dirname(__FILE__));
|
||||
load_plugin_textdomain('autopost-to-mastodon', false, $plugin_dir . '/languages');
|
||||
|
||||
if (isset($_GET['code'])) {
|
||||
$code = $_GET['code'];
|
||||
$client_id = get_option('autopostToMastodon-client-id');
|
||||
$client_secret = get_option('autopostToMastodon-client-secret');
|
||||
|
||||
if (!empty($code) && !empty($client_id) && !empty($client_secret)) {
|
||||
echo __('Authentification, please wait', 'autopost-to-mastodon') . '...';
|
||||
|
||||
update_option('autopostToMastodon-token', 'nada');
|
||||
|
||||
$instance = get_option('autopostToMastodon-instance');
|
||||
$client = new Client($instance);
|
||||
$token = $client->get_bearer_token($client_id, $client_secret, $code, get_admin_url());
|
||||
|
||||
if (isset($token->error)) {
|
||||
print_r($token);
|
||||
//TODO: Propper error message
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __("Can't log you in.", 'autopost-to-mastodon') .
|
||||
'<p><strong>' . __('Instance message', 'autopost-to-mastodon') . '</strong> : ' . $token->error_description . '</p>',
|
||||
'class' => 'error',
|
||||
)
|
||||
)
|
||||
);
|
||||
unset($token);
|
||||
update_option('autopostToMastodon-token', '');
|
||||
} else {
|
||||
update_option('autopostToMastodon-client-id', '');
|
||||
update_option('autopostToMastodon-client-secret', '');
|
||||
update_option('autopostToMastodon-token', $token->access_token);
|
||||
}
|
||||
$redirect_url = get_admin_url() . 'options-general.php?page=autopost-to-mastodon';
|
||||
} else {
|
||||
//Probably hack or bad refresh, redirect to homepage
|
||||
$redirect_url = home_url();
|
||||
}
|
||||
|
||||
wp_redirect($redirect_url);
|
||||
exit;
|
||||
}
|
||||
|
||||
$token = get_option('autopostToMastodon-token');
|
||||
if (empty($token)) {
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __('Please login to your mastodon account!', 'autopost-to-mastodon') . '<a href="' . get_admin_url() . 'options-general.php?page=autopost-to-mastodon"> ' . __('Go to Mastodon Autopost Settings', 'autopost-to-mastodon') . '</a>',
|
||||
'class' => 'error',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue_scripts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_scripts($hook)
|
||||
{
|
||||
|
||||
global $pagenow;
|
||||
|
||||
$infos = get_plugin_data(__FILE__);
|
||||
if ($pagenow == "options-general.php") {
|
||||
//We might be on settings page <-- Do you know a bette solution to get if we are in our own settings page?
|
||||
$plugin_url = plugin_dir_url(__FILE__);
|
||||
wp_enqueue_script('settings_page', $plugin_url . 'js/settings_page.js', array('jquery'), $infos['Version'], true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration_page
|
||||
*
|
||||
* Add the configuration page menu
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function configuration_page()
|
||||
{
|
||||
add_options_page(
|
||||
'Mastodon Autopost',
|
||||
'Mastodon Autopost',
|
||||
'manage_options',
|
||||
'autopost-to-mastodon',
|
||||
array($this, 'show_configuration_page')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show_configuration_page
|
||||
*
|
||||
* Content of the configuration page
|
||||
*
|
||||
* @throws Exception The exception.
|
||||
* @return void
|
||||
*/
|
||||
public function show_configuration_page()
|
||||
{
|
||||
|
||||
wp_enqueue_style('autopostToMastodon-configuration', plugin_dir_url(__FILE__) . 'style.css');
|
||||
|
||||
if (isset($_GET['disconnect'])) {
|
||||
update_option('autopostToMastodon-token', '');
|
||||
} elseif (isset($_GET['testToot'])) {
|
||||
$this->sendTestToot();
|
||||
}
|
||||
|
||||
$token = get_option('autopostToMastodon-token');
|
||||
|
||||
if (isset($_POST['save'])) {
|
||||
|
||||
$is_valid_nonce = wp_verify_nonce($_POST['_wpnonce'], 'autopostToMastodon-configuration');
|
||||
|
||||
if ($is_valid_nonce) {
|
||||
$instance = esc_url($_POST['instance']);
|
||||
$message = stripslashes($_POST['message']);
|
||||
$content_warning = $_POST['content_warning'];
|
||||
|
||||
$client = new Client($instance);
|
||||
$redirect_url = get_admin_url();
|
||||
$auth_url = $client->register_app($redirect_url);
|
||||
|
||||
if ($auth_url == "ERROR") {
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __('The given instance url belongs to no valid mastodon instance !', 'autopost-to-mastodon'),
|
||||
'class' => 'error',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
if (empty($instance)) {
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __('Thank you to set your Mastodon instance before connect !', 'autopost-to-mastodon'),
|
||||
'class' => 'error',
|
||||
)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
update_option('autopostToMastodon-client-id', $client->get_client_id());
|
||||
update_option('autopostToMastodon-client-secret', $client->get_client_secret());
|
||||
update_option('autopostToMastodon-instance', $instance);
|
||||
|
||||
update_option('autopostToMastodon-message', sanitize_textarea_field($message));
|
||||
update_option('autopostToMastodon-mode', sanitize_text_field($_POST['mode']));
|
||||
update_option('autopostToMastodon-toot-size', (int) $_POST['size']);
|
||||
|
||||
if (isset($_POST['autopost_standard'])) {
|
||||
update_option('autopostToMastodon-postOnStandard', 'on');
|
||||
} else {
|
||||
update_option('autopostToMastodon-postOnStandard', 'off');
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['cats_as_tags'])) {
|
||||
update_option('autopostToMastodon-catsAsTags', 'on');
|
||||
} else {
|
||||
update_option('autopostToMastodon-catsAsTags', 'off');
|
||||
}
|
||||
|
||||
// get all post types
|
||||
$args = array(
|
||||
'public' => true,
|
||||
);
|
||||
$output = 'names';
|
||||
$operator = 'and';
|
||||
$post_types = get_post_types( $args, $output, $operator );
|
||||
// check post for content type configs
|
||||
foreach ( $post_types as $post_type ) {
|
||||
if (isset($_POST[$post_type]) ? $_POST[$post_type] : "off" == "on") {
|
||||
update_option("autopostToMastodon-post_types-$post_type", 'on');
|
||||
}
|
||||
else {
|
||||
update_option("autopostToMastodon-post_types-$post_type", 'off');
|
||||
}
|
||||
}
|
||||
|
||||
update_option('autopostToMastodon-content-warning', sanitize_textarea_field($content_warning));
|
||||
|
||||
$account = $client->verify_credentials($token);
|
||||
|
||||
if (isset($account->error)) {
|
||||
echo '<meta http-equiv="refresh" content="0; url=' . $auth_url . '" />';
|
||||
echo __('Redirect to ', 'autopost-to-mastodon') . $instance;
|
||||
exit;
|
||||
}
|
||||
|
||||
//Inform user that save was successfull
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __('Configuration successfully saved !', 'autopost-to-mastodon'),
|
||||
'class' => 'success',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->admin_notices();
|
||||
}
|
||||
}
|
||||
|
||||
$instance = get_option('autopostToMastodon-instance');
|
||||
|
||||
if (!empty($token)) {
|
||||
$client = new Client($instance);
|
||||
$account = $client->verify_credentials($token);
|
||||
}
|
||||
|
||||
$message = get_option('autopostToMastodon-message', "[title]\n[excerpt]\n[permalink]\n[tags]");
|
||||
$mode = get_option('autopostToMastodon-mode', 'public');
|
||||
$toot_size = get_option('autopostToMastodon-toot-size', 500);
|
||||
$content_warning = get_option('autopostToMastodon-content-warning', '');
|
||||
$autopost = get_option('autopostToMastodon-postOnStandard', 'on');
|
||||
$cats_as_tags = get_option('autopostToMastodon-catsAsTags', 'on');
|
||||
$post_types = [];
|
||||
|
||||
// get all post types
|
||||
$args = array(
|
||||
'public' => true,
|
||||
);
|
||||
$output = 'names';
|
||||
$operator = 'and';
|
||||
$wp_post_types = get_post_types( $args, $output, $operator );
|
||||
|
||||
// add form context data for post type options
|
||||
foreach ( $wp_post_types as $post_type ) {
|
||||
$post_types[$post_type] = get_option("autopostToMastodon-post_types-$post_type", 'on');
|
||||
}
|
||||
|
||||
include 'form.tpl.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Toot_post
|
||||
* Post the toot
|
||||
*
|
||||
* @param int $id The post ID.
|
||||
* @return void
|
||||
*/
|
||||
public function toot_post($id)
|
||||
{
|
||||
|
||||
$post = get_post($id);
|
||||
|
||||
$thumb_url = get_the_post_thumbnail_url($id, 'medium_large'); //Don't change the resolution !
|
||||
|
||||
$toot_size = (int) get_option('autopostToMastodon-toot-size', 500);
|
||||
|
||||
$toot_on_mastodon_option = false;
|
||||
$cw_content = (string) get_option('autopostToMastodon-content-warning', '');
|
||||
|
||||
$toot_on_mastodon_option = isset($_POST['toot_on_mastodon']);
|
||||
|
||||
if ($toot_on_mastodon_option) {
|
||||
update_post_meta($id, 'autopostToMastodon-post-status', 'on');
|
||||
} else {
|
||||
if (get_post_meta($id, 'autopostToMastodon-post-status', true) == 'on') {
|
||||
update_post_meta($id, 'autopostToMastodon-post-status', 'off');
|
||||
}
|
||||
}
|
||||
|
||||
if ($toot_on_mastodon_option) {
|
||||
$message = $this->getTootFromTemplate($id);
|
||||
|
||||
if (!empty($message)) {
|
||||
|
||||
//Save the toot, for scheduling
|
||||
if ($post->post_status == 'future') {
|
||||
update_post_meta($id, 'autopostToMastodon-toot', $message);
|
||||
|
||||
if ($thumb_url) {
|
||||
|
||||
$thumb_path = str_replace(get_site_url(), get_home_path(), $thumb_url);
|
||||
update_post_meta($id, 'autopostToMastodon-toot-thumbnail', $thumb_path);
|
||||
}
|
||||
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __('Toot saved for schedule !', 'autopost-to-mastodon'),
|
||||
'class' => 'info',
|
||||
)
|
||||
)
|
||||
);
|
||||
} else if ($post->post_status == 'publish') {
|
||||
|
||||
$instance = get_option('autopostToMastodon-instance');
|
||||
$access_token = get_option('autopostToMastodon-token');
|
||||
$mode = get_option('autopostToMastodon-mode', 'public');
|
||||
|
||||
$client = new Client($instance, $access_token);
|
||||
|
||||
if ($thumb_url) {
|
||||
|
||||
$thumb_path = str_replace(get_site_url(), get_home_path(), $thumb_url);
|
||||
$attachment = $client->create_attachment($thumb_path);
|
||||
|
||||
if (is_object($attachment)) {
|
||||
$media = $attachment->id;
|
||||
}
|
||||
}
|
||||
|
||||
$toot = $client->postStatus($message, $mode, $media, $cw_content);
|
||||
|
||||
update_post_meta($id, 'autopostToMastodon-post-status', 'off');
|
||||
|
||||
add_action('admin_notices', 'autopostToMastodon_notice_toot_success');
|
||||
if (isset($toot->errors)) {
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __('Sorry, can\'t send toot !', 'autopost-to-mastodon') .
|
||||
'<p><strong>' . __('Instance message', 'autopost-to-mastodon') . '</strong> : ' . json_encode($toot->errors) . '</p>',
|
||||
'class' => 'error',
|
||||
)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __('Toot successfully sent !', 'autopost-to-mastodon') . ' <a href="' . $toot->url . '" target="_blank">' . __('View Toot', 'autopost-to-mastodon') . '</a>',
|
||||
'class' => 'success',
|
||||
)
|
||||
)
|
||||
);
|
||||
//Save the toot url for syndication
|
||||
update_post_meta($id, 'autopostToMastodonshare-lastSuccessfullTootURL', $toot->url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toot_scheduled_post
|
||||
* @param integer $post_id
|
||||
*/
|
||||
public function toot_scheduled_post($post_id)
|
||||
{
|
||||
$instance = get_option('autopostToMastodon-instance');
|
||||
$access_token = get_option('autopostToMastodon-token');
|
||||
$mode = get_option('autopostToMastodon-mode', 'public');
|
||||
|
||||
$message = $this->getTootFromTemplate($post_id);
|
||||
if (!empty($message)) {
|
||||
|
||||
$thumb_url = get_the_post_thumbnail_url($post_id);
|
||||
$thumb_path = get_post_meta($post_id, 'autopostToMastodon-toot-thumbnail', true);
|
||||
|
||||
$client = new Client($instance, $access_token);
|
||||
|
||||
if ($thumb_url && $thumb_path) {
|
||||
|
||||
$attachment = $client->create_attachment($thumb_path);
|
||||
|
||||
if (is_object($attachment)) {
|
||||
$media = $attachment->id;
|
||||
}
|
||||
}
|
||||
|
||||
$toot = $client->postStatus($message, $mode, $media);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin_notices
|
||||
* Show the notice (error or info)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function admin_notices()
|
||||
{
|
||||
|
||||
$notice = unserialize(get_option('autopostToMastodon-notice'));
|
||||
|
||||
if (is_array($notice)) {
|
||||
echo '<div class="notice notice-' . sanitize_html_class($notice['class']) . ' is-dismissible"><p>' . $notice['message'] . '</p></div>';
|
||||
update_option('autopostToMastodon-notice', null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add_metabox
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_metabox()
|
||||
{
|
||||
$active_post_types = [];
|
||||
// get all post types
|
||||
$args = array(
|
||||
'public' => true,
|
||||
);
|
||||
$output = 'names';
|
||||
$operator = 'and';
|
||||
$post_types = get_post_types( $args, $output, $operator );
|
||||
|
||||
// add form context data for post type options
|
||||
foreach ( $post_types as $post_type ) {
|
||||
if (get_option("autopostToMastodon-post_types-$post_type", 'on') == 'on') {
|
||||
array_push($active_post_types, $post_type);
|
||||
}
|
||||
}
|
||||
|
||||
// empty array activates everywhere -> check
|
||||
if (!empty($active_post_types)) {
|
||||
add_meta_box(
|
||||
'autopostToMastodon_metabox',
|
||||
'Mastodon Autopost',
|
||||
array($this, 'metabox'),
|
||||
$active_post_types,
|
||||
'side',
|
||||
'high'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Metabox
|
||||
*
|
||||
* @param WP_Post $post the current post.
|
||||
* @return void
|
||||
*/
|
||||
public function metabox($post)
|
||||
{
|
||||
if ($post->post_title == '' && $post->post_content == '') {
|
||||
$status = ('on' == (string) get_option('autopostToMastodon-postOnStandard', true));
|
||||
} else {
|
||||
$status = ('on' == (string) get_post_meta($post->ID, 'autopostToMastodon-post-status', 'off'));
|
||||
}
|
||||
|
||||
$checked = ($status) ? 'checked' : '';
|
||||
|
||||
echo '<div style="margin: 20px 0;"><input ' . $checked . ' type="checkbox" name="toot_on_mastodon" id="toot_on_mastodon" value="on">' .
|
||||
'<label for="toot_on_mastodon">' . __('Toot on Mastodon', 'autopost-to-mastodon') . '</label></div>';
|
||||
|
||||
}
|
||||
|
||||
public function get_toot_preview_ajax_handler()
|
||||
{
|
||||
check_ajax_referer('mastodonNonce');
|
||||
|
||||
$return = array(
|
||||
'message' => $this->getTootFromTemplate($_POST['post_ID']),
|
||||
);
|
||||
|
||||
wp_send_json($return);
|
||||
}
|
||||
|
||||
private function getTootFromTemplate($id)
|
||||
{
|
||||
|
||||
$post = get_post($id);
|
||||
$toot_size = (int) get_option('autopostToMastodon-toot-size', 500);
|
||||
|
||||
$message_template = get_option('autopostToMastodon-message', "[title]\n[excerpt]\n[permalink]\n[tags]");
|
||||
|
||||
//Replace title
|
||||
$post_title = html_entity_decode(get_the_title($id), ENT_COMPAT, 'UTF-8');
|
||||
$message_template = str_replace("[title]", $post_title, $message_template);
|
||||
|
||||
//Replace permalink
|
||||
$post_permalink = get_the_permalink($id);
|
||||
$message_template = str_replace("[permalink]", $post_permalink, $message_template);
|
||||
|
||||
//Replace tags
|
||||
$post_tags_content = '';
|
||||
$cats_as_tags = get_option('autopostToMastodon-catsAsTags', 'off');
|
||||
if ($cats_as_tags == 'on') {
|
||||
$post_cats = get_the_category($id);
|
||||
if (sizeof($post_cats) > 0 && $post_cats) {
|
||||
foreach ($post_cats as $cat) {
|
||||
$post_tags_content = $post_tags_content . '#' . preg_replace('/\s+/', '', html_entity_decode($cat->name, ENT_COMPAT, 'UTF-8')) . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$post_tags = get_the_tags($id);
|
||||
if (sizeof($post_tags) > 0) {
|
||||
if ($post_tags) {
|
||||
foreach ($post_tags as $tag) {
|
||||
$post_tags_content = $post_tags_content . '#' . preg_replace('/\s+/', '', html_entity_decode($tag->name, ENT_COMPAT, 'UTF-8')) . ' ';
|
||||
}
|
||||
$post_tags_content = trim($post_tags_content);
|
||||
}
|
||||
}
|
||||
$message_template = str_replace("[tags]", $post_tags_content, $message_template);
|
||||
|
||||
//Replace excerpt
|
||||
//Replace with the excerpt of the post
|
||||
$post_optional_excerpt = $post->post_excerpt;
|
||||
if (strlen($post_optional_excerpt) > 0) {
|
||||
$post_content_long = $post_optional_excerpt;
|
||||
} else {
|
||||
$post_content_long = $post->post_content;
|
||||
}
|
||||
if ($wp_version[0] == "5") {
|
||||
$post_content_long = excerpt_remove_blocks($post_content_long);
|
||||
}
|
||||
$post_content_long = strip_shortcodes($post_content_long);
|
||||
$post_content_long = html_entity_decode($post_content_long, ENT_COMPAT, 'UTF-8');
|
||||
$post_content_long = wp_strip_all_tags($post_content_long);
|
||||
//$post_content_long = str_replace("...", "",$post_content_long);
|
||||
|
||||
$excerpt_len = $toot_size - strlen($message_template) + 9 - 5;
|
||||
|
||||
mb_internal_encoding("UTF-8");
|
||||
|
||||
$post_excerpt = mb_substr($post_content_long, 0, $excerpt_len);
|
||||
|
||||
$message_template = str_replace("[excerpt]", $post_excerpt, $message_template);
|
||||
|
||||
return mb_substr($message_template, 0, $toot_size);
|
||||
}
|
||||
|
||||
private function sendTestToot()
|
||||
{
|
||||
$instance = get_option('autopostToMastodon-instance');
|
||||
$access_token = get_option('autopostToMastodon-token');
|
||||
$mode = 'public';
|
||||
|
||||
$client = new Client($instance, $access_token);
|
||||
//TODO: Add propper message
|
||||
$message = __("This is my first post with Mastodon Autopost for Wordpress", 'autopost-to-mastodon') . " - https://wordpress.org/plugins/autopost-to-mastodon/";
|
||||
$media = null;
|
||||
$toot = $client->postStatus($message, $mode, $media);
|
||||
|
||||
if (isset($toot->error)) {
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __('Sorry, can\'t send toot !', 'autopost-to-mastodon') .
|
||||
'<p><strong>' . __('Instance message', 'autopost-to-mastodon') . '</strong> : ' . $toot->error . '</p>',
|
||||
'class' => 'error',
|
||||
)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
update_option(
|
||||
'autopostToMastodon-notice',
|
||||
serialize(
|
||||
array(
|
||||
'message' => '<strong>Mastodon Autopost</strong> : ' . __('Toot successfully sent !', 'autopost-to-mastodon') . ' <a href="' . $toot->url . '" target="_blank">' . __('View Toot', 'autopost-to-mastodon') . '</a>',
|
||||
'class' => 'success',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
$this->admin_notices();
|
||||
}
|
||||
}
|
||||
|
||||
$autopostToMastodon = new autopostToMastodon();
|
184
php-fpm/wordpress_files/plugins/autopost-to-mastodon/readme.txt
Normal file
@ -0,0 +1,184 @@
|
||||
=== Mastodon Autopost ===
|
||||
Contributors: l1am0, Hellexis
|
||||
Tags: mastodon, Mastodon, Mastdon Autopost, federated web, GNU social, statusnet, social web, social media, auto post
|
||||
Requires at least: 4.6
|
||||
Tested up to: 5.3.2
|
||||
Stable tag: 3.6
|
||||
License: GPLv2
|
||||
Donate link: https://paypal.me/51edpo
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
A Wordpress Plugin that automatically posts your new articles to Mastodon. The best: It is set and forget!
|
||||
|
||||
== Description ==
|
||||
|
||||
A Wordpress Plugin that automatically posts your new articles to Mastodon. The best: It is set and forget!
|
||||
|
||||
With Mastodon Autopost your post always get automatically posted to your Mastodon account.
|
||||
|
||||
Find the plugin settings: Settings > Mastodon Autpost
|
||||
|
||||
Just set your credentials and your post preference and lean back. The rest is done in the background and you don't have to care about it.
|
||||
|
||||
For any questions, do not hesitate to contact me:
|
||||
* Mail: mastodonautopost@simon-frey.eu
|
||||
* Mastodon: chaos.social/@l1am0
|
||||
|
||||
Do you want to help translating this plugin in your language? [Visit the translation page](https://translate.wordpress.org/projects/wp-plugins/autopost-to-mastodon)
|
||||
|
||||
Please consider donating via [PayPal](https://paypal.me/51edpo) <3
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Can I decide per post if I want to autopost it? =
|
||||
|
||||
Yes. Since version 1.1 you see a settings box in every post.
|
||||
|
||||
= Does the plugin send you my login data? =
|
||||
|
||||
The plugin never transmits any data to me, or anyone else than the mastodon node you set in the settings!
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Welcome site if you are not logged in
|
||||
2. Basic settings
|
||||
3. Advanced settings
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 3.6 =
|
||||
* Allow the plugin to work on custom post types (Thanks to [unicode-it](https://github.com/unicode-it))
|
||||
|
||||
= 3.5 =
|
||||
* Use categorys as hashtags on posts (Thanks to [rseabra](https://github.com/rseabra))
|
||||
|
||||
= 3.4 =
|
||||
* Fix for the manual added excerpt to also get encoded and remove html tags
|
||||
|
||||
= 3.3.4 =
|
||||
* Remove toot editor javascript as we do not have a toot editor anymore
|
||||
|
||||
= 3.3.3 =
|
||||
* Change permission for settings pages
|
||||
* Update for HTML tags striping
|
||||
|
||||
= 3.3.2 =
|
||||
* Remove HTML tags from excerpt (with php strip_tags())
|
||||
|
||||
= 3.3 =
|
||||
* Dutch translation (Thanks to [Alex Belgraver](https://fediversum.nl))
|
||||
|
||||
= 3.2.7 =
|
||||
* Auth workflow change
|
||||
|
||||
= 3.2.6 =
|
||||
* Change permission for settings page to manage_options
|
||||
|
||||
= 3.2.5 =
|
||||
* 5.0 Fix: Post only the tags of the post
|
||||
|
||||
= 3.2.4 =
|
||||
* Add version check to prevent call to undefined 5.0 function
|
||||
|
||||
= 3.2.3 =
|
||||
* fixup for tags
|
||||
* remove hardcoded `[...]` from post excerpt
|
||||
* different excerpt function
|
||||
* Works with 5.0 and Gutenberg Editor
|
||||
* Create future toot the moment it gets tooted (not upfront)
|
||||
|
||||
= 3.2.2 =
|
||||
* revert change
|
||||
|
||||
= 3.2.1 =
|
||||
* strip_shortcodes to don't toot them
|
||||
|
||||
= 3.2 =
|
||||
* Escape HTML codes in the toots (Thanks to [ojdo](https://github.com/ojdo))
|
||||
* Leave name for the the links to get nicer permalinks
|
||||
|
||||
= 3.1 =
|
||||
* Avoid empty thumbnail path (Thanks to [ldidry](https://github.com/ldidry))
|
||||
|
||||
= 3.0 =
|
||||
* Adapt to the base code of [kernox](https://github.com/kernox/Mastodon-Share-for-WordPress)
|
||||
* More error handling
|
||||
|
||||
= 2.1 =
|
||||
* Also toot post hashtags (Thanks to [jops](https://mastodon.bida.im/@jops))
|
||||
|
||||
= 2.0.9 =
|
||||
* Added spanish translation
|
||||
|
||||
= 2.0.4 =
|
||||
* Evaluates content HTML before tooting it
|
||||
* Changed to official naming convention "Mastodon"
|
||||
* Requires now minimum version 4.6 for translations via [the translation page](https://translate.wordpress.org/projects/wp-plugins/autopost-to-mastodon)
|
||||
|
||||
= 2.0.3 =
|
||||
* Changed to wordpress HTTP library
|
||||
|
||||
= 2.0.2 =
|
||||
* Add proper error messages
|
||||
|
||||
= 2.0.1 =
|
||||
* Removed token prompt in favor of nativ div
|
||||
|
||||
= 2.0.0.2 =
|
||||
* OAuth server communication bug
|
||||
|
||||
= 2.0.0.1 =
|
||||
* Fixed ajax server data bug
|
||||
|
||||
= 2.0 =
|
||||
* Changed backend libary
|
||||
* Now working with oauth
|
||||
* OTP and 2FA working
|
||||
* Different post formats available
|
||||
* Set post visibility
|
||||
* Suggest mastodon server
|
||||
* Works now also with pages
|
||||
* Test settings working again
|
||||
* The toot notification shows the url of the tooted post
|
||||
* For syndication: The plugin attaches the posted url to the post meta data. The tag is "mastodonAutopostLastSuccessfullPostURL"
|
||||
|
||||
= 1.3 =
|
||||
* Improved Feedback on post toot
|
||||
* Test Settings button, to check server settings
|
||||
* Global Hashtags that get added to every toot
|
||||
* Minor UX improvements
|
||||
= 1.1.0.4 =
|
||||
* Fixed settings page bug
|
||||
= 1.1.0.3 =
|
||||
* Added information to settings page
|
||||
= 1.1.0.2 =
|
||||
* Updated translation: Français
|
||||
= 1.1.0.1 =
|
||||
* New translation: Français
|
||||
= 1.1 =
|
||||
* Decide per post if you want to toot it to mastodon
|
||||
= 1.0.1 & 1.0.1.5 =
|
||||
* Added easy method for internationalization (get_text)
|
||||
* New translation: Deutsch
|
||||
= 1.0.1 & 1.0.1.1 =
|
||||
* Show notfication if post gets tooted
|
||||
= 1.0 =
|
||||
* Inital Plugin
|
||||
* New Functions: post on update, post only on publishing
|
||||
|
||||
== Credits ==
|
||||
|
||||
= Kernox =
|
||||
This project is baseds on [hellexis Mastodon Share Plugin](https://github.com/kernox/Mastodon-Share-for-WordPress). We are currently working together on a new one to combine our workforce.
|
||||
|
||||
= Graphics =
|
||||
Thanks to
|
||||
* [Ricardo Gomez Angel](https://unsplash.com/search/wall?photo=2WCT3mg5zlY) - Background Image (CC0)
|
||||
* [Flaticon](http://www.flaticon.com/free-icon/send_309395)- icon used in the logo (Flaticon Basis License)
|
||||
* [Wikipedia](https://commons.wikimedia.org/wiki/File:msatodon-logo.svg) - Mastodon logo used in the logo (CC0)
|
||||
* Bastien Ho & agentcobra - French translation and internationalization help
|
||||
* jorgesumle - Spanish translation
|
||||
|
||||
|
||||
= Idea =
|
||||
Special thanks to [Chris Riding](http://www.chrisridings.com/gnu-social-wordpress-plugin/) for inspiring this plugin with his original gnusocial project (GPLv2)
|
196
php-fpm/wordpress_files/plugins/autopost-to-mastodon/style.css
Normal file
@ -0,0 +1,196 @@
|
||||
.wrap{
|
||||
padding:10px;
|
||||
border-radius:10px;
|
||||
min-height:100%;
|
||||
}
|
||||
.wrap h1, .wrap label, .wrap form p{
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.wrap .button{
|
||||
color:#2b90d9 !important;
|
||||
border-color:#2b90d9 !important;
|
||||
box-shadow:none !important;
|
||||
text-shadow:none !important;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
.wrap .button:hover{
|
||||
background-color:transparent;
|
||||
}
|
||||
|
||||
.wrap input, .wrap textarea{
|
||||
background-color:transparent !important;
|
||||
color:#000 !important;
|
||||
border-color:#000;
|
||||
border-radius:4px;
|
||||
}
|
||||
|
||||
.wrap > form{
|
||||
border:solid 1px #2b90d9;
|
||||
padding:1%;
|
||||
background-color:#FFF;
|
||||
}
|
||||
|
||||
.spacer{
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.account{
|
||||
border: 1px solid #000;
|
||||
padding: 15px;
|
||||
border-radius:4px;
|
||||
float:left;
|
||||
|
||||
}
|
||||
|
||||
.m-avatar{
|
||||
float:left;
|
||||
border-radius: 100px;
|
||||
margin-right: 20px;
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
.details{
|
||||
float:left;
|
||||
}
|
||||
|
||||
.details .link{
|
||||
color:#000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.connected{
|
||||
color: #2b90d9;
|
||||
font-size: 16px;
|
||||
font-weight:bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.disconnected{
|
||||
color: #FF0000;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.advanced_setting{
|
||||
display:none;
|
||||
}
|
||||
|
||||
|
||||
.wrap .button:hover{
|
||||
background-color:transparent;
|
||||
}
|
||||
|
||||
.wrap input, .wrap textarea{
|
||||
background-color:transparent !important;
|
||||
color:#000 !important;
|
||||
border-color:#000;
|
||||
border-radius:4px;
|
||||
}
|
||||
.spacer{
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.account{
|
||||
border: 1px solid #000;
|
||||
padding: 15px;
|
||||
border-radius:4px;
|
||||
float:left;
|
||||
|
||||
}
|
||||
|
||||
.m-avatar{
|
||||
float:left;
|
||||
border-radius: 100px;
|
||||
margin-right: 20px;
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
.details{
|
||||
float:left;
|
||||
}
|
||||
|
||||
.details .link{
|
||||
color:#000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.connected{
|
||||
color: #2b90d9;
|
||||
font-size: 16px;
|
||||
font-weight:bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.disconnected{
|
||||
color: #FF0000;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.advanced_setting{
|
||||
display:none;
|
||||
}
|
||||
|
||||
|
||||
label{
|
||||
display:inline-block;
|
||||
vertical-align: bottom;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.messageRadioButtons label{
|
||||
padding:10px;
|
||||
border:dashed 2px #000;
|
||||
opacity:0.5;
|
||||
}
|
||||
|
||||
.scopeRadioButtons label{
|
||||
opacity:0.5;
|
||||
margin-right:1em;
|
||||
}
|
||||
|
||||
input[type="radio"]{
|
||||
display:none;
|
||||
}
|
||||
|
||||
.github-icon{
|
||||
margin-right: 10px;
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
html > body .liberapay-btn{
|
||||
margin-top: 3px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.github-icon{
|
||||
margin-right: 10px;
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.modeIcon{
|
||||
height:1em;
|
||||
}
|
||||
|
||||
html > body .liberapay-btn{
|
||||
margin-top: 3px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.tab-button{
|
||||
text-align:center;
|
||||
margin-bottom:-1px !important;
|
||||
border-bottom:none !important;
|
||||
border-radius:0 !important;
|
||||
}
|
||||
|
||||
.tab-button.active{
|
||||
background-color:#FFF !important;
|
||||
margin-bottom:-0px !important;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
if (!defined('WP_UNINSTALL_PLUGIN')) {
|
||||
die;
|
||||
}
|
||||
|
||||
delete_option( 'autopostToMastodon-client-id' );
|
||||
delete_option( 'autopostToMastodon-client-secret' );
|
||||
delete_option( 'autopostToMastodon-token' );
|
||||
delete_option( 'autopostToMastodon-instance' );
|
||||
delete_option( 'autopostToMastodon-message' );
|
||||
delete_option( 'autopostToMastodon-mode' );
|
||||
delete_option( 'autopostToMastodon-toot-size' );
|
||||
delete_option( 'autopostToMastodon-notice' );
|
||||
// get all post types
|
||||
$args = array(
|
||||
'public' => true,
|
||||
);
|
||||
$output = 'names';
|
||||
$operator = 'and';
|
||||
$post_types = get_post_types( $args, $output, $operator );
|
||||
// delete configs for all post_types
|
||||
foreach ( $post_types as $post_type ) {
|
||||
delete_option("autopostToMastodon-post_types-$post_type" );
|
||||
}
|
9
php-fpm/wordpress_files/plugins/backwpup/.htaccess
Normal file
@ -0,0 +1,9 @@
|
||||
<Files *.php>
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
</IfModule>
|
||||
</Files>
|
339
php-fpm/wordpress_files/plugins/backwpup/LICENSE
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) 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
|
||||
this service 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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. 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.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the 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 a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE 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.
|
||||
|
||||
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
|
||||
convey 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 2 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, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision 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, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This 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.
|
1
php-fpm/wordpress_files/plugins/backwpup/assets/css/main.min.css
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Generated by IcoMoon</metadata>
|
||||
<defs>
|
||||
<font id="backwpup" horiz-adv-x="1024">
|
||||
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
||||
<missing-glyph horiz-adv-x="1024" />
|
||||
<glyph unicode=" " d="" horiz-adv-x="512" />
|
||||
<glyph unicode="" d="M586.172 856.61c-225.655 0-408.61-182.955-408.61-408.61s182.955-408.61 408.61-408.61c225.655 0 408.61 182.921 408.61 408.61 0 225.655-182.955 408.61-408.61 408.61zM389.837 304.162l-77.039-40.823 10.684 294.537 249.719-156.501-83.934-44.476c68.54-155.136 173.124-149.47 173.124-149.47s-154.249-134.656-272.555 96.734zM860.74 336.384l-249.719 156.501 83.934 44.476c-68.54 155.136-173.124 149.47-173.124 149.47s154.283 134.656 272.589-96.768l77.039 40.823-10.718-294.502zM1031.27 637.815c-24.576 58.061-59.733 110.217-104.516 154.999-44.783 44.783-96.939 79.94-154.999 104.516-60.143 25.429-124.006 38.332-189.815 38.332-65.843 0-129.707-12.902-189.815-38.332-58.061-24.576-110.217-59.733-154.999-104.516-44.783-44.783-79.94-96.939-104.516-154.999-25.463-60.109-38.366-123.972-38.366-189.815 0-65.843 12.902-129.707 38.332-189.85 24.576-58.061 59.733-110.217 104.516-154.999 44.783-44.783 96.939-79.94 154.999-104.516 60.143-25.429 124.006-38.332 189.815-38.332 65.843 0 129.707 12.902 189.815 38.332 58.061 24.576 110.217 59.733 154.999 104.516 44.783 44.783 79.94 96.939 104.516 154.999 25.429 60.143 38.332 124.006 38.332 189.85 0.034 65.843-12.868 129.707-38.298 189.815zM581.939-13.141c-254.259 0-461.141 206.882-461.141 461.141 0 254.259 206.882 461.141 461.141 461.141 254.259 0 461.141-206.848 461.141-461.141 0-254.259-206.882-461.141-461.141-461.141zM1047.142 644.54c-25.429 60.109-61.85 114.108-108.203 160.461-46.353 46.353-100.352 82.773-160.495 108.203-62.259 26.317-128.375 39.697-196.54 39.697-68.164 0-134.281-13.346-196.54-39.697-60.075-25.429-114.074-61.815-160.461-108.203-46.353-46.353-82.773-100.352-108.203-160.461-26.317-62.259-39.663-128.375-39.663-196.54 0-68.164 13.346-134.281 39.697-196.54 25.429-60.109 61.85-114.108 108.203-160.495 46.353-46.353 100.352-82.773 160.495-108.203 62.259-26.351 128.375-39.697 196.54-39.697 68.164 0 134.281 13.346 196.54 39.697 60.109 25.429 114.108 61.815 160.495 108.203 46.353 46.353 82.773 100.352 108.203 160.495 26.317 62.259 39.663 128.375 39.663 196.54-0.068 68.164-13.414 134.281-39.731 196.54zM581.939-29.423c-263.27 0-477.423 214.187-477.423 477.423s214.153 477.423 477.423 477.423c263.236 0 477.423-214.153 477.423-477.423 0-263.236-214.187-477.423-477.423-477.423z" horiz-adv-x="1161" />
|
||||
</font></defs></svg>
|
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 132 B |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 10 KiB |
BIN
php-fpm/wordpress_files/plugins/backwpup/assets/images/even.png
Normal file
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 851 B |
BIN
php-fpm/wordpress_files/plugins/backwpup/assets/images/help.png
Normal file
After Width: | Height: | Size: 263 B |
BIN
php-fpm/wordpress_files/plugins/backwpup/assets/images/hgbox.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 9.5 KiB |
After Width: | Height: | Size: 7.9 KiB |
BIN
php-fpm/wordpress_files/plugins/backwpup/assets/images/hover.png
Normal file
After Width: | Height: | Size: 86 B |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 5.6 KiB |
BIN
php-fpm/wordpress_files/plugins/backwpup/assets/images/odd.png
Normal file
After Width: | Height: | Size: 141 KiB |
After Width: | Height: | Size: 670 B |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,285 @@
|
||||
window.BWU = window.BWU || {};
|
||||
|
||||
( function ( $, _, BWU, ajaxurl, tbRemove )
|
||||
{
|
||||
var downloader;
|
||||
var decrypter;
|
||||
var Downloader;
|
||||
|
||||
if ( !ajaxurl ) {
|
||||
// eslint-disable-line
|
||||
console.warn( 'Missing ajaxurl value.' );
|
||||
|
||||
return;
|
||||
}
|
||||
if ( !( 'EventSource' in window ) ) {
|
||||
// eslint-disable-line
|
||||
console.warn( 'Event Source does not exist in this browser' );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function destruct ()
|
||||
{
|
||||
this.closeEventSource();
|
||||
this.cleanUi();
|
||||
this.decrypter && this.decrypter.destruct();
|
||||
}
|
||||
|
||||
function hideElement ( el )
|
||||
{
|
||||
if ( !el ) {
|
||||
return;
|
||||
}
|
||||
|
||||
el.style.display = 'none';
|
||||
}
|
||||
|
||||
function showElement ( el )
|
||||
{
|
||||
if ( !el ) {
|
||||
return;
|
||||
}
|
||||
|
||||
el.style.display = 'block';
|
||||
}
|
||||
|
||||
Downloader = {
|
||||
|
||||
showWaitingMessage: function ()
|
||||
{
|
||||
showElement( this.waitingUi );
|
||||
},
|
||||
|
||||
showProgressUi: function ()
|
||||
{
|
||||
showElement( this.progressUi );
|
||||
},
|
||||
|
||||
showSuccessMsg: function ()
|
||||
{
|
||||
showElement( this.successUi );
|
||||
},
|
||||
|
||||
hideWaitingMessage: function ()
|
||||
{
|
||||
hideElement( this.waitingUi );
|
||||
},
|
||||
|
||||
hideProgressUi: function ()
|
||||
{
|
||||
hideElement( this.progressUi );
|
||||
},
|
||||
|
||||
hideNotice: function ()
|
||||
{
|
||||
BWU.Functions.removeMessages( this.containerUi );
|
||||
},
|
||||
|
||||
hideSuccessMsg: function ()
|
||||
{
|
||||
hideElement( this.successUi );
|
||||
},
|
||||
|
||||
cleanUi: function ()
|
||||
{
|
||||
this.hideWaitingMessage();
|
||||
this.hideProgressUi();
|
||||
this.hideNotice();
|
||||
this.hideSuccessMsg();
|
||||
this.decrypter && this.decrypter.hide();
|
||||
},
|
||||
|
||||
done: function ()
|
||||
{
|
||||
this.showSuccessMsg();
|
||||
window.location.href = this.currentTarget.dataset.url;
|
||||
|
||||
setTimeout( tbRemove, 3000 );
|
||||
},
|
||||
|
||||
onMessage: function ( message )
|
||||
{
|
||||
var data;
|
||||
|
||||
try {
|
||||
data = JSON.parse( message.data );
|
||||
|
||||
switch ( data.state ) {
|
||||
case BWU.States.DOWNLOADING:
|
||||
this.cleanUi();
|
||||
this.showProgressUi();
|
||||
|
||||
$( '#progresssteps' )
|
||||
.css( {
|
||||
width: data.download_percent + '%'
|
||||
} )
|
||||
.text( data.download_percent + '%' );
|
||||
break;
|
||||
|
||||
case BWU.States.DONE:
|
||||
this.done( data.message );
|
||||
break;
|
||||
}
|
||||
} catch ( exc ) {
|
||||
BWU.Functions.printMessageError(
|
||||
exc.message,
|
||||
this.containerUi
|
||||
);
|
||||
destruct.call( this );
|
||||
}
|
||||
},
|
||||
|
||||
onError: function ( message )
|
||||
{
|
||||
var data = JSON.parse( message.data );
|
||||
|
||||
this.closeEventSource();
|
||||
|
||||
switch ( data.message ) {
|
||||
case BWU.States.NEED_DECRYPTION_KEY:
|
||||
this.cleanUi();
|
||||
this.decrypter && this.decrypter.needDecryption( data.status );
|
||||
break;
|
||||
default:
|
||||
BWU.Functions.printMessageError( data.message, this.containerUi );
|
||||
destruct.call( this );
|
||||
break;
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
initializeEventSource: function ()
|
||||
{
|
||||
if ( !_.isUndefined( this.eventSource ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.eventSource = new EventSource(
|
||||
ajaxurl
|
||||
+ '?action=download_backup_file&destination=' + this.currentTarget.dataset.destination
|
||||
+ '&jobid=' + this.currentTarget.dataset.jobid
|
||||
+ '&file=' + this.currentTarget.dataset.file
|
||||
+ '&local_file=' + this.currentTarget.dataset.localFile
|
||||
+ '&backwpup_action_nonce=' + this.currentTarget.dataset.nonce
|
||||
);
|
||||
|
||||
this.eventSource.onmessage = this.onMessage;
|
||||
this.eventSource.addEventListener( 'log', this.onError );
|
||||
},
|
||||
|
||||
closeEventSource: function ()
|
||||
{
|
||||
if ( _.isUndefined( this.eventSource ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.eventSource.close();
|
||||
this.eventSource = undefined;
|
||||
},
|
||||
|
||||
startDownload: function ( evt )
|
||||
{
|
||||
evt.preventDefault();
|
||||
|
||||
this.currentTarget = evt.target;
|
||||
|
||||
this.showWaitingMessage();
|
||||
this.initializeEventSource();
|
||||
},
|
||||
|
||||
decrypt: function ()
|
||||
{
|
||||
this.cleanUi();
|
||||
this.decrypter && this.decrypter.decrypt( {
|
||||
backwpup_action_nonce: this.currentTarget.dataset.nonce,
|
||||
encrypted_file_path: this.currentTarget.dataset.localFile
|
||||
} );
|
||||
},
|
||||
|
||||
construct: function ( decrypter )
|
||||
{
|
||||
|
||||
var containerUi = document.querySelector( '#tb_container' );
|
||||
if ( !containerUi ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_.bindAll(
|
||||
this,
|
||||
'showWaitingMessage',
|
||||
'hideWaitingMessage',
|
||||
'showProgressUi',
|
||||
'hideSuccessMsg',
|
||||
'showSuccessMsg',
|
||||
'done',
|
||||
'onMessage',
|
||||
'onError',
|
||||
'initializeEventSource',
|
||||
'closeEventSource',
|
||||
'startDownload',
|
||||
'addListeners',
|
||||
'decrypt',
|
||||
'hideNotice',
|
||||
'cleanUi',
|
||||
'init'
|
||||
);
|
||||
|
||||
this.containerUi = containerUi;
|
||||
this.waitingUi = this.containerUi.querySelector( '#download-file-waiting' );
|
||||
this.progressUi = this.containerUi.querySelector( '.progressbar' );
|
||||
this.successUi = this.containerUi.querySelector( '#download-file-success' );
|
||||
|
||||
this.currentTarget = undefined;
|
||||
this.eventSource = undefined;
|
||||
this.decrypter = decrypter;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
addListeners: function ()
|
||||
{
|
||||
_.forEach( document.querySelectorAll( '.backup-download-link' ), function ( downloadLink )
|
||||
{
|
||||
downloadLink.addEventListener( 'click', this.startDownload );
|
||||
}.bind( this ) );
|
||||
|
||||
$( '#submit_decrypt_key' ).on( 'click', this.decrypt );
|
||||
$( 'body' ).on( 'thickbox:removed', function ()
|
||||
{
|
||||
destruct.call( this );
|
||||
}.bind( this ) );
|
||||
|
||||
if ( this.decrypter ) {
|
||||
$( 'body' ).on( this.decrypter.ACTION_DECRYPTION_SUCCESS, this.done );
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
init: function ()
|
||||
{
|
||||
this.addListeners();
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
downloader = Object.create( Downloader );
|
||||
|
||||
if ( !_.isUndefined( BWU.DecrypterFactory ) ) {
|
||||
decrypter = BWU.DecrypterFactory(
|
||||
ajaxurl,
|
||||
document.querySelector( '#decrypt_key' ),
|
||||
document.querySelector( '#decryption_key' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( downloader.construct( decrypter ) ) {
|
||||
downloader.init();
|
||||
}
|
||||
|
||||
}( window.jQuery, window._, window.BWU, window.ajaxurl, window.tb_remove ) );
|
1
php-fpm/wordpress_files/plugins/backwpup/assets/js/backup-downloader.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
window.BWU=window.BWU||{},function(i,s,n,e,t){var r,o,c;function a(){this.closeEventSource(),this.cleanUi(),this.decrypter&&this.decrypter.destruct()}function d(e){e&&(e.style.display="none")}function h(e){e&&(e.style.display="block")}e?"EventSource"in window?(c={showWaitingMessage:function(){h(this.waitingUi)},showProgressUi:function(){h(this.progressUi)},showSuccessMsg:function(){h(this.successUi)},hideWaitingMessage:function(){d(this.waitingUi)},hideProgressUi:function(){d(this.progressUi)},hideNotice:function(){n.Functions.removeMessages(this.containerUi)},hideSuccessMsg:function(){d(this.successUi)},cleanUi:function(){this.hideWaitingMessage(),this.hideProgressUi(),this.hideNotice(),this.hideSuccessMsg(),this.decrypter&&this.decrypter.hide()},done:function(){this.showSuccessMsg(),window.location.href=this.currentTarget.dataset.url,setTimeout(t,3e3)},onMessage:function(e){var t;try{switch((t=JSON.parse(e.data)).state){case n.States.DOWNLOADING:this.cleanUi(),this.showProgressUi(),i("#progresssteps").css({width:t.download_percent+"%"}).text(t.download_percent+"%");break;case n.States.DONE:this.done(t.message)}}catch(e){n.Functions.printMessageError(e.message,this.containerUi),a.call(this)}},onError:function(e){var t=JSON.parse(e.data);switch(this.closeEventSource(),t.message){case n.States.NEED_DECRYPTION_KEY:this.cleanUi(),this.decrypter&&this.decrypter.needDecryption(t.status);break;default:n.Functions.printMessageError(t.message,this.containerUi),a.call(this)}return this},initializeEventSource:function(){s.isUndefined(this.eventSource)&&(this.eventSource=new EventSource(e+"?action=download_backup_file&destination="+this.currentTarget.dataset.destination+"&jobid="+this.currentTarget.dataset.jobid+"&file="+this.currentTarget.dataset.file+"&local_file="+this.currentTarget.dataset.localFile+"&backwpup_action_nonce="+this.currentTarget.dataset.nonce),this.eventSource.onmessage=this.onMessage,this.eventSource.addEventListener("log",this.onError))},closeEventSource:function(){s.isUndefined(this.eventSource)||(this.eventSource.close(),this.eventSource=void 0)},startDownload:function(e){e.preventDefault(),this.currentTarget=e.target,this.showWaitingMessage(),this.initializeEventSource()},decrypt:function(){this.cleanUi(),this.decrypter&&this.decrypter.decrypt({backwpup_action_nonce:this.currentTarget.dataset.nonce,encrypted_file_path:this.currentTarget.dataset.localFile})},construct:function(e){var t=document.querySelector("#tb_container");return!!t&&(s.bindAll(this,"showWaitingMessage","hideWaitingMessage","showProgressUi","hideSuccessMsg","showSuccessMsg","done","onMessage","onError","initializeEventSource","closeEventSource","startDownload","addListeners","decrypt","hideNotice","cleanUi","init"),this.containerUi=t,this.waitingUi=this.containerUi.querySelector("#download-file-waiting"),this.progressUi=this.containerUi.querySelector(".progressbar"),this.successUi=this.containerUi.querySelector("#download-file-success"),this.currentTarget=void 0,this.eventSource=void 0,this.decrypter=e,this)},addListeners:function(){return s.forEach(document.querySelectorAll(".backup-download-link"),function(e){e.addEventListener("click",this.startDownload)}.bind(this)),i("#submit_decrypt_key").on("click",this.decrypt),i("body").on("thickbox:removed",function(){a.call(this)}.bind(this)),this.decrypter&&i("body").on(this.decrypter.ACTION_DECRYPTION_SUCCESS,this.done),this},init:function(){return this.addListeners(),this}},r=Object.create(c),s.isUndefined(n.DecrypterFactory)||(o=n.DecrypterFactory(e,document.querySelector("#decrypt_key"),document.querySelector("#decryption_key"))),r.construct(o)&&r.init()):console.warn("Event Source does not exist in this browser"):console.warn("Missing ajaxurl value.")}(window.jQuery,window._,window.BWU,window.ajaxurl,window.tb_remove);
|
@ -0,0 +1,44 @@
|
||||
jQuery(document).ready(function ($) {
|
||||
|
||||
backwpup_htmlspecialchars = function( string ) {
|
||||
return jQuery('<span>').text( string ).html();
|
||||
};
|
||||
|
||||
$.fn.backwpupDelayKeyup = function(callback){
|
||||
var timer = 0;
|
||||
$(this).keyup(function(){
|
||||
clearTimeout (timer);
|
||||
timer = setTimeout(callback, 200);
|
||||
});
|
||||
return $(this);
|
||||
};
|
||||
|
||||
/* change size of thickbox */
|
||||
backwpup_tb_position = function() {
|
||||
var tbWindow = $('#TB_window'), width = $(window).width(), height = $(window).height(), W = ( 720 < width ) ? 720 : width, H = ( 525 < height ) ? 525 : height, adminbar_height = 0;
|
||||
|
||||
if ( $('body.admin-bar').length )
|
||||
adminbar_height = 28;
|
||||
|
||||
if ( tbWindow.size() ) {
|
||||
tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
|
||||
$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
|
||||
tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
|
||||
if ( typeof document.body.style.maxWidth != 'undefined' )
|
||||
tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
|
||||
}
|
||||
|
||||
return $('a.thickbox').each( function() {
|
||||
var href = $(this).attr('href');
|
||||
if ( ! href )
|
||||
return;
|
||||
href = href.replace(/&width=[0-9]+/g, '');
|
||||
href = href.replace(/&height=[0-9]+/g, '');
|
||||
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
|
||||
});
|
||||
};
|
||||
|
||||
$(window).resize(function(){ backwpup_tb_position(); });
|
||||
backwpup_tb_position();
|
||||
|
||||
});
|
1
php-fpm/wordpress_files/plugins/backwpup/assets/js/general.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
jQuery(document).ready(function(a){backwpup_htmlspecialchars=function(t){return jQuery("<span>").text(t).html()},a.fn.backwpupDelayKeyup=function(t){var i=0;return a(this).keyup(function(){clearTimeout(i),i=setTimeout(t,200)}),a(this)},backwpup_tb_position=function(){var t=a("#TB_window"),i=a(window).width(),e=a(window).height(),n=720<i?720:i,h=525<e?525:e,o=0;return a("body.admin-bar").length&&(o=28),t.size()&&(t.width(n-50).height(h-45-o),a("#TB_iframeContent").width(n-50).height(h-75-o),t.css({"margin-left":"-"+parseInt((n-50)/2,10)+"px"}),void 0!==document.body.style.maxWidth&&t.css({top:20+o+"px","margin-top":"0"})),a("a.thickbox").each(function(){var t=a(this).attr("href");t&&(t=(t=t.replace(/&width=[0-9]+/g,"")).replace(/&height=[0-9]+/g,""),a(this).attr("href",t+"&width="+(n-80)+"&height="+(h-85-o)))})},a(window).resize(function(){backwpup_tb_position()}),backwpup_tb_position()});
|
53
php-fpm/wordpress_files/plugins/backwpup/assets/js/notice.js
Normal file
@ -0,0 +1,53 @@
|
||||
( function ( _, $, adminpage ) {
|
||||
|
||||
var PromoterNotice = {
|
||||
|
||||
dismiss: function ( evt ) {
|
||||
evt.preventDefault();
|
||||
evt.stopImmediatePropagation();
|
||||
|
||||
$.post( $( evt.target ).attr( 'href' ), { isAjax: 1 } );
|
||||
this.container.remove();
|
||||
},
|
||||
|
||||
construct: function () {
|
||||
|
||||
var container;
|
||||
|
||||
_.bindAll(
|
||||
this,
|
||||
'dismiss',
|
||||
'init',
|
||||
'addListeners'
|
||||
);
|
||||
|
||||
container = document.querySelector( '#backwpup_notice_promoter_notice', {
|
||||
useCapture: true
|
||||
} );
|
||||
|
||||
if ( !container ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.container = container;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
addListeners: function () {
|
||||
var dismisser = this.container.querySelector( '#backwpup_notice_promoter_dismiss' );
|
||||
dismisser && dismisser.addEventListener( 'click', this.dismiss );
|
||||
},
|
||||
|
||||
init: function () {
|
||||
this.addListeners();
|
||||
|
||||
return this;
|
||||
},
|
||||
};
|
||||
|
||||
if ( adminpage === 'toplevel_page_backwpup' ) {
|
||||
var promoterNotice = Object.create( PromoterNotice );
|
||||
promoterNotice.construct() && promoterNotice.init();
|
||||
}
|
||||
}( window._, window.jQuery, window.adminpage ) );
|
1
php-fpm/wordpress_files/plugins/backwpup/assets/js/notice.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(i,e){var t={dismiss:function(t){t.preventDefault(),t.stopImmediatePropagation(),e.post(e(t.target).attr("href"),{isAjax:1}),this.container.remove()},construct:function(){var t;return i.bindAll(this,"dismiss","init","addListeners"),!!(t=document.querySelector("#backwpup_notice_promoter_notice",{useCapture:!0}))&&(this.container=t,this)},addListeners:function(){var t=this.container.querySelector("#backwpup_notice_promoter_dismiss");t&&t.addEventListener("click",this.dismiss)},init:function(){return this.addListeners(),this}};if("toplevel_page_backwpup"===window.adminpage){var n=Object.create(t);n.construct()&&n.init()}}(window._,window.jQuery);
|
@ -0,0 +1,97 @@
|
||||
jQuery(document).ready(function ($) {
|
||||
|
||||
$('#dball').click(function () {
|
||||
$('input[name="tabledb[]"]').prop("checked", true).change();
|
||||
});
|
||||
|
||||
$('#dbnone').click(function () {
|
||||
$('input[name="tabledb[]"]').prop("checked", false).change();
|
||||
});
|
||||
|
||||
$('#dbwp').click(function () {
|
||||
$('input[name="tabledb[]"]').prop("checked", false).change();
|
||||
$('input[name="tabledb[]"][value^="' + $('#dbwp').val() + '"]').prop("checked", true).change();
|
||||
});
|
||||
|
||||
var dbdumpwpdbsettings = $('input[name="dbdumpwpdbsettings"]');
|
||||
if ( dbdumpwpdbsettings.length > 0 ) {
|
||||
dbdumpwpdbsettings.change(function () {
|
||||
if ( dbdumpwpdbsettings.prop("checked") ) {
|
||||
$('#dbconnection').hide();
|
||||
} else {
|
||||
$('#dbconnection').show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var trdbdumpmysqlfolder = $('#trdbdumpmysqlfolder');
|
||||
if ( trdbdumpmysqlfolder.length > 0 ) {
|
||||
$('input[name="dbdumptype"]').change(function () {
|
||||
if ( $('#iddbdumptype-syssql').prop("checked") ) {
|
||||
trdbdumpmysqlfolder.show();
|
||||
} else {
|
||||
trdbdumpmysqlfolder.hide();
|
||||
}
|
||||
});
|
||||
|
||||
if ( $('#iddbdumptype-syssql').prop("checked") ) {
|
||||
trdbdumpmysqlfolder.show();
|
||||
} else {
|
||||
trdbdumpmysqlfolder.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function db_tables() {
|
||||
var data = {
|
||||
action:'backwpup_jobtype_dbdump',
|
||||
action2:'tables',
|
||||
dbname:$('#dbdumpdbname').val(),
|
||||
dbhost:$('#dbdumpdbhost').val(),
|
||||
dbuser:$('#dbdumpdbuser').val(),
|
||||
dbpassword:$('#dbdumpdbpassword').val(),
|
||||
wpdbsettings:$('#dbdumpwpdbsettings:checked').val(),
|
||||
jobid:$('#jobid').val(),
|
||||
_ajax_nonce:$('#backwpupajaxnonce').val()
|
||||
};
|
||||
$.post(ajaxurl, data, function (response) {
|
||||
$('#dbtables').replaceWith(response);
|
||||
});
|
||||
}
|
||||
$('#dbdumpdbname').change(function () {
|
||||
db_tables();
|
||||
});
|
||||
$('#dbdumpwpdbsettings').change(function () {
|
||||
db_tables();
|
||||
db_databases();
|
||||
});
|
||||
|
||||
function db_databases() {
|
||||
var data = {
|
||||
action:'backwpup_jobtype_dbdump',
|
||||
action2:'databases',
|
||||
dbhost:$('#dbdumpdbhost').val(),
|
||||
dbuser:$('#dbdumpdbuser').val(),
|
||||
dbpassword:$('#dbdumpdbpassword').val(),
|
||||
dbname:$('input[name="dbselected"]').val(),
|
||||
wpdbsettings:$('#dbdumpwpdbsettings:checked').val(),
|
||||
_ajax_nonce:$('#backwpupajaxnonce').val()
|
||||
|
||||
};
|
||||
$.post(ajaxurl, data, function (response) {
|
||||
$('#dbdumpdbname').replaceWith(response);
|
||||
db_tables();
|
||||
$('#dbdumpdbname').change(function () {
|
||||
db_tables();
|
||||
});
|
||||
});
|
||||
}
|
||||
$('#dbdumpdbhost').change(function () {
|
||||
db_databases();
|
||||
});
|
||||
$('#dbdumpdbuser').change(function () {
|
||||
db_databases();
|
||||
});
|
||||
$('#dbdumpdbpassword').change(function () {
|
||||
db_databases();
|
||||
});
|
||||
});
|
1
php-fpm/wordpress_files/plugins/backwpup/assets/js/page_edit_jobtype_dbdump.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
jQuery(document).ready(function(n){n("#dball").click(function(){n('input[name="tabledb[]"]').prop("checked",!0).change()}),n("#dbnone").click(function(){n('input[name="tabledb[]"]').prop("checked",!1).change()}),n("#dbwp").click(function(){n('input[name="tabledb[]"]').prop("checked",!1).change(),n('input[name="tabledb[]"][value^="'+n("#dbwp").val()+'"]').prop("checked",!0).change()});var d=n('input[name="dbdumpwpdbsettings"]');0<d.length&&d.change(function(){d.prop("checked")?n("#dbconnection").hide():n("#dbconnection").show()});var e=n("#trdbdumpmysqlfolder");function a(){var d={action:"backwpup_jobtype_dbdump",action2:"tables",dbname:n("#dbdumpdbname").val(),dbhost:n("#dbdumpdbhost").val(),dbuser:n("#dbdumpdbuser").val(),dbpassword:n("#dbdumpdbpassword").val(),wpdbsettings:n("#dbdumpwpdbsettings:checked").val(),jobid:n("#jobid").val(),_ajax_nonce:n("#backwpupajaxnonce").val()};n.post(ajaxurl,d,function(d){n("#dbtables").replaceWith(d)})}function b(){var d={action:"backwpup_jobtype_dbdump",action2:"databases",dbhost:n("#dbdumpdbhost").val(),dbuser:n("#dbdumpdbuser").val(),dbpassword:n("#dbdumpdbpassword").val(),dbname:n('input[name="dbselected"]').val(),wpdbsettings:n("#dbdumpwpdbsettings:checked").val(),_ajax_nonce:n("#backwpupajaxnonce").val()};n.post(ajaxurl,d,function(d){n("#dbdumpdbname").replaceWith(d),a(),n("#dbdumpdbname").change(function(){a()})})}0<e.length&&(n('input[name="dbdumptype"]').change(function(){n("#iddbdumptype-syssql").prop("checked")?e.show():e.hide()}),n("#iddbdumptype-syssql").prop("checked")?e.show():e.hide()),n("#dbdumpdbname").change(function(){a()}),n("#dbdumpwpdbsettings").change(function(){a(),b()}),n("#dbdumpdbhost").change(function(){b()}),n("#dbdumpdbuser").change(function(){b()}),n("#dbdumpdbpassword").change(function(){b()})});
|
@ -0,0 +1,73 @@
|
||||
jQuery(document).ready(function ($) {
|
||||
|
||||
$('input[name="backuproot"]').change(function () {
|
||||
if ($('input[name="backuproot"]').prop("checked")) {
|
||||
$('#backuprootexcludedirs').show();
|
||||
} else {
|
||||
$('#backuprootexcludedirs').hide();
|
||||
}
|
||||
});
|
||||
|
||||
if ($('input[name="backuproot"]').prop("checked")) {
|
||||
$('#backuprootexcludedirs').show();
|
||||
} else {
|
||||
$('#backuprootexcludedirs').hide();
|
||||
}
|
||||
|
||||
$('input[name="backupcontent"]').change(function () {
|
||||
if ($('input[name="backupcontent"]').prop("checked")) {
|
||||
$('#backupcontentexcludedirs').show();
|
||||
} else {
|
||||
$('#backupcontentexcludedirs').hide();
|
||||
}
|
||||
});
|
||||
|
||||
if ($('input[name="backupcontent"]').prop("checked")) {
|
||||
$('#backupcontentexcludedirs').show();
|
||||
} else {
|
||||
$('#backupcontentexcludedirs').hide();
|
||||
}
|
||||
|
||||
$('input[name="backupplugins"]').change(function () {
|
||||
if ($('input[name="backupplugins"]').prop("checked")) {
|
||||
$('#backuppluginsexcludedirs').show();
|
||||
} else {
|
||||
$('#backuppluginsexcludedirs').hide();
|
||||
}
|
||||
});
|
||||
|
||||
if ($('input[name="backupplugins"]').prop("checked")) {
|
||||
$('#backuppluginsexcludedirs').show();
|
||||
} else {
|
||||
$('#backuppluginsexcludedirs').hide();
|
||||
}
|
||||
|
||||
$('input[name="backupthemes"]').change(function () {
|
||||
if ($('input[name="backupthemes"]').prop("checked")) {
|
||||
$('#backupthemesexcludedirs').show();
|
||||
} else {
|
||||
$('#backupthemesexcludedirs').hide();
|
||||
}
|
||||
});
|
||||
|
||||
if ($('input[name="backupthemes"]').prop("checked")) {
|
||||
$('#backupthemesexcludedirs').show();
|
||||
} else {
|
||||
$('#backupthemesexcludedirs').hide();
|
||||
}
|
||||
|
||||
$('input[name="backupuploads"]').change(function () {
|
||||
if ($('input[name="backupuploads"]').prop("checked")) {
|
||||
$('#backupuploadsexcludedirs').show();
|
||||
} else {
|
||||
$('#backupuploadsexcludedirs').hide();
|
||||
}
|
||||
});
|
||||
|
||||
if ($('input[name="backupuploads"]').prop("checked")) {
|
||||
$('#backupuploadsexcludedirs').show();
|
||||
} else {
|
||||
$('#backupuploadsexcludedirs').hide();
|
||||
}
|
||||
|
||||
});
|